@wopee-io/wopee.pw 4.24.1 → 4.24.3
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/.github/workflows/ci_cd.yaml +30 -12
- package/README.md +13 -0
- package/build/core/ports/configPort/configPort.js +2 -0
- package/build/core/ports/configPort/configPort.js.map +1 -1
- package/build/core/ports/configPort/configValidation.d.ts +2 -0
- package/build/core/ports/configPort/configValidation.js +49 -0
- package/build/core/ports/configPort/configValidation.js.map +1 -0
- package/build/shared/metadata/versionMetadata.js +15 -6
- package/build/shared/metadata/versionMetadata.js.map +1 -1
- package/build/tools/wopee-reporter/wopeeReporter.d.ts +3 -0
- package/build/tools/wopee-reporter/wopeeReporter.js +30 -3
- package/build/tools/wopee-reporter/wopeeReporter.js.map +1 -1
- package/docs/configuration.md +39 -15
- package/docs/troubleshooting.md +59 -0
- package/node_modules/@autonomous-testing/sdk/.github/workflows/ci_cd.yaml +47 -20
- package/node_modules/@autonomous-testing/sdk/README.md +129 -36
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/adapter.js +4 -8
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/axios-config.d.ts +12 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/axios-config.js +5 -4
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/errors.d.ts +20 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/errors.js +178 -0
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/interface.d.ts +1 -1
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/interface.js +13 -3
- package/node_modules/@autonomous-testing/sdk/build/infrastructure/services/apolloAdapterService/apolloAdapterService.js +6 -2
- package/node_modules/@autonomous-testing/sdk/build/shared/metadata/versionMetadata.js +2 -2
- package/node_modules/@autonomous-testing/sdk/build/shared/utils/error.interface.d.ts +13 -1
- package/node_modules/@autonomous-testing/sdk/build/shared/utils/error.interface.js +8 -1
- package/node_modules/@autonomous-testing/sdk/build/shared/utils/index.d.ts +2 -2
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/README.md +145 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/dist/src/index.d.ts +78 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/dist/src/index.js +203 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/dist/src/index.js.map +1 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/dist/src/promisify.d.ts +4 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/dist/src/promisify.js +18 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/dist/src/promisify.js.map +1 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/package.json +64 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/src/index.ts +345 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/agent-base/src/promisify.ts +33 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/README.md +137 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/agent.d.ts +30 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/agent.js +177 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/agent.js.map +1 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/index.d.ts +23 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/index.js +14 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/index.js.map +1 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/parse-proxy-response.d.ts +7 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/parse-proxy-response.js +66 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/dist/parse-proxy-response.js.map +1 -0
- package/node_modules/@autonomous-testing/sdk/node_modules/https-proxy-agent/package.json +56 -0
- package/node_modules/@autonomous-testing/sdk/package.json +18 -6
- package/node_modules/agent-base/LICENSE +22 -0
- package/node_modules/agent-base/README.md +69 -0
- package/node_modules/agent-base/dist/helpers.d.ts +15 -0
- package/node_modules/agent-base/dist/helpers.d.ts.map +1 -0
- package/node_modules/agent-base/dist/helpers.js +66 -0
- package/node_modules/agent-base/dist/helpers.js.map +1 -0
- package/node_modules/agent-base/dist/index.d.ts +41 -0
- package/node_modules/agent-base/dist/index.d.ts.map +1 -0
- package/node_modules/agent-base/dist/index.js +178 -0
- package/node_modules/agent-base/dist/index.js.map +1 -0
- package/node_modules/agent-base/package.json +46 -0
- package/node_modules/debug/LICENSE +20 -0
- package/node_modules/debug/README.md +481 -0
- package/node_modules/debug/package.json +64 -0
- package/node_modules/debug/src/browser.js +272 -0
- package/node_modules/debug/src/common.js +292 -0
- package/node_modules/debug/src/index.js +10 -0
- package/node_modules/debug/src/node.js +263 -0
- package/node_modules/http-proxy-agent/LICENSE +22 -0
- package/node_modules/http-proxy-agent/README.md +44 -0
- package/node_modules/http-proxy-agent/dist/index.d.ts +44 -0
- package/node_modules/http-proxy-agent/dist/index.d.ts.map +1 -0
- package/node_modules/http-proxy-agent/dist/index.js +148 -0
- package/node_modules/http-proxy-agent/dist/index.js.map +1 -0
- package/node_modules/http-proxy-agent/package.json +47 -0
- package/node_modules/ms/index.js +162 -0
- package/node_modules/ms/license.md +21 -0
- package/node_modules/ms/package.json +38 -0
- package/node_modules/ms/readme.md +59 -0
- package/package.json +2 -2
- package/.github/actions/npm_clean_install/action.yaml +0 -35
- package/node_modules/@autonomous-testing/sdk/.github/actions/npm_clean_install/action.yaml +0 -35
|
@@ -8,36 +8,46 @@ on:
|
|
|
8
8
|
branches:
|
|
9
9
|
- 'dev'
|
|
10
10
|
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
packages: read
|
|
14
|
+
|
|
11
15
|
jobs:
|
|
12
16
|
npm-clean-install:
|
|
13
17
|
runs-on: builder
|
|
18
|
+
container:
|
|
19
|
+
image: node:24
|
|
20
|
+
options: --user 1000
|
|
14
21
|
|
|
15
22
|
steps:
|
|
16
23
|
- name: Check-out
|
|
17
|
-
uses: actions/checkout@
|
|
24
|
+
uses: actions/checkout@v7
|
|
18
25
|
with:
|
|
19
26
|
fetch-depth: 1
|
|
20
27
|
|
|
21
28
|
- name: Install
|
|
22
|
-
uses:
|
|
29
|
+
uses: autonomous-testing/npm-install-action@v3
|
|
23
30
|
with:
|
|
24
|
-
npm-token: ${{
|
|
31
|
+
npm-token: ${{ github.token }}
|
|
25
32
|
|
|
26
33
|
static-check:
|
|
27
34
|
needs: [npm-clean-install]
|
|
28
35
|
if: github.event_name == 'pull_request'
|
|
29
36
|
runs-on: builder
|
|
37
|
+
container:
|
|
38
|
+
image: node:24
|
|
39
|
+
options: --user 1000
|
|
30
40
|
|
|
31
41
|
steps:
|
|
32
42
|
- name: Check-out
|
|
33
|
-
uses: actions/checkout@
|
|
43
|
+
uses: actions/checkout@v7
|
|
34
44
|
with:
|
|
35
45
|
fetch-depth: 0
|
|
36
46
|
|
|
37
47
|
- name: Install
|
|
38
|
-
uses:
|
|
48
|
+
uses: autonomous-testing/npm-install-action@v3
|
|
39
49
|
with:
|
|
40
|
-
npm-token: ${{
|
|
50
|
+
npm-token: ${{ github.token }}
|
|
41
51
|
|
|
42
52
|
- name: Commitlint
|
|
43
53
|
if: ${{ always() }}
|
|
@@ -61,17 +71,20 @@ jobs:
|
|
|
61
71
|
before-build-test:
|
|
62
72
|
needs: [npm-clean-install]
|
|
63
73
|
runs-on: builder
|
|
74
|
+
container:
|
|
75
|
+
image: node:24
|
|
76
|
+
options: --user 1000
|
|
64
77
|
|
|
65
78
|
steps:
|
|
66
79
|
- name: Check-out
|
|
67
|
-
uses: actions/checkout@
|
|
80
|
+
uses: actions/checkout@v7
|
|
68
81
|
with:
|
|
69
82
|
fetch-depth: 1
|
|
70
83
|
|
|
71
84
|
- name: Install
|
|
72
|
-
uses:
|
|
85
|
+
uses: autonomous-testing/npm-install-action@v3
|
|
73
86
|
with:
|
|
74
|
-
npm-token: ${{
|
|
87
|
+
npm-token: ${{ github.token }}
|
|
75
88
|
|
|
76
89
|
- name: Prepare .env
|
|
77
90
|
shell: bash
|
|
@@ -94,17 +107,20 @@ jobs:
|
|
|
94
107
|
build:
|
|
95
108
|
needs: [npm-clean-install]
|
|
96
109
|
runs-on: builder
|
|
110
|
+
container:
|
|
111
|
+
image: node:24
|
|
112
|
+
options: --user 1000
|
|
97
113
|
|
|
98
114
|
steps:
|
|
99
115
|
- name: Check-out
|
|
100
|
-
uses: actions/checkout@
|
|
116
|
+
uses: actions/checkout@v7
|
|
101
117
|
with:
|
|
102
118
|
fetch-depth: 1
|
|
103
119
|
|
|
104
120
|
- name: Install
|
|
105
|
-
uses:
|
|
121
|
+
uses: autonomous-testing/npm-install-action@v3
|
|
106
122
|
with:
|
|
107
|
-
npm-token: ${{
|
|
123
|
+
npm-token: ${{ github.token }}
|
|
108
124
|
|
|
109
125
|
- name: Build
|
|
110
126
|
run: make build
|
|
@@ -112,17 +128,20 @@ jobs:
|
|
|
112
128
|
after-build-test:
|
|
113
129
|
needs: [build]
|
|
114
130
|
runs-on: builder
|
|
131
|
+
container:
|
|
132
|
+
image: node:24
|
|
133
|
+
options: --user 1000
|
|
115
134
|
|
|
116
135
|
steps:
|
|
117
136
|
- name: Check-out
|
|
118
|
-
uses: actions/checkout@
|
|
137
|
+
uses: actions/checkout@v7
|
|
119
138
|
with:
|
|
120
139
|
fetch-depth: 1
|
|
121
140
|
|
|
122
141
|
- name: Install
|
|
123
|
-
uses:
|
|
142
|
+
uses: autonomous-testing/npm-install-action@v3
|
|
124
143
|
with:
|
|
125
|
-
npm-token: ${{
|
|
144
|
+
npm-token: ${{ github.token }}
|
|
126
145
|
|
|
127
146
|
- name: E2E test
|
|
128
147
|
run: echo no-test
|
|
@@ -131,21 +150,29 @@ jobs:
|
|
|
131
150
|
needs: [before-build-test, after-build-test]
|
|
132
151
|
if: github.event_name == 'push'
|
|
133
152
|
runs-on: builder
|
|
153
|
+
permissions:
|
|
154
|
+
contents: write
|
|
155
|
+
issues: write
|
|
156
|
+
pull-requests: write
|
|
157
|
+
packages: write
|
|
158
|
+
container:
|
|
159
|
+
image: node:24
|
|
160
|
+
options: --user 1000
|
|
134
161
|
|
|
135
162
|
steps:
|
|
136
163
|
- name: Check-out
|
|
137
|
-
uses: actions/checkout@
|
|
164
|
+
uses: actions/checkout@v7
|
|
138
165
|
with:
|
|
139
166
|
fetch-depth: 1
|
|
140
167
|
|
|
141
168
|
- name: Install
|
|
142
|
-
uses:
|
|
169
|
+
uses: autonomous-testing/npm-install-action@v3
|
|
143
170
|
with:
|
|
144
|
-
npm-token: ${{
|
|
171
|
+
npm-token: ${{ github.token }}
|
|
145
172
|
|
|
146
173
|
- name: Release
|
|
147
174
|
shell: bash
|
|
148
175
|
env:
|
|
149
|
-
GH_TOKEN: ${{
|
|
150
|
-
NPM_TOKEN: ${{
|
|
176
|
+
GH_TOKEN: ${{ github.token }}
|
|
177
|
+
NPM_TOKEN: ${{ github.token }}
|
|
151
178
|
run: make release
|
|
@@ -1,57 +1,150 @@
|
|
|
1
|
-
# Wopee SDK
|
|
1
|
+
# Wopee.io JavaScript SDK for Autonomous Testing
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@wopee-io/sdk)
|
|
4
|
+
[](https://www.npmjs.com/package/@wopee-io/sdk)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
Connect any JavaScript or TypeScript test framework to [Wopee.io](https://wopee.io) for visual regression testing. Capture screenshots from your tests and let Wopee.io compare them against baselines — with AI-powered autonomous maintenance.
|
|
6
7
|
|
|
8
|
+
## When to use this SDK
|
|
9
|
+
|
|
10
|
+
Use `@wopee-io/sdk` when you want to add visual testing to a framework that doesn't have a dedicated Wopee.io plugin. If you use Playwright, Cypress, or WebdriverIO, use the dedicated packages instead:
|
|
11
|
+
|
|
12
|
+
- **Playwright** → [`@wopee-io/wopee.pw`](https://www.npmjs.com/package/@wopee-io/wopee.pw)
|
|
13
|
+
- **Cypress** → [`@wopee-io/wopee.cy`](https://www.npmjs.com/package/@wopee-io/wopee.cy)
|
|
14
|
+
- **WebdriverIO** → [`@wopee-io/wopee.wdio`](https://www.npmjs.com/package/@wopee-io/wopee.wdio)
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @wopee-io/sdk
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
### 1. Get your credentials
|
|
25
|
+
|
|
26
|
+
Sign up at [cmd.wopee.io](https://cmd.wopee.io) and create a project. You'll need:
|
|
27
|
+
|
|
28
|
+
- **API Key** — from Project Settings → API Keys
|
|
29
|
+
- **Project UUID** — from Project Settings
|
|
30
|
+
|
|
31
|
+
### 2. Set environment variables
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
export WOPEE_API_URL=https://api.wopee.io
|
|
35
|
+
export WOPEE_API_KEY=your-api-key
|
|
36
|
+
export WOPEE_PROJECT_UUID=your-project-uuid
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`WOPEE_API_KEY` and `WOPEE_PROJECT_UUID` are required. `WOPEE_API_URL` is optional and defaults to the SaaS endpoint `https://api.wopee.io`.
|
|
40
|
+
|
|
41
|
+
#### Self-hosted instances
|
|
42
|
+
|
|
43
|
+
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.
|
|
44
|
+
|
|
45
|
+
The SDK honours the standard proxy variables:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
export HTTPS_PROXY=http://proxy.corp:8080
|
|
49
|
+
export NO_PROXY=localhost,127.0.0.1,.internal
|
|
7
50
|
```
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
51
|
+
|
|
52
|
+
`NO_PROXY` supports exact hosts, leading-dot suffixes (`.acme.io`), `host:port` entries, CIDR ranges (`10.0.0.0/8`) and `*`.
|
|
53
|
+
|
|
54
|
+
### 3. Capture and track screenshots
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { ApolloTrackAdapterService } from '@wopee-io/sdk';
|
|
58
|
+
|
|
59
|
+
// Create a tracker instance
|
|
60
|
+
const tracker = ApolloTrackAdapterService.create({
|
|
61
|
+
apiUrl: process.env.WOPEE_API_URL,
|
|
62
|
+
apiKey: process.env.WOPEE_API_KEY,
|
|
63
|
+
projectId: process.env.WOPEE_PROJECT_UUID,
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// Start a test suite
|
|
67
|
+
await tracker.startSuite('My Test Suite');
|
|
68
|
+
|
|
69
|
+
// Track a screenshot (pass a base64-encoded image)
|
|
70
|
+
await tracker.track({
|
|
71
|
+
stepName: 'Homepage',
|
|
72
|
+
imageBase64: screenshotData,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Track another step
|
|
76
|
+
await tracker.track({
|
|
77
|
+
stepName: 'After Login',
|
|
78
|
+
imageBase64: anotherScreenshot,
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
// End the suite
|
|
82
|
+
await tracker.stopSuite();
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Example: Integration with Puppeteer
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { ApolloTrackAdapterService } from '@wopee-io/sdk';
|
|
89
|
+
import puppeteer from 'puppeteer';
|
|
90
|
+
|
|
91
|
+
const browser = await puppeteer.launch();
|
|
92
|
+
const page = await browser.newPage();
|
|
93
|
+
|
|
94
|
+
const tracker = ApolloTrackAdapterService.create({
|
|
95
|
+
apiUrl: process.env.WOPEE_API_URL,
|
|
96
|
+
apiKey: process.env.WOPEE_API_KEY,
|
|
97
|
+
projectId: process.env.WOPEE_PROJECT_UUID,
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
await tracker.startSuite('Puppeteer Visual Tests');
|
|
101
|
+
|
|
102
|
+
await page.goto('https://example.com');
|
|
103
|
+
const screenshot = await page.screenshot({ encoding: 'base64' });
|
|
104
|
+
await tracker.track({ stepName: 'Homepage', imageBase64: screenshot });
|
|
105
|
+
|
|
106
|
+
await tracker.stopSuite();
|
|
107
|
+
await browser.close();
|
|
25
108
|
```
|
|
26
109
|
|
|
27
|
-
##
|
|
110
|
+
## How it works
|
|
28
111
|
|
|
29
|
-
|
|
112
|
+
1. Your test captures a screenshot (any method — Puppeteer, Selenium, custom)
|
|
113
|
+
2. The SDK sends the base64 image to the Wopee.io API
|
|
114
|
+
3. Wopee.io compares it against the stored baseline
|
|
115
|
+
4. Results are available in the [Wopee.io dashboard](https://cmd.wopee.io)
|
|
116
|
+
5. AI-powered maintenance automatically handles expected UI changes
|
|
30
117
|
|
|
31
|
-
|
|
118
|
+
## Troubleshooting
|
|
32
119
|
|
|
33
|
-
|
|
120
|
+
The SDK throws `WopeeError`. Branch on `error.code` rather than matching the message text — messages are written for humans and may be reworded.
|
|
34
121
|
|
|
35
|
-
|
|
122
|
+
### `Wopee SDK configuration is invalid — cannot initialize.`
|
|
36
123
|
|
|
37
|
-
|
|
124
|
+
Code: `WOPEE_CONFIG_INVALID`. A required value was missing or malformed. The error lists each offending field and where to get the value:
|
|
38
125
|
|
|
39
|
-
-
|
|
126
|
+
- `apiKey` — Project Settings → API Keys at [cmd.wopee.io](https://cmd.wopee.io), usually supplied as `WOPEE_API_KEY`.
|
|
127
|
+
- `projectUuid` — Project Settings, usually supplied as `WOPEE_PROJECT_UUID`.
|
|
128
|
+
- `apiUrl` — must include the scheme. `api.acme.wopee.io` is rejected; `https://api.acme.wopee.io` is accepted.
|
|
40
129
|
|
|
41
|
-
|
|
130
|
+
An empty string counts as missing, so a stray `WOPEE_API_KEY=` in a `.env` file is reported here rather than failing later as a `401`.
|
|
42
131
|
|
|
43
|
-
|
|
132
|
+
### `Cannot reach the Wopee API at <url>.`
|
|
44
133
|
|
|
45
|
-
|
|
134
|
+
Code: `WOPEE_API_UNREACHABLE`. The request never got a response — DNS, TCP, TLS or proxy failure. The message reports the URL that was attempted, the underlying failure, and whether a proxy was in effect. Common causes:
|
|
46
135
|
|
|
47
|
-
|
|
136
|
+
1. The instance is self-hosted and only reachable from the customer network — connect to the VPN or run the tests from a CI runner inside it.
|
|
137
|
+
2. A corporate proxy is required — set `HTTPS_PROXY`. If the message says the host was **bypassed**, it matched `NO_PROXY`; remove the matching entry if the proxy is how you reach it.
|
|
138
|
+
3. `WOPEE_API_URL` points at the wrong host — confirm it with your Wopee administrator.
|
|
48
139
|
|
|
49
|
-
|
|
140
|
+
Credentials embedded in a proxy URL are redacted before the message is printed.
|
|
50
141
|
|
|
51
|
-
|
|
142
|
+
### `Wopee API rejected the request: 401 Unauthorized.`
|
|
52
143
|
|
|
53
|
-
|
|
144
|
+
Code: `WOPEE_API_UNAUTHORIZED`. The API key was not accepted. View or regenerate it under Project Settings → API Keys at [cmd.wopee.io](https://cmd.wopee.io), and check that the key belongs to the project shown in the message.
|
|
54
145
|
|
|
55
|
-
|
|
146
|
+
## Links
|
|
56
147
|
|
|
57
|
-
|
|
148
|
+
- [Documentation](https://docs.wopee.io/) — setup guides and API reference
|
|
149
|
+
- [Wopee.io Platform](https://cmd.wopee.io) — manage baselines, review results
|
|
150
|
+
- [Wopee.io Website](https://wopee.io) — learn more about autonomous testing
|
package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/adapter.js
CHANGED
|
@@ -7,6 +7,7 @@ exports.ApolloAdapter = void 0;
|
|
|
7
7
|
const core_1 = require("../../../core");
|
|
8
8
|
const shared_1 = require("../../../shared");
|
|
9
9
|
const axios_config_1 = require("./axios-config");
|
|
10
|
+
const errors_1 = require("./errors");
|
|
10
11
|
const factories_1 = require("./factories");
|
|
11
12
|
const interface_1 = require("./interface");
|
|
12
13
|
const mutations_1 = require("./mutations");
|
|
@@ -22,18 +23,13 @@ class ApolloAdapter extends core_1.ApiPort {
|
|
|
22
23
|
this._config = config;
|
|
23
24
|
}
|
|
24
25
|
async _post(query, variables) {
|
|
26
|
+
const apiUrl = this._config.apiUrl;
|
|
25
27
|
try {
|
|
26
28
|
const headers = { api_key: this._config.apiKey };
|
|
27
|
-
|
|
28
|
-
return await axios_1.default.post(this._config.apiUrl, { query, variables }, config);
|
|
29
|
+
return await axios_1.default.post(apiUrl, { query, variables }, (0, axios_config_1.buildAxiosConfig)(apiUrl, headers));
|
|
29
30
|
}
|
|
30
31
|
catch (error) {
|
|
31
|
-
|
|
32
|
-
const status = error.response?.status;
|
|
33
|
-
const errorMessage = error.message;
|
|
34
|
-
throw new shared_1.WopeeError(`API request failed with status code: ${status}. ${errorMessage}`);
|
|
35
|
-
}
|
|
36
|
-
throw new Error('Unexpected error occurred during API call.');
|
|
32
|
+
throw (0, errors_1.toApiRequestError)(error, { apiUrl, projectUuid: this._config.projectUuid });
|
|
37
33
|
}
|
|
38
34
|
}
|
|
39
35
|
get suite() {
|
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import type { AxiosRequestConfig } from 'axios';
|
|
2
2
|
import 'dotenv/config';
|
|
3
|
+
export type ProxyDecision = {
|
|
4
|
+
proxyUrl: string | null;
|
|
5
|
+
noProxy: string;
|
|
6
|
+
/**
|
|
7
|
+
* True when a proxy was skipped *because the host matched NO_PROXY*, as
|
|
8
|
+
* opposed to no proxy being configured at all. The two look identical from
|
|
9
|
+
* `proxyUrl` alone but have very different fixes, so error reporting needs
|
|
10
|
+
* to tell them apart.
|
|
11
|
+
*/
|
|
12
|
+
bypassedByNoProxy: boolean;
|
|
13
|
+
};
|
|
14
|
+
export declare function getProxyDecision(url: string): ProxyDecision;
|
|
3
15
|
export declare function buildAxiosConfig(url: string, headers: Record<string, string>): AxiosRequestConfig;
|
|
4
16
|
//# sourceMappingURL=axios-config.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getProxyDecision = getProxyDecision;
|
|
3
4
|
exports.buildAxiosConfig = buildAxiosConfig;
|
|
4
5
|
require("dotenv/config");
|
|
5
6
|
const http_proxy_agent_1 = require("http-proxy-agent");
|
|
@@ -87,17 +88,17 @@ function isNoProxyMatch(url, noProxy) {
|
|
|
87
88
|
function getProxyDecision(url) {
|
|
88
89
|
const noProxy = process.env['NO_PROXY'] || process.env['no_proxy'] || '';
|
|
89
90
|
if (!url) {
|
|
90
|
-
return { proxyUrl: null, noProxy };
|
|
91
|
+
return { proxyUrl: null, noProxy, bypassedByNoProxy: false };
|
|
91
92
|
}
|
|
92
93
|
if (isNoProxyMatch(url, noProxy)) {
|
|
93
|
-
return { proxyUrl: null, noProxy };
|
|
94
|
+
return { proxyUrl: null, noProxy, bypassedByNoProxy: true };
|
|
94
95
|
}
|
|
95
96
|
try {
|
|
96
97
|
const proxyUrl = (0, proxy_from_env_1.getProxyForUrl)(url);
|
|
97
|
-
return { proxyUrl: proxyUrl || null, noProxy };
|
|
98
|
+
return { proxyUrl: proxyUrl || null, noProxy, bypassedByNoProxy: false };
|
|
98
99
|
}
|
|
99
100
|
catch {
|
|
100
|
-
return { proxyUrl: null, noProxy };
|
|
101
|
+
return { proxyUrl: null, noProxy, bypassedByNoProxy: false };
|
|
101
102
|
}
|
|
102
103
|
}
|
|
103
104
|
function buildAxiosConfig(url, headers) {
|
package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/errors.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { WopeeError } from '../../../shared';
|
|
2
|
+
import { ZodError } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Turns a zod validation failure into readable prose. Fields without a hint fall
|
|
5
|
+
* back to the bare zod message, so every config failure reads as a sentence
|
|
6
|
+
* rather than a ZodError dump.
|
|
7
|
+
*/
|
|
8
|
+
export declare function toConfigError(error: ZodError): WopeeError;
|
|
9
|
+
/**
|
|
10
|
+
* Wraps a failed API call in a `WopeeError` that says what to do about it.
|
|
11
|
+
*
|
|
12
|
+
* The discriminator for "unreachable" is the absence of a response rather than
|
|
13
|
+
* an errno allowlist — that covers DNS, TCP, TLS and proxy-tunnel failures
|
|
14
|
+
* without going stale.
|
|
15
|
+
*/
|
|
16
|
+
export declare function toApiRequestError(error: unknown, context: {
|
|
17
|
+
apiUrl: string;
|
|
18
|
+
projectUuid?: string;
|
|
19
|
+
}): WopeeError;
|
|
20
|
+
//# sourceMappingURL=errors.d.ts.map
|
package/node_modules/@autonomous-testing/sdk/build/infrastructure/adapters/apolloAdapter/errors.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.toConfigError = toConfigError;
|
|
7
|
+
exports.toApiRequestError = toApiRequestError;
|
|
8
|
+
const shared_1 = require("../../../shared");
|
|
9
|
+
const axios_config_1 = require("./axios-config");
|
|
10
|
+
const axios_1 = __importDefault(require("axios"));
|
|
11
|
+
const DOCS_URL = 'https://docs.wopee.io/';
|
|
12
|
+
const CMD_URL = 'https://cmd.wopee.io';
|
|
13
|
+
const DEFAULT_API_URL = 'https://api.wopee.io';
|
|
14
|
+
/**
|
|
15
|
+
* Where each configuration value comes from. The SDK is handed a config object
|
|
16
|
+
* and never reads the environment itself, so the environment variable is named
|
|
17
|
+
* as the usual source rather than as the thing that was validated.
|
|
18
|
+
*/
|
|
19
|
+
const CONFIG_FIELD_HINTS = {
|
|
20
|
+
apiKey: `Get it from Project Settings → API Keys at ${CMD_URL}\n (usually the WOPEE_API_KEY environment variable).`,
|
|
21
|
+
projectUuid: `Get it from Project Settings at ${CMD_URL}\n (usually the WOPEE_PROJECT_UUID environment variable).`,
|
|
22
|
+
apiUrl: `This is your Wopee instance URL (usually the WOPEE_API_URL environment\n variable). The default SaaS endpoint is ${DEFAULT_API_URL}.`,
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Strips credentials out of a proxy URL. `HTTPS_PROXY` commonly embeds
|
|
26
|
+
* `user:password@`, and these messages end up in CI logs.
|
|
27
|
+
*/
|
|
28
|
+
function redactProxyUrl(raw) {
|
|
29
|
+
try {
|
|
30
|
+
const parsed = new URL(raw);
|
|
31
|
+
if (parsed.username || parsed.password) {
|
|
32
|
+
parsed.username = '***';
|
|
33
|
+
parsed.password = '***';
|
|
34
|
+
}
|
|
35
|
+
return parsed.toString();
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return '(unparsable proxy URL)';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function describeProxy(decision) {
|
|
42
|
+
if (decision.proxyUrl) {
|
|
43
|
+
return `${redactProxyUrl(decision.proxyUrl)} (from HTTPS_PROXY/HTTP_PROXY)`;
|
|
44
|
+
}
|
|
45
|
+
if (decision.bypassedByNoProxy) {
|
|
46
|
+
return `bypassed — this host matches NO_PROXY="${decision.noProxy}"`;
|
|
47
|
+
}
|
|
48
|
+
return `none — no HTTP_PROXY/HTTPS_PROXY matched this URL (NO_PROXY="${decision.noProxy}")`;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The middle "likely cause" is the one that changes with the proxy situation —
|
|
52
|
+
* telling someone to set HTTPS_PROXY when it is already set is noise.
|
|
53
|
+
*/
|
|
54
|
+
function proxyCause(decision) {
|
|
55
|
+
if (decision.proxyUrl) {
|
|
56
|
+
return [
|
|
57
|
+
'2. The proxy itself may be down, or may not allow this host. Verify the',
|
|
58
|
+
' proxy is reachable, or add the host to NO_PROXY if it should be',
|
|
59
|
+
' reached directly.',
|
|
60
|
+
].join('\n ');
|
|
61
|
+
}
|
|
62
|
+
if (decision.bypassedByNoProxy) {
|
|
63
|
+
return [
|
|
64
|
+
'2. This host is excluded from the proxy by NO_PROXY. Remove the matching',
|
|
65
|
+
' entry if the proxy is how you reach it.',
|
|
66
|
+
].join('\n ');
|
|
67
|
+
}
|
|
68
|
+
return [
|
|
69
|
+
'2. A corporate proxy is required to reach it. The Wopee SDK honours',
|
|
70
|
+
' HTTP_PROXY, HTTPS_PROXY and NO_PROXY — set HTTPS_PROXY and retry.',
|
|
71
|
+
].join('\n ');
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Turns a zod validation failure into readable prose. Fields without a hint fall
|
|
75
|
+
* back to the bare zod message, so every config failure reads as a sentence
|
|
76
|
+
* rather than a ZodError dump.
|
|
77
|
+
*/
|
|
78
|
+
function toConfigError(error) {
|
|
79
|
+
const details = error.issues.map((issue) => {
|
|
80
|
+
const field = issue.path.join('.');
|
|
81
|
+
const hint = CONFIG_FIELD_HINTS[field];
|
|
82
|
+
const headline = ` • ${field || 'configuration'}: ${issue.message}.`;
|
|
83
|
+
return hint ? `${headline}\n ${hint}` : headline;
|
|
84
|
+
});
|
|
85
|
+
const message = [
|
|
86
|
+
'Wopee SDK configuration is invalid — cannot initialize.',
|
|
87
|
+
'',
|
|
88
|
+
...details,
|
|
89
|
+
'',
|
|
90
|
+
`Docs: ${DOCS_URL}`,
|
|
91
|
+
].join('\n');
|
|
92
|
+
return new shared_1.WopeeError(message, { code: 'WOPEE_CONFIG_INVALID', cause: error });
|
|
93
|
+
}
|
|
94
|
+
function unreachableMessage(apiUrl, failure, code) {
|
|
95
|
+
const decision = (0, axios_config_1.getProxyDecision)(apiUrl);
|
|
96
|
+
const failureLine = code ? `${failure} (${code})` : failure;
|
|
97
|
+
return [
|
|
98
|
+
`Cannot reach the Wopee API at ${apiUrl}.`,
|
|
99
|
+
'',
|
|
100
|
+
` Attempted: POST ${apiUrl}`,
|
|
101
|
+
` Failure: ${failureLine}`,
|
|
102
|
+
` Proxy: ${describeProxy(decision)}`,
|
|
103
|
+
'',
|
|
104
|
+
' Likely causes:',
|
|
105
|
+
' 1. This is a self-hosted Wopee instance that is only reachable from the',
|
|
106
|
+
' customer network. Connect to the VPN, or run the tests from a CI',
|
|
107
|
+
' runner inside that network.',
|
|
108
|
+
` ${proxyCause(decision)}`,
|
|
109
|
+
' 3. WOPEE_API_URL points at the wrong host. Confirm the value with your',
|
|
110
|
+
` Wopee administrator; the default SaaS endpoint is ${DEFAULT_API_URL}.`,
|
|
111
|
+
'',
|
|
112
|
+
` Docs: ${DOCS_URL}`,
|
|
113
|
+
].join('\n');
|
|
114
|
+
}
|
|
115
|
+
function unauthorizedMessage(apiUrl, status, projectUuid) {
|
|
116
|
+
const label = status === 403 ? 'Forbidden' : 'Unauthorized';
|
|
117
|
+
return [
|
|
118
|
+
`Wopee API rejected the request: ${status} ${label}.`,
|
|
119
|
+
'',
|
|
120
|
+
` Endpoint: ${apiUrl}`,
|
|
121
|
+
` Project: ${projectUuid ?? '(not set)'}`,
|
|
122
|
+
'',
|
|
123
|
+
' The API key was not accepted. Check WOPEE_API_KEY — you can view or',
|
|
124
|
+
` regenerate it under Project Settings → API Keys at ${CMD_URL}.`,
|
|
125
|
+
' Make sure the key belongs to the project above.',
|
|
126
|
+
'',
|
|
127
|
+
` Docs: ${DOCS_URL}`,
|
|
128
|
+
].join('\n');
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Pulls the GraphQL error the API returns in the response body, which the
|
|
132
|
+
* previous implementation discarded.
|
|
133
|
+
*/
|
|
134
|
+
function serverMessage(data) {
|
|
135
|
+
const errors = data?.errors;
|
|
136
|
+
const message = Array.isArray(errors) ? errors[0]?.message : undefined;
|
|
137
|
+
return typeof message === 'string' && message.length > 0 ? message : null;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Wraps a failed API call in a `WopeeError` that says what to do about it.
|
|
141
|
+
*
|
|
142
|
+
* The discriminator for "unreachable" is the absence of a response rather than
|
|
143
|
+
* an errno allowlist — that covers DNS, TCP, TLS and proxy-tunnel failures
|
|
144
|
+
* without going stale.
|
|
145
|
+
*/
|
|
146
|
+
function toApiRequestError(error, context) {
|
|
147
|
+
const { apiUrl, projectUuid } = context;
|
|
148
|
+
if (axios_1.default.isAxiosError(error)) {
|
|
149
|
+
if (!error.response) {
|
|
150
|
+
return new shared_1.WopeeError(unreachableMessage(apiUrl, error.message, error.code), {
|
|
151
|
+
code: 'WOPEE_API_UNREACHABLE',
|
|
152
|
+
cause: error,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
const status = error.response.status;
|
|
156
|
+
if (status === 401 || status === 403) {
|
|
157
|
+
return new shared_1.WopeeError(unauthorizedMessage(apiUrl, status, projectUuid), {
|
|
158
|
+
code: 'WOPEE_API_UNAUTHORIZED',
|
|
159
|
+
cause: error,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
// Keeps the historical "API request failed with status code" wording so
|
|
163
|
+
// anything matching on it keeps working.
|
|
164
|
+
const details = serverMessage(error.response.data);
|
|
165
|
+
const message = [
|
|
166
|
+
`Wopee API request failed with status code ${status} at ${apiUrl}.`,
|
|
167
|
+
error.message,
|
|
168
|
+
...(details ? [`Server said: ${details}`] : []),
|
|
169
|
+
].join('\n');
|
|
170
|
+
return new shared_1.WopeeError(message, { code: 'WOPEE_API_ERROR', cause: error });
|
|
171
|
+
}
|
|
172
|
+
const description = error instanceof Error ? error.message : String(error);
|
|
173
|
+
return new shared_1.WopeeError(`Unexpected error during the Wopee API call: ${description}`, {
|
|
174
|
+
code: 'WOPEE_API_ERROR',
|
|
175
|
+
cause: error,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -16,10 +16,10 @@ declare const ApolloAdapterConfigSchema: z.ZodObject<{
|
|
|
16
16
|
suiteUuid: z.ZodOptional<z.ZodString>;
|
|
17
17
|
}, "strip", z.ZodTypeAny, {
|
|
18
18
|
apiKey: string;
|
|
19
|
+
projectUuid: string;
|
|
19
20
|
apiUrl: string;
|
|
20
21
|
branchName: string;
|
|
21
22
|
enableSoftAssert: boolean;
|
|
22
|
-
projectUuid: string;
|
|
23
23
|
browser?: string | undefined;
|
|
24
24
|
comment?: string | undefined;
|
|
25
25
|
customTags?: string | undefined;
|
|
@@ -3,9 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VisualAssertApolloResponseSchema = exports.VisualAssertApolloPayloadSchema = exports.SuiteIntegrationConfigApolloPayloadSchema = exports.StopIntegrationScenarioApolloPayloadSchema = exports.IgnoreAreaApolloPayloadSchema = exports.CreateIntegrationSuiteApolloPayloadSchema = exports.CreateIntegrationStepConfigApolloPayloadSchema = exports.CreateIntegrationStepApolloResponseSchema = exports.CreateIntegrationStepApolloPayloadSchema = exports.CreateIntegrationScenarioApolloPayloadSchema = exports.ApolloAdapterConfigSchema = void 0;
|
|
4
4
|
const shared_1 = require("../../../shared");
|
|
5
5
|
const zod_1 = require("zod");
|
|
6
|
+
// The messages below are rendered into a human-readable summary by
|
|
7
|
+
// `toConfigError` in ./errors.ts, so they read as a sentence fragment following
|
|
8
|
+
// the field name, e.g. "apiKey: missing.".
|
|
6
9
|
const ApolloAdapterConfigSchema = zod_1.z.object({
|
|
7
|
-
apiKey: zod_1.z
|
|
8
|
-
|
|
10
|
+
apiKey: zod_1.z
|
|
11
|
+
.string({ required_error: 'missing', invalid_type_error: 'must be a string' })
|
|
12
|
+
.min(1, 'missing (empty string)'),
|
|
13
|
+
apiUrl: zod_1.z
|
|
14
|
+
.string({ invalid_type_error: 'must be a string' })
|
|
15
|
+
.url('must be an absolute URL including the scheme, e.g. https://api.wopee.io')
|
|
16
|
+
.default('https://api.wopee.io'),
|
|
9
17
|
branchName: zod_1.z.string().default('master'),
|
|
10
18
|
browser: zod_1.z.string().optional(),
|
|
11
19
|
comment: zod_1.z.string().optional(),
|
|
@@ -14,7 +22,9 @@ const ApolloAdapterConfigSchema = zod_1.z.object({
|
|
|
14
22
|
enableSoftAssert: shared_1.ZodHelper.parseStringToBoolean().default(true),
|
|
15
23
|
os: zod_1.z.string().optional(),
|
|
16
24
|
pixelToPixelDiffTolerance: shared_1.ZodHelper.parseStringToNumberSchema().optional(),
|
|
17
|
-
projectUuid: zod_1.z
|
|
25
|
+
projectUuid: zod_1.z
|
|
26
|
+
.string({ required_error: 'missing', invalid_type_error: 'must be a string' })
|
|
27
|
+
.min(1, 'missing (empty string)'),
|
|
18
28
|
viewport: zod_1.z.string().optional(),
|
|
19
29
|
baselineBranchName: zod_1.z.string().optional(),
|
|
20
30
|
suiteUuid: zod_1.z.string().optional(),
|