@skyramp/testbot-core 0.0.0-pr728.223 → 0.0.0-pr953.449
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/assets/skyramp-walk/walk.cjs +45 -13
- package/dist/VERSION.json +1 -1
- package/dist/data-safety-worker.js +135 -0
- package/dist/main.js +775 -521
- package/dist/post.js +247 -120
- package/dist/runner-client.cjs +220 -74
- package/dist/runner-client.d.cts +952 -132
- package/dist/shared-environment-test.cjs +7 -0
- package/dist/shared-environment-test.d.cts +372 -0
- package/package.json +13 -8
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* await w.fill("page.getByPlaceholder('e.g. Apple Macbook Pro')", "Desk Lamp");
|
|
11
11
|
* w.expectRequest(); // the next action's request body is checked in the test
|
|
12
12
|
* await w.click("page.getByRole('button', { name: 'Submit' })");
|
|
13
|
-
* await w.expectText("page.getByRole('heading')
|
|
13
|
+
* await w.expectText("page.getByRole('heading', { name: 'Product Details' })", "Product Details");
|
|
14
14
|
* });
|
|
15
15
|
*
|
|
16
16
|
* Other options: actionTimeoutMs (each action, default 10 s), checkTimeoutMs (each expect*, retried until it holds,
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"use strict";
|
|
30
30
|
const path = require("path");
|
|
31
31
|
const fs = require("fs");
|
|
32
|
+
const { fork } = require("child_process");
|
|
32
33
|
|
|
33
34
|
const req = (name, dirs) => {
|
|
34
35
|
for (const d of dirs.filter(Boolean)) {
|
|
@@ -40,18 +41,21 @@ const roots = () => [process.env.SKYRAMP_WALK_SDK, ...(process.env.NODE_PATH ||
|
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
43
|
* The fork's Playwright, launching the Chromium walk.ts installed for it (SKYRAMP_WALK_BROWSERS_PATH) rather than
|
|
43
|
-
* whatever a repo's PLAYWRIGHT_BROWSERS_PATH points at
|
|
44
|
+
* whatever a repo's PLAYWRIGHT_BROWSERS_PATH points at, under the host it was installed for
|
|
45
|
+
* (SKYRAMP_WALK_HOST_PLATFORM, on an Ubuntu newer than the fork). Playwright reads both once, as it loads, so a repo's
|
|
46
|
+
* own Playwright in the session is left as it is.
|
|
44
47
|
*/
|
|
45
48
|
function loadPlaywright(load = () => req("playwright", roots())) {
|
|
46
|
-
const want = process.env.SKYRAMP_WALK_BROWSERS_PATH;
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
+
const want = { PLAYWRIGHT_BROWSERS_PATH: process.env.SKYRAMP_WALK_BROWSERS_PATH, PLAYWRIGHT_HOST_PLATFORM_OVERRIDE: process.env.SKYRAMP_WALK_HOST_PLATFORM };
|
|
50
|
+
const set = Object.keys(want).filter((k) => want[k]);
|
|
51
|
+
const prev = Object.fromEntries(set.map((k) => [k, process.env[k]]));
|
|
52
|
+
for (const k of set) process.env[k] = want[k];
|
|
49
53
|
try {
|
|
50
54
|
return load();
|
|
51
55
|
} finally {
|
|
52
|
-
|
|
53
|
-
if (prev === undefined) delete process.env
|
|
54
|
-
else process.env
|
|
56
|
+
for (const k of set) {
|
|
57
|
+
if (prev[k] === undefined) delete process.env[k];
|
|
58
|
+
else process.env[k] = prev[k];
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
}
|
|
@@ -162,7 +166,8 @@ function patchAssertLocators(jsonl, byTimestamp) {
|
|
|
162
166
|
.join("\n");
|
|
163
167
|
}
|
|
164
168
|
|
|
165
|
-
|
|
169
|
+
// In the order to reach for them: a layout change breaks a CSS path or a position, not a role and name.
|
|
170
|
+
const EXPORTABLE = "getByRole, getByLabel or getByTestId where the page has them, else getByText, getByPlaceholder, getByAltText, getByTitle, locator('css') and chains of these; .first() or .nth(n) only where the order is what the test checks";
|
|
166
171
|
|
|
167
172
|
let generating = Promise.resolve();
|
|
168
173
|
|
|
@@ -193,10 +198,35 @@ function withCredential(fn) {
|
|
|
193
198
|
return next;
|
|
194
199
|
}
|
|
195
200
|
|
|
201
|
+
/**
|
|
202
|
+
* Generate in a process of its own, started under the credential: the SDK's native library sees only the environment
|
|
203
|
+
* its process started with, so a licence set here, even before the SDK loads, gives "LICENSE_FILE required for CI
|
|
204
|
+
* environments".
|
|
205
|
+
*/
|
|
206
|
+
function generate(args, start = fork) {
|
|
207
|
+
return withCredential(
|
|
208
|
+
() =>
|
|
209
|
+
new Promise((resolve, reject) => {
|
|
210
|
+
const child = start(__filename, ["--generate", JSON.stringify(args)], { stdio: ["ignore", "inherit", "inherit", "ipc"] });
|
|
211
|
+
child.once("message", resolve);
|
|
212
|
+
child.once("error", reject);
|
|
213
|
+
child.once("exit", (code) => reject(new Error(`Skyramp generation exited with ${code} and no result`)));
|
|
214
|
+
}),
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
/** The other end of generate: this file run as its own process. */
|
|
219
|
+
function generateHere(args) {
|
|
220
|
+
const { SkyrampClient } = req("@skyramp/skyramp", roots());
|
|
221
|
+
new SkyrampClient()
|
|
222
|
+
.generateRestTest(args)
|
|
223
|
+
.then(String, (e) => `failed: ${e.message}`)
|
|
224
|
+
.then((result) => process.send(result, () => process.exit(0)));
|
|
225
|
+
}
|
|
226
|
+
|
|
196
227
|
async function walk(opts, body) {
|
|
197
228
|
const { chromium } = loadPlaywright();
|
|
198
229
|
const exp = req("playwright/lib/mcp/skyramp", roots());
|
|
199
|
-
const { SkyrampClient } = req("@skyramp/skyramp", roots());
|
|
200
230
|
const scratch = fs.mkdtempSync(path.join(require("os").tmpdir(), "skyramp-walk-"));
|
|
201
231
|
const zip = opts.zip || path.join(scratch, "walk.zip");
|
|
202
232
|
const har = path.join(scratch, "walk.har");
|
|
@@ -304,7 +334,7 @@ async function walk(opts, body) {
|
|
|
304
334
|
throw failure;
|
|
305
335
|
}
|
|
306
336
|
await record();
|
|
307
|
-
const result = await
|
|
337
|
+
const result = await generate({
|
|
308
338
|
testType: "ui",
|
|
309
339
|
language: opts.language || "typescript",
|
|
310
340
|
framework: "playwright",
|
|
@@ -313,9 +343,11 @@ async function walk(opts, body) {
|
|
|
313
343
|
playwrightInput: zip,
|
|
314
344
|
generateInclude: hosts,
|
|
315
345
|
force: true,
|
|
316
|
-
})
|
|
346
|
+
});
|
|
317
347
|
if (!/success/i.test(String(result))) throw new Error(`Skyramp generation failed: ${result}`);
|
|
318
348
|
return { zip, test: path.resolve(opts.outputDir || ".", opts.output), actions: actions.length, ...(leftOut.length ? { leftOut } : {}) };
|
|
319
349
|
}
|
|
320
350
|
|
|
321
|
-
|
|
351
|
+
if (require.main === module && process.argv[2] === "--generate") generateHere(JSON.parse(process.argv[3]));
|
|
352
|
+
|
|
353
|
+
module.exports = { walk, _internal: { generate, withCredential, retryUntil, apiRoute, stepFailure, forkLocator, exportable, patchAssertLocators, loadPlaywright } };
|
package/dist/VERSION.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"0.0.0-
|
|
1
|
+
{"version":"0.0.0-pr953.449","commit":"94f2e0ccd55b3551071a83bee215bf31aa222a01"}
|