@wopee-io/wopee.pw 4.8.0 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/core/services/wopeeService/wopee.d.ts +2 -1
- package/build/core/services/wopeeService/wopee.js +8 -2
- package/build/core/services/wopeeService/wopee.js.map +1 -1
- package/build/shared/metadata/versionMetadata.js +2 -2
- package/build/tools/wopee-reporter/index.d.ts +2 -0
- package/build/tools/wopee-reporter/index.js +5 -0
- package/build/tools/wopee-reporter/index.js.map +1 -0
- package/build/tools/wopee-reporter/types/wopeeReporter.interface.d.ts +30 -0
- package/build/tools/wopee-reporter/types/wopeeReporter.interface.js +17 -0
- package/build/tools/wopee-reporter/types/wopeeReporter.interface.js.map +1 -0
- package/build/tools/wopee-reporter/wopeeReporter.d.ts +5 -0
- package/build/tools/wopee-reporter/wopeeReporter.js +70 -0
- package/build/tools/wopee-reporter/wopeeReporter.js.map +1 -0
- package/package.json +5 -2
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { TrackElementOptions, TrackFullPageOptions, TrackImageOptions, TrackViewportOptions } from '../../domain/valueObjects/track.interface.js';
|
|
2
2
|
import { IntegrationStep } from '@autonomous-testing/sdk';
|
|
3
|
+
import { TestInfo } from '@playwright/test';
|
|
3
4
|
export declare class Wopee {
|
|
4
5
|
private _config;
|
|
5
6
|
private _screenshotValidation;
|
|
6
7
|
constructor();
|
|
7
8
|
private _createApolloTrackAdapter;
|
|
8
9
|
startSuite(suiteName: string): Promise<void>;
|
|
9
|
-
startScenario(scenarioName: string): Promise<void>;
|
|
10
|
+
startScenario(scenarioName: string, testInfo?: TestInfo): Promise<void>;
|
|
10
11
|
stopScenario(): Promise<void>;
|
|
11
12
|
_trackImage(trackImageOptions: TrackImageOptions): Promise<IntegrationStep>;
|
|
12
13
|
trackImage(trackImageOptions: TrackImageOptions): Promise<IntegrationStep>;
|
|
@@ -50,10 +50,16 @@ class Wopee {
|
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
|
-
startScenario(scenarioName) {
|
|
53
|
+
startScenario(scenarioName, testInfo) {
|
|
54
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
55
|
if (this._config.screenshotValidation.screenshotValidationEnabled) {
|
|
56
|
-
yield this._screenshotValidation.createIntegrationScenario({ scenarioName });
|
|
56
|
+
const scenario = yield this._screenshotValidation.createIntegrationScenario({ scenarioName });
|
|
57
|
+
if (testInfo) {
|
|
58
|
+
yield testInfo.attach('wopee-scenario-uuid', {
|
|
59
|
+
contentType: 'text/plain',
|
|
60
|
+
body: scenario === null || scenario === void 0 ? void 0 : scenario.uuid,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
57
63
|
}
|
|
58
64
|
});
|
|
59
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wopee.js","sourceRoot":"","sources":["../../../../lib/core/services/wopeeService/wopee.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+GAAyG;AACzG,uDAA8D;AAQ9D,iDAOiC;AAOjC,MAAa,KAAK;IAQhB;QAPQ,YAAO,GAAiB,IAAI,CAAC;QAQnC,IAAA,6BAAkB,GAAE,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,IAAI,sCAAgB,EAAE,CAAC,UAAU,EAAE,CAAC;QAEnD,IAAI,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,2BAA2B,EAAE,CAAC;YAClE,IAAI,CAAC,qBAAqB,GAAG,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAChE,CAAC;IACH,CAAC;IAMO,yBAAyB;;QAC/B,MAAM,mBAAmB,GAAwB;YAC/C,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,MAAM;YAChD,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,MAAM;YAChD,UAAU,EAAE,MAAA,IAAI,CAAC,OAAO,CAAC,oBAAoB,0CAAE,UAAU;YACz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C,2BAA2B,EAAE,CAAC;gBAClE,MAAM,qBAAqB,GAA0B;oBACnD,UAAU,EAAE,UAAU;oBACtB,KAAK,EAAE,SAAS;oBAChB,QAAQ,EAAE,KAAK;oBACf,KAAK,EAAE,KAAK;oBACZ,IAAI,EAAE,KAAK;iBACZ,CAAC;gBACF,MAAM,WAAW,GAAG,MAAM,oBAAoB,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAC,CAAC;gBACtF,MAAM,WAAW,GAAG,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;gBACnD,MAAM,OAAO,GAAiC,wCAAkC,CAAC,KAAK,iCACjF,oBAAoB,KACvB,WAAW,IACX,CAAC;gBACH,iBAAiB,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;YACtF,CAAC;YACD,OAAO,iBAAiB,CAAC;QAC3B,CAAC;KAAA;IAOK,aAAa,CAAC,oBAA0C;;YAC5D,IAAI,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,2BAA2B,EAAE,CAAC;gBAClE,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;YACzD,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;CACF;AAzLD,sBAyLC","sourcesContent":["import { EnvConfigAdapter } from '../../../infrastructure/adapters/envConfigAdapter/envConfigAdapter.js';\nimport { logVersionMetadata } from '../../../shared/index.js';\nimport { WopeeOptions } from '../../domain/configuration/config.interface.js';\nimport {\n TrackElementOptions,\n TrackFullPageOptions,\n TrackImageOptions,\n TrackViewportOptions,\n} from '../../domain/valueObjects/track.interface.js';\nimport {\n ApolloAdapter,\n ApolloAdapterConfig,\n CreateIntegrationStepPayload,\n CreateIntegrationStepPayloadSchema,\n IntegrationStep,\n createApolloTrackAdapter,\n} from '@autonomous-testing/sdk';\nimport { LocatorScreenshotOptions, PageScreenshotOptions } from '@playwright/test';\n\n/**\n * The Wopee class provides methods to configure and manage screenshot validation\n * for testing environments, leveraging external APIs and customized options.\n */\nexport class Wopee {\n private _config: WopeeOptions = null;\n private _screenshotValidation: ApolloAdapter;\n\n /**\n * Initializes the class by logging version metadata, parsing configuration,\n * and setting up instance options based on environmental variables or defaults.\n */\n constructor() {\n logVersionMetadata();\n this._config = new EnvConfigAdapter().loadConfig();\n\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n this._screenshotValidation = this._createApolloTrackAdapter();\n }\n }\n\n /**\n * Creates an ApolloTrackAdapter for tracking and validating screenshots.\n * @returns {ApolloTrackAdapter} The initialized tracking adapter.\n */\n private _createApolloTrackAdapter(): ApolloAdapter {\n const apolloAdapterConfig: ApolloAdapterConfig = {\n apiKey: this._config.screenshotValidation.apiKey,\n apiUrl: this._config.screenshotValidation.apiUrl,\n branchName: this._config.screenshotValidation?.branchName,\n enableSoftAssert: this._config.screenshotValidation?.enableSoftAssert,\n projectUuid: this._config.screenshotValidation.projectUuid,\n browser: this._config.screenshotValidation?.browser,\n comment: this._config.screenshotValidation?.comment,\n device: this._config.screenshotValidation?.device,\n os: this._config.screenshotValidation?.os,\n pixelToPixelDiffTolerance: this._config.screenshotValidation.pixelToPixelDiffTolerance,\n viewport: this._config.screenshotValidation?.viewport,\n customTags: this._config.screenshotValidation?.customTags,\n };\n return createApolloTrackAdapter({\n apolloAdapterConfig: apolloAdapterConfig,\n loggerOptions: { logger: 'ConsoleLogger' },\n });\n }\n\n /**\n * Starts the screenshot validation process, create/connect to Suite.\n */\n async startSuite(suiteName: string): Promise<void> {\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n await this._screenshotValidation.createIntegrationSuite({ suiteName });\n }\n }\n\n /**\n * Starts the screenshot validation process, create/connect to Suite.\n */\n async startScenario(scenarioName: string): Promise<void> {\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n await this._screenshotValidation.createIntegrationScenario({ scenarioName });\n }\n }\n\n /**\n * Stops the screenshot validation process.\n */\n async stopScenario(): Promise<void> {\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n await this._screenshotValidation.stopIntegrationScenario();\n }\n }\n\n async _trackImage(trackImageOptions: TrackImageOptions): Promise<IntegrationStep> {\n const payload: CreateIntegrationStepPayload = CreateIntegrationStepPayloadSchema.parse({\n ...trackImageOptions,\n });\n return await this._screenshotValidation.createIntegrationStep(payload);\n }\n\n /**\n * Submits a given image for tracking and validation.\n * @param trackImageOptions Parameters for image tracking.\n * @returns {ApolloTrackResult} The result of the tracking operation.\n */\n async trackImage(trackImageOptions: TrackImageOptions): Promise<IntegrationStep> {\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n return await this._trackImage(trackImageOptions);\n }\n return null;\n }\n\n async _trackFullPage(trackFullPageOptions: TrackFullPageOptions): Promise<IntegrationStep> {\n let apolloTrackResult: IntegrationStep = null;\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n const pageScreenshotOptions: PageScreenshotOptions = {\n animations: 'disabled',\n caret: 'initial',\n fullPage: true,\n scale: 'css',\n type: 'png',\n };\n const imageBuffer = await trackFullPageOptions.page.screenshot(pageScreenshotOptions);\n const imageBase64 = imageBuffer.toString('base64');\n const payload: CreateIntegrationStepPayload = CreateIntegrationStepPayloadSchema.parse({\n ...trackFullPageOptions,\n imageBase64,\n });\n apolloTrackResult = await this._screenshotValidation.createIntegrationStep(payload);\n }\n return apolloTrackResult;\n }\n\n /**\n * Captures and tracks a full page screenshot for validation.\n * @param trackFullPageOptions Parameters for image tracking.\n * @returns {ApolloTrackResult} The result of the tracking operation.\n */\n async trackFullPage(trackFullPageOptions: TrackFullPageOptions): Promise<IntegrationStep> {\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n return await this._trackFullPage(trackFullPageOptions);\n }\n return null;\n }\n\n async _trackElement(trackElementOptions: TrackElementOptions): Promise<IntegrationStep> {\n let apolloTrackResult: IntegrationStep = null;\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n const locatorScreenshotOptions: LocatorScreenshotOptions = {\n animations: 'disabled',\n caret: 'initial',\n scale: 'css',\n type: 'png',\n };\n const imageBuffer = await trackElementOptions.locator.screenshot(locatorScreenshotOptions);\n const imageBase64 = imageBuffer.toString('base64');\n const payload: CreateIntegrationStepPayload = CreateIntegrationStepPayloadSchema.parse({\n ...trackElementOptions,\n imageBase64,\n });\n apolloTrackResult = await this._screenshotValidation.createIntegrationStep(payload);\n }\n return apolloTrackResult;\n }\n\n /**\n * Captures and tracks a element screenshot for validation.\n * @param trackElementOptions Parameters for image tracking.\n * @returns {ApolloTrackResult} The result of the tracking operation.\n */\n async trackElement(trackElementOptions: TrackElementOptions): Promise<IntegrationStep> {\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n return await this._trackElement(trackElementOptions);\n }\n return null;\n }\n\n async _trackViewport(trackViewportOptions: TrackViewportOptions): Promise<IntegrationStep> {\n let apolloTrackResult: IntegrationStep = null;\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n const pageScreenshotOptions: PageScreenshotOptions = {\n animations: 'disabled',\n caret: 'initial',\n fullPage: false,\n scale: 'css',\n type: 'png',\n };\n const imageBuffer = await trackViewportOptions.page.screenshot(pageScreenshotOptions);\n const imageBase64 = imageBuffer.toString('base64');\n const payload: CreateIntegrationStepPayload = CreateIntegrationStepPayloadSchema.parse({\n ...trackViewportOptions,\n imageBase64,\n });\n apolloTrackResult = await this._screenshotValidation.createIntegrationStep(payload);\n }\n return apolloTrackResult;\n }\n\n /**\n * Captures and tracks a viewport screenshot for validation.\n * @param TrackViewportOptions Parameters for image tracking.\n * @returns {ApolloTrackResult} The result of the tracking operation.\n */\n async trackViewport(trackViewportOptions: TrackViewportOptions): Promise<IntegrationStep> {\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n return await this._trackViewport(trackViewportOptions);\n }\n return null;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"wopee.js","sourceRoot":"","sources":["../../../../lib/core/services/wopeeService/wopee.ts"],"names":[],"mappings":";;;;;;;;;;;;AAA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CAAkC,CAAC,KAAK,iCACjF,oBAAoB,KACvB,WAAW,IACX,CAAC;gBACH,iBAAiB,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;YACtF,CAAC;YACD,OAAO,iBAAiB,CAAC;QAC3B,CAAC;KAAA;IAOK,aAAa,CAAC,oBAA0C;;YAC5D,IAAI,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,2BAA2B,EAAE,CAAC;gBAClE,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC;YACzD,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;CACF;AA/LD,sBA+LC","sourcesContent":["import { EnvConfigAdapter } from '../../../infrastructure/adapters/envConfigAdapter/envConfigAdapter.js';\nimport { logVersionMetadata } from '../../../shared/index.js';\nimport { WopeeOptions } from '../../domain/configuration/config.interface.js';\nimport {\n TrackElementOptions,\n TrackFullPageOptions,\n TrackImageOptions,\n TrackViewportOptions,\n} from '../../domain/valueObjects/track.interface.js';\nimport {\n ApolloAdapter,\n ApolloAdapterConfig,\n CreateIntegrationStepPayload,\n CreateIntegrationStepPayloadSchema,\n IntegrationStep,\n createApolloTrackAdapter,\n} from '@autonomous-testing/sdk';\nimport { LocatorScreenshotOptions, PageScreenshotOptions, TestInfo } from '@playwright/test';\n\n/**\n * The Wopee class provides methods to configure and manage screenshot validation\n * for testing environments, leveraging external APIs and customized options.\n */\nexport class Wopee {\n private _config: WopeeOptions = null;\n private _screenshotValidation: ApolloAdapter;\n\n /**\n * Initializes the class by logging version metadata, parsing configuration,\n * and setting up instance options based on environmental variables or defaults.\n */\n constructor() {\n logVersionMetadata();\n this._config = new EnvConfigAdapter().loadConfig();\n\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n this._screenshotValidation = this._createApolloTrackAdapter();\n }\n }\n\n /**\n * Creates an ApolloTrackAdapter for tracking and validating screenshots.\n * @returns {ApolloTrackAdapter} The initialized tracking adapter.\n */\n private _createApolloTrackAdapter(): ApolloAdapter {\n const apolloAdapterConfig: ApolloAdapterConfig = {\n apiKey: this._config.screenshotValidation.apiKey,\n apiUrl: this._config.screenshotValidation.apiUrl,\n branchName: this._config.screenshotValidation?.branchName,\n enableSoftAssert: this._config.screenshotValidation?.enableSoftAssert,\n projectUuid: this._config.screenshotValidation.projectUuid,\n browser: this._config.screenshotValidation?.browser,\n comment: this._config.screenshotValidation?.comment,\n device: this._config.screenshotValidation?.device,\n os: this._config.screenshotValidation?.os,\n pixelToPixelDiffTolerance: this._config.screenshotValidation.pixelToPixelDiffTolerance,\n viewport: this._config.screenshotValidation?.viewport,\n customTags: this._config.screenshotValidation?.customTags,\n };\n return createApolloTrackAdapter({\n apolloAdapterConfig: apolloAdapterConfig,\n loggerOptions: { logger: 'ConsoleLogger' },\n });\n }\n\n /**\n * Starts the screenshot validation process, create/connect to Suite.\n */\n async startSuite(suiteName: string): Promise<void> {\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n await this._screenshotValidation.createIntegrationSuite({ suiteName });\n }\n }\n\n /**\n * Starts the screenshot validation process, create/connect to Suite.\n */\n async startScenario(scenarioName: string, testInfo?: TestInfo): Promise<void> {\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n const scenario = await this._screenshotValidation.createIntegrationScenario({ scenarioName });\n if (testInfo) {\n await testInfo.attach('wopee-scenario-uuid', {\n contentType: 'text/plain',\n body: scenario?.uuid,\n });\n }\n }\n }\n\n /**\n * Stops the screenshot validation process.\n */\n async stopScenario(): Promise<void> {\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n await this._screenshotValidation.stopIntegrationScenario();\n }\n }\n\n async _trackImage(trackImageOptions: TrackImageOptions): Promise<IntegrationStep> {\n const payload: CreateIntegrationStepPayload = CreateIntegrationStepPayloadSchema.parse({\n ...trackImageOptions,\n });\n return await this._screenshotValidation.createIntegrationStep(payload);\n }\n\n /**\n * Submits a given image for tracking and validation.\n * @param trackImageOptions Parameters for image tracking.\n * @returns {ApolloTrackResult} The result of the tracking operation.\n */\n async trackImage(trackImageOptions: TrackImageOptions): Promise<IntegrationStep> {\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n return await this._trackImage(trackImageOptions);\n }\n return null;\n }\n\n async _trackFullPage(trackFullPageOptions: TrackFullPageOptions): Promise<IntegrationStep> {\n let apolloTrackResult: IntegrationStep = null;\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n const pageScreenshotOptions: PageScreenshotOptions = {\n animations: 'disabled',\n caret: 'initial',\n fullPage: true,\n scale: 'css',\n type: 'png',\n };\n const imageBuffer = await trackFullPageOptions.page.screenshot(pageScreenshotOptions);\n const imageBase64 = imageBuffer.toString('base64');\n const payload: CreateIntegrationStepPayload = CreateIntegrationStepPayloadSchema.parse({\n ...trackFullPageOptions,\n imageBase64,\n });\n apolloTrackResult = await this._screenshotValidation.createIntegrationStep(payload);\n }\n return apolloTrackResult;\n }\n\n /**\n * Captures and tracks a full page screenshot for validation.\n * @param trackFullPageOptions Parameters for image tracking.\n * @returns {ApolloTrackResult} The result of the tracking operation.\n */\n async trackFullPage(trackFullPageOptions: TrackFullPageOptions): Promise<IntegrationStep> {\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n return await this._trackFullPage(trackFullPageOptions);\n }\n return null;\n }\n\n async _trackElement(trackElementOptions: TrackElementOptions): Promise<IntegrationStep> {\n let apolloTrackResult: IntegrationStep = null;\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n const locatorScreenshotOptions: LocatorScreenshotOptions = {\n animations: 'disabled',\n caret: 'initial',\n scale: 'css',\n type: 'png',\n };\n const imageBuffer = await trackElementOptions.locator.screenshot(locatorScreenshotOptions);\n const imageBase64 = imageBuffer.toString('base64');\n const payload: CreateIntegrationStepPayload = CreateIntegrationStepPayloadSchema.parse({\n ...trackElementOptions,\n imageBase64,\n });\n apolloTrackResult = await this._screenshotValidation.createIntegrationStep(payload);\n }\n return apolloTrackResult;\n }\n\n /**\n * Captures and tracks a element screenshot for validation.\n * @param trackElementOptions Parameters for image tracking.\n * @returns {ApolloTrackResult} The result of the tracking operation.\n */\n async trackElement(trackElementOptions: TrackElementOptions): Promise<IntegrationStep> {\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n return await this._trackElement(trackElementOptions);\n }\n return null;\n }\n\n async _trackViewport(trackViewportOptions: TrackViewportOptions): Promise<IntegrationStep> {\n let apolloTrackResult: IntegrationStep = null;\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n const pageScreenshotOptions: PageScreenshotOptions = {\n animations: 'disabled',\n caret: 'initial',\n fullPage: false,\n scale: 'css',\n type: 'png',\n };\n const imageBuffer = await trackViewportOptions.page.screenshot(pageScreenshotOptions);\n const imageBase64 = imageBuffer.toString('base64');\n const payload: CreateIntegrationStepPayload = CreateIntegrationStepPayloadSchema.parse({\n ...trackViewportOptions,\n imageBase64,\n });\n apolloTrackResult = await this._screenshotValidation.createIntegrationStep(payload);\n }\n return apolloTrackResult;\n }\n\n /**\n * Captures and tracks a viewport screenshot for validation.\n * @param TrackViewportOptions Parameters for image tracking.\n * @returns {ApolloTrackResult} The result of the tracking operation.\n */\n async trackViewport(trackViewportOptions: TrackViewportOptions): Promise<IntegrationStep> {\n if (this._config.screenshotValidation.screenshotValidationEnabled) {\n return await this._trackViewport(trackViewportOptions);\n }\n return null;\n }\n}\n"]}
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.logVersionMetadata = void 0;
|
|
4
4
|
const child_process_1 = require("child_process");
|
|
5
5
|
const logVersionMetadata = () => {
|
|
6
|
-
let version = "4.
|
|
7
|
-
let hash = "
|
|
6
|
+
let version = "4.10.0"
|
|
7
|
+
let hash = "ce41411ac9e06db629ec10ff6865864c53851b8f"
|
|
8
8
|
if (version === '__LOCAL__') {
|
|
9
9
|
version = process.env.npm_package_version || '__LOCAL__';
|
|
10
10
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/tools/wopee-reporter/index.ts"],"names":[],"mappings":";;AAAA,yDAAmD;AAEnD,kBAAe,gCAAa,CAAC","sourcesContent":["import { WopeeReporter } from './wopeeReporter.js';\n\nexport default WopeeReporter;\n"]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const ExtendIntegrationScenarioPayloadSchema: z.ZodObject<{
|
|
3
|
+
input: z.ZodObject<{
|
|
4
|
+
projectUuid: z.ZodString;
|
|
5
|
+
scenarioUuid: z.ZodString;
|
|
6
|
+
pwSteps: z.ZodString;
|
|
7
|
+
}, "strip", z.ZodTypeAny, {
|
|
8
|
+
projectUuid?: string;
|
|
9
|
+
scenarioUuid?: string;
|
|
10
|
+
pwSteps?: string;
|
|
11
|
+
}, {
|
|
12
|
+
projectUuid?: string;
|
|
13
|
+
scenarioUuid?: string;
|
|
14
|
+
pwSteps?: string;
|
|
15
|
+
}>;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
input?: {
|
|
18
|
+
projectUuid?: string;
|
|
19
|
+
scenarioUuid?: string;
|
|
20
|
+
pwSteps?: string;
|
|
21
|
+
};
|
|
22
|
+
}, {
|
|
23
|
+
input?: {
|
|
24
|
+
projectUuid?: string;
|
|
25
|
+
scenarioUuid?: string;
|
|
26
|
+
pwSteps?: string;
|
|
27
|
+
};
|
|
28
|
+
}>;
|
|
29
|
+
type ExtendIntegrationScenarioPayload = z.infer<typeof ExtendIntegrationScenarioPayloadSchema>;
|
|
30
|
+
export { ExtendIntegrationScenarioPayloadSchema, ExtendIntegrationScenarioPayload };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExtendIntegrationScenarioPayloadSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const ExtendIntegrationScenarioPayloadSchema = zod_1.z.object({
|
|
6
|
+
input: zod_1.z.object({
|
|
7
|
+
projectUuid: zod_1.z.string({
|
|
8
|
+
required_error: 'Project UUID is required',
|
|
9
|
+
}),
|
|
10
|
+
scenarioUuid: zod_1.z.string({
|
|
11
|
+
required_error: 'Scenario UUID is required, please propagate "testInfo" as second argument in "test.beforeEach" hook and pass it to "wopee.startScenario("scenarioTitle", testInfo)" method as second argument if you want to use features of Wopee reporter',
|
|
12
|
+
}),
|
|
13
|
+
pwSteps: zod_1.z.string(),
|
|
14
|
+
}),
|
|
15
|
+
});
|
|
16
|
+
exports.ExtendIntegrationScenarioPayloadSchema = ExtendIntegrationScenarioPayloadSchema;
|
|
17
|
+
//# sourceMappingURL=wopeeReporter.interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wopeeReporter.interface.js","sourceRoot":"","sources":["../../../../lib/tools/wopee-reporter/types/wopeeReporter.interface.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,MAAM,sCAAsC,GAAG,OAAC,CAAC,MAAM,CAAC;IACtD,KAAK,EAAE,OAAC,CAAC,MAAM,CAAC;QACd,WAAW,EAAE,OAAC,CAAC,MAAM,CAAC;YACpB,cAAc,EAAE,0BAA0B;SAC3C,CAAC;QACF,YAAY,EAAE,OAAC,CAAC,MAAM,CAAC;YACrB,cAAc,EACZ,6OAA6O;SAChP,CAAC;QACF,OAAO,EAAE,OAAC,CAAC,MAAM,EAAE;KACpB,CAAC;CACH,CAAC,CAAC;AAIM,wFAAsC","sourcesContent":["import { z } from 'zod';\n\nconst ExtendIntegrationScenarioPayloadSchema = z.object({\n input: z.object({\n projectUuid: z.string({\n required_error: 'Project UUID is required',\n }),\n scenarioUuid: z.string({\n required_error:\n 'Scenario UUID is required, please propagate \"testInfo\" as second argument in \"test.beforeEach\" hook and pass it to \"wopee.startScenario(\"scenarioTitle\", testInfo)\" method as second argument if you want to use features of Wopee reporter',\n }),\n pwSteps: z.string(),\n }),\n});\n\ntype ExtendIntegrationScenarioPayload = z.infer<typeof ExtendIntegrationScenarioPayloadSchema>;\n\nexport { ExtendIntegrationScenarioPayloadSchema, ExtendIntegrationScenarioPayload };\n"]}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.WopeeReporter = void 0;
|
|
16
|
+
const wopeeReporter_interface_js_1 = require("./types/wopeeReporter.interface.js");
|
|
17
|
+
const utils_1 = require("./utils");
|
|
18
|
+
const axios_1 = __importDefault(require("axios"));
|
|
19
|
+
require("dotenv/config");
|
|
20
|
+
const { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID } = process.env;
|
|
21
|
+
class WopeeReporter {
|
|
22
|
+
onTestEnd(test) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
var _a, _b, _c, _d, _e;
|
|
25
|
+
const testRunId = (0, utils_1.generateTestRunId)();
|
|
26
|
+
const testResults = (_a = test.results) === null || _a === void 0 ? void 0 : _a[0];
|
|
27
|
+
const wopeeScenarioUuid = (_c = (_b = testResults === null || testResults === void 0 ? void 0 : testResults.attachments.find((a) => (a === null || a === void 0 ? void 0 : a.name) === 'wopee-scenario-uuid')) === null || _b === void 0 ? void 0 : _b.body) === null || _c === void 0 ? void 0 : _c.toString('utf-8');
|
|
28
|
+
const steps = testResults === null || testResults === void 0 ? void 0 : testResults.steps.map((step, index) => ({
|
|
29
|
+
testRunId,
|
|
30
|
+
number: index + 1,
|
|
31
|
+
testTitle: test.title,
|
|
32
|
+
title: step.title,
|
|
33
|
+
status: step.error ? 'failed' : 'passed',
|
|
34
|
+
error: step.error ? (0, utils_1.parseError)(step.error) : step.error,
|
|
35
|
+
category: step.category,
|
|
36
|
+
location: step.location,
|
|
37
|
+
}));
|
|
38
|
+
const query = `
|
|
39
|
+
mutation ExtendIntegrationScenario($input: ExtendIntegrationScenarioInput!) {
|
|
40
|
+
extendIntegrationScenario(input: $input)
|
|
41
|
+
}`;
|
|
42
|
+
const extendIntegrationScenarioPayload = {
|
|
43
|
+
input: {
|
|
44
|
+
projectUuid: WOPEE_PROJECT_UUID,
|
|
45
|
+
scenarioUuid: wopeeScenarioUuid,
|
|
46
|
+
pwSteps: JSON.stringify(steps),
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
const variables = wopeeReporter_interface_js_1.ExtendIntegrationScenarioPayloadSchema.parse(extendIntegrationScenarioPayload);
|
|
50
|
+
try {
|
|
51
|
+
return yield axios_1.default.post(WOPEE_API_URL, { query, variables }, {
|
|
52
|
+
headers: {
|
|
53
|
+
api_key: WOPEE_API_KEY,
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
59
|
+
const status = (_d = error.response) === null || _d === void 0 ? void 0 : _d.status;
|
|
60
|
+
const errorData = (_e = error.response) === null || _e === void 0 ? void 0 : _e.data;
|
|
61
|
+
console.error('[WOPEE_REPORTER_ERROR]', errorData);
|
|
62
|
+
throw new Error(`API request failed with status code: ${status}.`);
|
|
63
|
+
}
|
|
64
|
+
throw new Error('Unexpected error occurred during API call.');
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.WopeeReporter = WopeeReporter;
|
|
70
|
+
//# sourceMappingURL=wopeeReporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wopeeReporter.js","sourceRoot":"","sources":["../../../lib/tools/wopee-reporter/wopeeReporter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,mFAG4C;AAC5C,mCAAwD;AAExD,kDAA0B;AAC1B,yBAAuB;AAEvB,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAEzE,MAAa,aAAa;IAClB,SAAS,CAAC,IAAc;;;YAC5B,MAAM,SAAS,GAAG,IAAA,yBAAiB,GAAE,CAAC;YACtC,MAAM,WAAW,GAAG,MAAA,IAAI,CAAC,OAAO,0CAAG,CAAC,CAAC,CAAC;YACtC,MAAM,iBAAiB,GAAG,MAAA,MAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,WAAW,CAC/C,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,IAAI,MAAK,qBAAqB,CAAC,0CAC7C,IAAI,0CAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;YAE5B,MAAM,KAAK,GAAG,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC;gBACrD,SAAS;gBACT,MAAM,EAAE,KAAK,GAAG,CAAC;gBACjB,SAAS,EAAE,IAAI,CAAC,KAAK;gBACrB,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAA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ExtendIntegrationScenarioPayloadSchema,\n} from './types/wopeeReporter.interface.js';\nimport { generateTestRunId, parseError } from './utils';\nimport type { Reporter, TestCase } from '@playwright/test/reporter';\nimport axios from 'axios';\nimport 'dotenv/config';\n\nconst { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID } = process.env;\n\nexport class WopeeReporter implements Reporter {\n async onTestEnd(test: TestCase) {\n const testRunId = generateTestRunId();\n const testResults = test.results?.[0];\n const wopeeScenarioUuid = testResults?.attachments\n .find((a) => a?.name === 'wopee-scenario-uuid')\n ?.body?.toString('utf-8');\n\n const steps = testResults?.steps.map((step, index) => ({\n testRunId,\n number: index + 1,\n testTitle: test.title,\n title: step.title,\n status: step.error ? 'failed' : 'passed',\n error: step.error ? parseError(step.error) : step.error,\n category: step.category,\n location: step.location,\n }));\n\n const query = `\n mutation ExtendIntegrationScenario($input: ExtendIntegrationScenarioInput!) {\n extendIntegrationScenario(input: $input)\n }`;\n\n const extendIntegrationScenarioPayload: ExtendIntegrationScenarioPayload = {\n input: {\n projectUuid: WOPEE_PROJECT_UUID,\n scenarioUuid: wopeeScenarioUuid,\n pwSteps: JSON.stringify(steps),\n },\n };\n const variables = ExtendIntegrationScenarioPayloadSchema.parse(extendIntegrationScenarioPayload);\n\n try {\n return await axios.post(\n WOPEE_API_URL,\n { query, variables },\n {\n headers: {\n api_key: WOPEE_API_KEY,\n },\n },\n );\n } catch (error) {\n if (axios.isAxiosError(error)) {\n const status = error.response?.status;\n const errorData = error.response?.data;\n console.error('[WOPEE_REPORTER_ERROR]', errorData);\n throw new Error(`API request failed with status code: ${status}.`);\n }\n throw new Error('Unexpected error occurred during API call.');\n }\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wopee-io/wopee.pw",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.10.0",
|
|
4
4
|
"description": "Wopee's Playwright integration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"visual testing",
|
|
7
7
|
"playwright",
|
|
8
8
|
"wopee"
|
|
9
9
|
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build:win": "rm -rf ./build/ && npx tsc && node utils/addVersionToBuild.mjs"
|
|
12
|
+
},
|
|
10
13
|
"author": "Ondrej Winter <ondrej.winter@gmail.com>",
|
|
11
14
|
"license": "PROPRIETARY",
|
|
12
15
|
"homepage": "https://Wopee.io",
|
|
@@ -20,7 +23,7 @@
|
|
|
20
23
|
"type": "commonjs",
|
|
21
24
|
"dependencies": {
|
|
22
25
|
"@autonomous-testing/sdk": "3.2.6",
|
|
23
|
-
"dotenv": "^16.4.
|
|
26
|
+
"dotenv": "^16.4.7",
|
|
24
27
|
"lodash": "^4.17.21"
|
|
25
28
|
},
|
|
26
29
|
"devDependencies": {
|