@wopee-io/wopee.pw 4.12.0 → 4.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.12.0"
7
- let hash = "90906d4e50929ac62a6054a66f1cdb72f0b88031"
6
+ let version = "4.14.0"
7
+ let hash = "d56ffdd6b138b6839632803a7ca77e193299a158"
8
8
  if (version === '__LOCAL__') {
9
9
  version = process.env.npm_package_version || '__LOCAL__';
10
10
  }
@@ -1,3 +1,5 @@
1
1
  import { generateTestRunId } from './generateTestRunId.js';
2
2
  import { parseError } from './parseError.js';
3
- export { generateTestRunId, parseError };
3
+ import { parseNestedSteps } from './parseNestedSteps.js';
4
+ import { replacer } from './replacer.js';
5
+ export { generateTestRunId, parseError, replacer, parseNestedSteps };
@@ -1,8 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseError = exports.generateTestRunId = void 0;
3
+ exports.parseNestedSteps = exports.replacer = exports.parseError = exports.generateTestRunId = void 0;
4
4
  const generateTestRunId_js_1 = require("./generateTestRunId.js");
5
5
  Object.defineProperty(exports, "generateTestRunId", { enumerable: true, get: function () { return generateTestRunId_js_1.generateTestRunId; } });
6
6
  const parseError_js_1 = require("./parseError.js");
7
7
  Object.defineProperty(exports, "parseError", { enumerable: true, get: function () { return parseError_js_1.parseError; } });
8
+ const parseNestedSteps_js_1 = require("./parseNestedSteps.js");
9
+ Object.defineProperty(exports, "parseNestedSteps", { enumerable: true, get: function () { return parseNestedSteps_js_1.parseNestedSteps; } });
10
+ const replacer_js_1 = require("./replacer.js");
11
+ Object.defineProperty(exports, "replacer", { enumerable: true, get: function () { return replacer_js_1.replacer; } });
8
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lib/tools/wopee-reporter/helpers/index.ts"],"names":[],"mappings":";;;AAAA,iEAA2D;AAGlD,kGAHA,wCAAiB,OAGA;AAF1B,mDAA6C;AAEjB,2FAFnB,0BAAU,OAEmB","sourcesContent":["import { generateTestRunId } from './generateTestRunId.js';\nimport { parseError } from './parseError.js';\n\nexport { generateTestRunId, parseError };\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../lib/tools/wopee-reporter/helpers/index.ts"],"names":[],"mappings":";;;AAAA,iEAA2D;AAKlD,kGALA,wCAAiB,OAKA;AAJ1B,mDAA6C;AAIjB,2FAJnB,0BAAU,OAImB;AAHtC,+DAAyD;AAGP,iGAHzC,sCAAgB,OAGyC;AAFlE,+CAAyC;AAED,yFAF/B,sBAAQ,OAE+B","sourcesContent":["import { generateTestRunId } from './generateTestRunId.js';\nimport { parseError } from './parseError.js';\nimport { parseNestedSteps } from './parseNestedSteps.js';\nimport { replacer } from './replacer.js';\n\nexport { generateTestRunId, parseError, replacer, parseNestedSteps };\n"]}
@@ -0,0 +1,12 @@
1
+ import { TestResult, TestStep } from '@playwright/test/reporter';
2
+ type NestedStepT = {
3
+ number: number;
4
+ title: string;
5
+ status: 'passed' | 'failed';
6
+ error: TestStep['error'];
7
+ category: string;
8
+ location: TestStep['location'];
9
+ steps: NestedStepT[];
10
+ };
11
+ export declare function parseNestedSteps(steps: TestResult['steps']): NestedStepT[];
12
+ export {};
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseNestedSteps = void 0;
4
+ const parseError_1 = require("./parseError");
5
+ function parseNestedSteps(steps) {
6
+ if (!steps || steps.length === 0) {
7
+ return [];
8
+ }
9
+ return steps.map((step, index) => ({
10
+ number: index + 1,
11
+ title: step.title,
12
+ status: step.error ? 'failed' : 'passed',
13
+ error: step.error ? (0, parseError_1.parseError)(step.error) : step.error,
14
+ category: step.category,
15
+ location: step.location,
16
+ duration: step.duration,
17
+ startTime: step.startTime,
18
+ steps: parseNestedSteps(step.steps),
19
+ }));
20
+ }
21
+ exports.parseNestedSteps = parseNestedSteps;
22
+ //# sourceMappingURL=parseNestedSteps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseNestedSteps.js","sourceRoot":"","sources":["../../../../lib/tools/wopee-reporter/helpers/parseNestedSteps.ts"],"names":[],"mappings":";;;AAAA,6CAA0C;AAa1C,SAAgB,gBAAgB,CAAC,KAA0B;IACzD,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACjC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAc,EAAE,KAAa,EAAE,EAAE,CAAC,CAAC;QACnD,MAAM,EAAE,KAAK,GAAG,CAAC;QACjB,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ;QACxC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,uBAAU,EAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK;QACvD,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,KAAK,EAAE,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC;KACpC,CAAC,CAAC,CAAC;AACN,CAAC;AAhBD,4CAgBC","sourcesContent":["import { parseError } from './parseError';\nimport { TestResult, TestStep } from '@playwright/test/reporter';\n\ntype NestedStepT = {\n number: number;\n title: string;\n status: 'passed' | 'failed';\n error: TestStep['error'];\n category: string;\n location: TestStep['location'];\n steps: NestedStepT[];\n};\n\nexport function parseNestedSteps(steps: TestResult['steps']): NestedStepT[] {\n if (!steps || steps.length === 0) {\n return [];\n }\n\n return steps.map((step: TestStep, index: number) => ({\n number: index + 1,\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 }));\n}\n"]}
@@ -0,0 +1 @@
1
+ export declare const replacer: (key: string, value: any) => any;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.replacer = void 0;
4
+ const replacer = (key, value) => {
5
+ if (key === 'parent') {
6
+ return '[Circular]';
7
+ }
8
+ return value;
9
+ };
10
+ exports.replacer = replacer;
11
+ //# sourceMappingURL=replacer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replacer.js","sourceRoot":"","sources":["../../../../lib/tools/wopee-reporter/helpers/replacer.ts"],"names":[],"mappings":";;;AAAO,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,KAAU,EAAE,EAAE;IAClD,IAAI,GAAG,KAAK,QAAQ,EAAE,CAAC;QACrB,OAAO,YAAY,CAAC;IACtB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AALW,QAAA,QAAQ,YAKnB","sourcesContent":["export const replacer = (key: string, value: any) => {\n if (key === 'parent') {\n return '[Circular]';\n }\n return value;\n};\n"]}
@@ -1,5 +1,5 @@
1
- import type { Reporter, TestCase } from '@playwright/test/reporter';
1
+ import type { Reporter, TestCase, TestResult } from '@playwright/test/reporter';
2
2
  import 'dotenv/config';
