@wopee-io/wopee.pw 4.24.1 → 4.25.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.
Files changed (82) hide show
  1. package/.github/workflows/ci_cd.yaml +30 -12
  2. package/README.md +13 -0
  3. package/build/core/ports/configPort/configPort.js +2 -0
  4. package/build/core/ports/configPort/configPort.js.map +1 -1
  5. package/build/core/ports/configPort/configValidation.d.ts +2 -0
  6. package/build/core/ports/configPort/configValidation.js +49 -0
  7. package/build/core/ports/configPort/configValidation.js.map +1 -0
  8. package/build/shared/metadata/versionMetadata.js +15 -6
  9. package/build/shared/metadata/versionMetadata.js.map +1 -1
  10. package/build/tools/wopee-reporter/wopeeReporter.d.ts +3 -0
  11. package/build/tools/wopee-reporter/wopeeReporter.js +30 -3
  12. package/build/tools/wopee-reporter/wopeeReporter.js.map +1 -1
  13. package/docs/configuration.md +39 -15
  14. package/docs/troubleshooting.md +59 -0
  15. package/node_modules/@autonomous-testing/sdk/.github/workflows/ci_cd.yaml +47 -20
  16. package/node_modules/@autonomous-testing/sdk/README.md +129 -36
  17. package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/adapter.js +4 -8
  18. package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/axios-config.d.ts +12 -0
  19. package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/axios-config.js +5 -4
  20. package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/errors.d.ts +20 -0
  21. package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/errors.js +178 -0
  22. package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/interface.d.ts +1 -1
  23. package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/interface.js +13 -3
  24. package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/apolloAdapterService/apolloAdapterService.js +6 -2
  25. package/node_modules/@autonomous-testing/sdk/build/shared/metadata/versionMetadata.js +2 -2
  26. package/node_modules/@autonomous-testing/sdk/build/shared/utils/error.interface.d.ts +13 -1
  27. package/node_modules/@autonomous-testing/sdk/build/shared/utils/error.interface.js +8 -1
  28. package/node_modules/@autonomous-testing/sdk/build/shared/utils/index.d.ts +2 -2
  29. package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/README.md +145 -0
  30. package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/dist/src/index.d.ts +78 -0
  31. package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/dist/src/index.js +203 -0
  32. package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/dist/src/index.js.map +1 -0
  33. package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/dist/src/promisify.d.ts +4 -0
  34. package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/dist/src/promisify.js +18 -0
  35. package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/dist/src/promisify.js.map +1 -0
  36. package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/package.json +64 -0
  37. package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/src/index.ts +345 -0
  38. package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/src/promisify.ts +33 -0
  39. package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/README.md +137 -0
  40. package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/agent.d.ts +30 -0
  41. package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/agent.js +177 -0
  42. package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/agent.js.map +1 -0
  43. package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/index.d.ts +23 -0
  44. package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/index.js +14 -0
  45. package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/index.js.map +1 -0
  46. package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts +7 -0
  47. package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/parse-proxy-response.js +66 -0
  48. package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/parse-proxy-response.js.map +1 -0
  49. package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/package.json +56 -0
  50. package/node_modules/@autonomous-testing/sdk/package.json +18 -6
  51. package/node_modules/agent-base/LICENSE +22 -0
  52. package/node_modules/agent-base/README.md +69 -0
  53. package/node_modules/agent-base/dist/helpers.d.ts +15 -0
  54. package/node_modules/agent-base/dist/helpers.d.ts.map +1 -0
  55. package/node_modules/agent-base/dist/helpers.js +66 -0
  56. package/node_modules/agent-base/dist/helpers.js.map +1 -0
  57. package/node_modules/agent-base/dist/index.d.ts +41 -0
  58. package/node_modules/agent-base/dist/index.d.ts.map +1 -0
  59. package/node_modules/agent-base/dist/index.js +178 -0
  60. package/node_modules/agent-base/dist/index.js.map +1 -0
  61. package/node_modules/agent-base/package.json +46 -0
  62. package/node_modules/debug/LICENSE +20 -0
  63. package/node_modules/debug/README.md +481 -0
  64. package/node_modules/debug/package.json +64 -0
  65. package/node_modules/debug/src/browser.js +272 -0
  66. package/node_modules/debug/src/common.js +292 -0
  67. package/node_modules/debug/src/index.js +10 -0
  68. package/node_modules/debug/src/node.js +263 -0
  69. package/node_modules/http-proxy-agent/LICENSE +22 -0
  70. package/node_modules/http-proxy-agent/README.md +44 -0
  71. package/node_modules/http-proxy-agent/dist/index.d.ts +44 -0
  72. package/node_modules/http-proxy-agent/dist/index.d.ts.map +1 -0
  73. package/node_modules/http-proxy-agent/dist/index.js +148 -0
  74. package/node_modules/http-proxy-agent/dist/index.js.map +1 -0
  75. package/node_modules/http-proxy-agent/package.json +47 -0
  76. package/node_modules/ms/index.js +162 -0
  77. package/node_modules/ms/license.md +21 -0
  78. package/node_modules/ms/package.json +38 -0
  79. package/node_modules/ms/readme.md +59 -0
  80. package/package.json +14 -3
  81. package/.github/actions/npm_clean_install/action.yaml +0 -35
  82. package/node_modules/@autonomous-testing/sdk/.github/actions/npm_clean_install/action.yaml +0 -35
