@antelopejs/dms 0.20.8-next.941.g5ff1751 → 0.20.8-next.943.g59ea329
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/E2E.md +45 -0
- package/bin/control/e2e-run.mjs +21 -7
- package/bin/control/e2e-suite.mjs +128 -0
- package/bin/control/e2e-suite.test.mjs +174 -0
- package/bin/control/e2e.mjs +22 -21
- package/bin/control/journey-load.mjs +27 -3
- package/bin/control/journey.mjs +3 -1
- package/bin/control/journey.test.mjs +2 -0
- package/dist/bin/control/e2e-run.d.mts +8 -5
- package/dist/bin/control/e2e-suite.d.mts +52 -0
- package/dist/bin/control/e2e.d.mts +13 -3
- package/dist/bin/control/journey-load.d.mts +8 -1
- package/package.json +3 -2
package/E2E.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# The e2e kit
|
|
2
|
+
|
|
3
|
+
`@antelopejs/dms/e2e` runs the journeys of a repository's verify skill as a Playwright suite. Each journey runs through the same runner as `dms-control journey`, in Playwright's browser. The global setup of a config prepares the skill, starts one `dms-control up` run for the whole invocation, and stops it after the last test.
|
|
4
|
+
|
|
5
|
+
## Configure a suite
|
|
6
|
+
|
|
7
|
+
`e2e/playwright.config.ts`:
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { e2eConfig } from "@antelopejs/dms/e2e";
|
|
11
|
+
|
|
12
|
+
export default e2eConfig();
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`e2e/journeys.spec.ts`:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { registerJourneys } from "@antelopejs/dms/e2e";
|
|
19
|
+
|
|
20
|
+
await registerJourneys();
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
`e2eConfig` takes two options:
|
|
24
|
+
|
|
25
|
+
- `skill`: the verify skill folder, relative to the repository root. A repository with one `.agents/skills/verify-*` folder leaves it out. A repository with several names the one its suite runs, such as `e2eConfig({ skill: ".agents/skills/verify-dms-assistant" })`.
|
|
26
|
+
- `frontend: "dev"`: the run serves the dashboard with `ajs dms dev` (`up --dev-frontend`), and the suite runs only the journeys that set `frontend: "dev"`. A suite without it serves a build and leaves those journeys out. Its test output and report folders end in `-dev`.
|
|
27
|
+
|
|
28
|
+
`registerJourneys()` reads both from the config that loaded it.
|
|
29
|
+
|
|
30
|
+
## Journey fields for the suite
|
|
31
|
+
|
|
32
|
+
- `tag`: Playwright tags, such as `@smoke`.
|
|
33
|
+
- `knownFailures`: the name of each check that fails today, mapped to the finding that makes it fail. A listed check that fails does not fail the journey. A listed check that passes does.
|
|
34
|
+
- `last: true`: runs the journey after all others, for a journey that changes the run's playground for later backends.
|
|
35
|
+
- `frontend: "dev"`: the journey needs the development dashboard, for UI that only `import.meta.env.DEV` renders. `dms-control journey` refuses it on a run started without `--dev-frontend`.
|
|
36
|
+
|
|
37
|
+
## Port recipe
|
|
38
|
+
|
|
39
|
+
1. Pin `@antelopejs/dms` to the exact preview that `next` publishes (dist-tag `next`). A range such as `>=0.20.2 <0.21.0` does not match a prerelease. Add `@playwright/test` `~1.65.0` as a devDependency, on the line of the `playwright-core` that `@antelopejs/dms` resolves.
|
|
40
|
+
2. Add the two files above, an `e2e/tsconfig.json` (`allowJs`, `noEmit`, `nodenext`), and the script `"e2e": "playwright test -c e2e"`. A repository with several verify skills passes `skill` to `e2eConfig`.
|
|
41
|
+
3. Move the skill's `journeys/` folder and the helpers it imports to `e2e/`, and set `journeys: "e2e/journeys"` in `verify.config.ts`. `dms-control map` must exit 0.
|
|
42
|
+
4. Give each journey that needs the development dashboard `frontend: "dev"`, and add `e2e/playwright.dev.config.ts` with `e2eConfig({ frontend: "dev" })` (and the same `skill`). Run it with `playwright test -c e2e/playwright.dev.config.ts`.
|
|
43
|
+
5. A journey that fails today because of a product finding gets `knownFailures`, never a skip. A journey that changes the run's playground for later backends gets `last: true`.
|
|
44
|
+
6. Tag `@smoke` on about 5 fast journeys, the `smoke` journey first, none that needs `backend: "watch"`, `withBaseBackend`, `standby: false` or `frontend: "dev"`.
|
|
45
|
+
7. Copy the `e2e` and `e2e-report` jobs of AntelopeJS/dms's `ci.yml` and the `e2e` line of its `ubuntu` gate: nothing on a draft or the fast tier, `--grep @smoke` on the full tier, `--shard=i/N --reporter=blob` on the nightly tier, with N chosen so that one shard stays under about 30 minutes. A dev config runs in the same job, after the build config.
|
package/bin/control/e2e-run.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { parseArgs } from "node:util";
|
|
2
2
|
import { startRun } from "./commands-stack.mjs";
|
|
3
|
+
import { declaredSuite, upArgs } from "./e2e-suite.mjs";
|
|
3
4
|
import { OPTIONS } from "./options.mjs";
|
|
4
5
|
import { loadRun } from "./run-state.mjs";
|
|
5
6
|
import { down } from "./stack.mjs";
|
|
@@ -8,17 +9,30 @@ const RUN = "DMS_E2E_RUN";
|
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Playwright's global setup of a journeys suite, once per `playwright test`.
|
|
11
|
-
* With `DMS_E2E_RUN` set, the tests drive that run and it stops nothing
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* With `DMS_E2E_RUN` set, the tests drive that run and it stops nothing; a
|
|
13
|
+
* run whose dashboard is not served the way the suite asks is refused.
|
|
14
|
+
* Otherwise it starts a run as `dms-control up --prepare` does, on the
|
|
15
|
+
* config's skill and with `--dev-frontend` for a `frontend: "dev"` suite
|
|
16
|
+
* (`up` alone with `DMS_E2E_PREBUILT=1`), publishes its folder in
|
|
17
|
+
* `DMS_E2E_RUN` for the workers, and returns the teardown that stops it.
|
|
18
|
+
* The run outlives the worker Playwright replaces after a failed test.
|
|
16
19
|
*
|
|
17
20
|
* @returns {Promise<(() => Promise<void>) | undefined>} The teardown of the run it started
|
|
21
|
+
* @throws When the adopted run serves its dashboard another way than the suite asks
|
|
18
22
|
*/
|
|
19
23
|
export default async function globalSetup() {
|
|
20
|
-
|
|
21
|
-
const
|
|
24
|
+
const suite = declaredSuite();
|
|
25
|
+
const adopted = process.env[RUN];
|
|
26
|
+
if (adopted) {
|
|
27
|
+
const mode = loadRun(adopted).frontendMode ?? "build";
|
|
28
|
+
if (mode !== suite.frontend) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
`${RUN} serves a ${mode} dashboard, and this suite runs the journeys of a ${suite.frontend} one`,
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
const args = upArgs(suite, process.env.DMS_E2E_PREBUILT === "1");
|
|
22
36
|
const { values } = parseArgs({ args, options: OPTIONS });
|
|
23
37
|
const state = await startRun(values, process.cwd());
|
|
24
38
|
process.env[RUN] = state.dir;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { checkoutOf } from "./git.mjs";
|
|
4
|
+
import { isRecord, isString } from "./json.mjs";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {import("./journey-load.mjs").Journey} Journey
|
|
8
|
+
* @typedef {{ skill?: string, frontend?: "dev" }} SuiteOptions What a journeys suite runs: `skill` is the verify skill folder, relative to the repository root, for a repository with several; `frontend: "dev"` serves the dashboard with `ajs dms dev` and runs only the journeys that ask for it
|
|
9
|
+
* @typedef {{ skill: string | undefined, frontend: "build" | "dev" }} Suite The suite a config declared, its skill folder absolute
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const SUITE = "DMS_E2E_SUITE";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {unknown} value A suite option
|
|
16
|
+
* @returns {value is SuiteOptions} True for the options `e2eConfig` takes
|
|
17
|
+
*/
|
|
18
|
+
function isSuiteOptions(value) {
|
|
19
|
+
return (
|
|
20
|
+
isRecord(value) &&
|
|
21
|
+
Object.keys(value).every((key) => key === "skill" || key === "frontend") &&
|
|
22
|
+
(value.skill === undefined ||
|
|
23
|
+
(isString(value.skill) && value.skill !== "")) &&
|
|
24
|
+
(value.frontend === undefined || value.frontend === "dev")
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Records the suite a config declares, for its global setup and for the
|
|
30
|
+
* workers that load its spec, which inherit the environment of the process
|
|
31
|
+
* that loaded the config.
|
|
32
|
+
*
|
|
33
|
+
* @param {unknown} options The options of `e2eConfig`
|
|
34
|
+
* @throws When an option is unknown, its value is not one the suite takes, or `skill` holds no `verify.config.ts`
|
|
35
|
+
*/
|
|
36
|
+
export function declareSuite(options) {
|
|
37
|
+
if (!isSuiteOptions(options)) {
|
|
38
|
+
throw new Error(
|
|
39
|
+
`e2eConfig takes { skill?: <the verify skill folder>, frontend?: "dev" }, got ${JSON.stringify(options)}`,
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
const root = checkoutOf(process.cwd()).root ?? process.cwd();
|
|
43
|
+
/** @type {Suite} */
|
|
44
|
+
const suite = {
|
|
45
|
+
skill:
|
|
46
|
+
options.skill === undefined ? undefined : resolve(root, options.skill),
|
|
47
|
+
frontend: options.frontend ?? "build",
|
|
48
|
+
};
|
|
49
|
+
if (suite.skill && !existsSync(join(suite.skill, "verify.config.ts"))) {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`e2eConfig's skill ${suite.skill} holds no verify.config.ts`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
process.env[SUITE] = JSON.stringify(suite);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @returns {Suite} The suite of the config that loaded this process
|
|
59
|
+
* @throws When no `e2eConfig` ran in it
|
|
60
|
+
*/
|
|
61
|
+
export function declaredSuite() {
|
|
62
|
+
const recorded = process.env[SUITE];
|
|
63
|
+
if (!recorded) {
|
|
64
|
+
throw new Error(
|
|
65
|
+
`${SUITE} is not set: run the suite through a Playwright config built by e2eConfig()`,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
/** @type {unknown} */
|
|
69
|
+
const suite = JSON.parse(recorded);
|
|
70
|
+
if (!isSuite(suite)) throw new Error(`${SUITE} holds no suite: ${recorded}`);
|
|
71
|
+
return suite;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* @param {unknown} value What the environment recorded
|
|
76
|
+
* @returns {value is Suite} True for a suite `declareSuite` recorded
|
|
77
|
+
*/
|
|
78
|
+
function isSuite(value) {
|
|
79
|
+
return (
|
|
80
|
+
isRecord(value) &&
|
|
81
|
+
(value.skill === undefined || isString(value.skill)) &&
|
|
82
|
+
(value.frontend === "build" || value.frontend === "dev")
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* @param {Suite} suite The suite
|
|
88
|
+
* @param {boolean} prepared Whether the skill's prepare commands already ran
|
|
89
|
+
* @returns {string[]} The options of `dms-control up` that start its run
|
|
90
|
+
*/
|
|
91
|
+
export function upArgs(suite, prepared) {
|
|
92
|
+
return [
|
|
93
|
+
...(prepared ? [] : ["--prepare"]),
|
|
94
|
+
...(suite.skill ? ["--skill", suite.skill] : []),
|
|
95
|
+
...(suite.frontend === "dev" ? ["--dev-frontend"] : []),
|
|
96
|
+
];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The journeys a suite runs, in the order of its features and with those
|
|
101
|
+
* marked `last` after all others: a `frontend: "dev"` suite runs the
|
|
102
|
+
* journeys that ask for the development dashboard, any other the rest.
|
|
103
|
+
*
|
|
104
|
+
* @param {{ name: string, journeys: Journey[] }[]} features The features and their journeys
|
|
105
|
+
* @param {Suite["frontend"]} frontend How the suite's run serves its dashboard
|
|
106
|
+
* @returns {{ feature: string, journey: Journey }[]} The journeys, each with its feature
|
|
107
|
+
* @throws When two journeys share an id
|
|
108
|
+
*/
|
|
109
|
+
export function suiteJourneys(features, frontend) {
|
|
110
|
+
const ids = features.flatMap((feature) =>
|
|
111
|
+
feature.journeys.map((journey) => journey.id),
|
|
112
|
+
);
|
|
113
|
+
const repeated = ids.filter((id, index) => ids.indexOf(id) !== index);
|
|
114
|
+
if (repeated.length > 0) {
|
|
115
|
+
throw new Error(`Journey ids registered twice: ${repeated.join(", ")}`);
|
|
116
|
+
}
|
|
117
|
+
const entries = features
|
|
118
|
+
.flatMap((feature) =>
|
|
119
|
+
feature.journeys.map((journey) => ({ feature: feature.name, journey })),
|
|
120
|
+
)
|
|
121
|
+
.filter(
|
|
122
|
+
(entry) => (entry.journey.frontend === "dev") === (frontend === "dev"),
|
|
123
|
+
);
|
|
124
|
+
return [
|
|
125
|
+
...entries.filter((entry) => !entry.journey.last),
|
|
126
|
+
...entries.filter((entry) => entry.journey.last),
|
|
127
|
+
];
|
|
128
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import {
|
|
4
|
+
mkdirSync,
|
|
5
|
+
mkdtempSync,
|
|
6
|
+
realpathSync,
|
|
7
|
+
rmSync,
|
|
8
|
+
writeFileSync,
|
|
9
|
+
} from "node:fs";
|
|
10
|
+
import { tmpdir } from "node:os";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import { parseArgs } from "node:util";
|
|
13
|
+
import test from "node:test";
|
|
14
|
+
import {
|
|
15
|
+
declareSuite,
|
|
16
|
+
declaredSuite,
|
|
17
|
+
suiteJourneys,
|
|
18
|
+
upArgs,
|
|
19
|
+
} from "./e2e-suite.mjs";
|
|
20
|
+
import { frontendRefusal } from "./journey-load.mjs";
|
|
21
|
+
import { OPTIONS } from "./options.mjs";
|
|
22
|
+
import { loadSkill } from "./verify/skill.mjs";
|
|
23
|
+
|
|
24
|
+
const CONFIG = `export default ${JSON.stringify({
|
|
25
|
+
playground: "p",
|
|
26
|
+
prepare: [],
|
|
27
|
+
userFacing: ["src/**"],
|
|
28
|
+
smoke: "smoke",
|
|
29
|
+
smokeJourney: "",
|
|
30
|
+
doors: {},
|
|
31
|
+
formal: [],
|
|
32
|
+
})};\n`;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A git checkout holding two verify skills, as dms-assistant does, with the
|
|
36
|
+
* process inside its `e2e/` folder, where Playwright loads a config.
|
|
37
|
+
*
|
|
38
|
+
* @param {import("node:test").TestContext} t The test
|
|
39
|
+
* @returns {string} The checkout root
|
|
40
|
+
*/
|
|
41
|
+
function twoSkillCheckout(t) {
|
|
42
|
+
const root = realpathSync(mkdtempSync(join(tmpdir(), "dms-e2e-suite-")));
|
|
43
|
+
const cwd = process.cwd();
|
|
44
|
+
const recorded = process.env.DMS_E2E_SUITE;
|
|
45
|
+
t.after(() => {
|
|
46
|
+
process.chdir(cwd);
|
|
47
|
+
if (recorded === undefined) delete process.env.DMS_E2E_SUITE;
|
|
48
|
+
else process.env.DMS_E2E_SUITE = recorded;
|
|
49
|
+
rmSync(root, { recursive: true, force: true });
|
|
50
|
+
});
|
|
51
|
+
spawnSync("git", ["init", "-q"], { cwd: root });
|
|
52
|
+
for (const skill of ["verify-dms-assistant", "verify-dms-builder"]) {
|
|
53
|
+
mkdirSync(join(root, ".agents", "skills", skill), { recursive: true });
|
|
54
|
+
writeFileSync(
|
|
55
|
+
join(root, ".agents", "skills", skill, "verify.config.ts"),
|
|
56
|
+
CONFIG,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
mkdirSync(join(root, "e2e"));
|
|
60
|
+
spawnSync("git", ["add", "-A"], { cwd: root });
|
|
61
|
+
spawnSync(
|
|
62
|
+
"git",
|
|
63
|
+
["-c", "user.name=t", "-c", "user.email=t@t", "commit", "-qm", "skills"],
|
|
64
|
+
{ cwd: root },
|
|
65
|
+
);
|
|
66
|
+
process.chdir(join(root, "e2e"));
|
|
67
|
+
return root;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @param {string} id The journey id
|
|
72
|
+
* @param {Partial<import("./journey-load.mjs").Journey>} [fields] Its other fields
|
|
73
|
+
* @returns {import("./journey-load.mjs").Journey} The journey
|
|
74
|
+
*/
|
|
75
|
+
function journey(id, fields = {}) {
|
|
76
|
+
return { id, title: id, entryPoint: "/", async run() {}, ...fields };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
await test("a suite that names one of two skills loads it from e2e/ and starts its run with --skill (catches a global setup or registerJourneys that discovers the skill, which throws on two)", async (t) => {
|
|
80
|
+
const root = twoSkillCheckout(t);
|
|
81
|
+
await assert.rejects(
|
|
82
|
+
loadSkill(undefined, process.cwd()),
|
|
83
|
+
/found 2; pass --skill/,
|
|
84
|
+
);
|
|
85
|
+
declareSuite({ skill: ".agents/skills/verify-dms-assistant" });
|
|
86
|
+
const suite = declaredSuite();
|
|
87
|
+
const skill = await loadSkill(suite.skill, process.cwd());
|
|
88
|
+
assert.equal(skill.name, "verify-dms-assistant");
|
|
89
|
+
const { values } = parseArgs({
|
|
90
|
+
args: upArgs(suite, false),
|
|
91
|
+
options: OPTIONS,
|
|
92
|
+
});
|
|
93
|
+
assert.equal(
|
|
94
|
+
values.skill,
|
|
95
|
+
join(root, ".agents", "skills", "verify-dms-assistant"),
|
|
96
|
+
);
|
|
97
|
+
assert.equal(values.prepare, true);
|
|
98
|
+
assert.equal(values["dev-frontend"], undefined);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
await test("a frontend: dev suite starts its run with --dev-frontend, and a prepared one skips --prepare (catches a global setup that always serves a build)", (t) => {
|
|
102
|
+
twoSkillCheckout(t);
|
|
103
|
+
declareSuite({ skill: ".agents/skills/verify-dms-builder", frontend: "dev" });
|
|
104
|
+
const { values } = parseArgs({
|
|
105
|
+
args: upArgs(declaredSuite(), true),
|
|
106
|
+
options: OPTIONS,
|
|
107
|
+
});
|
|
108
|
+
assert.equal(values["dev-frontend"], true);
|
|
109
|
+
assert.equal(values.prepare, undefined);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
await test('a suite option e2eConfig does not take is refused (catches a typo such as frontend: "development" silently serving a build)', (t) => {
|
|
113
|
+
const root = twoSkillCheckout(t);
|
|
114
|
+
assert.throws(() => declareSuite({ skill: ".agents/skills/verify-nope" }), {
|
|
115
|
+
message: `e2eConfig's skill ${join(root, ".agents/skills/verify-nope")} holds no verify.config.ts`,
|
|
116
|
+
});
|
|
117
|
+
for (const options of [
|
|
118
|
+
{ frontend: "development" },
|
|
119
|
+
{ frontend: "build" },
|
|
120
|
+
{ skill: "" },
|
|
121
|
+
{ skills: "x" },
|
|
122
|
+
]) {
|
|
123
|
+
assert.throws(
|
|
124
|
+
() => declareSuite(options),
|
|
125
|
+
/e2eConfig takes/,
|
|
126
|
+
JSON.stringify(options),
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
await test("a build suite leaves out the journeys that need the development dashboard and a dev suite runs only those, each keeping last ones last (catches a suite that runs a dev journey on a built dashboard)", () => {
|
|
132
|
+
const features = [
|
|
133
|
+
{
|
|
134
|
+
name: "a",
|
|
135
|
+
journeys: [
|
|
136
|
+
journey("a-1", { last: true }),
|
|
137
|
+
journey("a-2"),
|
|
138
|
+
journey("a-dev", { frontend: "dev" }),
|
|
139
|
+
],
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "b",
|
|
143
|
+
journeys: [
|
|
144
|
+
journey("b-dev", { frontend: "dev", last: true }),
|
|
145
|
+
journey("b-1"),
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
];
|
|
149
|
+
const ids = (/** @type {"build" | "dev"} */ frontend) =>
|
|
150
|
+
suiteJourneys(features, frontend).map(
|
|
151
|
+
(entry) => `${entry.feature}/${entry.journey.id}`,
|
|
152
|
+
);
|
|
153
|
+
assert.deepEqual(ids("build"), ["a/a-2", "b/b-1", "a/a-1"]);
|
|
154
|
+
assert.deepEqual(ids("dev"), ["a/a-dev", "b/b-dev"]);
|
|
155
|
+
assert.throws(
|
|
156
|
+
() =>
|
|
157
|
+
suiteJourneys(
|
|
158
|
+
[...features, { name: "c", journeys: [journey("b-1")] }],
|
|
159
|
+
"build",
|
|
160
|
+
),
|
|
161
|
+
/b-1/,
|
|
162
|
+
);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
await test("dms-control journey refuses a journey that needs the development dashboard on a run that serves a build (catches a run that fails it on a missing launcher instead of saying why)", () => {
|
|
166
|
+
const journeys = [journey("plain"), journey("launcher", { frontend: "dev" })];
|
|
167
|
+
assert.match(
|
|
168
|
+
frontendRefusal(journeys, "build") ?? "",
|
|
169
|
+
/^launcher need the development dashboard: start the run with up --dev-frontend$/,
|
|
170
|
+
);
|
|
171
|
+
assert.match(frontendRefusal(journeys, undefined) ?? "", /launcher/);
|
|
172
|
+
assert.equal(frontendRefusal(journeys, "dev"), null);
|
|
173
|
+
assert.equal(frontendRefusal([journey("plain")], "build"), null);
|
|
174
|
+
});
|
package/bin/control/e2e.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { join } from "node:path";
|
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { expect, test } from "@playwright/test";
|
|
5
5
|
import { currentRun } from "./e2e-run.mjs";
|
|
6
|
+
import { declareSuite, declaredSuite, suiteJourneys } from "./e2e-suite.mjs";
|
|
6
7
|
import { assertForwardedRun } from "./backend.mjs";
|
|
7
8
|
import { runJourney } from "./journey.mjs";
|
|
8
9
|
import { loadJourneys } from "./journey-load.mjs";
|
|
@@ -14,6 +15,7 @@ import { journeysFile, loadSkill, readFeatures } from "./verify/skill.mjs";
|
|
|
14
15
|
* @typedef {import("./tab.mjs").Tab} Tab A browser tab of a journey
|
|
15
16
|
* @typedef {import("./journey.mjs").Check} Check A check a journey records
|
|
16
17
|
* @typedef {import("./journey-load.mjs").Journey} Journey A journey a feature's module exports
|
|
18
|
+
* @typedef {import("./e2e-suite.mjs").SuiteOptions} SuiteOptions What a journeys suite runs
|
|
17
19
|
*/
|
|
18
20
|
|
|
19
21
|
const MINUTE = 60_000;
|
|
@@ -28,14 +30,21 @@ const STEP_EVIDENCE = [
|
|
|
28
30
|
* global setup starts (parallelism comes from `--shard`), no retries, a test
|
|
29
31
|
* timeout above dms-control's own waits, and the CI reporters. It is plain
|
|
30
32
|
* Playwright config, so `defineConfig(e2eConfig(), overrides)` adjusts it.
|
|
33
|
+
* `skill` names the verify skill of a repository that has several.
|
|
34
|
+
* `frontend: "dev"` starts the run with `up --dev-frontend` and runs only
|
|
35
|
+
* the journeys that set `frontend: "dev"`, which every other suite leaves
|
|
36
|
+
* out; its test output and report folders end in `-dev`.
|
|
31
37
|
*
|
|
38
|
+
* @param {SuiteOptions} [options] The suite
|
|
32
39
|
* @returns {import("@playwright/test").PlaywrightTestConfig} The config
|
|
33
40
|
*/
|
|
34
|
-
export function e2eConfig() {
|
|
41
|
+
export function e2eConfig(options = {}) {
|
|
42
|
+
declareSuite(options);
|
|
43
|
+
const suffix = options.frontend === "dev" ? "-dev" : "";
|
|
35
44
|
return {
|
|
36
45
|
testDir: ".",
|
|
37
46
|
testMatch: /\.spec\.ts$/,
|
|
38
|
-
outputDir:
|
|
47
|
+
outputDir: `test-results${suffix}`,
|
|
39
48
|
fullyParallel: true,
|
|
40
49
|
workers: 1,
|
|
41
50
|
retries: 0,
|
|
@@ -46,8 +55,11 @@ export function e2eConfig() {
|
|
|
46
55
|
? [
|
|
47
56
|
["list"],
|
|
48
57
|
["github"],
|
|
49
|
-
[
|
|
50
|
-
|
|
58
|
+
[
|
|
59
|
+
"html",
|
|
60
|
+
{ open: "never", outputFolder: `playwright-report${suffix}` },
|
|
61
|
+
],
|
|
62
|
+
["json", { outputFile: `playwright-report${suffix}/results.json` }],
|
|
51
63
|
]
|
|
52
64
|
: "list",
|
|
53
65
|
use: { trace: "retain-on-failure" },
|
|
@@ -56,8 +68,9 @@ export function e2eConfig() {
|
|
|
56
68
|
}
|
|
57
69
|
|
|
58
70
|
/**
|
|
59
|
-
* Registers
|
|
60
|
-
*
|
|
71
|
+
* Registers the journeys of the suite its config declared: those of the
|
|
72
|
+
* config's verify skill that its `frontend` serves, in the order of the
|
|
73
|
+
* skill's feature files and with those marked `last` after all others. One
|
|
61
74
|
* test per journey, named by its id under its feature's name, with the
|
|
62
75
|
* journey's `tag` and its title and entry point as annotations. A test
|
|
63
76
|
* drives its journey through `runJourney` in Playwright's browser, on the
|
|
@@ -67,27 +80,15 @@ export function e2eConfig() {
|
|
|
67
80
|
* @throws When a feature has no journeys module, or two journeys share an id
|
|
68
81
|
*/
|
|
69
82
|
export async function registerJourneys() {
|
|
70
|
-
const
|
|
83
|
+
const suite = declaredSuite();
|
|
84
|
+
const skill = await loadSkill(suite.skill, process.cwd());
|
|
71
85
|
const features = await Promise.all(
|
|
72
86
|
readFeatures(skill).map(async (feature) => ({
|
|
73
87
|
name: feature.name,
|
|
74
88
|
journeys: await loadJourneys(journeysFile(skill, feature.name)),
|
|
75
89
|
})),
|
|
76
90
|
);
|
|
77
|
-
const
|
|
78
|
-
feature.journeys.map((journey) => journey.id),
|
|
79
|
-
);
|
|
80
|
-
const repeated = ids.filter((id, index) => ids.indexOf(id) !== index);
|
|
81
|
-
if (repeated.length > 0) {
|
|
82
|
-
throw new Error(`Journey ids registered twice: ${repeated.join(", ")}`);
|
|
83
|
-
}
|
|
84
|
-
const entries = features.flatMap((feature) =>
|
|
85
|
-
feature.journeys.map((journey) => ({ feature: feature.name, journey })),
|
|
86
|
-
);
|
|
87
|
-
for (const { feature, journey } of [
|
|
88
|
-
...entries.filter((entry) => !entry.journey.last),
|
|
89
|
-
...entries.filter((entry) => entry.journey.last),
|
|
90
|
-
]) {
|
|
91
|
+
for (const { feature, journey } of suiteJourneys(features, suite.frontend)) {
|
|
91
92
|
const annotation = [
|
|
92
93
|
{ type: "title", description: journey.title },
|
|
93
94
|
{ type: "entry point", description: journey.entryPoint },
|
|
@@ -4,7 +4,7 @@ import { isRecord, isString } from "./json.mjs";
|
|
|
4
4
|
import { isBackendMode } from "./run-state.mjs";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @typedef {{ id: string, title: string, entryPoint: string, database?: string, onboard?: boolean, backend?: import("./run-state.mjs").BackendMode, standby?: boolean, tag?: string | string[], knownFailures?: Readonly<Record<string, string>>, last?: boolean, run: (context: import("./journey.mjs").JourneyContext) => Promise<void> }} Journey `backend` pins how the backend of its fresh database runs, whatever mode `up` gave the run; `standby: false` serves its fresh database with a backend started for it, not a standby, and starts no standby while it runs; `tag` is its Playwright tags, such as `@smoke`; `knownFailures` maps the name of each check that fails today to the finding that makes it fail; `last: true` runs it after every other journey of the suite, for a journey that leaves the run's playground changed for every later backend
|
|
7
|
+
* @typedef {{ id: string, title: string, entryPoint: string, database?: string, onboard?: boolean, backend?: import("./run-state.mjs").BackendMode, standby?: boolean, tag?: string | string[], knownFailures?: Readonly<Record<string, string>>, last?: boolean, frontend?: "dev", run: (context: import("./journey.mjs").JourneyContext) => Promise<void> }} Journey `backend` pins how the backend of its fresh database runs, whatever mode `up` gave the run; `standby: false` serves its fresh database with a backend started for it, not a standby, and starts no standby while it runs; `tag` is its Playwright tags, such as `@smoke`; `knownFailures` maps the name of each check that fails today to the finding that makes it fail; `last: true` runs it after every other journey of the suite, for a journey that leaves the run's playground changed for every later backend; `frontend: "dev"` needs a run whose dashboard `ajs dms dev` serves (`up --dev-frontend`), for what only development renders
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
const TAG = /^@[a-z0-9-]+$/;
|
|
@@ -50,10 +50,21 @@ function isJourney(value) {
|
|
|
50
50
|
(value.database !== "shared" && isBackendMode(value.backend))) &&
|
|
51
51
|
(value.standby === undefined ||
|
|
52
52
|
(value.database !== "shared" && typeof value.standby === "boolean")) &&
|
|
53
|
+
isSuiteJourney(value) &&
|
|
54
|
+
typeof value.run === "function"
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @param {Record<string, unknown>} value A journey
|
|
60
|
+
* @returns {value is Pick<Journey, "tag" | "knownFailures" | "last" | "frontend">} True when the fields the Playwright suite reads are absent or valid
|
|
61
|
+
*/
|
|
62
|
+
function isSuiteJourney(value) {
|
|
63
|
+
return (
|
|
53
64
|
isTags(value.tag) &&
|
|
54
65
|
isKnownFailures(value.knownFailures) &&
|
|
55
66
|
(value.last === undefined || typeof value.last === "boolean") &&
|
|
56
|
-
|
|
67
|
+
(value.frontend === undefined || value.frontend === "dev")
|
|
57
68
|
);
|
|
58
69
|
}
|
|
59
70
|
|
|
@@ -73,7 +84,20 @@ export async function loadJourneys(file) {
|
|
|
73
84
|
const journeys = entries.filter(isJourney);
|
|
74
85
|
if (journeys.length !== entries.length)
|
|
75
86
|
throw new Error(
|
|
76
|
-
`${file} exports a journey without an id, title, entry point or run function, pins a backend or standby on a shared database, or has a tag that is not @kebab-case, a known failure without its finding
|
|
87
|
+
`${file} exports a journey without an id, title, entry point or run function, pins a backend or standby on a shared database, or has a tag that is not @kebab-case, a known failure without its finding, a last that is not a boolean or a frontend other than "dev"`,
|
|
77
88
|
);
|
|
78
89
|
return journeys;
|
|
79
90
|
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @param {Journey[]} journeys The journeys a command would run
|
|
94
|
+
* @param {import("./run-state.mjs").FrontendMode | undefined} mode How the run serves its dashboard
|
|
95
|
+
* @returns {string | null} Why the run cannot serve some of them, or `null` when it serves them all
|
|
96
|
+
*/
|
|
97
|
+
export function frontendRefusal(journeys, mode) {
|
|
98
|
+
if (mode === "dev") return null;
|
|
99
|
+
const dev = journeys.filter((journey) => journey.frontend === "dev");
|
|
100
|
+
return dev.length === 0
|
|
101
|
+
? null
|
|
102
|
+
: `${dev.map((journey) => journey.id).join(", ")} need the development dashboard: start the run with up --dev-frontend`;
|
|
103
|
+
}
|
package/bin/control/journey.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { launchBrowser, newContext, screenshot } from "./browser.mjs";
|
|
|
6
6
|
import { startDatabase, stopDatabase } from "./database.mjs";
|
|
7
7
|
import { capturedMail } from "./mail.mjs";
|
|
8
8
|
import { abortMessage, judge } from "./journey-judge.mjs";
|
|
9
|
-
import { loadJourneys } from "./journey-load.mjs";
|
|
9
|
+
import { frontendRefusal, loadJourneys } from "./journey-load.mjs";
|
|
10
10
|
import { readRecordList } from "./json.mjs";
|
|
11
11
|
import { saveRun } from "./run-state.mjs";
|
|
12
12
|
import {
|
|
@@ -552,6 +552,8 @@ export async function runJourneyFile(state, request) {
|
|
|
552
552
|
request.ids.length > 0
|
|
553
553
|
? journeys.filter((journey) => request.ids.includes(journey.id))
|
|
554
554
|
: journeys;
|
|
555
|
+
const refusal = frontendRefusal(selected, state.frontendMode);
|
|
556
|
+
if (refusal) throw new Error(refusal);
|
|
555
557
|
/** @type {FeatureResult[]} */
|
|
556
558
|
const results = [];
|
|
557
559
|
for (const journey of selected)
|
|
@@ -76,6 +76,8 @@ await test("a journey missing a field a run reads is refused", async (t) => {
|
|
|
76
76
|
'{ id: "x", title: "t", entryPoint: "e", knownFailures: { "the page answers": "" }, async run() {} }',
|
|
77
77
|
'{ id: "x", title: "t", entryPoint: "e", knownFailures: { "the page answers": true }, async run() {} }',
|
|
78
78
|
'{ id: "x", title: "t", entryPoint: "e", last: "yes", async run() {} }',
|
|
79
|
+
'{ id: "x", title: "t", entryPoint: "e", frontend: "build", async run() {} }',
|
|
80
|
+
'{ id: "x", title: "t", entryPoint: "e", frontend: true, async run() {} }',
|
|
79
81
|
"null",
|
|
80
82
|
];
|
|
81
83
|
for (const journey of broken) {
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Playwright's global setup of a journeys suite, once per `playwright test`.
|
|
3
|
-
* With `DMS_E2E_RUN` set, the tests drive that run and it stops nothing
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* With `DMS_E2E_RUN` set, the tests drive that run and it stops nothing; a
|
|
4
|
+
* run whose dashboard is not served the way the suite asks is refused.
|
|
5
|
+
* Otherwise it starts a run as `dms-control up --prepare` does, on the
|
|
6
|
+
* config's skill and with `--dev-frontend` for a `frontend: "dev"` suite
|
|
7
|
+
* (`up` alone with `DMS_E2E_PREBUILT=1`), publishes its folder in
|
|
8
|
+
* `DMS_E2E_RUN` for the workers, and returns the teardown that stops it.
|
|
9
|
+
* The run outlives the worker Playwright replaces after a failed test.
|
|
8
10
|
*
|
|
9
11
|
* @returns {Promise<(() => Promise<void>) | undefined>} The teardown of the run it started
|
|
12
|
+
* @throws When the adopted run serves its dashboard another way than the suite asks
|
|
10
13
|
*/
|
|
11
14
|
export default function globalSetup(): Promise<(() => Promise<void>) | undefined>;
|
|
12
15
|
/**
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Records the suite a config declares, for its global setup and for the
|
|
3
|
+
* workers that load its spec, which inherit the environment of the process
|
|
4
|
+
* that loaded the config.
|
|
5
|
+
*
|
|
6
|
+
* @param {unknown} options The options of `e2eConfig`
|
|
7
|
+
* @throws When an option is unknown, its value is not one the suite takes, or `skill` holds no `verify.config.ts`
|
|
8
|
+
*/
|
|
9
|
+
export function declareSuite(options: unknown): void;
|
|
10
|
+
/**
|
|
11
|
+
* @returns {Suite} The suite of the config that loaded this process
|
|
12
|
+
* @throws When no `e2eConfig` ran in it
|
|
13
|
+
*/
|
|
14
|
+
export function declaredSuite(): Suite;
|
|
15
|
+
/**
|
|
16
|
+
* @param {Suite} suite The suite
|
|
17
|
+
* @param {boolean} prepared Whether the skill's prepare commands already ran
|
|
18
|
+
* @returns {string[]} The options of `dms-control up` that start its run
|
|
19
|
+
*/
|
|
20
|
+
export function upArgs(suite: Suite, prepared: boolean): string[];
|
|
21
|
+
/**
|
|
22
|
+
* The journeys a suite runs, in the order of its features and with those
|
|
23
|
+
* marked `last` after all others: a `frontend: "dev"` suite runs the
|
|
24
|
+
* journeys that ask for the development dashboard, any other the rest.
|
|
25
|
+
*
|
|
26
|
+
* @param {{ name: string, journeys: Journey[] }[]} features The features and their journeys
|
|
27
|
+
* @param {Suite["frontend"]} frontend How the suite's run serves its dashboard
|
|
28
|
+
* @returns {{ feature: string, journey: Journey }[]} The journeys, each with its feature
|
|
29
|
+
* @throws When two journeys share an id
|
|
30
|
+
*/
|
|
31
|
+
export function suiteJourneys(features: {
|
|
32
|
+
name: string;
|
|
33
|
+
journeys: Journey[];
|
|
34
|
+
}[], frontend: Suite["frontend"]): {
|
|
35
|
+
feature: string;
|
|
36
|
+
journey: Journey;
|
|
37
|
+
}[];
|
|
38
|
+
export type Journey = import("./journey-load.mjs").Journey;
|
|
39
|
+
/**
|
|
40
|
+
* What a journeys suite runs: `skill` is the verify skill folder, relative to the repository root, for a repository with several; `frontend: "dev"` serves the dashboard with `ajs dms dev` and runs only the journeys that ask for it
|
|
41
|
+
*/
|
|
42
|
+
export type SuiteOptions = {
|
|
43
|
+
skill?: string;
|
|
44
|
+
frontend?: "dev";
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* The suite a config declared, its skill folder absolute
|
|
48
|
+
*/
|
|
49
|
+
export type Suite = {
|
|
50
|
+
skill: string | undefined;
|
|
51
|
+
frontend: "build" | "dev";
|
|
52
|
+
};
|
|
@@ -3,13 +3,19 @@
|
|
|
3
3
|
* global setup starts (parallelism comes from `--shard`), no retries, a test
|
|
4
4
|
* timeout above dms-control's own waits, and the CI reporters. It is plain
|
|
5
5
|
* Playwright config, so `defineConfig(e2eConfig(), overrides)` adjusts it.
|
|
6
|
+
* `skill` names the verify skill of a repository that has several.
|
|
7
|
+
* `frontend: "dev"` starts the run with `up --dev-frontend` and runs only
|
|
8
|
+
* the journeys that set `frontend: "dev"`, which every other suite leaves
|
|
9
|
+
* out; its test output and report folders end in `-dev`.
|
|
6
10
|
*
|
|
11
|
+
* @param {SuiteOptions} [options] The suite
|
|
7
12
|
* @returns {import("@playwright/test").PlaywrightTestConfig} The config
|
|
8
13
|
*/
|
|
9
|
-
export function e2eConfig(): import("@playwright/test").PlaywrightTestConfig;
|
|
14
|
+
export function e2eConfig(options?: SuiteOptions): import("@playwright/test").PlaywrightTestConfig;
|
|
10
15
|
/**
|
|
11
|
-
* Registers
|
|
12
|
-
*
|
|
16
|
+
* Registers the journeys of the suite its config declared: those of the
|
|
17
|
+
* config's verify skill that its `frontend` serves, in the order of the
|
|
18
|
+
* skill's feature files and with those marked `last` after all others. One
|
|
13
19
|
* test per journey, named by its id under its feature's name, with the
|
|
14
20
|
* journey's `tag` and its title and entry point as annotations. A test
|
|
15
21
|
* drives its journey through `runJourney` in Playwright's browser, on the
|
|
@@ -35,3 +41,7 @@ export type Check = import("./journey.mjs").Check;
|
|
|
35
41
|
* A journey a feature's module exports
|
|
36
42
|
*/
|
|
37
43
|
export type Journey = import("./journey-load.mjs").Journey;
|
|
44
|
+
/**
|
|
45
|
+
* What a journeys suite runs
|
|
46
|
+
*/
|
|
47
|
+
export type SuiteOptions = import("./e2e-suite.mjs").SuiteOptions;
|
|
@@ -6,7 +6,13 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export function loadJourneys(file: string): Promise<Journey[]>;
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
9
|
+
* @param {Journey[]} journeys The journeys a command would run
|
|
10
|
+
* @param {import("./run-state.mjs").FrontendMode | undefined} mode How the run serves its dashboard
|
|
11
|
+
* @returns {string | null} Why the run cannot serve some of them, or `null` when it serves them all
|
|
12
|
+
*/
|
|
13
|
+
export function frontendRefusal(journeys: Journey[], mode: import("./run-state.mjs").FrontendMode | undefined): string | null;
|
|
14
|
+
/**
|
|
15
|
+
* `backend` pins how the backend of its fresh database runs, whatever mode `up` gave the run; `standby: false` serves its fresh database with a backend started for it, not a standby, and starts no standby while it runs; `tag` is its Playwright tags, such as `@smoke`; `knownFailures` maps the name of each check that fails today to the finding that makes it fail; `last: true` runs it after every other journey of the suite, for a journey that leaves the run's playground changed for every later backend; `frontend: "dev"` needs a run whose dashboard `ajs dms dev` serves (`up --dev-frontend`), for what only development renders
|
|
10
16
|
*/
|
|
11
17
|
export type Journey = {
|
|
12
18
|
id: string;
|
|
@@ -19,5 +25,6 @@ export type Journey = {
|
|
|
19
25
|
tag?: string | string[];
|
|
20
26
|
knownFailures?: Readonly<Record<string, string>>;
|
|
21
27
|
last?: boolean;
|
|
28
|
+
frontend?: "dev";
|
|
22
29
|
run: (context: import("./journey.mjs").JourneyContext) => Promise<void>;
|
|
23
30
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antelopejs/dms",
|
|
3
|
-
"version": "0.20.8-next.
|
|
3
|
+
"version": "0.20.8-next.943.g59ea329",
|
|
4
4
|
"description": "AntelopeJS DMS. Plug in your PostgreSQL, MySQL, MariaDB, MongoDB or RethinkDB database and your coding agent builds a back office and analytics dashboard as typed TypeScript. Real-time updates on the data the DMS manages.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"antelopejs",
|
|
@@ -63,6 +63,7 @@
|
|
|
63
63
|
"!data/*.mmdb",
|
|
64
64
|
"package.json",
|
|
65
65
|
"README.md",
|
|
66
|
+
"E2E.md",
|
|
66
67
|
"CHANGELOG.md",
|
|
67
68
|
"LICENSE"
|
|
68
69
|
],
|
|
@@ -208,7 +209,7 @@
|
|
|
208
209
|
"optional": true
|
|
209
210
|
}
|
|
210
211
|
},
|
|
211
|
-
"gitHead": "
|
|
212
|
+
"gitHead": "59ea32967f8b80bfa0bb4ee97f3f6cb9aad92d90",
|
|
212
213
|
"scripts": {
|
|
213
214
|
"build": "pnpm --filter @antelopejs/interface-dms --filter @antelopejs/interface-dms-builder build && rimraf dist && tsc && tsc-alias && tsc -p bin/tsconfig.types.json",
|
|
214
215
|
"dev": "ajs project run --inspect -w -p playground",
|