3
3
  export declare class WopeeReporter implements Reporter {
4
- onTestEnd(test: TestCase): Promise<void | import("axios").AxiosResponse<any, any>>;
4
+ onTestEnd(test: TestCase, result: TestResult): Promise<void | import("axios").AxiosResponse<any, any>>;
5
5
  }
@@ -17,18 +17,36 @@ const helpers_1 = require("./helpers");
17
17
  const wopeeReporter_interface_js_1 = require("./types/wopeeReporter.interface.js");
18
18
  const axios_1 = __importDefault(require("axios"));
19
19
  require("dotenv/config");
20
+ const node_fs_1 = __importDefault(require("node:fs"));
20
21
  const { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID } = process.env;
21
22
  class WopeeReporter {
22
- onTestEnd(test) {
23
+ onTestEnd(test, result) {
23
24
  return __awaiter(this, void 0, void 0, function* () {
24
- var _a, _b, _c, _d, _e;
25
+ var _a, _b, _c, _d;
25
26
  const testRunId = (0, helpers_1.generateTestRunId)();
26
- const testResults = (_a = test.results) === null || _a === void 0 ? void 0 : _a[0];
27
- const wopeeScenarioUuid = (_c = (_b = testResults === null || testResults === void 0 ? void 0 : testResults.attachments.find((a) => (a === null || a === void 0 ? void 0 : a.name) === 'wopee-scenario-uuid')) === null || _b === void 0 ? void 0 : _b.body) === null || _c === void 0 ? void 0 : _c.toString('utf-8');
27
+ const wopeeScenarioUuid = (_b = (_a = result.attachments
28
+ .find((a) => (a === null || a === void 0 ? void 0 : a.name) === 'wopee-scenario-uuid')) === null || _a === void 0 ? void 0 : _a.body) === null || _b === void 0 ? void 0 : _b.toString('utf-8');
29
+ const failedStep = [...result.steps].reverse().find((step) => step.error);
30
+ let screenshotBase64 = null;
31
+ for (const attachment of result.attachments) {
32
+ if (attachment.name === 'screenshot' && attachment.contentType === 'image/png') {
33
+ const filePath = attachment.path;
34
+ if (filePath) {
35
+ try {
36
+ const imageBuffer = node_fs_1.default.readFileSync(filePath);
37
+ screenshotBase64 = imageBuffer.toString('base64');
38
+ break;
39
+ }
40
+ catch (error) {
41
+ console.error('Error reading screenshot:', error);
42
+ }
43
+ }
44
+ }
45
+ }
28
46
  if (!wopeeScenarioUuid) {
29
47
  return console.error('[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');
30
48
  }
31
- const steps = testResults === null || testResults === void 0 ? void 0 : testResults.steps.map((step, index) => ({
49
+ const steps = result.steps.map((step, index) => ({
32
50
  testRunId,
33
51
  number: index + 1,
34
52
  testTitle: test.title,
@@ -37,6 +55,10 @@ class WopeeReporter {
37
55
  error: step.error ? (0, helpers_1.parseError)(step.error) : step.error,
38
56
  category: step.category,
39
57
  location: step.location,
58
+ duration: step.duration,
59
+ startTime: step.startTime,
60
+ steps: (0, helpers_1.parseNestedSteps)(step.steps),
61
+ screenshotBase64: step === failedStep ? screenshotBase64 : null,
40
62
  }));
41
63
  const query = `
42
64
  mutation ExtendIntegrationScenario($input: ExtendIntegrationScenarioInput!) {
@@ -46,7 +68,7 @@ class WopeeReporter {
46
68
  input: {
47
69
  projectUuid: WOPEE_PROJECT_UUID,
48
70
  scenarioUuid: wopeeScenarioUuid,
49
- pwSteps: JSON.stringify(steps),
71
+ pwSteps: JSON.stringify(steps, helpers_1.replacer),
50
72
  },
51
73
  };
52
74
  const variables = wopeeReporter_interface_js_1.ExtendIntegrationScenarioPayloadSchema.parse(extendIntegrationScenarioPayload);
@@ -59,8 +81,8 @@ class WopeeReporter {
59
81
  }
60
82
  catch (error) {
61
83
  if (axios_1.default.isAxiosError(error)) {
62
- const status = (_d = error.response) === null || _d === void 0 ? void 0 : _d.status;
63
- const errorData = (_e = error.response) === null || _e === void 0 ? void 0 : _e.data;
84
+ const status = (_c = error.response) === null || _c === void 0 ? void 0 : _c.status;
85
+ const errorData = (_d = error.response) === null || _d === void 0 ? void 0 : _d.data;
64
86
  console.error('[WOPEE_REPORTER_ERROR]', errorData);
65
87
  throw new Error(`API request failed with status code: ${status}.`);
66
88
  }
@@ -1 +1 @@
1
- {"version":3,"file":"wopeeReporter.js","sourceRoot":"","sources":["../../../lib/tools/wopee-reporter/wopeeReporter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAA0D;AAC1D,mFAG4C;AAE5C,kDAA0B;AAC1B,yBAAuB;AAEvB,MAAM,EAAE,aAAa,EAAE,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AgC,GAAqC;gBACzE,KAAK,EAAE;oBACL,WAAW,EAAE,kBAAkB;oBAC/B,YAAY,EAAE,iBAAiB;oBAC/B,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC;iBAC/B;aACF,CAAC;YACF,MAAM,SAAS,GAAG,mEAAsC,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC;YAEjG,IAAI,CAAC;gBACH,OAAO,MAAM,eAAK,CAAC,IAAI,CACrB,aAAa,EACb,EAAE,KAAK,EAAE,SAAS,EAAE,EACpB;oBACE,OAAO,EAAE;wBACP,OAAO,EAAE,aAAa;qBACvB;iBACF,CACF,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,eAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC9B,MAAM,MAAM,GAAG,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,CAAC;oBACtC,MAAM,SAAS,GAAG,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAI,CAAC;oBACvC,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,SAAS,CAAC,CAAC;oBACnD,MAAM,IAAI,KAAK,CAAC,wCAAwC,MAAM,GAAG,CAAC,CAAC;gBACrE,CAAC;gBACD,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;KAAA;CACF;AA3DD,sCA2DC","sourcesContent":["import { generateTestRunId, parseError } from './helpers';\nimport {\n ExtendIntegrationScenarioPayload,\n ExtendIntegrationScenarioPayloadSchema,\n} from './types/wopeeReporter.interface.js';\nimport type { Reporter, TestCase } from '@playwright/test/reporter';\nimport axios from 'axios';\nimport 'dotenv/config';\n\nconst { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID } = process.env;\n\nexport class WopeeReporter implements Reporter {\n async onTestEnd(test: TestCase) {\n const testRunId = generateTestRunId();\n const testResults = test.results?.[0];\n const wopeeScenarioUuid = testResults?.attachments\n .find((a) => a?.name === 'wopee-scenario-uuid')\n ?.body?.toString('utf-8');\n\n 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 const steps = testResults?.steps.map((step, index) => ({\n testRunId,\n number: index + 1,\n testTitle: test.title,\n title: step.title,\n status: step.error ? 'failed' : 'passed',\n error: step.error ? parseError(step.error) : step.error,\n category: step.category,\n location: step.location,\n }));\n\n const query = `\n mutation ExtendIntegrationScenario($input: ExtendIntegrationScenarioInput!) {\n extendIntegrationScenario(input: $input)\n }`;\n\n const extendIntegrationScenarioPayload: ExtendIntegrationScenarioPayload = {\n input: {\n projectUuid: WOPEE_PROJECT_UUID,\n scenarioUuid: wopeeScenarioUuid,\n pwSteps: JSON.stringify(steps),\n },\n };\n const variables = ExtendIntegrationScenarioPayloadSchema.parse(extendIntegrationScenarioPayload);\n\n try {\n return await axios.post(\n WOPEE_API_URL,\n { query, variables },\n {\n headers: {\n api_key: WOPEE_API_KEY,\n },\n },\n );\n } catch (error) {\n if (axios.isAxiosError(error)) {\n const status = error.response?.status;\n const errorData = error.response?.data;\n console.error('[WOPEE_REPORTER_ERROR]', errorData);\n throw new Error(`API request failed with status code: ${status}.`);\n }\n throw new Error('Unexpected error occurred during API call.');\n }\n }\n}\n"]}
1
+ {"version":3,"file":"wopeeReporter.js","sourceRoot":"","sources":["../../../lib/tools/wopee-reporter/wopeeReporter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAsF;AACtF,mFAG4C;AAE5C,kDAA0B;AAC1B,yBAAuB;AACvB,sDAAyB;AAEzB,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAEzE,MAAa,aAAa;IAClB,SAAS,CAA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AK,EAAE,CAAC;gBACf,IAAI,eAAK,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;oBAC9B,MAAM,MAAM,GAAG,MAAA,KAAK,CAAC,QAAQ,0CAAE,MAAM,CAAC;oBACtC,MAAM,SAAS,GAAG,MAAA,KAAK,CAAC,QAAQ,0CAAE,IAAI,CAAC;oBACvC,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,SAAS,CAAC,CAAC;oBACnD,MAAM,IAAI,KAAK,CAAC,wCAAwC,MAAM,GAAG,CAAC,CAAC;gBACrE,CAAC;gBACD,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;KAAA;CACF;AAjFD,sCAiFC","sourcesContent":["import { generateTestRunId, parseError, parseNestedSteps, replacer } from './helpers';\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 { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID } = process.env;\n\nexport class WopeeReporter implements Reporter {\n async onTestEnd(test: TestCase, result: TestResult) {\n const testRunId = generateTestRunId();\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 let screenshotBase64: string | null = null;\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 break;\n } catch (error) {\n console.error('Error reading screenshot:', 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 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: step === failedStep ? screenshotBase64 : 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: WOPEE_PROJECT_UUID,\n scenarioUuid: wopeeScenarioUuid,\n pwSteps: JSON.stringify(steps, replacer),\n },\n };\n const variables = ExtendIntegrationScenarioPayloadSchema.parse(extendIntegrationScenarioPayload);\n\n try {\n return await axios.post(\n WOPEE_API_URL,\n { query, variables },\n {\n headers: {\n api_key: WOPEE_API_KEY,\n },\n },\n );\n } catch (error) {\n if (axios.isAxiosError(error)) {\n const status = error.response?.status;\n const errorData = error.response?.data;\n console.error('[WOPEE_REPORTER_ERROR]', errorData);\n throw new Error(`API request failed with status code: ${status}.`);\n }\n throw new Error('Unexpected error occurred during API call.');\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wopee-io/wopee.pw",
3
- "version": "4.12.0",
3
+ "version": "4.14.0",
4
4
  "description": "Wopee's Playwright integration.",
5
5
  "keywords": [
6
6
  "visual testing",