@@ -15,15 +15,18 @@ permissions:
15
15
  jobs:
16
16
  npm-clean-install:
17
17
  runs-on: builder
18
+ container:
19
+ image: node:24
20
+ options: --user 1000
18
21
 
19
22
  steps:
20
23
  - name: Check-out
21
- uses: actions/checkout@v6
24
+ uses: actions/checkout@v7
22
25
  with:
23
26
  fetch-depth: 1
24
27
 
25
28
  - name: Install
26
- uses: ./.github/actions/npm_clean_install
29
+ uses: autonomous-testing/npm-install-action@v3
27
30
  with:
28
31
  npm-token: ${{ github.token }}
29
32
 
@@ -31,15 +34,18 @@ jobs:
31
34
  needs: [npm-clean-install]
32
35
  if: github.event_name == 'pull_request'
33
36
  runs-on: builder
37
+ container:
38
+ image: node:24
39
+ options: --user 1000
34
40
 
35
41
  steps:
36
42
  - name: Check-out
37
- uses: actions/checkout@v6
43
+ uses: actions/checkout@v7
38
44
  with:
39
45
  fetch-depth: 0
40
46
 
41
47
  - name: Install
42
- uses: ./.github/actions/npm_clean_install
48
+ uses: autonomous-testing/npm-install-action@v3
43
49
  with:
44
50
  npm-token: ${{ github.token }}
45
51
 
@@ -65,15 +71,18 @@ jobs:
65
71
  before-build-test:
66
72
  needs: [npm-clean-install]
67
73
  runs-on: builder
74
+ container:
75
+ image: node:24
76
+ options: --user 1000
68
77
 
69
78
  steps:
70
79
  - name: Check-out
71
- uses: actions/checkout@v6
80
+ uses: actions/checkout@v7
72
81
  with:
73
82
  fetch-depth: 1
74
83
 
75
84
  - name: Install
76
- uses: ./.github/actions/npm_clean_install
85
+ uses: autonomous-testing/npm-install-action@v3
77
86
  with:
78
87
  npm-token: ${{ github.token }}
79
88
 
@@ -84,15 +93,18 @@ jobs:
84
93
  build:
85
94
  needs: [npm-clean-install]
86
95
  runs-on: builder
96
+ container:
97
+ image: node:24
98
+ options: --user 1000
87
99
 
88
100
  steps:
89
101
  - name: Check-out
90
- uses: actions/checkout@v6
102
+ uses: actions/checkout@v7
91
103
  with:
92
104
  fetch-depth: 1
93
105
 
94
106
  - name: Install
95
- uses: ./.github/actions/npm_clean_install
107
+ uses: autonomous-testing/npm-install-action@v3
96
108
  with:
97
109
  npm-token: ${{ github.token }}
98
110
 
@@ -102,15 +114,18 @@ jobs:
102
114
  after-build-test:
103
115
  needs: [build]
104
116
  runs-on: builder
117
+ container:
118
+ image: node:24
119
+ options: --user 1000
105
120
 
106
121
  steps:
107
122
  - name: Check-out
108
- uses: actions/checkout@v6
123
+ uses: actions/checkout@v7
109
124
  with:
110
125
  fetch-depth: 1
111
126
 
112
127
  - name: Install
113
- uses: ./.github/actions/npm_clean_install
128
+ uses: autonomous-testing/npm-install-action@v3
114
129
  with:
115
130
  npm-token: ${{ github.token }}
116
131
 
@@ -132,18 +147,21 @@ jobs:
132
147
  needs: [before-build-test, after-build-test]
133
148
  if: github.event_name == 'push'
134
149
  runs-on: builder
150
+ container:
151
+ image: node:24
152
+ options: --user 1000
135
153
  permissions:
136
154
  contents: write
137
155
  packages: write
138
156
 
139
157
  steps:
140
158
  - name: Check-out
141
- uses: actions/checkout@v6
159
+ uses: actions/checkout@v7
142
160
  with:
143
161
  fetch-depth: 0
144
162
 
145
163
  - name: Install
146
- uses: ./.github/actions/npm_clean_install
164
+ uses: autonomous-testing/npm-install-action@v3
147
165
  with:
148
166
  npm-token: ${{ github.token }}
149
167
 
package/README.md CHANGED
@@ -29,6 +29,19 @@ test('visual check', async ({ page }) => {
29
29
  });
