@wopee-io/wopee.pw 4.26.0 → 4.26.2
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/shared/metadata/versionMetadata.js +2 -2
- package/build/tools/wopee-reporter/wopeeReporter.js +19 -2
- package/build/tools/wopee-reporter/wopeeReporter.js.map +1 -1
- package/docs/configuration.md +8 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/adapter.js +6 -1
- package/node_modules/@autonomous-testing/sdk/build/shared/metadata/versionMetadata.js +2 -2
- package/node_modules/@autonomous-testing/sdk/package.json +1 -1
- package/node_modules/follow-redirects/README.md +27 -1
- package/node_modules/follow-redirects/index.js +11 -6
- package/node_modules/follow-redirects/package.json +1 -1
- package/package.json +2 -2
|
@@ -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.26.
|
|
7
|
-
let hash = "
|
|
6
|
+
let version = "4.26.2"
|
|
7
|
+
let hash = "2c8bbb88be8c141e4bdae53932ce618afa39826f"
|
|
8
8
|
if (version === '__LOCAL__') {
|
|
9
9
|
version = process.env.npm_package_version || '__LOCAL__';
|
|
10
10
|
}
|
|
@@ -19,6 +19,23 @@ const wopeeReporter_interface_js_1 = require("./types/wopeeReporter.interface.js
|
|
|
19
19
|
const axios_1 = __importDefault(require("axios"));
|
|
20
20
|
require("dotenv/config");
|
|
21
21
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
22
|
+
const DEFAULT_MAX_VIDEO_MB = 60;
|
|
23
|
+
const BYTES_PER_MB = 1024 * 1024;
|
|
24
|
+
function maxVideoBytes() {
|
|
25
|
+
var _a;
|
|
26
|
+
const parsed = Number(((_a = process.env.WOPEE_MAX_VIDEO_MB) === null || _a === void 0 ? void 0 : _a.trim()) || NaN);
|
|
27
|
+
return (Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_MAX_VIDEO_MB) * BYTES_PER_MB;
|
|
28
|
+
}
|
|
29
|
+
function readVideoWithinCap(filePath) {
|
|
30
|
+
const size = node_fs_1.default.statSync(filePath).size;
|
|
31
|
+
const cap = maxVideoBytes();
|
|
32
|
+
if (size > cap) {
|
|
33
|
+
const toMb = (bytes) => (bytes / BYTES_PER_MB).toFixed(1);
|
|
34
|
+
console.warn(`[WOPEE_REPORTER_WARNING]: video ${filePath} is ${toMb(size)} MB, above the ${toMb(cap)} MB that can be uploaded inline; reporting the steps without it.`);
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return node_fs_1.default.readFileSync(filePath).toString('base64');
|
|
38
|
+
}
|
|
22
39
|
class WopeeReporter {
|
|
23
40
|
constructor() {
|
|
24
41
|
this.uploadQueue = [];
|
|
@@ -78,8 +95,7 @@ class WopeeReporter {
|
|
|
78
95
|
const filePath = attachment.path;
|
|
79
96
|
if (filePath) {
|
|
80
97
|
try {
|
|
81
|
-
|
|
82
|
-
videoBase64 = videoBuffer.toString('base64');
|
|
98
|
+
videoBase64 = readVideoWithinCap(filePath);
|
|
83
99
|
}
|
|
84
100
|
catch (error) {
|
|
85
101
|
console.error('Error reading video:', error);
|
|
@@ -163,6 +179,7 @@ class WopeeReporter {
|
|
|
163
179
|
const apiUrl = WOPEE_API_URL || 'https://api.wopee.io';
|
|
164
180
|
const headers = {
|
|
165
181
|
api_key: WOPEE_API_KEY,
|
|
182
|
+
'x-api-key': WOPEE_API_KEY,
|
|
166
183
|
};
|
|
167
184
|
return { apiUrl, config: (0, axios_config_js_1.buildAxiosConfig)(apiUrl, headers) };
|
|
168
185
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wopeeReporter.js","sourceRoot":"","sources":["../../../lib/tools/wopee-reporter/wopeeReporter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAsF;AACtF,+DA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AAgB,EAAE,CAAC;oBACnD,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;oBACvF,MAAM,MAAM,GAAG,MAAA,QAAQ,CAAC,IAAI,0CAAE,MAAM,CAAC;oBACrC,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,EAAE,CAAC;wBACnB,OAAO,CAAC,KAAK,CAAC,+CAA+C,SAAS,GAAG,EAAE,MAAA,MAAM,CAAC,CAAC,CAAC,0CAAE,OAAO,CAAC,CAAC;oBACjG,CAAC;yBAAM,CAAC;wBACN,OAAO,CAAC,GAAG,CAAC,cAAc,SAAS,eAAe,CAAC,CAAC;oBACtD,CAAC;gBACH,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;AAhOD,sCAgOC","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 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,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,CAAC;AAQjC,SAAS,aAAa;;IACpB,MAAM,MAAM,GAAG,MAAM,CAAC,CAAA,MAAA,OAAO,CAAC,GAAG,CAAC,kBAAkB,0CAAE,IAAI,EAAE,KAAI,GAAG,CAAC,CAAC;IACrE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,oBAAoB,CAAC,GAAG,YAAY,CAAC;AAChG,CAAC;AAED,SAAS,kBAAkB,CAAC,QAAgB;IAC1C,MAAM,IAAI,GAAG,iBAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC;IACxC,MAAM,GAAG,GAAG,aAAa,EAAE,CAAC;IAC5B,IAAI,IAAI,GAAG,GAAG,EAAE,CAAC;QACf,MAAM,IAAI,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,CAAC,KAAK,GAAG,YAAY,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAClE,OAAO,CAAC,IAAI,CACV,mCAAmC,QAAQ,OAAO,IAAI,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,GAAG,CAAC,kEAA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EAAE,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;oBACnD,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;oBACvF,MAAM,MAAM,GAAG,MAAA,QAAQ,CAAC,IAAI,0CAAE,MAAM,CAAC;oBACrC,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,EAAE,CAAC;wBACnB,OAAO,CAAC,KAAK,CAAC,+CAA+C,SAAS,GAAG,EAAE,MAAA,MAAM,CAAC,CAAC,CAAC,0CAAE,OAAO,CAAC,CAAC;oBACjG,CAAC;yBAAM,CAAC;wBACN,OAAO,CAAC,GAAG,CAAC,cAAc,SAAS,eAAe,CAAC,CAAC;oBACtD,CAAC;gBACH,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;AArOD,sCAqOC","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\nconst DEFAULT_MAX_VIDEO_MB = 60;\nconst BYTES_PER_MB = 1024 * 1024;\n\n/*\nThe video goes inline as base64 (~33% larger) in the same request as the steps,\nand the api refuses a request over its body limit (100 MB by default) as a whole.\n60 MB of video stays under that; above the cap the steps are reported without it.\nWOPEE_MAX_VIDEO_MB lowers the cap for an api with a smaller limit.\n*/\nfunction maxVideoBytes(): number {\n const parsed = Number(process.env.WOPEE_MAX_VIDEO_MB?.trim() || NaN);\n return (Number.isFinite(parsed) && parsed > 0 ? parsed : DEFAULT_MAX_VIDEO_MB) * BYTES_PER_MB;\n}\n\nfunction readVideoWithinCap(filePath: string): string | null {\n const size = fs.statSync(filePath).size;\n const cap = maxVideoBytes();\n if (size > cap) {\n const toMb = (bytes: number) => (bytes / BYTES_PER_MB).toFixed(1);\n console.warn(\n `[WOPEE_REPORTER_WARNING]: video ${filePath} is ${toMb(size)} MB, above the ${toMb(cap)} MB that can be uploaded inline; reporting the steps without it.`,\n );\n return null;\n }\n return fs.readFileSync(filePath).toString('base64');\n}\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 videoBase64 = readVideoWithinCap(filePath);\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
|
@@ -47,6 +47,14 @@ are retried (no response at all, the attempt's own timeout, `408`, `429`, `499`,
|
|
|
47
47
|
`504`); a request the API looked at and rejected is not. Set it to `0` to switch retries off, for
|
|
48
48
|
example if you would rather a tracking call fail fast than risk a duplicated step record.
|
|
49
49
|
|
|
50
|
+
### Reporter videos
|
|
51
|
+
|
|
52
|
+
The Wopee reporter sends a failing test's video inline, base64-encoded, in the same request as its
|
|
53
|
+
steps. A video over `WOPEE_MAX_VIDEO_MB` (default `60`) is left out with a
|
|
54
|
+
`[WOPEE_REPORTER_WARNING]`, and the steps and screenshot are still reported. The API refuses a
|
|
55
|
+
request over its body limit (100 MB by default) as a whole, so lower this cap if your self-hosted
|
|
56
|
+
instance sets a smaller limit.
|
|
57
|
+
|
|
50
58
|
### Self-hosted instances and proxies
|
|
51
59
|
|
|
52
60
|
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.
|
package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/adapter.js
CHANGED
|
@@ -37,7 +37,12 @@ class ApolloAdapter extends core_1.ApiPort {
|
|
|
37
37
|
}
|
|
38
38
|
async _post(query, variables) {
|
|
39
39
|
const apiUrl = this._config.apiUrl;
|
|
40
|
-
|
|
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 };
|
|
41
46
|
const timeoutMs = this._config.requestTimeoutMs;
|
|
42
47
|
const requestConfig = (0, axios_config_1.buildAxiosConfig)(apiUrl, headers, timeoutMs);
|
|
43
48
|
const maxRetries = this._config.maxRetries;
|
|
@@ -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.10.
|
|
5
|
-
exports.hash = "
|
|
4
|
+
exports.version = "3.10.1"
|
|
5
|
+
exports.hash = "f4aa3b2f38308f0704ac8b622ef66a359d7252c0"
|
|
6
6
|
//# sourceMappingURL=versionMetadata.js.map
|
|
@@ -1,4 +1,30 @@
|
|
|
1
|
-
##
|
|
1
|
+
## _Follow Redirects_ is in need of funding
|
|
2
|
+
|
|
3
|
+
> [!IMPORTANT]
|
|
4
|
+
> **Maintenance paused until funding found.**
|
|
5
|
+
>
|
|
6
|
+
> follow-redirects is downloaded over 400 million times per month,
|
|
7
|
+
> It has been maintained for over ten years by one volunteer,
|
|
8
|
+
> who has no funds to provide update and security guarantees.
|
|
9
|
+
>
|
|
10
|
+
> **What this means for you:**
|
|
11
|
+
> the package stays published and keeps working as it does today,
|
|
12
|
+
> but there are no guarantees of bug fixes, security fixes,
|
|
13
|
+
> or replies to issues and pull requests.
|
|
14
|
+
> Security reports are handled best-effort only; see [SECURITY.md](SECURITY.md).
|
|
15
|
+
>
|
|
16
|
+
> **What can restart maintenance:**
|
|
17
|
+
> Even if only 0.1% of downloads paid $0.01, we'd be fully funded
|
|
18
|
+
> with $4000 per month.
|
|
19
|
+
> That's not the case, and that's okay,
|
|
20
|
+
> but unfortunately also insufficient to continue.
|
|
21
|
+
> We need to cover security triage, CVE handling, fixes, and releases.
|
|
22
|
+
> Progress toward that goal will be posted here.
|
|
23
|
+
>
|
|
24
|
+
> **If your company depends on follow-redirects,**
|
|
25
|
+
> directly or another library,
|
|
26
|
+
> please [sponsor on GitHub](https://github.com/sponsors/RubenVerborgh)
|
|
27
|
+
> or email us for invoice-based funding or a security support agreement.
|
|
2
28
|
|
|
3
29
|
Drop-in replacement for Node's `http` and `https` modules that automatically follows redirects.
|
|
4
30
|
|
|
@@ -302,7 +302,16 @@ RedirectableRequest.prototype._sanitizeOptions = function (options) {
|
|
|
302
302
|
if (!options.headers) {
|
|
303
303
|
options.headers = {};
|
|
304
304
|
}
|
|
305
|
-
|
|
305
|
+
// Convert [header1, value1, header2, value2, …] to object
|
|
306
|
+
else if (Array.isArray(options.headers)) {
|
|
307
|
+
var headerList = options.headers;
|
|
308
|
+
options.headers = {};
|
|
309
|
+
for (var i = 0; i < headerList.length; i += 2) {
|
|
310
|
+
options.headers[headerList[i]] = headerList[i + 1];
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
// Ensure sensitive headers are always present
|
|
314
|
+
if (!Array.isArray(options.sensitiveHeaders)) {
|
|
306
315
|
options.sensitiveHeaders = [];
|
|
307
316
|
}
|
|
308
317
|
|
|
@@ -680,10 +689,6 @@ function isSubdomain(subdomain, domain) {
|
|
|
680
689
|
return dot > 0 && subdomain[dot] === "." && subdomain.endsWith(domain);
|
|
681
690
|
}
|
|
682
691
|
|
|
683
|
-
function isArray(value) {
|
|
684
|
-
return value instanceof Array;
|
|
685
|
-
}
|
|
686
|
-
|
|
687
692
|
function isString(value) {
|
|
688
693
|
return typeof value === "string" || value instanceof String;
|
|
689
694
|
}
|
|
@@ -701,7 +706,7 @@ function isURL(value) {
|
|
|
701
706
|
}
|
|
702
707
|
|
|
703
708
|
function escapeRegex(regex) {
|
|
704
|
-
return regex.replace(/[\]\\/()
|
|
709
|
+
return regex.replace(/[[\]\\/()*+?.^$|]/g, "\\$&");
|
|
705
710
|
}
|
|
706
711
|
|
|
707
712
|
// Exports
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wopee-io/wopee.pw",
|
|
3
|
-
"version": "4.26.
|
|
3
|
+
"version": "4.26.2",
|
|
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.10.
|
|
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",
|