@wopee-io/wopee.pw 4.25.1 → 4.26.1
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/domain/configuration/config.interface.d.ts +2 -2
- package/build/core/domain/configuration/config.interface.js.map +1 -1
- package/build/core/services/wopeeService/wopee.js +3 -1
- package/build/core/services/wopeeService/wopee.js.map +1 -1
- package/build/infrastructure/adapters/envConfigAdapter/envConfigAdapter.js +11 -9
- package/build/infrastructure/adapters/envConfigAdapter/envConfigAdapter.js.map +1 -1
- package/build/shared/metadata/versionMetadata.js +2 -2
- package/build/tools/wopee-reporter/wopeeReporter.js +1 -0
- package/build/tools/wopee-reporter/wopeeReporter.js.map +1 -1
- package/docs/configuration.md +18 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/adapter.d.ts +9 -2
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/adapter.js +30 -3
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/axios-config.d.ts +15 -1
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/axios-config.js +17 -1
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/deadline.d.ts +36 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/deadline.js +63 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/errors.js +10 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/index.d.ts +2 -2
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/interface.d.ts +15 -1
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/interface.js +8 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/retry.d.ts +52 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/retry.js +122 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/apolloAdapterService/apolloAdapterService.js +3 -7
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/apolloAdapterService/apolloService.interface.d.ts +2 -2
- package/node_modules/@autonomous-testing/sdk/build/shared/metadata/versionMetadata.js +2 -2
- package/node_modules/@autonomous-testing/sdk/package.json +1 -1
- package/package.json +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface ScreenshotValidationOptions extends
|
|
1
|
+
import { ApolloAdapterConfigInput } from '@autonomous-testing/sdk';
|
|
2
|
+
export interface ScreenshotValidationOptions extends ApolloAdapterConfigInput {
|
|
3
3
|
screenshotValidationEnabled?: boolean;
|
|
4
4
|
collectPageContent?: boolean;
|
|
5
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.interface.js","sourceRoot":"","sources":["../../../../lib/core/domain/configuration/config.interface.ts"],"names":[],"mappings":"","sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"config.interface.js","sourceRoot":"","sources":["../../../../lib/core/domain/configuration/config.interface.ts"],"names":[],"mappings":"","sourcesContent":["import { ApolloAdapterConfigInput } from '@autonomous-testing/sdk';\n\n/*\nExtends the SDK's *input* config rather than its parsed one. Every SDK option\nthat has a default is required on the parsed type, so extending that would make\neach new defaulted SDK option a breaking change here.\n*/\nexport interface ScreenshotValidationOptions extends ApolloAdapterConfigInput {\n /*\n If true, screenshotValidation is enabled.\n */\n screenshotValidationEnabled?: boolean;\n /*\n If true, will be collected through trackFullPage and trackViewport methods if screenshotValidationEnabled is also true.\n */\n collectPageContent?: boolean;\n}\n\nexport interface WopeeOptions {\n screenshotValidation?: ScreenshotValidationOptions;\n}\n"]}
|
|
@@ -23,7 +23,7 @@ class Wopee {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
_createApolloTrackAdapter() {
|
|
26
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
26
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
27
27
|
const apolloAdapterConfig = {
|
|
28
28
|
apiKey: this._config.screenshotValidation.apiKey,
|
|
29
29
|
apiUrl: this._config.screenshotValidation.apiUrl,
|
|
@@ -39,6 +39,8 @@ class Wopee {
|
|
|
39
39
|
customTags: (_h = this._config.screenshotValidation) === null || _h === void 0 ? void 0 : _h.customTags,
|
|
40
40
|
baselineBranchName: (_j = this._config.screenshotValidation) === null || _j === void 0 ? void 0 : _j.baselineBranchName,
|
|
41
41
|
suiteUuid: (_k = this._config.screenshotValidation) === null || _k === void 0 ? void 0 : _k.suiteUuid,
|
|
42
|
+
maxRetries: (_l = this._config.screenshotValidation) === null || _l === void 0 ? void 0 : _l.maxRetries,
|
|
43
|
+
requestTimeoutMs: (_m = this._config.screenshotValidation) === null || _m === void 0 ? void 0 : _m.requestTimeoutMs,
|
|
42
44
|
};
|
|
43
45
|
return (0, sdk_1.createApolloTrackAdapter)({
|
|
44
46
|
apolloAdapterConfig: apolloAdapterConfig,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wopee.js","sourceRoot":"","sources":["../../../../lib/core/services/wopeeService/wopee.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+GAAyG;AACzG,uDAA8D;AAS9D,iDAUiC;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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EAAE,CAAC;gBACpC,MAAM,WAAW,GAAG,MAAM,mBAAmB,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;gBAChE,WAAW,GAAG,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAC/C,CAAC;YACD,MAAM,OAAO,GAAwB,+BAAyB,CAAC,KAAK,CAAC;gBACnE,WAAW;gBACX,MAAM,EAAE,mBAAmB,CAAC,MAAM;gBAClC,OAAO,EAAE,mBAAmB,CAAC,OAAO;aACrC,CAAC,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAChE,CAAC;KAAA;CACF;AA1OD,sBA0OC","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 { VisualAssertOptions } from '../../domain/valueObjects/visualAssert.interface.js';\nimport {\n ApolloAdapter,\n ApolloAdapterConfig,\n CreateIntegrationStepPayload,\n CreateIntegrationStepPayloadSchema,\n IntegrationStep,\n VisualAssert,\n VisualAssertPayload,\n VisualAssertPayloadSchema,\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 baselineBranchName: this._config.screenshotValidation?.baselineBranchName,\n suiteUuid: this._config.screenshotValidation?.suiteUuid,\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 // Lets the wopee reporter stop the suite at the end of the run (worker → reporter channel).\n if (this._screenshotValidation.suite?.uuid) {\n await testInfo.attach('wopee-suite-uuid', {\n contentType: 'text/plain',\n body: this._screenshotValidation.suite.uuid,\n });\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 let pageContentBase64 = 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 if (this._config.screenshotValidation.collectPageContent) {\n const pageContent = await trackFullPageOptions.page.content();\n pageContentBase64 = Buffer.from(pageContent, 'utf-8').toString('base64');\n }\n const payload: CreateIntegrationStepPayload = CreateIntegrationStepPayloadSchema.parse({\n ...trackFullPageOptions,\n imageBase64,\n pageContentBase64,\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 let pageContentBase64 = 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 if (this._config.screenshotValidation.collectPageContent) {\n const pageContent = await trackViewportOptions.page.content();\n pageContentBase64 = Buffer.from(pageContent, 'utf-8').toString('base64');\n }\n const payload: CreateIntegrationStepPayload = CreateIntegrationStepPayloadSchema.parse({\n ...trackViewportOptions,\n imageBase64,\n pageContentBase64,\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 /**\n * Visual assert based on provided context, prompt (question) against an image.\n * Provide either imageBase64 or page object to take a screenshot at the current state.\n * @param VisualAssertOptions Parameters for visual assertion.\n * @returns {VisualAssert} The result of the visual assertion operation.\n */\n async visualAssert(visualAssertOptions: VisualAssertOptions): Promise<VisualAssert> {\n let imageBase64 = null;\n if (visualAssertOptions.imageBase64) {\n imageBase64 = visualAssertOptions.imageBase64;\n } else if (visualAssertOptions.page) {\n const imageBuffer = await visualAssertOptions.page.screenshot();\n imageBase64 = imageBuffer.toString('base64');\n }\n const payload: VisualAssertPayload = VisualAssertPayloadSchema.parse({\n imageBase64,\n prompt: visualAssertOptions.prompt,\n context: visualAssertOptions.context,\n });\n return await this._screenshotValidation.visualAssert(payload);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"wopee.js","sourceRoot":"","sources":["../../../../lib/core/services/wopeeService/wopee.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+GAAyG;AACzG,uDAA8D;AAS9D,iDAUiC;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,GAA6B;YACpD,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,M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EAAE,CAAC;gBACpC,WAAW,GAAG,mBAAmB,CAAC,WAAW,CAAC;YAChD,CAAC;iBAAM,IAAI,mBAAmB,CAAC,IAAI,EAAE,CAAC;gBACpC,MAAM,WAAW,GAAG,MAAM,mBAAmB,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;gBAChE,WAAW,GAAG,WAAW,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAC/C,CAAC;YACD,MAAM,OAAO,GAAwB,+BAAyB,CAAC,KAAK,CAAC;gBACnE,WAAW;gBACX,MAAM,EAAE,mBAAmB,CAAC,MAAM;gBAClC,OAAO,EAAE,mBAAmB,CAAC,OAAO;aACrC,CAAC,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QAChE,CAAC;KAAA;CACF;AA5OD,sBA4OC","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 { VisualAssertOptions } from '../../domain/valueObjects/visualAssert.interface.js';\nimport {\n ApolloAdapter,\n ApolloAdapterConfigInput,\n CreateIntegrationStepPayload,\n CreateIntegrationStepPayloadSchema,\n IntegrationStep,\n VisualAssert,\n VisualAssertPayload,\n VisualAssertPayloadSchema,\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: ApolloAdapterConfigInput = {\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 baselineBranchName: this._config.screenshotValidation?.baselineBranchName,\n suiteUuid: this._config.screenshotValidation?.suiteUuid,\n maxRetries: this._config.screenshotValidation?.maxRetries,\n requestTimeoutMs: this._config.screenshotValidation?.requestTimeoutMs,\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 // Lets the wopee reporter stop the suite at the end of the run (worker → reporter channel).\n if (this._screenshotValidation.suite?.uuid) {\n await testInfo.attach('wopee-suite-uuid', {\n contentType: 'text/plain',\n body: this._screenshotValidation.suite.uuid,\n });\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 let pageContentBase64 = 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 if (this._config.screenshotValidation.collectPageContent) {\n const pageContent = await trackFullPageOptions.page.content();\n pageContentBase64 = Buffer.from(pageContent, 'utf-8').toString('base64');\n }\n const payload: CreateIntegrationStepPayload = CreateIntegrationStepPayloadSchema.parse({\n ...trackFullPageOptions,\n imageBase64,\n pageContentBase64,\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 let pageContentBase64 = 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 if (this._config.screenshotValidation.collectPageContent) {\n const pageContent = await trackViewportOptions.page.content();\n pageContentBase64 = Buffer.from(pageContent, 'utf-8').toString('base64');\n }\n const payload: CreateIntegrationStepPayload = CreateIntegrationStepPayloadSchema.parse({\n ...trackViewportOptions,\n imageBase64,\n pageContentBase64,\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 /**\n * Visual assert based on provided context, prompt (question) against an image.\n * Provide either imageBase64 or page object to take a screenshot at the current state.\n * @param VisualAssertOptions Parameters for visual assertion.\n * @returns {VisualAssert} The result of the visual assertion operation.\n */\n async visualAssert(visualAssertOptions: VisualAssertOptions): Promise<VisualAssert> {\n let imageBase64 = null;\n if (visualAssertOptions.imageBase64) {\n imageBase64 = visualAssertOptions.imageBase64;\n } else if (visualAssertOptions.page) {\n const imageBuffer = await visualAssertOptions.page.screenshot();\n imageBase64 = imageBuffer.toString('base64');\n }\n const payload: VisualAssertPayload = VisualAssertPayloadSchema.parse({\n imageBase64,\n prompt: visualAssertOptions.prompt,\n context: visualAssertOptions.context,\n });\n return await this._screenshotValidation.visualAssert(payload);\n }\n}\n"]}
|
|
@@ -5,7 +5,7 @@ const configPort_js_1 = require("../../../core/ports/configPort/configPort.js");
|
|
|
5
5
|
require("dotenv/config");
|
|
6
6
|
class EnvConfigAdapter extends configPort_js_1.ConfigPort {
|
|
7
7
|
_loadConfig() {
|
|
8
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
8
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
9
9
|
const screenshotValidationOptions = {
|
|
10
10
|
apiKey: (_a = process.env) === null || _a === void 0 ? void 0 : _a.WOPEE_API_KEY,
|
|
11
11
|
apiUrl: (_b = process.env) === null || _b === void 0 ? void 0 : _b.WOPEE_API_URL,
|
|
@@ -15,14 +15,16 @@ class EnvConfigAdapter extends configPort_js_1.ConfigPort {
|
|
|
15
15
|
customTags: (_f = process.env) === null || _f === void 0 ? void 0 : _f.WOPEE_CUSTOM_TAGS,
|
|
16
16
|
device: (_g = process.env) === null || _g === void 0 ? void 0 : _g.WOPEE_DEVICE,
|
|
17
17
|
enableSoftAssert: (_h = process.env) === null || _h === void 0 ? void 0 : _h.WOPEE_ENABLE_SOFT_ASSERT,
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
maxRetries: ((_j = process.env) === null || _j === void 0 ? void 0 : _j.WOPEE_API_MAX_RETRIES) || undefined,
|
|
19
|
+
os: (_k = process.env) === null || _k === void 0 ? void 0 : _k.WOPEE_OS,
|
|
20
|
+
pixelToPixelDiffTolerance: (_l = process.env) === null || _l === void 0 ? void 0 : _l.WOPEE_PIXEL_TO_PIXEL_DIFF_TOLERANCE,
|
|
21
|
+
projectUuid: (_m = process.env) === null || _m === void 0 ? void 0 : _m.WOPEE_PROJECT_UUID,
|
|
22
|
+
requestTimeoutMs: ((_o = process.env) === null || _o === void 0 ? void 0 : _o.WOPEE_API_TIMEOUT_MS) || undefined,
|
|
23
|
+
screenshotValidationEnabled: (_p = process.env) === null || _p === void 0 ? void 0 : _p.WOPEE_SCREENSHOT_VALIDATION_ENABLED,
|
|
24
|
+
viewport: (_q = process.env) === null || _q === void 0 ? void 0 : _q.WOPEE_VIEWPORT,
|
|
25
|
+
collectPageContent: (_r = process.env) === null || _r === void 0 ? void 0 : _r.WOPEE_COLLECT_PAGE_CONTENT,
|
|
26
|
+
baselineBranchName: (_s = process.env) === null || _s === void 0 ? void 0 : _s.WOPEE_BASELINE_BRANCH_NAME,
|
|
27
|
+
suiteUuid: (_t = process.env) === null || _t === void 0 ? void 0 : _t.WOPEE_SUITE_UUID,
|
|
26
28
|
};
|
|
27
29
|
return { screenshotValidation: screenshotValidationOptions };
|
|
28
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"envConfigAdapter.js","sourceRoot":"","sources":["../../../../lib/infrastructure/adapters/envConfigAdapter/envConfigAdapter.ts"],"names":[],"mappings":";;;AACA,gFAA0E;AAC1E,yBAAuB;AAEvB,MAAa,gBAAiB,SAAQ,0BAAU;IAC9C,WAAW;;QACT,MAAM,2BAA2B,GAAG;YAClC,MAAM,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,aAAa;YAClC,MAAM,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,aAAa;YAClC,UAAU,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,iBAAiB;YAC1C,OAAO,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,aAAa;YACnC,OAAO,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,aAAa;YACnC,UAAU,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,iBAAiB;YAC1C,MAAM,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,YAAY;YACjC,gBAAgB,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,wBAAwB;
|
|
1
|
+
{"version":3,"file":"envConfigAdapter.js","sourceRoot":"","sources":["../../../../lib/infrastructure/adapters/envConfigAdapter/envConfigAdapter.ts"],"names":[],"mappings":";;;AACA,gFAA0E;AAC1E,yBAAuB;AAEvB,MAAa,gBAAiB,SAAQ,0BAAU;IAC9C,WAAW;;QACT,MAAM,2BAA2B,GAAG;YAClC,MAAM,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,aAAa;YAClC,MAAM,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,aAAa;YAClC,UAAU,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,iBAAiB;YAC1C,OAAO,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,aAAa;YACnC,OAAO,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,aAAa;YACnC,UAAU,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,iBAAiB;YAC1C,MAAM,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,YAAY;YACjC,gBAAgB,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,wBAAwB;YAKvD,UAAU,EAAE,CAAA,MAAA,OAAO,CAAC,GAAG,0CAAE,qBAAqB,KAAI,SAAS;YAC3D,EAAE,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,QAAQ;YACzB,yBAAyB,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,mCAAmC;YAC3E,WAAW,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,kBAAkB;YAC5C,gBAAgB,EAAE,CAAA,MAAA,OAAO,CAAC,GAAG,0CAAE,oBAAoB,KAAI,SAAS;YAChE,2BAA2B,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,mCAAmC;YAC7E,QAAQ,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,cAAc;YACrC,kBAAkB,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,0BAA0B;YAC3D,kBAAkB,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,0BAA0B;YAC3D,SAAS,EAAE,MAAA,OAAO,CAAC,GAAG,0CAAE,gBAAgB;SACzC,CAAC;QAEF,OAAO,EAAE,oBAAoB,EAAE,2BAAiE,EAAE,CAAC;IACrG,CAAC;CACF;AA7BD,4CA6BC","sourcesContent":["import { ScreenshotValidationOptions, WopeeOptions } from '../../../core/domain/configuration/config.interface.js';\nimport { ConfigPort } from '../../../core/ports/configPort/configPort.js';\nimport 'dotenv/config';\n\nexport class EnvConfigAdapter extends ConfigPort {\n _loadConfig(): WopeeOptions {\n const screenshotValidationOptions = {\n apiKey: process.env?.WOPEE_API_KEY,\n apiUrl: process.env?.WOPEE_API_URL,\n branchName: process.env?.WOPEE_BRANCH_NAME,\n browser: process.env?.WOPEE_BROWSER,\n comment: process.env?.WOPEE_COMMENT,\n customTags: process.env?.WOPEE_CUSTOM_TAGS,\n device: process.env?.WOPEE_DEVICE,\n enableSoftAssert: process.env?.WOPEE_ENABLE_SOFT_ASSERT,\n // `|| undefined` because an exported-but-empty variable arrives as '',\n // and Number('') is 0 — which would silently mean \"no retries\" and \"no\n // timeout\" rather than \"not configured\". The SDK never reads the\n // environment itself, so blank has to be normalised here.\n maxRetries: process.env?.WOPEE_API_MAX_RETRIES || undefined,\n os: process.env?.WOPEE_OS,\n pixelToPixelDiffTolerance: process.env?.WOPEE_PIXEL_TO_PIXEL_DIFF_TOLERANCE,\n projectUuid: process.env?.WOPEE_PROJECT_UUID,\n requestTimeoutMs: process.env?.WOPEE_API_TIMEOUT_MS || undefined,\n screenshotValidationEnabled: process.env?.WOPEE_SCREENSHOT_VALIDATION_ENABLED,\n viewport: process.env?.WOPEE_VIEWPORT,\n collectPageContent: process.env?.WOPEE_COLLECT_PAGE_CONTENT,\n baselineBranchName: process.env?.WOPEE_BASELINE_BRANCH_NAME,\n suiteUuid: process.env?.WOPEE_SUITE_UUID,\n };\n\n return { screenshotValidation: screenshotValidationOptions as any as ScreenshotValidationOptions };\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.26.1"
|
|
7
|
+
let hash = "fe83ca0dc8ab9364ec77655b8b0575ef4f632c1f"
|
|
8
8
|
if (version === '__LOCAL__') {
|
|
9
9
|
version = process.env.npm_package_version || '__LOCAL__';
|
|
10
10
|
}
|
|
@@ -163,6 +163,7 @@ class WopeeReporter {
|
|
|
163
163
|
const apiUrl = WOPEE_API_URL || 'https://api.wopee.io';
|
|
164
164
|
const headers = {
|
|
165
165
|
api_key: WOPEE_API_KEY,
|
|
166
|
+
'x-api-key': WOPEE_API_KEY,
|
|
166
167
|
};
|
|
167
168
|
return { apiUrl, config: (0, axios_config_js_1.buildAxiosConfig)(apiUrl, headers) };
|
|
168
169
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wopeeReporter.js","sourceRoot":"","sources":["../../../lib/tools/wopee-reporter/wopeeReporter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAsF;AACtF,+DAA6D;AAC7D,mFAG4C;AAE5C,kDAA0B;AAC1B,yBAAuB;AACvB,sDAAyB;AAEzB,MAAa,aAAa;IAKxB;QACE,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC5B,CAAC;IAMO,GAAG;QACT,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;QACzE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,CAAC;IAC9D,CAAC;IAOO,cAAc;QACpB,MAAM,EAAE,aAAa,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzD,MAAM,OAAO,GAAG;YACd,GAAG,CAAC,CAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,IAAI,EAAE,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC;YACnD,GAAG,CAAC,CAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,IAAI,EAAE,EAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC;SAC9D,CAAC;QAEF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EA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port { buildAxiosConfig } from './helpers/axios-config.js';\nimport {\n ExtendIntegrationScenarioPayload,\n ExtendIntegrationScenarioPayloadSchema,\n} from './types/wopeeReporter.interface.js';\nimport type { Reporter, TestCase, TestResult } from '@playwright/test/reporter';\nimport axios from 'axios';\nimport 'dotenv/config';\nimport fs from 'node:fs';\n\nexport class WopeeReporter implements Reporter {\n private uploadQueue: Promise<any>[];\n private suiteUuids: Set<string>;\n private configWarned: boolean;\n\n constructor() {\n this.uploadQueue = [];\n this.suiteUuids = new Set();\n this.configWarned = false;\n }\n\n /*\n Read lazily rather than at module load, so a playwright.config.ts that assigns\n process.env.WOPEE_* at runtime is picked up.\n */\n private env() {\n const { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID } = process.env;\n return { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID };\n }\n\n /*\n A reporter must never fail the run, so this warns and skips rather than\n throwing — otherwise an unauthenticated request is queued and its 401 is\n swallowed by onExit, leaving the user with silently missing results.\n */\n private hasCredentials(): boolean {\n const { WOPEE_API_KEY, WOPEE_PROJECT_UUID } = this.env();\n const missing = [\n ...(WOPEE_API_KEY?.trim() ? [] : ['WOPEE_API_KEY']),\n ...(WOPEE_PROJECT_UUID?.trim() ? [] : ['WOPEE_PROJECT_UUID']),\n ];\n\n if (missing.length === 0) {\n return true;\n }\n\n if (!this.configWarned) {\n this.configWarned = true;\n console.error(\n `[WOPEE_REPORTER_ERROR]: Wopee reporter is disabled — ${missing.join(' and ')} ${\n missing.length > 1 ? 'are' : 'is'\n } not set. Get credentials from Project Settings → API Keys at https://cmd.wopee.io and set them in your shell, a .env file, or CI secrets. Test results will not be uploaded.`,\n );\n }\n return false;\n }\n\n onTestEnd(test: TestCase, result: TestResult) {\n const testRunId = generateTestRunId();\n\n const wopeeSuiteUuid = result.attachments.find((a) => a?.name === 'wopee-suite-uuid')?.body?.toString('utf-8');\n if (wopeeSuiteUuid) {\n this.suiteUuids.add(wopeeSuiteUuid);\n }\n\n const wopeeScenarioUuid = result.attachments\n .find((a) => a?.name === 'wopee-scenario-uuid')\n ?.body?.toString('utf-8');\n\n const failedStep = [...result.steps].reverse().find((step) => step.error);\n\n const createStepId = (step: any) => `${step.title}-${step.category}-${step.startTime}`;\n const failedStepId = failedStep ? createStepId(failedStep) : null;\n\n let screenshotBase64: string | null = null;\n let videoBase64: string | null = null;\n\n for (const attachment of result.attachments) {\n if (attachment.name === 'screenshot' && attachment.contentType === 'image/png') {\n const filePath = attachment.path;\n if (filePath) {\n try {\n const imageBuffer = fs.readFileSync(filePath);\n screenshotBase64 = imageBuffer.toString('base64');\n } catch (error) {\n console.error('Error reading screenshot:', error);\n }\n }\n }\n\n if (\n attachment.name === 'video' &&\n (attachment.contentType === 'video/webm' ||\n attachment.contentType === 'video/mp4' ||\n attachment.contentType === 'video/avi')\n ) {\n const filePath = attachment.path;\n if (filePath) {\n try {\n const videoBuffer = fs.readFileSync(filePath);\n videoBase64 = videoBuffer.toString('base64');\n } catch (error) {\n console.error('Error reading video:', error);\n }\n }\n }\n }\n\n if (!wopeeScenarioUuid) {\n return console.error(\n '[WOPEE_REPORTER_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',\n );\n }\n\n if (!this.hasCredentials()) {\n return;\n }\n\n const steps = result.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 duration: step.duration,\n startTime: step.startTime,\n steps: parseNestedSteps(step.steps),\n screenshotBase64: createStepId(step) === failedStepId ? screenshotBase64 : null,\n videoBase64: createStepId(step) === failedStepId ? videoBase64 : null,\n }));\n\n const query = `\n mutation ExtendIntegrationScenario($input: ExtendIntegrationScenarioInput!) {\n extendIntegrationScenario(input: $input)\n }`;\n\n const extendIntegrationScenarioPayload: ExtendIntegrationScenarioPayload = {\n input: {\n projectUuid: this.env().WOPEE_PROJECT_UUID,\n scenarioUuid: wopeeScenarioUuid,\n pwSteps: JSON.stringify(steps, replacer),\n ...(process.env.GITHUB_RUN_ID && {\n githubRunId: process.env.GITHUB_RUN_ID,\n }),\n ...(process.env.GITHUB_RUN_ATTEMPT && {\n githubRunAttempt: Number(process.env.GITHUB_RUN_ATTEMPT),\n }),\n },\n };\n const variables = ExtendIntegrationScenarioPayloadSchema.parse(extendIntegrationScenarioPayload);\n\n const uploadPromise = new Promise(async (resolve, reject) => {\n try {\n const { apiUrl, config } = this.apiRequestConfig();\n const response = await axios.post(apiUrl, { query, variables }, config);\n resolve(response);\n } catch (error) {\n if (axios.isAxiosError(error)) {\n const status = error.response?.status;\n const errorData = error.response?.data;\n const errorMessage = error.message;\n console.error('[WOPEE_REPORTER_ERROR]', errorMessage, errorData);\n return reject(new Error(`API request failed with status code: ${status}.`));\n }\n reject(new Error(`[WOPEE_REPORTER_ERROR] Unexpected error occurred during API call: ${error?.message}`));\n }\n });\n\n this.uploadQueue.push(uploadPromise);\n }\n\n async onExit(): Promise<void> {\n if (this.uploadQueue.length > 0) {\n console.log(`Uploading ${this.uploadQueue.length} remaining test results...`);\n try {\n await Promise.all(this.uploadQueue);\n console.log('Successfully uploaded all test results.');\n } catch (error) {\n console.error('Error uploading test results:', error);\n } finally {\n this.uploadQueue = [];\n }\n }\n\n await this.stopSuites();\n }\n\n private apiRequestConfig() {\n const { WOPEE_API_KEY, WOPEE_API_URL } = this.env();\n const apiUrl = WOPEE_API_URL || 'https://api.wopee.io';\n const headers = {\n api_key: WOPEE_API_KEY,\n };\n return { apiUrl, config: buildAxiosConfig(apiUrl, headers) };\n }\n\n // Teardown is best-effort: a failed stop must never fail the run — suites are also\n // finished lazily by the API when left IDLE.\n private async stopSuites(): Promise<void> {\n // Without credentials this would fire unauthenticated requests whose 401s\n // contradict the \"results will not be uploaded\" warning already logged.\n if (this.suiteUuids.size > 0 && !this.hasCredentials()) {\n this.suiteUuids.clear();\n return;\n }\n\n const query = `\n mutation StopIntegrationSuite($suiteUuid: ID!) {\n stopIntegrationSuite(suiteUuid: $suiteUuid) { uuid suiteRunningStatus }\n }`;\n\n for (const suiteUuid of this.suiteUuids) {\n try {\n const { apiUrl, config } = this.apiRequestConfig();\n const response = await axios.post(apiUrl, { query, variables: { suiteUuid } }, config);\n const errors = response.data?.errors;\n if (errors?.length) {\n console.error(`[WOPEE_REPORTER_ERROR] Failed to stop suite ${suiteUuid}:`, errors[0]?.message);\n } else {\n console.log(`Suite(uuid=${suiteUuid}) is stopped.`);\n }\n } catch (error: any) {\n console.error(`[WOPEE_REPORTER_ERROR] Failed to stop suite ${suiteUuid}: ${error?.message}`);\n }\n }\n this.suiteUuids.clear();\n }\n\n printsToStdio(): boolean {\n return false;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"wopeeReporter.js","sourceRoot":"","sources":["../../../lib/tools/wopee-reporter/wopeeReporter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAsF;AACtF,+DAA6D;AAC7D,mFAG4C;AAE5C,kDAA0B;AAC1B,yBAAuB;AACvB,sDAAyB;AAEzB,MAAa,aAAa;IAKxB;QACE,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC5B,CAAC;IAMO,GAAG;QACT,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;QACzE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,CAAC;IAC9D,CAAC;IAOO,cAAc;QACpB,MAAM,EAAE,aAAa,EAAE,kBAAkB,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACzD,MAAM,OAAO,GAAG;YACd,GAAG,C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H,CAAC;gBAAC,OAAO,KAAU,EAAE,CAAC;oBACpB,OAAO,CAAC,KAAK,CAAC,+CAA+C,SAAS,KAAK,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,OAAO,EAAE,CAAC,CAAC;gBAC/F,CAAC;YACH,CAAC;YACD,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;QAC1B,CAAC;KAAA;IAED,aAAa;QACX,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAtOD,sCAsOC","sourcesContent":["import { generateTestRunId, parseError, parseNestedSteps, replacer } from './helpers';\nimport { buildAxiosConfig } from './helpers/axios-config.js';\nimport {\n ExtendIntegrationScenarioPayload,\n ExtendIntegrationScenarioPayloadSchema,\n} from './types/wopeeReporter.interface.js';\nimport type { Reporter, TestCase, TestResult } from '@playwright/test/reporter';\nimport axios from 'axios';\nimport 'dotenv/config';\nimport fs from 'node:fs';\n\nexport class WopeeReporter implements Reporter {\n private uploadQueue: Promise<any>[];\n private suiteUuids: Set<string>;\n private configWarned: boolean;\n\n constructor() {\n this.uploadQueue = [];\n this.suiteUuids = new Set();\n this.configWarned = false;\n }\n\n /*\n Read lazily rather than at module load, so a playwright.config.ts that assigns\n process.env.WOPEE_* at runtime is picked up.\n */\n private env() {\n const { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID } = process.env;\n return { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID };\n }\n\n /*\n A reporter must never fail the run, so this warns and skips rather than\n throwing — otherwise an unauthenticated request is queued and its 401 is\n swallowed by onExit, leaving the user with silently missing results.\n */\n private hasCredentials(): boolean {\n const { WOPEE_API_KEY, WOPEE_PROJECT_UUID } = this.env();\n const missing = [\n ...(WOPEE_API_KEY?.trim() ? [] : ['WOPEE_API_KEY']),\n ...(WOPEE_PROJECT_UUID?.trim() ? [] : ['WOPEE_PROJECT_UUID']),\n ];\n\n if (missing.length === 0) {\n return true;\n }\n\n if (!this.configWarned) {\n this.configWarned = true;\n console.error(\n `[WOPEE_REPORTER_ERROR]: Wopee reporter is disabled — ${missing.join(' and ')} ${\n missing.length > 1 ? 'are' : 'is'\n } not set. Get credentials from Project Settings → API Keys at https://cmd.wopee.io and set them in your shell, a .env file, or CI secrets. Test results will not be uploaded.`,\n );\n }\n return false;\n }\n\n onTestEnd(test: TestCase, result: TestResult) {\n const testRunId = generateTestRunId();\n\n const wopeeSuiteUuid = result.attachments.find((a) => a?.name === 'wopee-suite-uuid')?.body?.toString('utf-8');\n if (wopeeSuiteUuid) {\n this.suiteUuids.add(wopeeSuiteUuid);\n }\n\n const wopeeScenarioUuid = result.attachments\n .find((a) => a?.name === 'wopee-scenario-uuid')\n ?.body?.toString('utf-8');\n\n const failedStep = [...result.steps].reverse().find((step) => step.error);\n\n const createStepId = (step: any) => `${step.title}-${step.category}-${step.startTime}`;\n const failedStepId = failedStep ? createStepId(failedStep) : null;\n\n let screenshotBase64: string | null = null;\n let videoBase64: string | null = null;\n\n for (const attachment of result.attachments) {\n if (attachment.name === 'screenshot' && attachment.contentType === 'image/png') {\n const filePath = attachment.path;\n if (filePath) {\n try {\n const imageBuffer = fs.readFileSync(filePath);\n screenshotBase64 = imageBuffer.toString('base64');\n } catch (error) {\n console.error('Error reading screenshot:', error);\n }\n }\n }\n\n if (\n attachment.name === 'video' &&\n (attachment.contentType === 'video/webm' ||\n attachment.contentType === 'video/mp4' ||\n attachment.contentType === 'video/avi')\n ) {\n const filePath = attachment.path;\n if (filePath) {\n try {\n const videoBuffer = fs.readFileSync(filePath);\n videoBase64 = videoBuffer.toString('base64');\n } catch (error) {\n console.error('Error reading video:', error);\n }\n }\n }\n }\n\n if (!wopeeScenarioUuid) {\n return console.error(\n '[WOPEE_REPORTER_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',\n );\n }\n\n if (!this.hasCredentials()) {\n return;\n }\n\n const steps = result.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 duration: step.duration,\n startTime: step.startTime,\n steps: parseNestedSteps(step.steps),\n screenshotBase64: createStepId(step) === failedStepId ? screenshotBase64 : null,\n videoBase64: createStepId(step) === failedStepId ? videoBase64 : null,\n }));\n\n const query = `\n mutation ExtendIntegrationScenario($input: ExtendIntegrationScenarioInput!) {\n extendIntegrationScenario(input: $input)\n }`;\n\n const extendIntegrationScenarioPayload: ExtendIntegrationScenarioPayload = {\n input: {\n projectUuid: this.env().WOPEE_PROJECT_UUID,\n scenarioUuid: wopeeScenarioUuid,\n pwSteps: JSON.stringify(steps, replacer),\n ...(process.env.GITHUB_RUN_ID && {\n githubRunId: process.env.GITHUB_RUN_ID,\n }),\n ...(process.env.GITHUB_RUN_ATTEMPT && {\n githubRunAttempt: Number(process.env.GITHUB_RUN_ATTEMPT),\n }),\n },\n };\n const variables = ExtendIntegrationScenarioPayloadSchema.parse(extendIntegrationScenarioPayload);\n\n const uploadPromise = new Promise(async (resolve, reject) => {\n try {\n const { apiUrl, config } = this.apiRequestConfig();\n const response = await axios.post(apiUrl, { query, variables }, config);\n resolve(response);\n } catch (error) {\n if (axios.isAxiosError(error)) {\n const status = error.response?.status;\n const errorData = error.response?.data;\n const errorMessage = error.message;\n console.error('[WOPEE_REPORTER_ERROR]', errorMessage, errorData);\n return reject(new Error(`API request failed with status code: ${status}.`));\n }\n reject(new Error(`[WOPEE_REPORTER_ERROR] Unexpected error occurred during API call: ${error?.message}`));\n }\n });\n\n this.uploadQueue.push(uploadPromise);\n }\n\n async onExit(): Promise<void> {\n if (this.uploadQueue.length > 0) {\n console.log(`Uploading ${this.uploadQueue.length} remaining test results...`);\n try {\n await Promise.all(this.uploadQueue);\n console.log('Successfully uploaded all test results.');\n } catch (error) {\n console.error('Error uploading test results:', error);\n } finally {\n this.uploadQueue = [];\n }\n }\n\n await this.stopSuites();\n }\n\n private apiRequestConfig() {\n const { WOPEE_API_KEY, WOPEE_API_URL } = this.env();\n const apiUrl = WOPEE_API_URL || 'https://api.wopee.io';\n // The same key under two names. `api_key` is what the api has always read; corporate\n // gateways in front of tenant apis strip header names with an underscore (nginx\n // `underscores_in_headers off` and the like) — measured 2026-10-01 behind a bank's load\n // balancer, where every call arrived keyless and was refused as if the key were wrong.\n // `x-api-key` is the alias the api reads since v5.216.2; an older api ignores it.\n const headers = {\n api_key: WOPEE_API_KEY,\n 'x-api-key': WOPEE_API_KEY,\n };\n return { apiUrl, config: buildAxiosConfig(apiUrl, headers) };\n }\n\n // Teardown is best-effort: a failed stop must never fail the run — suites are also\n // finished lazily by the API when left IDLE.\n private async stopSuites(): Promise<void> {\n // Without credentials this would fire unauthenticated requests whose 401s\n // contradict the \"results will not be uploaded\" warning already logged.\n if (this.suiteUuids.size > 0 && !this.hasCredentials()) {\n this.suiteUuids.clear();\n return;\n }\n\n const query = `\n mutation StopIntegrationSuite($suiteUuid: ID!) {\n stopIntegrationSuite(suiteUuid: $suiteUuid) { uuid suiteRunningStatus }\n }`;\n\n for (const suiteUuid of this.suiteUuids) {\n try {\n const { apiUrl, config } = this.apiRequestConfig();\n const response = await axios.post(apiUrl, { query, variables: { suiteUuid } }, config);\n const errors = response.data?.errors;\n if (errors?.length) {\n console.error(`[WOPEE_REPORTER_ERROR] Failed to stop suite ${suiteUuid}:`, errors[0]?.message);\n } else {\n console.log(`Suite(uuid=${suiteUuid}) is stopped.`);\n }\n } catch (error: any) {\n console.error(`[WOPEE_REPORTER_ERROR] Failed to stop suite ${suiteUuid}: ${error?.message}`);\n }\n }\n this.suiteUuids.clear();\n }\n\n printsToStdio(): boolean {\n return false;\n }\n}\n"]}
|
package/docs/configuration.md
CHANGED
|
@@ -20,6 +20,8 @@ Each configuration option is provided by environment variable given as
|
|
|
20
20
|
| screenshotValidation.pixelToPixelDiffTolerance | WOPEE_PIXEL_TO_PIXEL_DIFF_TOLERANCE | no |
|
|
21
21
|
| screenshotValidation.viewport | WOPEE_VIEWPORT | no |
|
|
22
22
|
| screenshotValidation.customTags | WOPEE_CUSTOM_TAGS | no |
|
|
23
|
+
| screenshotValidation.maxRetries | WOPEE_API_MAX_RETRIES | no |
|
|
24
|
+
| screenshotValidation.requestTimeoutMs | WOPEE_API_TIMEOUT_MS | no |
|
|
23
25
|
|
|
24
26
|
where separate values are described in `WopeeOptions` and `ScreenshotValidationOptions` interfaces with default values defined in `DEFAULT_SCREENSHOT_VALIDATION_OPTIONS`,
|
|
25
27
|
|
|
@@ -29,6 +31,22 @@ where separate values are described in `WopeeOptions` and `ScreenshotValidationO
|
|
|
29
31
|
|
|
30
32
|
`WOPEE_API_URL` is optional and defaults to the SaaS endpoint `https://api.wopee.io`. Set it only for self-hosted instances.
|
|
31
33
|
|
|
34
|
+
### Timeouts and retries
|
|
35
|
+
|
|
36
|
+
Calls to the Wopee API carry a screenshot and can be several megabytes, so on a slow or
|
|
37
|
+
traffic-inspected link they occasionally time out at a gateway. The SDK bounds each attempt and
|
|
38
|
+
retries the ones that look transient; both defaults are usually right and neither variable needs
|
|
39
|
+
setting.
|
|
40
|
+
|
|
41
|
+
`WOPEE_API_TIMEOUT_MS` is the ceiling for a single attempt, default `180000` (3 minutes). `0`
|
|
42
|
+
removes the ceiling.
|
|
43
|
+
|
|
44
|
+
`WOPEE_API_MAX_RETRIES` is how many times a transient failure is retried, default `2` — three
|
|
45
|
+
attempts in all, backing off 1 s then 2 s. Only failures that mean the request did not get through
|
|
46
|
+
are retried (no response at all, the attempt's own timeout, `408`, `429`, `499`, `502`, `503`,
|
|
47
|
+
`504`); a request the API looked at and rejected is not. Set it to `0` to switch retries off, for
|
|
48
|
+
example if you would rather a tracking call fail fast than risk a duplicated step record.
|
|
49
|
+
|
|
32
50
|
### Self-hosted instances and proxies
|
|
33
51
|
|
|
34
52
|
If your organisation runs its own Wopee instance, `WOPEE_API_URL` points at a host inside the customer network (for example `https://api.acme.wopee.io`). That host is usually **not reachable from a laptop on the public internet** — you need to be on the corporate VPN, behind the corporate proxy, or running the tests from a CI runner inside that network.
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import { ApiPort, CreateIntegrationScenarioPayload, CreateIntegrationStepPayload, CreateIntegrationSuitePayload, IntegrationScenario, IntegrationStep, IntegrationSuite, LoggerPort, VisualAssert, VisualAssertPayload } from '../../../core';
|
|
2
|
-
import {
|
|
2
|
+
import { ApolloAdapterConfigInput } from './interface';
|
|
3
3
|
declare class ApolloAdapter extends ApiPort {
|
|
4
4
|
private _config;
|
|
5
5
|
private _logger;
|
|
6
6
|
private _scenario;
|
|
7
7
|
private _suite;
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Takes the config as a caller may actually hand it in and parses it here,
|
|
10
|
+
* rather than demanding the fully-defaulted shape. Every option with a
|
|
11
|
+
* `.default()` is required on `ApolloAdapterConfig`, so accepting that type
|
|
12
|
+
* would mean each new defaulted option breaks the compile of anyone
|
|
13
|
+
* constructing an adapter directly — `wopee.pw` among them.
|
|
14
|
+
*/
|
|
15
|
+
constructor(config: ApolloAdapterConfigInput, logger: LoggerPort);
|
|
9
16
|
private _post;
|
|
10
17
|
get suite(): IntegrationSuite;
|
|
11
18
|
get scenario(): IntegrationScenario;
|
package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/adapter.js
CHANGED
|
@@ -7,26 +7,53 @@ exports.ApolloAdapter = void 0;
|
|
|
7
7
|
const core_1 = require("../../../core");
|
|
8
8
|
const shared_1 = require("../../../shared");
|
|
9
9
|
const axios_config_1 = require("./axios-config");
|
|
10
|
+
const deadline_1 = require("./deadline");
|
|
10
11
|
const errors_1 = require("./errors");
|
|
11
12
|
const factories_1 = require("./factories");
|
|
12
13
|
const interface_1 = require("./interface");
|
|
13
14
|
const mutations_1 = require("./mutations");
|
|
15
|
+
const retry_1 = require("./retry");
|
|
14
16
|
const axios_1 = __importDefault(require("axios"));
|
|
15
17
|
class ApolloAdapter extends core_1.ApiPort {
|
|
16
18
|
_config;
|
|
17
19
|
_logger;
|
|
18
20
|
_scenario = null;
|
|
19
21
|
_suite = null;
|
|
22
|
+
/**
|
|
23
|
+
* Takes the config as a caller may actually hand it in and parses it here,
|
|
24
|
+
* rather than demanding the fully-defaulted shape. Every option with a
|
|
25
|
+
* `.default()` is required on `ApolloAdapterConfig`, so accepting that type
|
|
26
|
+
* would mean each new defaulted option breaks the compile of anyone
|
|
27
|
+
* constructing an adapter directly — `wopee.pw` among them.
|
|
28
|
+
*/
|
|
20
29
|
constructor(config, logger) {
|
|
21
30
|
super();
|
|
31
|
+
const parsed = interface_1.ApolloAdapterConfigSchema.safeParse(config);
|
|
32
|
+
if (!parsed.success) {
|
|
33
|
+
throw (0, errors_1.toConfigError)(parsed.error);
|
|
34
|
+
}
|
|
22
35
|
this._logger = logger;
|
|
23
|
-
this._config =
|
|
36
|
+
this._config = parsed.data;
|
|
24
37
|
}
|
|
25
38
|
async _post(query, variables) {
|
|
26
39
|
const apiUrl = this._config.apiUrl;
|
|
40
|
+
// The same key under two names. `api_key` is what the api has always read; corporate
|
|
41
|
+
// gateways in front of tenant apis strip header names with an underscore (nginx
|
|
42
|
+
// `underscores_in_headers off` and the like) — measured 2026-10-01 behind a bank's load
|
|
43
|
+
// balancer, where every call arrived keyless and was refused as if the key were wrong.
|
|
44
|
+
// `x-api-key` is the alias the api reads since v5.216.2; an older api ignores it.
|
|
45
|
+
const headers = { api_key: this._config.apiKey, 'x-api-key': this._config.apiKey };
|
|
46
|
+
const timeoutMs = this._config.requestTimeoutMs;
|
|
47
|
+
const requestConfig = (0, axios_config_1.buildAxiosConfig)(apiUrl, headers, timeoutMs);
|
|
48
|
+
const maxRetries = this._config.maxRetries;
|
|
27
49
|
try {
|
|
28
|
-
|
|
29
|
-
|
|
50
|
+
return await (0, retry_1.withRetry)(() => (0, deadline_1.withDeadline)(timeoutMs, (signal) => axios_1.default.post(apiUrl, { query, variables }, { ...requestConfig, signal })), {
|
|
51
|
+
maxRetries,
|
|
52
|
+
onRetry: ({ attempt, maxRetries: budget, delayMs, error }) => {
|
|
53
|
+
this._logger.warning(`Wopee API call to ${apiUrl} failed with ${(0, retry_1.describeFailure)(error)}; ` +
|
|
54
|
+
`retrying in ${delayMs}ms (retry ${attempt} of ${budget}).`);
|
|
55
|
+
},
|
|
56
|
+
});
|
|
30
57
|
}
|
|
31
58
|
catch (error) {
|
|
32
59
|
throw (0, errors_1.toApiRequestError)(error, { apiUrl, projectUuid: this._config.projectUuid });
|
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
import type { AxiosRequestConfig } from 'axios';
|
|
2
2
|
import 'dotenv/config';
|
|
3
|
+
/**
|
|
4
|
+
* Three minutes. Tracking calls carry a screenshot plus the step's tool-call
|
|
5
|
+
* JSON, which on a slow or traffic-inspected customer link genuinely needs a
|
|
6
|
+
* minute or more, so anything tighter would abort healthy uploads. The point is
|
|
7
|
+
* that the SDK now has *a* ceiling: axios defaults to none, so a connection
|
|
8
|
+
* that stalls with no gateway in front of it used to hang a test run forever.
|
|
9
|
+
*
|
|
10
|
+
* The value is used twice, for two different mechanisms. As `config.timeout` it
|
|
11
|
+
* is a socket *inactivity* ceiling — axios implements it as `req.setTimeout` —
|
|
12
|
+
* which catches a connection that has gone quiet but never fires on an upload
|
|
13
|
+
* that keeps trickling. `withDeadline` in ./deadline.ts applies the same number
|
|
14
|
+
* as an actual wall-clock deadline; see that file for why both are needed.
|
|
15
|
+
*/
|
|
16
|
+
export declare const DEFAULT_REQUEST_TIMEOUT_MS = 180000;
|
|
3
17
|
export type ProxyDecision = {
|
|
4
18
|
proxyUrl: string | null;
|
|
5
19
|
noProxy: string;
|
|
@@ -12,5 +26,5 @@ export type ProxyDecision = {
|
|
|
12
26
|
bypassedByNoProxy: boolean;
|
|
13
27
|
};
|
|
14
28
|
export declare function getProxyDecision(url: string): ProxyDecision;
|
|
15
|
-
export declare function buildAxiosConfig(url: string, headers: Record<string, string
|
|
29
|
+
export declare function buildAxiosConfig(url: string, headers: Record<string, string>, timeoutMs: number): AxiosRequestConfig;
|
|
16
30
|
//# sourceMappingURL=axios-config.d.ts.map
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_REQUEST_TIMEOUT_MS = void 0;
|
|
3
4
|
exports.getProxyDecision = getProxyDecision;
|
|
4
5
|
exports.buildAxiosConfig = buildAxiosConfig;
|
|
5
6
|
require("dotenv/config");
|
|
6
7
|
const http_proxy_agent_1 = require("http-proxy-agent");
|
|
7
8
|
const https_proxy_agent_1 = require("https-proxy-agent");
|
|
8
9
|
const proxy_from_env_1 = require("proxy-from-env");
|
|
10
|
+
/**
|
|
11
|
+
* Three minutes. Tracking calls carry a screenshot plus the step's tool-call
|
|
12
|
+
* JSON, which on a slow or traffic-inspected customer link genuinely needs a
|
|
13
|
+
* minute or more, so anything tighter would abort healthy uploads. The point is
|
|
14
|
+
* that the SDK now has *a* ceiling: axios defaults to none, so a connection
|
|
15
|
+
* that stalls with no gateway in front of it used to hang a test run forever.
|
|
16
|
+
*
|
|
17
|
+
* The value is used twice, for two different mechanisms. As `config.timeout` it
|
|
18
|
+
* is a socket *inactivity* ceiling — axios implements it as `req.setTimeout` —
|
|
19
|
+
* which catches a connection that has gone quiet but never fires on an upload
|
|
20
|
+
* that keeps trickling. `withDeadline` in ./deadline.ts applies the same number
|
|
21
|
+
* as an actual wall-clock deadline; see that file for why both are needed.
|
|
22
|
+
*/
|
|
23
|
+
exports.DEFAULT_REQUEST_TIMEOUT_MS = 180_000;
|
|
9
24
|
function isIpv4(value) {
|
|
10
25
|
const parts = value.split('.');
|
|
11
26
|
if (parts.length !== 4)
|
|
@@ -101,10 +116,11 @@ function getProxyDecision(url) {
|
|
|
101
116
|
return { proxyUrl: null, noProxy, bypassedByNoProxy: false };
|
|
102
117
|
}
|
|
103
118
|
}
|
|
104
|
-
function buildAxiosConfig(url, headers) {
|
|
119
|
+
function buildAxiosConfig(url, headers, timeoutMs) {
|
|
105
120
|
const config = {
|
|
106
121
|
headers,
|
|
107
122
|
proxy: false,
|
|
123
|
+
timeout: timeoutMs,
|
|
108
124
|
};
|
|
109
125
|
const { proxyUrl } = getProxyDecision(url);
|
|
110
126
|
if (!proxyUrl) {
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A wall-clock ceiling that actually holds.
|
|
3
|
+
*
|
|
4
|
+
* axios's own `config.timeout` is a socket *inactivity* timeout — the node
|
|
5
|
+
* adapter implements it as `req.setTimeout`, which only fires when nothing has
|
|
6
|
+
* moved on the socket for that long. A multi-megabyte tracking upload that
|
|
7
|
+
* keeps trickling bytes over a slow, traffic-inspected link therefore never
|
|
8
|
+
* trips it, however long it takes overall. Worse, it is not reliably enforced
|
|
9
|
+
* at all once a custom proxy agent is attached, which `buildAxiosConfig` does
|
|
10
|
+
* whenever HTTPS_PROXY is set.
|
|
11
|
+
*
|
|
12
|
+
* So the two mechanisms are kept side by side, deliberately: axios's timeout
|
|
13
|
+
* fails fast on a connection that has genuinely gone quiet, and this deadline
|
|
14
|
+
* is the backstop that bounds the attempt no matter what the socket is doing.
|
|
15
|
+
*/
|
|
16
|
+
export declare class DeadlineExceededError extends Error {
|
|
17
|
+
readonly timeoutMs: number;
|
|
18
|
+
constructor(timeoutMs: number);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Runs `operation` under a wall-clock deadline, handing it an `AbortSignal` to
|
|
22
|
+
* pass to the underlying request.
|
|
23
|
+
*
|
|
24
|
+
* A non-finite or non-positive `timeoutMs` means "no deadline" and the operation
|
|
25
|
+
* runs with no signal at all. That is both the escape hatch — symmetric with
|
|
26
|
+
* `maxRetries: 0` — and a guard: `setTimeout(fn, NaN)` fires immediately, which
|
|
27
|
+
* would abort every request the moment it started.
|
|
28
|
+
*
|
|
29
|
+
* When the deadline is what killed the operation, the rejection is replaced with
|
|
30
|
+
* a `DeadlineExceededError`. Letting axios's own `CanceledError` through instead
|
|
31
|
+
* would surface as the bare message "canceled", and its `ERR_CANCELED` code is
|
|
32
|
+
* specifically treated as *not* retryable — an abort is normally a caller's
|
|
33
|
+
* decision — so our own deadline would silently become a non-retryable failure.
|
|
34
|
+
*/
|
|
35
|
+
export declare function withDeadline<T>(timeoutMs: number, operation: (signal?: AbortSignal) => Promise<T>): Promise<T>;
|
|
36
|
+
//# sourceMappingURL=deadline.d.ts.map
|
package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/deadline.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* A wall-clock ceiling that actually holds.
|
|
4
|
+
*
|
|
5
|
+
* axios's own `config.timeout` is a socket *inactivity* timeout — the node
|
|
6
|
+
* adapter implements it as `req.setTimeout`, which only fires when nothing has
|
|
7
|
+
* moved on the socket for that long. A multi-megabyte tracking upload that
|
|
8
|
+
* keeps trickling bytes over a slow, traffic-inspected link therefore never
|
|
9
|
+
* trips it, however long it takes overall. Worse, it is not reliably enforced
|
|
10
|
+
* at all once a custom proxy agent is attached, which `buildAxiosConfig` does
|
|
11
|
+
* whenever HTTPS_PROXY is set.
|
|
12
|
+
*
|
|
13
|
+
* So the two mechanisms are kept side by side, deliberately: axios's timeout
|
|
14
|
+
* fails fast on a connection that has genuinely gone quiet, and this deadline
|
|
15
|
+
* is the backstop that bounds the attempt no matter what the socket is doing.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.DeadlineExceededError = void 0;
|
|
19
|
+
exports.withDeadline = withDeadline;
|
|
20
|
+
class DeadlineExceededError extends Error {
|
|
21
|
+
timeoutMs;
|
|
22
|
+
constructor(timeoutMs) {
|
|
23
|
+
super(`deadline of ${timeoutMs}ms exceeded`);
|
|
24
|
+
this.timeoutMs = timeoutMs;
|
|
25
|
+
this.name = 'DeadlineExceededError';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.DeadlineExceededError = DeadlineExceededError;
|
|
29
|
+
/**
|
|
30
|
+
* Runs `operation` under a wall-clock deadline, handing it an `AbortSignal` to
|
|
31
|
+
* pass to the underlying request.
|
|
32
|
+
*
|
|
33
|
+
* A non-finite or non-positive `timeoutMs` means "no deadline" and the operation
|
|
34
|
+
* runs with no signal at all. That is both the escape hatch — symmetric with
|
|
35
|
+
* `maxRetries: 0` — and a guard: `setTimeout(fn, NaN)` fires immediately, which
|
|
36
|
+
* would abort every request the moment it started.
|
|
37
|
+
*
|
|
38
|
+
* When the deadline is what killed the operation, the rejection is replaced with
|
|
39
|
+
* a `DeadlineExceededError`. Letting axios's own `CanceledError` through instead
|
|
40
|
+
* would surface as the bare message "canceled", and its `ERR_CANCELED` code is
|
|
41
|
+
* specifically treated as *not* retryable — an abort is normally a caller's
|
|
42
|
+
* decision — so our own deadline would silently become a non-retryable failure.
|
|
43
|
+
*/
|
|
44
|
+
async function withDeadline(timeoutMs, operation) {
|
|
45
|
+
if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
|
|
46
|
+
return operation();
|
|
47
|
+
}
|
|
48
|
+
const controller = new AbortController();
|
|
49
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
50
|
+
try {
|
|
51
|
+
return await operation(controller.signal);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
if (controller.signal.aborted) {
|
|
55
|
+
throw new DeadlineExceededError(timeoutMs);
|
|
56
|
+
}
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
finally {
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=deadline.js.map
|
package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/errors.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.toConfigError = toConfigError;
|
|
|
7
7
|
exports.toApiRequestError = toApiRequestError;
|
|
8
8
|
const shared_1 = require("../../../shared");
|
|
9
9
|
const axios_config_1 = require("./axios-config");
|
|
10
|
+
const deadline_1 = require("./deadline");
|
|
10
11
|
const axios_1 = __importDefault(require("axios"));
|
|
11
12
|
const DOCS_URL = 'https://docs.wopee.io/';
|
|
12
13
|
const CMD_URL = 'https://cmd.wopee.io';
|
|
@@ -145,6 +146,15 @@ function serverMessage(data) {
|
|
|
145
146
|
*/
|
|
146
147
|
function toApiRequestError(error, context) {
|
|
147
148
|
const { apiUrl, projectUuid } = context;
|
|
149
|
+
// Our own deadline aborted the request, so axios never produced a response
|
|
150
|
+
// either — the same advice applies, and the proxy diagnostics are the most
|
|
151
|
+
// useful part of it when a call is timing out.
|
|
152
|
+
if (error instanceof deadline_1.DeadlineExceededError) {
|
|
153
|
+
return new shared_1.WopeeError(unreachableMessage(apiUrl, error.message, 'ETIMEDOUT'), {
|
|
154
|
+
code: 'WOPEE_API_UNREACHABLE',
|
|
155
|
+
cause: error,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
148
158
|
if (axios_1.default.isAxiosError(error)) {
|
|
149
159
|
if (!error.response) {
|
|
150
160
|
return new shared_1.WopeeError(unreachableMessage(apiUrl, error.message, error.code), {
|
package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ApolloAdapter } from './adapter';
|
|
2
|
-
import { ApolloAdapterConfig, ApolloAdapterConfigSchema } from './interface';
|
|
3
|
-
export { ApolloAdapter, ApolloAdapterConfig, ApolloAdapterConfigSchema };
|
|
2
|
+
import { ApolloAdapterConfig, ApolloAdapterConfigInput, ApolloAdapterConfigSchema } from './interface';
|
|
3
|
+
export { ApolloAdapter, ApolloAdapterConfig, ApolloAdapterConfigInput, ApolloAdapterConfigSchema };
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -8,9 +8,11 @@ declare const ApolloAdapterConfigSchema: z.ZodObject<{
|
|
|
8
8
|
customTags: z.ZodOptional<z.ZodString>;
|
|
9
9
|
device: z.ZodOptional<z.ZodString>;
|
|
10
10
|
enableSoftAssert: z.ZodDefault<z.ZodType<boolean, z.ZodTypeDef, boolean>>;
|
|
11
|
+
maxRetries: z.ZodDefault<z.ZodType<number, z.ZodTypeDef, number>>;
|
|
11
12
|
os: z.ZodOptional<z.ZodString>;
|
|
12
13
|
pixelToPixelDiffTolerance: z.ZodOptional<z.ZodType<number, z.ZodTypeDef, number>>;
|
|
13
14
|
projectUuid: z.ZodString;
|
|
15
|
+
requestTimeoutMs: z.ZodDefault<z.ZodType<number, z.ZodTypeDef, number>>;
|
|
14
16
|
viewport: z.ZodOptional<z.ZodString>;
|
|
15
17
|
baselineBranchName: z.ZodOptional<z.ZodString>;
|
|
16
18
|
suiteUuid: z.ZodOptional<z.ZodString>;
|
|
@@ -18,8 +20,10 @@ declare const ApolloAdapterConfigSchema: z.ZodObject<{
|
|
|
18
20
|
apiKey: string;
|
|
19
21
|
projectUuid: string;
|
|
20
22
|
apiUrl: string;
|
|
23
|
+
maxRetries: number;
|
|
21
24
|
branchName: string;
|
|
22
25
|
enableSoftAssert: boolean;
|
|
26
|
+
requestTimeoutMs: number;
|
|
23
27
|
browser?: string | undefined;
|
|
24
28
|
comment?: string | undefined;
|
|
25
29
|
customTags?: string | undefined;
|
|
@@ -39,13 +43,23 @@ declare const ApolloAdapterConfigSchema: z.ZodObject<{
|
|
|
39
43
|
viewport?: string | undefined;
|
|
40
44
|
baselineBranchName?: string | undefined;
|
|
41
45
|
apiUrl?: string | undefined;
|
|
46
|
+
maxRetries?: number | undefined;
|
|
42
47
|
branchName?: string | undefined;
|
|
43
48
|
device?: string | undefined;
|
|
44
49
|
enableSoftAssert?: boolean | undefined;
|
|
45
50
|
os?: string | undefined;
|
|
51
|
+
requestTimeoutMs?: number | undefined;
|
|
46
52
|
suiteUuid?: string | undefined;
|
|
47
53
|
}>;
|
|
48
54
|
type ApolloAdapterConfig = z.infer<typeof ApolloAdapterConfigSchema>;
|
|
55
|
+
/**
|
|
56
|
+
* What a caller may hand in, as opposed to what the adapter ends up holding.
|
|
57
|
+
* Every field with a `.default()` is optional here and required in
|
|
58
|
+
* `ApolloAdapterConfig`, so this is the type to accept at the boundary —
|
|
59
|
+
* otherwise adding a defaulted option forces every TypeScript consumer to
|
|
60
|
+
* start passing it.
|
|
61
|
+
*/
|
|
62
|
+
type ApolloAdapterConfigInput = z.input<typeof ApolloAdapterConfigSchema>;
|
|
49
63
|
declare const SuiteIntegrationConfigApolloPayloadSchema: z.ZodObject<{
|
|
50
64
|
branchName: z.ZodString;
|
|
51
65
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -299,5 +313,5 @@ declare const VisualAssertApolloResponseSchema: z.ZodObject<{
|
|
|
299
313
|
confidence: number;
|
|
300
314
|
}>;
|
|
301
315
|
type VisualAssertApolloResponse = z.infer<typeof VisualAssertApolloResponseSchema>;
|
|
302
|
-
export { ApolloAdapterConfig, ApolloAdapterConfigSchema, CreateIntegrationScenarioApolloPayload, CreateIntegrationScenarioApolloPayloadSchema, CreateIntegrationStepApolloPayload, CreateIntegrationStepApolloPayloadSchema, CreateIntegrationStepApolloResponse, CreateIntegrationStepApolloResponseSchema, CreateIntegrationStepConfigApolloPayload, CreateIntegrationStepConfigApolloPayloadSchema, CreateIntegrationSuiteApolloPayload, CreateIntegrationSuiteApolloPayloadSchema, IgnoreAreaApolloPayload, IgnoreAreaApolloPayloadSchema, StopIntegrationScenarioApolloPayload, StopIntegrationScenarioApolloPayloadSchema, SuiteIntegrationConfigApolloPayload, SuiteIntegrationConfigApolloPayloadSchema, VisualAssertApolloPayloadSchema, VisualAssertApolloPayload, VisualAssertApolloResponse, VisualAssertApolloResponseSchema, };
|
|
316
|
+
export { ApolloAdapterConfig, ApolloAdapterConfigInput, ApolloAdapterConfigSchema, CreateIntegrationScenarioApolloPayload, CreateIntegrationScenarioApolloPayloadSchema, CreateIntegrationStepApolloPayload, CreateIntegrationStepApolloPayloadSchema, CreateIntegrationStepApolloResponse, CreateIntegrationStepApolloResponseSchema, CreateIntegrationStepConfigApolloPayload, CreateIntegrationStepConfigApolloPayloadSchema, CreateIntegrationSuiteApolloPayload, CreateIntegrationSuiteApolloPayloadSchema, IgnoreAreaApolloPayload, IgnoreAreaApolloPayloadSchema, StopIntegrationScenarioApolloPayload, StopIntegrationScenarioApolloPayloadSchema, SuiteIntegrationConfigApolloPayload, SuiteIntegrationConfigApolloPayloadSchema, VisualAssertApolloPayloadSchema, VisualAssertApolloPayload, VisualAssertApolloResponse, VisualAssertApolloResponseSchema, };
|
|
303
317
|
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VisualAssertApolloResponseSchema = exports.VisualAssertApolloPayloadSchema = exports.SuiteIntegrationConfigApolloPayloadSchema = exports.StopIntegrationScenarioApolloPayloadSchema = exports.IgnoreAreaApolloPayloadSchema = exports.CreateIntegrationSuiteApolloPayloadSchema = exports.CreateIntegrationStepConfigApolloPayloadSchema = exports.CreateIntegrationStepApolloResponseSchema = exports.CreateIntegrationStepApolloPayloadSchema = exports.CreateIntegrationScenarioApolloPayloadSchema = exports.ApolloAdapterConfigSchema = void 0;
|
|
4
4
|
const shared_1 = require("../../../shared");
|
|
5
|
+
const axios_config_1 = require("./axios-config");
|
|
6
|
+
const retry_1 = require("./retry");
|
|
5
7
|
const zod_1 = require("zod");
|
|
6
8
|
// The messages below are rendered into a human-readable summary by
|
|
7
9
|
// `toConfigError` in ./errors.ts, so they read as a sentence fragment following
|
|
@@ -20,11 +22,17 @@ const ApolloAdapterConfigSchema = zod_1.z.object({
|
|
|
20
22
|
customTags: zod_1.z.string().optional(),
|
|
21
23
|
device: zod_1.z.string().optional(),
|
|
22
24
|
enableSoftAssert: shared_1.ZodHelper.parseStringToBoolean().default(true),
|
|
25
|
+
// How many times a transient API failure is retried before it surfaces.
|
|
26
|
+
// Set to 0 to disable retries entirely (see ./retry.ts).
|
|
27
|
+
maxRetries: shared_1.ZodHelper.parseStringToNumberSchema().default(retry_1.DEFAULT_MAX_RETRIES),
|
|
23
28
|
os: zod_1.z.string().optional(),
|
|
24
29
|
pixelToPixelDiffTolerance: shared_1.ZodHelper.parseStringToNumberSchema().optional(),
|
|
25
30
|
projectUuid: zod_1.z
|
|
26
31
|
.string({ required_error: 'missing', invalid_type_error: 'must be a string' })
|
|
27
32
|
.min(1, 'missing (empty string)'),
|
|
33
|
+
// Wall-clock ceiling for a single attempt at an API call, in milliseconds.
|
|
34
|
+
// Set to 0 to remove the ceiling entirely (see ./deadline.ts).
|
|
35
|
+
requestTimeoutMs: shared_1.ZodHelper.parseStringToNumberSchema().default(axios_config_1.DEFAULT_REQUEST_TIMEOUT_MS),
|
|
28
36
|
viewport: zod_1.z.string().optional(),
|
|
29
37
|
baselineBranchName: zod_1.z.string().optional(),
|
|
30
38
|
suiteUuid: zod_1.z.string().optional(),
|
package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/retry.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Two retries, so three attempts in total. Each attempt of a tracking call can
|
|
3
|
+
* carry a multi-megabyte payload and take a minute on a slow link, so the point
|
|
4
|
+
* of the budget is to ride out a blip without turning one lost step into a
|
|
5
|
+
* multi-minute stall.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DEFAULT_MAX_RETRIES = 2;
|
|
8
|
+
export declare const RETRY_BASE_DELAY_MS = 1000;
|
|
9
|
+
/**
|
|
10
|
+
* Whether a failed call is worth attempting again.
|
|
11
|
+
*
|
|
12
|
+
* Note that a request that never produced a response is treated as transient.
|
|
13
|
+
* For a mutation that is a deliberate trade: the call may in principle have
|
|
14
|
+
* reached the API and been applied, so a retry can duplicate it. Losing a step
|
|
15
|
+
* record is the failure we actually observe, a duplicated one is hypothetical,
|
|
16
|
+
* and callers that disagree can set `maxRetries: 0`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function isRetryable(error: unknown): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Exponential backoff, deliberately without jitter: the retry budget is two and
|
|
21
|
+
* tracking calls fire per test step rather than in a synchronized burst, so
|
|
22
|
+
* there is no herd to spread out and a predictable delay is easier to reason
|
|
23
|
+
* about in a CI log.
|
|
24
|
+
*/
|
|
25
|
+
export declare function retryDelayMs(attempt: number): number;
|
|
26
|
+
/**
|
|
27
|
+
* One-line summary of a failure, for the retry log line. The status code is the
|
|
28
|
+
* useful part when there is a response; the errno is what identifies a
|
|
29
|
+
* connection that never got one.
|
|
30
|
+
*/
|
|
31
|
+
export declare function describeFailure(error: unknown): string;
|
|
32
|
+
export type RetryContext = {
|
|
33
|
+
/** 1-based, so the first retry reads as "attempt 1 of 2". */
|
|
34
|
+
attempt: number;
|
|
35
|
+
/** The budget actually in force, which is the clamped `maxRetries`. */
|
|
36
|
+
maxRetries: number;
|
|
37
|
+
delayMs: number;
|
|
38
|
+
error: unknown;
|
|
39
|
+
};
|
|
40
|
+
export type WithRetryOptions = {
|
|
41
|
+
maxRetries: number;
|
|
42
|
+
onRetry?: (context: RetryContext) => void;
|
|
43
|
+
/** Injectable so tests do not have to wait out the backoff. */
|
|
44
|
+
sleep?: (ms: number) => Promise<void>;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Runs `operation`, retrying it while the failure looks transient and the retry
|
|
48
|
+
* budget lasts. The original error is rethrown untouched once either runs out,
|
|
49
|
+
* so error reporting upstream stays unchanged.
|
|
50
|
+
*/
|
|
51
|
+
export declare function withRetry<T>(operation: () => Promise<T>, options: WithRetryOptions): Promise<T>;
|
|
52
|
+
//# sourceMappingURL=retry.d.ts.map
|
package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/retry.js
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.RETRY_BASE_DELAY_MS = exports.DEFAULT_MAX_RETRIES = void 0;
|
|
7
|
+
exports.isRetryable = isRetryable;
|
|
8
|
+
exports.retryDelayMs = retryDelayMs;
|
|
9
|
+
exports.describeFailure = describeFailure;
|
|
10
|
+
exports.withRetry = withRetry;
|
|
11
|
+
const deadline_1 = require("./deadline");
|
|
12
|
+
const axios_1 = __importDefault(require("axios"));
|
|
13
|
+
/**
|
|
14
|
+
* Two retries, so three attempts in total. Each attempt of a tracking call can
|
|
15
|
+
* carry a multi-megabyte payload and take a minute on a slow link, so the point
|
|
16
|
+
* of the budget is to ride out a blip without turning one lost step into a
|
|
17
|
+
* multi-minute stall.
|
|
18
|
+
*/
|
|
19
|
+
exports.DEFAULT_MAX_RETRIES = 2;
|
|
20
|
+
exports.RETRY_BASE_DELAY_MS = 1_000;
|
|
21
|
+
/**
|
|
22
|
+
* HTTP statuses worth a second attempt. Every one of them means the request did
|
|
23
|
+
* not get through to the API, or the API asked us to come back later. Statuses
|
|
24
|
+
* that mean "the API looked at what you sent and rejected it" — 400, 401, 403,
|
|
25
|
+
* 404, 422 — are deliberately absent: retrying those just fails slower.
|
|
26
|
+
*
|
|
27
|
+
* 500 is absent for a different reason, worth stating because it is not the same
|
|
28
|
+
* argument: a 500 is an unhandled server exception, not a rejection, so the API
|
|
29
|
+
* may well have applied part of the mutation before it threw. Repeating it risks
|
|
30
|
+
* a duplicate — the same reasoning that makes 504 a judgment call below, except
|
|
31
|
+
* that here there is no evidence the request failed to land.
|
|
32
|
+
*
|
|
33
|
+
* 499 is the one that is easy to miss. It is not a real IANA status; it is what
|
|
34
|
+
* a gateway (traefik, nginx) reports when it gave up reading the *request* and
|
|
35
|
+
* cancelled it. The API never saw a complete request, so a retry cannot
|
|
36
|
+
* duplicate anything.
|
|
37
|
+
*/
|
|
38
|
+
const RETRYABLE_STATUS_CODES = new Set([
|
|
39
|
+
408, // Request Timeout
|
|
40
|
+
429, // Too Many Requests
|
|
41
|
+
499, // Client Closed Request — the gateway cancelled reading the request body
|
|
42
|
+
502, // Bad Gateway
|
|
43
|
+
503, // Service Unavailable
|
|
44
|
+
504, // Gateway Timeout
|
|
45
|
+
]);
|
|
46
|
+
/**
|
|
47
|
+
* Whether a failed call is worth attempting again.
|
|
48
|
+
*
|
|
49
|
+
* Note that a request that never produced a response is treated as transient.
|
|
50
|
+
* For a mutation that is a deliberate trade: the call may in principle have
|
|
51
|
+
* reached the API and been applied, so a retry can duplicate it. Losing a step
|
|
52
|
+
* record is the failure we actually observe, a duplicated one is hypothetical,
|
|
53
|
+
* and callers that disagree can set `maxRetries: 0`.
|
|
54
|
+
*/
|
|
55
|
+
function isRetryable(error) {
|
|
56
|
+
// Our own wall-clock deadline. It has to be checked before the abort guard
|
|
57
|
+
// below, because that is the mechanism it fires through.
|
|
58
|
+
if (error instanceof deadline_1.DeadlineExceededError) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
if (!axios_1.default.isAxiosError(error)) {
|
|
62
|
+
return false;
|
|
63
|
+
}
|
|
64
|
+
// An abort is a caller's decision, not a transient failure.
|
|
65
|
+
if (error.code === 'ERR_CANCELED') {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
// No response at all: DNS, TCP, TLS, a proxy tunnel, or our own timeout.
|
|
69
|
+
if (!error.response) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
return RETRYABLE_STATUS_CODES.has(error.response.status);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Exponential backoff, deliberately without jitter: the retry budget is two and
|
|
76
|
+
* tracking calls fire per test step rather than in a synchronized burst, so
|
|
77
|
+
* there is no herd to spread out and a predictable delay is easier to reason
|
|
78
|
+
* about in a CI log.
|
|
79
|
+
*/
|
|
80
|
+
function retryDelayMs(attempt) {
|
|
81
|
+
return exports.RETRY_BASE_DELAY_MS * 2 ** attempt;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* One-line summary of a failure, for the retry log line. The status code is the
|
|
85
|
+
* useful part when there is a response; the errno is what identifies a
|
|
86
|
+
* connection that never got one.
|
|
87
|
+
*/
|
|
88
|
+
function describeFailure(error) {
|
|
89
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
90
|
+
return error.response ? `HTTP ${error.response.status}` : (error.code ?? error.message);
|
|
91
|
+
}
|
|
92
|
+
return error instanceof Error ? error.message : String(error);
|
|
93
|
+
}
|
|
94
|
+
const defaultSleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
95
|
+
/**
|
|
96
|
+
* Runs `operation`, retrying it while the failure looks transient and the retry
|
|
97
|
+
* budget lasts. The original error is rethrown untouched once either runs out,
|
|
98
|
+
* so error reporting upstream stays unchanged.
|
|
99
|
+
*/
|
|
100
|
+
async function withRetry(operation, options) {
|
|
101
|
+
const { maxRetries, onRetry, sleep = defaultSleep } = options;
|
|
102
|
+
// The loop has no upper bound of its own, so the budget is the only thing
|
|
103
|
+
// that ends it — and `attempt >= NaN` is always false, which would spin
|
|
104
|
+
// forever on a retryable failure. Config parsing rejects NaN, but this
|
|
105
|
+
// option is a plain `number`, so make the guarantee structural rather than
|
|
106
|
+
// borrowed from whoever happened to build the config.
|
|
107
|
+
const budget = Number.isFinite(maxRetries) ? Math.max(0, Math.floor(maxRetries)) : 0;
|
|
108
|
+
for (let attempt = 0;; attempt++) {
|
|
109
|
+
try {
|
|
110
|
+
return await operation();
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
if (attempt >= budget || !isRetryable(error)) {
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
const delayMs = retryDelayMs(attempt);
|
|
117
|
+
onRetry?.({ attempt: attempt + 1, maxRetries: budget, delayMs, error });
|
|
118
|
+
await sleep(delayMs);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=retry.js.map
|
|
@@ -2,15 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createApolloTrackAdapter = createApolloTrackAdapter;
|
|
4
4
|
const adapters_1 = require("../../adapters");
|
|
5
|
-
const adapters_2 = require("../../adapters");
|
|
6
|
-
const errors_1 = require("../../adapters/apolloAdapter/errors");
|
|
7
5
|
const loggerService_1 = require("../loggerService");
|
|
8
6
|
function createApolloTrackAdapter(apolloAdapterOptions) {
|
|
9
7
|
const logger = (0, loggerService_1.createLogger)(apolloAdapterOptions.loggerOptions);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
return new adapters_1.ApolloAdapter(parsed.data, logger);
|
|
8
|
+
// The adapter parses and validates its own config, so an invalid one throws
|
|
9
|
+
// the same WOPEE_CONFIG_INVALID error whichever way it is constructed.
|
|
10
|
+
return new adapters_1.ApolloAdapter(apolloAdapterOptions.apolloAdapterConfig, logger);
|
|
15
11
|
}
|
|
16
12
|
//# sourceMappingURL=apolloAdapterService.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ApolloAdapterConfigInput } from '../../adapters';
|
|
2
2
|
import { LoggerOptions } from '../loggerService';
|
|
3
3
|
export interface ApolloAdapterOptions {
|
|
4
|
-
apolloAdapterConfig:
|
|
4
|
+
apolloAdapterConfig: ApolloAdapterConfigInput;
|
|
5
5
|
loggerOptions: LoggerOptions;
|
|
6
6
|
}
|
|
7
7
|
//# sourceMappingURL=apolloService.interface.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.hash = exports.version = void 0;
|
|
4
|
-
exports.version = "3.
|
|
5
|
-
exports.hash = "
|
|
4
|
+
exports.version = "3.10.1"
|
|
5
|
+
exports.hash = "f4aa3b2f38308f0704ac8b622ef66a359d7252c0"
|
|
6
6
|
//# sourceMappingURL=versionMetadata.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wopee-io/wopee.pw",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.26.1",
|
|
4
4
|
"description": "Playwright visual testing plugin by Wopee.io — catch visual regressions with AI-powered autonomous test maintenance",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"playwright",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@autonomous-testing/sdk": "3.
|
|
49
|
+
"@autonomous-testing/sdk": "3.10.1",
|
|
50
50
|
"axios": "^1.20.0",
|
|
51
51
|
"dotenv": "^16.6.1",
|
|
52
52
|
"http-proxy-agent": "^7.0.2",
|