30
30
  ```
31
31
 
32
+ ## Configuration
33
+
34
+ Two environment variables are required. Get both from your project at [cmd.wopee.io](https://cmd.wopee.io) — the key from Project Settings → API Keys, the UUID from Project Settings:
35
+
36
+ ```bash
37
+ export WOPEE_API_KEY=<your api key>
38
+ export WOPEE_PROJECT_UUID=<your project uuid>
39
+ ```
40
+
41
+ Set them in your shell, in a `.env` file next to your Playwright config, or as CI secrets. If either is missing, `new Wopee()` fails immediately with a message naming the variable.
42
+
43
+ Self-hosted instances also set `WOPEE_API_URL`, and are typically reachable only from the customer network — see [docs/configuration.md](./docs/configuration.md) for the full variable list and proxy support, and [docs/troubleshooting.md](./docs/troubleshooting.md) if a run cannot reach the API.
44
+
32
45
  ## Features
33
46
 
34
47
  - **Visual regression testing** — pixel-level and AI-powered comparison
@@ -2,9 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConfigPort = void 0;
4
4
  const configDefaults_js_1 = require("./configDefaults.js");
5
+ const configValidation_js_1 = require("./configValidation.js");
5
6
  class ConfigPort {
6
7
  loadConfig() {
7
8
  this._config = (0, configDefaults_js_1.setWopeeOptionsDefaults)(this._loadConfig());
9
+ (0, configValidation_js_1.assertScreenshotValidationConfig)(this._config.screenshotValidation);
8
10
  return this._config;
9
11
  }
10
12
  }
@@ -1 +1 @@
1
- {"version":3,"file":"configPort.js","sourceRoot":"","sources":["../../../../lib/core/ports/configPort/configPort.ts"],"names":[],"mappings":";;;AACA,2DAA8D;AAE9D,MAAsB,UAAU;IAK9B,UAAU;QACR,IAAI,CAAC,OAAO,GAAG,IAAA,2CAAuB,EAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AATD,gCASC","sourcesContent":["import { WopeeOptions } from '../../domain/configuration/config.interface.js';\nimport { setWopeeOptionsDefaults } from './configDefaults.js';\n\nexport abstract class ConfigPort {\n private _config: WopeeOptions;\n\n abstract _loadConfig(): WopeeOptions;\n\n loadConfig(): WopeeOptions {\n this._config = setWopeeOptionsDefaults(this._loadConfig());\n return this._config;\n }\n}\n"]}
1
+ {"version":3,"file":"configPort.js","sourceRoot":"","sources":["../../../../lib/core/ports/configPort/configPort.ts"],"names":[],"mappings":";;;AACA,2DAA8D;AAC9D,+DAAyE;AAEzE,MAAsB,UAAU;IAK9B,UAAU;QACR,IAAI,CAAC,OAAO,GAAG,IAAA,2CAAuB,EAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QAE3D,IAAA,sDAAgC,EAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;QACpE,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAXD,gCAWC","sourcesContent":["import { WopeeOptions } from '../../domain/configuration/config.interface.js';\nimport { setWopeeOptionsDefaults } from './configDefaults.js';\nimport { assertScreenshotValidationConfig } from './configValidation.js';\n\nexport abstract class ConfigPort {\n private _config: WopeeOptions;\n\n abstract _loadConfig(): WopeeOptions;\n\n loadConfig(): WopeeOptions {\n this._config = setWopeeOptionsDefaults(this._loadConfig());\n // Validated after defaults are merged, so the enabled flag is resolved.\n assertScreenshotValidationConfig(this._config.screenshotValidation);\n return this._config;\n }\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import { ScreenshotValidationOptions } from '../../domain/configuration/config.interface.js';
2
+ export declare function assertScreenshotValidationConfig(options?: ScreenshotValidationOptions): void;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.assertScreenshotValidationConfig = assertScreenshotValidationConfig;
4
+ const sdk_1 = require("@autonomous-testing/sdk");
5
+ const DOCS_URL = 'https://docs.wopee.io/playwright-visual-testing/';
6
+ const CMD_URL = 'https://cmd.wopee.io';
7
+ const REQUIRED_OPTIONS = [
8
+ {
9
+ key: 'apiKey',
10
+ env: 'WOPEE_API_KEY',
11
+ where: `Project Settings → API Keys at ${CMD_URL}`,
12
+ placeholder: '<your api key>',
13
+ },
14
+ {
15
+ key: 'projectUuid',
16
+ env: 'WOPEE_PROJECT_UUID',
17
+ where: `Project Settings at ${CMD_URL}`,
18
+ placeholder: '<your project uuid>',
19
+ },
20
+ ];
21
+ function isMissing(value) {
22
+ return value === undefined || value === null || String(value).trim() === '';
23
+ }
24
+ function assertScreenshotValidationConfig(options) {
25
+ if (!(options === null || options === void 0 ? void 0 : options.screenshotValidationEnabled)) {
26
+ return;
27
+ }
28
+ const missing = REQUIRED_OPTIONS.filter((option) => isMissing(options[option.key]));
29
+ if (missing.length === 0) {
30
+ return;
31
+ }
32
+ const width = Math.max(...missing.map((option) => option.env.length));
33
+ const message = [
34
+ 'Wopee is not configured — missing required environment variables.',
35
+ '',
36
+ ' Missing:',
37
+ ...missing.map((option) => ` • ${option.env.padEnd(width)} — ${option.where}`),
38
+ '',
39
+ ' Set them in your shell, in a .env file next to your Playwright config, or as',
40
+ ' CI secrets:',
41
+ '',
42
+ ...missing.map((option) => ` ${option.env}=${option.placeholder}`),
43
+ ' WOPEE_API_URL=https://api.wopee.io # only for self-hosted instances',
44
+ '',
45
+ ` Docs: ${DOCS_URL}`,
46
+ ].join('\n');
47
+ throw new sdk_1.WopeeError(message, { code: 'WOPEE_CONFIG_INVALID' });
48
+ }
49
+ //# sourceMappingURL=configValidation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"configValidation.js","sourceRoot":"","sources":["../../../../lib/core/ports/configPort/configValidation.ts"],"names":[],"mappings":";;AAuCA,4EA+BC;AArED,iDAAqD;AAErD,MAAM,QAAQ,GAAG,kDAAkD,CAAC;AACpE,MAAM,OAAO,GAAG,sBAAsB,CAAC;AAOvC,MAAM,gBAAgB,GAAG;IACvB;QACE,GAAG,EAAE,QAAQ;QACb,GAAG,EAAE,eAAe;QACpB,KAAK,EAAE,kCAAkC,OAAO,EAAE;QAClD,WAAW,EAAE,gBAAgB;KAC9B;IACD;QACE,GAAG,EAAE,aAAa;QAClB,GAAG,EAAE,oBAAoB;QACzB,KAAK,EAAE,uBAAuB,OAAO,EAAE;QACvC,WAAW,EAAE,qBAAqB;KACnC;CACO,CAAC;AAOX,SAAS,SAAS,CAAC,KAAc;IAC/B,OAAO,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC;AAC9E,CAAC;AAMD,SAAgB,gCAAgC,CAAC,OAAqC;IAGpF,IAAI,CAAC,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,2BAA2B,CAAA,EAAE,CAAC;QAC1C,OAAO;IACT,CAAC;IAED,MAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACpF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO;IACT,CAAC;IAED,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACtE,MAAM,OAAO,GAAG;QACd,mEAAmE;QACnE,EAAE;QACF,YAAY;QACZ,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,SAAS,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,MAAM,CAAC,KAAK,EAAE,CAAC;QAClF,EAAE;QACF,gFAAgF;QAChF,eAAe;QACf,EAAE;QACF,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,WAAW,EAAE,CAAC;QACrE,2EAA2E;QAC3E,EAAE;QACF,WAAW,QAAQ,EAAE;KACtB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAIb,MAAM,IAAI,gBAAU,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,sBAAsB,EAAE,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import { ScreenshotValidationOptions } from '../../domain/configuration/config.interface.js';\nimport { WopeeError } from '@autonomous-testing/sdk';\n\nconst DOCS_URL = 'https://docs.wopee.io/playwright-visual-testing/';\nconst CMD_URL = 'https://cmd.wopee.io';\n\n/*\nMirrors the mapping in EnvConfigAdapter. Kept here so the error can name the\nenvironment variable the user actually has to set, rather than the internal\nconfig field.\n*/\nconst REQUIRED_OPTIONS = [\n {\n key: 'apiKey',\n env: 'WOPEE_API_KEY',\n where: `Project Settings → API Keys at ${CMD_URL}`,\n placeholder: '<your api key>',\n },\n {\n key: 'projectUuid',\n env: 'WOPEE_PROJECT_UUID',\n where: `Project Settings at ${CMD_URL}`,\n placeholder: '<your project uuid>',\n },\n] as const;\n\n/*\nWOPEE_API_URL is deliberately not required — it has a working SaaS default in\nthe SDK schema, and requiring it would break every existing SaaS user.\n*/\n\nfunction isMissing(value: unknown): boolean {\n return value === undefined || value === null || String(value).trim() === '';\n}\n\n/**\n * Fails fast, before the SDK adapter is constructed, so the user sees which\n * variable to set instead of a validation dump from deeper in the stack.\n */\nexport function assertScreenshotValidationConfig(options?: ScreenshotValidationOptions): void {\n // Same expression Wopee uses to decide whether to build the adapter, so the\n // two can never disagree about whether Wopee is switched on.\n if (!options?.screenshotValidationEnabled) {\n return;\n }\n\n const missing = REQUIRED_OPTIONS.filter((option) => isMissing(options[option.key]));\n if (missing.length === 0) {\n return;\n }\n\n const width = Math.max(...missing.map((option) => option.env.length));\n const message = [\n 'Wopee is not configured — missing required environment variables.',\n '',\n ' Missing:',\n ...missing.map((option) => ` • ${option.env.padEnd(width)} — ${option.where}`),\n '',\n ' Set them in your shell, in a .env file next to your Playwright config, or as',\n ' CI secrets:',\n '',\n ...missing.map((option) => ` ${option.env}=${option.placeholder}`),\n ' WOPEE_API_URL=https://api.wopee.io # only for self-hosted instances',\n '',\n ` Docs: ${DOCS_URL}`,\n ].join('\\n');\n\n // Same code the SDK uses for its own configuration failures, so callers can\n // branch on error.code regardless of which layer rejected the config.\n throw new WopeeError(message, { code: 'WOPEE_CONFIG_INVALID' });\n}\n"]}
@@ -3,16 +3,25 @@ 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.24.1"
7
- let hash = "6a947e32ebe5ad9c11c3cb5f04bd5d70472c5083"
6
+ let version = "4.25.0"
7
+ let hash = "869d463f02825eecf26c88458f16668e25ca376b"
8
8
  if (version === '__LOCAL__') {
9
9
  version = process.env.npm_package_version || '__LOCAL__';
10
10
  }
11
11
  if (hash === '__LOCAL__') {
12
- hash = (0, child_process_1.execSync)('git rev-parse HEAD').toString().trim();
13
- const status = (0, child_process_1.execSync)('git status --porcelain').toString().trim();
14
- if (status) {
15
- hash = `${hash}: ${status.split('\n').join(', ')}`;
12
+ try {
13
+ hash = (0, child_process_1.execSync)('git rev-parse HEAD', { stdio: ['ignore', 'pipe', 'ignore'] })
14
+ .toString()
15
+ .trim();
16
+ const status = (0, child_process_1.execSync)('git status --porcelain', { stdio: ['ignore', 'pipe', 'ignore'] })
17
+ .toString()
18
+ .trim();
19
+ if (status) {
20
+ hash = `${hash}: ${status.split('\n').join(', ')}`;
21
+ }
22
+ }
23
+ catch (_a) {
24
+ hash = '__LOCAL__';
16
25
  }
17
26
  }
18
27
  console.log('info', `Initializing Wopee's Playwright integration: version(${version}), hash(${hash})`);
@@ -1 +1 @@
1
- {"version":3,"file":"versionMetadata.js","sourceRoot":"","sources":["../../../lib/shared/metadata/versionMetadata.ts"],"names":[],"mappings":";;;AAAA,iDAAyC;AAElC,MAAM,kBAAkB,GAAG,GAAS,EAAE;IAC3C,IAAI,OAAO,GAAW,WAAW,CAAC;IAClC,IAAI,IAAI,GAAW,WAAW,CAAC;IAG/B,IAAI,OAAO,KAAK,WAAW,EAAE,CAAC;QAC5B,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,WAAW,CAAC;IAC3D,CAAC;IAGD,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;QACzB,IAAI,GAAG,IAAA,wBAAQ,EAAC,oBAAoB,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;QACxD,MAAM,MAAM,GAAG,IAAA,wBAAQ,EAAC,wBAAwB,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;QACpE,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,GAAG,GAAG,IAAI,KAAK,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACrD,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,wDAAwD,OAAO,WAAW,IAAI,GAAG,CAAC,CAAC;AACzG,CAAC,CAAC;AAnBW,QAAA,kBAAkB,sBAmB7B","sourcesContent":["import { execSync } from 'child_process';\n\nexport const logVersionMetadata = (): void => {\n let version: string = '__LOCAL__';\n let hash: string = '__LOCAL__';\n\n // If version is not \"__LOCAL__,\" get it from npm package\n if (version === '__LOCAL__') {\n version = process.env.npm_package_version || '__LOCAL__';\n }\n\n // If hash is not \"__LOCAL__,\" get it from Git\n if (hash === '__LOCAL__') {\n hash = execSync('git rev-parse HEAD').toString().trim();\n const status = execSync('git status --porcelain').toString().trim();\n if (status) {\n hash = `${hash}: ${status.split('\\n').join(', ')}`;\n }\n }\n\n console.log('info', `Initializing Wopee's Playwright integration: version(${version}), hash(${hash})`);\n};\n"]}
1
+ {"version":3,"file":"versionMetadata.js","sourceRoot":"","sources":["../../../lib/shared/metadata/versionMetadata.ts"],"names":[],"mappings":";;;AAAA,iDAAyC;AAElC,MAAM,kBAAkB,GAAG,GAAS,EAAE;IAC3C,IAAI,OAAO,GAAW,WAAW,CAAC;IAClC,IAAI,IAAI,GAAW,WAAW,CAAC;IAG/B,IAAI,OAAO,KAAK,WAAW,EAAE,CAAC;QAC5B,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,WAAW,CAAC;IAC3D,CAAC;IAMD,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;QACzB,IAAI,CAAC;YACH,IAAI,GAAG,IAAA,wBAAQ,EAAC,oBAAoB,EAAE,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC;iBAC3E,QAAQ,EAAE;iBACV,IAAI,EAAE,CAAC;YACV,MAAM,MAAM,GAAG,IAAA,wBAAQ,EAAC,wBAAwB,EAAE,EAAE,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,CAAC;iBACvF,QAAQ,EAAE;iBACV,IAAI,EAAE,CAAC;YACV,IAAI,MAAM,EAAE,CAAC;gBACX,IAAI,GAAG,GAAG,IAAI,KAAK,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACrD,CAAC;QACH,CAAC;QAAC,WAAM,CAAC;YACP,IAAI,GAAG,WAAW,CAAC;QACrB,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,wDAAwD,OAAO,WAAW,IAAI,GAAG,CAAC,CAAC;AACzG,CAAC,CAAC;AA9BW,QAAA,kBAAkB,sBA8B7B","sourcesContent":["import { execSync } from 'child_process';\n\nexport const logVersionMetadata = (): void => {\n let version: string = '__LOCAL__';\n let hash: string = '__LOCAL__';\n\n // If version is not \"__LOCAL__,\" get it from npm package\n if (version === '__LOCAL__') {\n version = process.env.npm_package_version || '__LOCAL__';\n }\n\n // If hash is not \"__LOCAL__,\" get it from Git. Guarded because this runs\n // first in the Wopee constructor, and an unpacked template is not a git\n // checkout — an unhandled git error here would mask the real configuration\n // problem the user needs to see.\n if (hash === '__LOCAL__') {\n try {\n hash = execSync('git rev-parse HEAD', { stdio: ['ignore', 'pipe', 'ignore'] })\n .toString()\n .trim();\n const status = execSync('git status --porcelain', { stdio: ['ignore', 'pipe', 'ignore'] })\n .toString()\n .trim();\n if (status) {\n hash = `${hash}: ${status.split('\\n').join(', ')}`;\n }\n } catch {\n hash = '__LOCAL__';\n }\n }\n\n console.log('info', `Initializing Wopee's Playwright integration: version(${version}), hash(${hash})`);\n};\n"]}
@@ -3,7 +3,10 @@ import 'dotenv/config';
3
3
  export declare class WopeeReporter implements Reporter {
4
4
  private uploadQueue;
5
5
  private suiteUuids;
6
+ private configWarned;
6
7
  constructor();
8
+ private env;
9
+ private hasCredentials;
7
10
  onTestEnd(test: TestCase, result: TestResult): void;
8
11
  onExit(): Promise<void>;
9
12
  private apiRequestConfig;
@@ -19,11 +19,30 @@ 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 { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID } = process.env;
23
22
  class WopeeReporter {
24
23
  constructor() {
25
24
  this.uploadQueue = [];
26
25
  this.suiteUuids = new Set();
26
+ this.configWarned = false;
27
+ }
28
+ env() {
29
+ const { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID } = process.env;
30
+ return { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID };
31
+ }
32
+ hasCredentials() {
33
+ const { WOPEE_API_KEY, WOPEE_PROJECT_UUID } = this.env();
34
+ const missing = [
35
+ ...((WOPEE_API_KEY === null || WOPEE_API_KEY === void 0 ? void 0 : WOPEE_API_KEY.trim()) ? [] : ['WOPEE_API_KEY']),
36
+ ...((WOPEE_PROJECT_UUID === null || WOPEE_PROJECT_UUID === void 0 ? void 0 : WOPEE_PROJECT_UUID.trim()) ? [] : ['WOPEE_PROJECT_UUID']),
37
+ ];
38
+ if (missing.length === 0) {
39
+ return true;
40
+ }
41
+ if (!this.configWarned) {
42
+ this.configWarned = true;
43
+ console.error(`[WOPEE_REPORTER_ERROR]: Wopee reporter is disabled — ${missing.join(' and ')} ${missing.length > 1 ? 'are' : 'is'} 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.`);
44
+ }
45
+ return false;
27
46
  }
28
47
  onTestEnd(test, result) {
29
48
  var _a, _b, _c, _d;
@@ -71,6 +90,9 @@ class WopeeReporter {
71
90
  if (!wopeeScenarioUuid) {
72
91
  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');
73
92
  }
93
+ if (!this.hasCredentials()) {
94
+ return;
95
+ }
74
96
  const steps = result.steps.map((step, index) => ({
75
97
  testRunId,
76
98
  number: index + 1,
@@ -91,7 +113,7 @@ class WopeeReporter {
91
113
  extendIntegrationScenario(input: $input)
92
114
  }`;
93
115
  const extendIntegrationScenarioPayload = {
94
- input: Object.assign(Object.assign({ projectUuid: WOPEE_PROJECT_UUID, scenarioUuid: wopeeScenarioUuid, pwSteps: JSON.stringify(steps, helpers_1.replacer) }, (process.env.GITHUB_RUN_ID && {
116
+ input: Object.assign(Object.assign({ projectUuid: this.env().WOPEE_PROJECT_UUID, scenarioUuid: wopeeScenarioUuid, pwSteps: JSON.stringify(steps, helpers_1.replacer) }, (process.env.GITHUB_RUN_ID && {
95
117
  githubRunId: process.env.GITHUB_RUN_ID,
96
118
  })), (process.env.GITHUB_RUN_ATTEMPT && {
97
119
  githubRunAttempt: Number(process.env.GITHUB_RUN_ATTEMPT),
@@ -111,7 +133,7 @@ class WopeeReporter {
111
133
  const errorData = (_b = error.response) === null || _b === void 0 ? void 0 : _b.data;
112
134
  const errorMessage = error.message;
113
135
  console.error('[WOPEE_REPORTER_ERROR]', errorMessage, errorData);
114
- reject(new Error(`API request failed with status code: ${status}.`));
136
+ return reject(new Error(`API request failed with status code: ${status}.`));
115
137
  }
116
138
  reject(new Error(`[WOPEE_REPORTER_ERROR] Unexpected error occurred during API call: ${error === null || error === void 0 ? void 0 : error.message}`));
117
139
  }
@@ -137,6 +159,7 @@ class WopeeReporter {
137
159
  });
138
160
  }
139
161
  apiRequestConfig() {
162
+ const { WOPEE_API_KEY, WOPEE_API_URL } = this.env();
140
163
  const apiUrl = WOPEE_API_URL || 'https://api.wopee.io';
141
164
  const headers = {
142
165
  api_key: WOPEE_API_KEY,
@@ -146,6 +169,10 @@ class WopeeReporter {
146
169
  stopSuites() {
147
170
  return __awaiter(this, void 0, void 0, function* () {
148
171
  var _a, _b;
172
+ if (this.suiteUuids.size > 0 && !this.hasCredentials()) {
173
+ this.suiteUuids.clear();
174
+ return;
175
+ }
149
176
  const query = `
150
177
  mutation StopIntegrationSuite($suiteUuid: ID!) {
151
178
  stopIntegrationSuite(suiteUuid: $suiteUuid) { uuid suiteRunningStatus }
@@ -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,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;AAEzE,MAAa,aAAa;IAIxB;QACE,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAE,CAAC;IAC9B,CAAC;IAED,SAAS,CAAC,IAAc,EAAE,MAAkB;;QAC1C,MAAM,SAAS,GAAG,IAAA,2BAAiB,GAAE,CAAC;QAEtC,MAAM,cAAc,GAAG,MAAA,MAAA,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,IAAI,MAAK,kBAAkB,CAAC,0CAAE,IAAI,0CAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;QAC/G,IAAI,cAAc,EAAE,CAAC;YACnB,IAAI,CAAC,UAA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QAC1B,CAAC;KAAA;IAED,aAAa;QACX,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA9KD,sCA8KC","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 { WOPEE_API_KEY, WOPEE_API_URL, WOPEE_PROJECT_UUID } = process.env;\n\nexport class WopeeReporter implements Reporter {\n private uploadQueue: Promise<any>[];\n private suiteUuids: Set<string>;\n\n constructor() {\n this.uploadQueue = [];\n this.suiteUuids = new Set();\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 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: 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 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 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 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;AAEz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AC,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"]}
@@ -2,20 +2,44 @@
2
2
 
3
3
  Each configuration option is provided by environment variable given as
4
4
 
5
- | Configuration option | Environmental variable |
6
- | ------------------------------------------------ | ----------------------------------- |
7
- | screenshotValidation.screenshotValidationEnabled | WOPEE_SCREENSHOT_VALIDATION_ENABLED |
8
- | screenshotValidation.apiKey | WOPEE_API_KEY |
9
- | screenshotValidation.apiUrl | WOPEE_API_URL |
10
- | screenshotValidation.projectUuid | WOPEE_PROJECT_UUID |
11
- | screenshotValidation.branchName | WOPEE_BRANCH_NAME |
12
- | screenshotValidation.enableSoftAssert | WOPEE_ENABLE_SOFT_ASSERT |
13
- | screenshotValidation.browser | WOPEE_BROWSER |
14
- | screenshotValidation.comment | WOPEE_COMMENT |
15
- | screenshotValidation.device | WOPEE_DEVICE |
16
- | screenshotValidation.os | WOPEE_OS |
17
- | screenshotValidation.pixelToPixelDiffTolerance | WOPEE_PIXEL_TO_PIXEL_DIFF_TOLERANCE |
18
- | screenshotValidation.viewport | WOPEE_VIEWPORT |
19
- | screenshotValidation.customTags | WOPEE_CUSTOM_TAGS |
5
+ | Configuration option | Environmental variable | Required |
6
+ | ------------------------------------------------ | ----------------------------------- | -------- |
7
+ | screenshotValidation.apiKey | WOPEE_API_KEY | yes |
8
+ | screenshotValidation.projectUuid | WOPEE_PROJECT_UUID | yes |
9
+ | screenshotValidation.screenshotValidationEnabled | WOPEE_SCREENSHOT_VALIDATION_ENABLED | no |
10
+ | screenshotValidation.apiUrl | WOPEE_API_URL | no |
11
+ | screenshotValidation.branchName | WOPEE_BRANCH_NAME | no |
12
+ | screenshotValidation.baselineBranchName | WOPEE_BASELINE_BRANCH_NAME | no |
13
+ | screenshotValidation.suiteUuid | WOPEE_SUITE_UUID | no |
14
+ | screenshotValidation.enableSoftAssert | WOPEE_ENABLE_SOFT_ASSERT | no |
15
+ | screenshotValidation.collectPageContent | WOPEE_COLLECT_PAGE_CONTENT | no |
16
+ | screenshotValidation.browser | WOPEE_BROWSER | no |
17
+ | screenshotValidation.comment | WOPEE_COMMENT | no |
18
+ | screenshotValidation.device | WOPEE_DEVICE | no |
19
+ | screenshotValidation.os | WOPEE_OS | no |
20
+ | screenshotValidation.pixelToPixelDiffTolerance | WOPEE_PIXEL_TO_PIXEL_DIFF_TOLERANCE | no |
21
+ | screenshotValidation.viewport | WOPEE_VIEWPORT | no |
22
+ | screenshotValidation.customTags | WOPEE_CUSTOM_TAGS | no |
20
23
 
21
24
  where separate values are described in `WopeeOptions` and `ScreenshotValidationOptions` interfaces with default values defined in `DEFAULT_SCREENSHOT_VALIDATION_OPTIONS`,
25
+
26
+ ### Required values
27
+
28
+ `WOPEE_API_KEY` and `WOPEE_PROJECT_UUID` come from your project at [cmd.wopee.io](https://cmd.wopee.io) — the key from Project Settings → API Keys, the UUID from Project Settings. If either is missing, `new Wopee()` fails immediately with a message naming the variable, rather than failing later inside a test.
29
+
30
+ `WOPEE_API_URL` is optional and defaults to the SaaS endpoint `https://api.wopee.io`. Set it only for self-hosted instances.
31
+
32
+ ### Self-hosted instances and proxies
33
+
34
+ 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.
35
+
36
+ Wopee honours the standard proxy variables:
37
+
38
+ ```bash
39
+ export HTTPS_PROXY=http://proxy.corp:8080
40
+ export NO_PROXY=localhost,127.0.0.1,.internal
41
+ ```
42
+
43
+ `NO_PROXY` supports exact hosts, leading-dot suffixes (`.acme.io`), `host:port` entries, CIDR ranges (`10.0.0.0/8`) and `*`.
44
+
45
+ See [troubleshooting.md](./troubleshooting.md) if a run cannot reach the API.
@@ -0,0 +1,59 @@
1
+ # Troubleshooting
2
+
3
+ ## `Wopee is not configured — missing required environment variables.`
4
+
5
+ **Symptom.** `new Wopee()` throws before any test runs. Because the template constructs `Wopee` at module scope, Playwright reports this during collection and the whole run stops.
6
+
7
+ **Cause.** `WOPEE_API_KEY` and/or `WOPEE_PROJECT_UUID` is unset or empty. An empty value (`WOPEE_API_KEY=` with nothing after it in a `.env`) counts as missing.
8
+
9
+ **Fix.** Get the values from your project at [cmd.wopee.io](https://cmd.wopee.io) — the key from Project Settings → API Keys, the UUID from Project Settings — and set them in your shell, in a `.env` file next to your Playwright config, or as CI secrets:
10
+
11
+ ```bash
12
+ export WOPEE_API_KEY=<your api key>
13
+ export WOPEE_PROJECT_UUID=<your project uuid>
14
+ ```
15
+
16
+ Note that Wopee has always required these to construct — previously it failed with a validation dump instead of the message above. There is currently no supported way to run a suite that constructs `Wopee` without credentials.
17
+
18
+ ## `Cannot reach the Wopee API at <url>.`
19
+
20
+ **Symptom.** Tests start, then fail on the first Wopee call. The message reports the URL that was attempted, the underlying failure, and whether a proxy was in effect.
21
+
22
+ **Cause.** The request never got a response — DNS, TCP, TLS or proxy failure. For self-hosted instances this is almost always a network reachability problem rather than a Wopee problem.
23
+
24
+ **Fix**, in the order the message lists them:
25
+
26
+ 1. **The instance is only reachable from the customer network.** `WOPEE_API_URL` may resolve to a private address (for example `10.120.0.187`) that a laptop on the public internet cannot route to. Connect to the corporate VPN, or run the tests from a CI runner inside that network.
27
+ 2. **A corporate proxy is required.** Set `HTTPS_PROXY` (and `HTTP_PROXY` for plain-HTTP endpoints) and retry.
28
+ - If the message says the proxy was **bypassed**, the host matched `NO_PROXY`. Remove the matching entry if the proxy is how you reach it.
29
+ - If a proxy **was** in use and the failure names the proxy host, the proxy itself is unreachable or is refusing the host.
30
+ 3. **`WOPEE_API_URL` points at the wrong host.** Confirm the value with your Wopee administrator. The default SaaS endpoint is `https://api.wopee.io`.
31
+
32
+ Credentials embedded in a proxy URL are redacted before the message is printed, so it is safe to paste into an issue.
33
+
34
+ ## `Wopee API rejected the request: 401 Unauthorized.`
35
+
36
+ **Symptom.** The API is reachable but refuses the request.
37
+
38
+ **Cause.** `WOPEE_API_KEY` was not accepted, or it belongs to a different project than `WOPEE_PROJECT_UUID`.
39
+
40
+ **Fix.** View or regenerate the key under Project Settings → API Keys at [cmd.wopee.io](https://cmd.wopee.io), and check it belongs to the project UUID shown in the message.
41
+
42
+ ## `[WOPEE_REPORTER_ERROR]: Wopee reporter is disabled`
43
+
44
+ **Symptom.** Tests run and visual checks work, but results never appear in the dashboard.
45
+
46
+ **Cause.** The reporter reads `WOPEE_API_KEY` and `WOPEE_PROJECT_UUID` independently of the fixture. If they are not visible to the reporter process, it skips uploading rather than sending unauthenticated requests.
47
+
48
+ **Fix.** Ensure the variables are set in the environment Playwright itself runs in. Assigning them inside `playwright.config.ts` works; assigning them inside a test file does not, because the reporter is constructed first.
49
+
50
+ ## Programmatic handling
51
+
52
+ Errors are `WopeeError` instances carrying a stable `code`. Branch on that rather than on message text:
53
+
54
+ | Code | Meaning |
55
+ | ------------------------ | ------------------------------------------- |
56
+ | `WOPEE_CONFIG_INVALID` | Required configuration missing or malformed |
57
+ | `WOPEE_API_UNREACHABLE` | No response — network, DNS, TLS or proxy |
58
+ | `WOPEE_API_UNAUTHORIZED` | API key rejected (401/403) |
59
+ | `WOPEE_API_ERROR` | Any other API failure |