@antelopejs/dms 0.18.0 → 0.18.1
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/CHANGELOG.md +31 -0
- package/README.md +3 -3
- package/bin/control/backend-records.test.mjs +276 -0
- package/bin/control/backend.mjs +212 -0
- package/bin/control/backend.test.mjs +325 -0
- package/bin/control/base.mjs +3 -7
- package/bin/control/browser-client.mjs +6 -4
- package/bin/control/browser.mjs +173 -36
- package/bin/control/build-cache.mjs +394 -0
- package/bin/control/build-cache.test.mjs +270 -0
- package/bin/control/build-inputs.mjs +172 -0
- package/bin/control/build-key-refusals.test.mjs +138 -0
- package/bin/control/build-key.mjs +479 -0
- package/bin/control/build-key.test.mjs +392 -0
- package/bin/control/build-layout.test.mjs +314 -0
- package/bin/control/commands-stack.mjs +46 -6
- package/bin/control/commands-verify.mjs +9 -2
- package/bin/control/doctor.mjs +87 -16
- package/bin/control/forwarder.mjs +86 -0
- package/bin/control/forwarder.test.mjs +141 -0
- package/bin/control/frontend-check.mjs +54 -0
- package/bin/control/frontend-workspace.mjs +150 -0
- package/bin/control/frontend-workspace.test.mjs +133 -0
- package/bin/control/helpers/env.mjs +21 -0
- package/bin/control/helpers/evidence.mjs +13 -0
- package/bin/control/helpers/fake-run.mjs +290 -0
- package/bin/control/helpers/key-fixture.mjs +82 -0
- package/bin/control/helpers/pids.mjs +27 -0
- package/bin/control/helpers/repo.mjs +13 -0
- package/bin/control/helpers/tree.mjs +40 -0
- package/bin/control/identity.mjs +238 -0
- package/bin/control/identity.test.mjs +166 -0
- package/bin/control/journey.mjs +64 -16
- package/bin/control/journey.test.mjs +60 -2
- package/bin/control/namespaces.test.mjs +211 -0
- package/bin/control/options.mjs +2 -0
- package/bin/control/pid-guard.test.mjs +202 -0
- package/bin/control/prepared-workspace.mjs +20 -0
- package/bin/control/processes.mjs +122 -33
- package/bin/control/processes.test.mjs +255 -0
- package/bin/control/renderer.test.mjs +2 -1
- package/bin/control/run-copy.mjs +77 -0
- package/bin/control/run-state.mjs +142 -16
- package/bin/control/stack.mjs +259 -210
- package/bin/control/tab.mjs +13 -6
- package/bin/control/tab.test.mjs +444 -0
- package/bin/control/timing.mjs +244 -0
- package/bin/control/timing.test.mjs +197 -0
- package/bin/control/verify/decode.mjs +34 -21
- package/bin/control/verify/decode.test.mjs +39 -0
- package/bin/control/verify/doors.test.mjs +2 -0
- package/bin/control/verify/map.mjs +57 -7
- package/bin/control/verify/map.test.mjs +264 -0
- package/bin/control/verify/skill.mjs +12 -3
- package/bin/control/verify/types.mjs +2 -2
- package/bin/control/verify/verdict.mjs +37 -7
- package/bin/dms-control.mjs +14 -6
- package/frontend-vue/layers/dms-layout/app/components/layout/DashboardSearch.vue +24 -1
- package/package.json +1 -1
- package/skills/dms-project/SKILL.md +6 -3
package/bin/control/tab.mjs
CHANGED
|
@@ -30,9 +30,10 @@ function flatten(text) {
|
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* A browser tab a journey drives, as one account. Each action writes a
|
|
33
|
-
* numbered step folder with the action, the URL
|
|
34
|
-
* screenshot. An action whose target is missing,
|
|
35
|
-
* the step and ends the journey.
|
|
33
|
+
* numbered step folder with the action, the URL and the ARIA snapshot, and a
|
|
34
|
+
* screenshot when the action failed. An action whose target is missing,
|
|
35
|
+
* hidden or disabled fails the step and ends the journey. The journey's
|
|
36
|
+
* `verify` steps take the screenshots of the tab driven last.
|
|
36
37
|
*/
|
|
37
38
|
export class Tab {
|
|
38
39
|
/**
|
|
@@ -51,14 +52,18 @@ export class Tab {
|
|
|
51
52
|
*
|
|
52
53
|
* @param {Omit<Action, "baseUrl">} action The action, as `perform` takes it
|
|
53
54
|
* @param {string} label What the step does
|
|
55
|
+
* @param {{ screenshot?: boolean }} [options] Whether to write a screenshot though the action succeeds
|
|
54
56
|
* @returns {Promise<Outcome & { folder: string }>} The outcome
|
|
55
57
|
*/
|
|
56
|
-
async act(action, label) {
|
|
58
|
+
async act(action, label, options = {}) {
|
|
57
59
|
const folder = this.context.step(`${this.label} ${label}`);
|
|
60
|
+
this.context.lastTab = this;
|
|
58
61
|
const outcome = await perform(
|
|
59
62
|
this.page,
|
|
60
63
|
{ ...action, baseUrl: this.context.state.webUrl },
|
|
61
64
|
folder,
|
|
65
|
+
this.context.state,
|
|
66
|
+
options,
|
|
62
67
|
);
|
|
63
68
|
this.context.record(
|
|
64
69
|
folder,
|
|
@@ -150,13 +155,13 @@ export class Tab {
|
|
|
150
155
|
}
|
|
151
156
|
|
|
152
157
|
/**
|
|
153
|
-
* Records the page as it is now.
|
|
158
|
+
* Records the page as it is now, screenshot included.
|
|
154
159
|
*
|
|
155
160
|
* @param {string} label What the step records
|
|
156
161
|
* @returns {Promise<Outcome & { folder: string }>} The outcome
|
|
157
162
|
*/
|
|
158
163
|
snapshot(label) {
|
|
159
|
-
return this.act({ do: "snapshot" }, label);
|
|
164
|
+
return this.act({ do: "snapshot" }, label, { screenshot: true });
|
|
160
165
|
}
|
|
161
166
|
|
|
162
167
|
/**
|
|
@@ -167,10 +172,12 @@ export class Tab {
|
|
|
167
172
|
*/
|
|
168
173
|
async signIn(account) {
|
|
169
174
|
const credentials = this.context.state.accounts?.[account];
|
|
175
|
+
this.context.lastTab = this;
|
|
170
176
|
const outcome = credentials
|
|
171
177
|
? await signInThroughForm(this.page, credentials, {
|
|
172
178
|
baseUrl: this.context.state.webUrl,
|
|
173
179
|
folder: (label) => this.context.step(`${this.label} ${label}`),
|
|
180
|
+
state: this.context.state,
|
|
174
181
|
})
|
|
175
182
|
: { ok: false, url: "", error: `no account ${account}` };
|
|
176
183
|
const folder = this.context.step(`${this.label} signed in as ${account}`);
|
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdtempSync, rmSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { dirname, join, relative } from "node:path";
|
|
5
|
+
import test from "node:test";
|
|
6
|
+
import { runInNewContext } from "node:vm";
|
|
7
|
+
import { evidenceText } from "./helpers/evidence.mjs";
|
|
8
|
+
import { JourneyContext } from "./journey.mjs";
|
|
9
|
+
import { Tab } from "./tab.mjs";
|
|
10
|
+
import { readTimings } from "./timing.mjs";
|
|
11
|
+
/**
|
|
12
|
+
* Tells each listener that two requests failed: one with
|
|
13
|
+
* `net::ERR_NETWORK_CHANGED`, one with `net::ERR_ABORTED`.
|
|
14
|
+
*
|
|
15
|
+
* @param {((request: object) => void)[]} listeners The `requestfailed` listeners
|
|
16
|
+
*/
|
|
17
|
+
function failRequests(listeners) {
|
|
18
|
+
for (const [errorText, failed] of [
|
|
19
|
+
["net::ERR_ABORTED", "http://web/assets/aborted.js"],
|
|
20
|
+
["net::ERR_NETWORK_CHANGED", "http://web/assets/changed.js"],
|
|
21
|
+
]) {
|
|
22
|
+
const request = { failure: () => ({ errorText }), url: () => failed };
|
|
23
|
+
for (const listener of listeners) listener(request);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Evaluates an expression the way `page.waitForFunction` does, every
|
|
29
|
+
* `polling` milliseconds until it holds. It gives up at once when nothing on
|
|
30
|
+
* the page is still on its way, as Playwright does once its timeout passes.
|
|
31
|
+
*
|
|
32
|
+
* @param {string} expression The expression
|
|
33
|
+
* @param {number} polling How often to evaluate it
|
|
34
|
+
* @param {() => object} globals The globals it reads, as they are now
|
|
35
|
+
* @param {() => boolean} changing Whether something on the page is still on its way
|
|
36
|
+
* @returns {Promise<boolean>} Whether it came to hold
|
|
37
|
+
*/
|
|
38
|
+
async function cameToHold(expression, polling, globals, changing) {
|
|
39
|
+
while (!runInNewContext(expression, globals())) {
|
|
40
|
+
if (!changing()) return false;
|
|
41
|
+
await new Promise((resolve) => setTimeout(resolve, polling));
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A page whose documents the server rendered for a Vue app, which hydrates
|
|
48
|
+
* each one `now` (on load), `later` (parsed a few milliseconds after load,
|
|
49
|
+
* mounted a few more after that) or `never`; with `none` its documents have
|
|
50
|
+
* no server-rendered root, as a JSON answer. The first `networkChanges`
|
|
51
|
+
* loads, and every click with `networkChangeOnClick`, see a request fail
|
|
52
|
+
* with `net::ERR_NETWORK_CHANGED` and another with `net::ERR_ABORTED`, and
|
|
53
|
+
* leave a page that never hydrates. Its page content region holds the page
|
|
54
|
+
* from the start, or with `landing` fills a few milliseconds after a click
|
|
55
|
+
* (`later`) or stays empty (`never`). A `waitForFunction` whose expression
|
|
56
|
+
* cannot come to hold gives up at once, as Playwright does once its timeout
|
|
57
|
+
* passes.
|
|
58
|
+
*
|
|
59
|
+
* @param {string} url The URL the page reports
|
|
60
|
+
* @param {{ failGoto?: boolean, hydration?: "now" | "later" | "never" | "none", networkChanges?: number, networkChangeOnClick?: boolean, landing?: "later" | "never" }} [options] Whether navigation throws, how the page hydrates, which loads and clicks a network change disturbs, and when a click renders the page it leads to
|
|
61
|
+
* @returns {{ page: object, shots: string[], inputs: { input: string, hydrated: boolean }[], load: () => void, loads: () => number, hydrated: () => boolean, landed: () => boolean, giveUps: () => number }} The page, the paths it was asked to screenshot, the input it received and whether it had hydrated then, a way to load a new document into it, how many documents it loaded, whether its document has hydrated, whether its page content region holds a page, and how many waits ran into their timeout
|
|
62
|
+
*/
|
|
63
|
+
function fakePage(url, options = {}) {
|
|
64
|
+
const hydration = options.hydration ?? "now";
|
|
65
|
+
let giveUps = 0;
|
|
66
|
+
let loads = 0;
|
|
67
|
+
let networkChanges = options.networkChanges ?? 0;
|
|
68
|
+
/** @type {((request: object) => void)[]} */
|
|
69
|
+
let listeners = [];
|
|
70
|
+
const networkChange = () => failRequests(listeners);
|
|
71
|
+
/** @type {string[]} */
|
|
72
|
+
const shots = [];
|
|
73
|
+
/** @type {{ input: string, hydrated: boolean }[]} */
|
|
74
|
+
const inputs = [];
|
|
75
|
+
let readyState = "complete";
|
|
76
|
+
/** @type {{ __vue_app__?: object }[]} */
|
|
77
|
+
let roots = [];
|
|
78
|
+
let pending = 0;
|
|
79
|
+
const region = { childElementCount: options.landing ? 0 : 1 };
|
|
80
|
+
const mounted = () =>
|
|
81
|
+
readyState !== "loading" && roots.every((root) => "__vue_app__" in root);
|
|
82
|
+
const load = () => {
|
|
83
|
+
loads += 1;
|
|
84
|
+
if (hydration === "none") return;
|
|
85
|
+
/** @type {{ __vue_app__?: object }} */
|
|
86
|
+
const root = {};
|
|
87
|
+
if (networkChanges > 0) {
|
|
88
|
+
networkChanges -= 1;
|
|
89
|
+
roots = [root];
|
|
90
|
+
networkChange();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (hydration !== "later") {
|
|
94
|
+
roots = [root];
|
|
95
|
+
if (hydration === "now") root.__vue_app__ = {};
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
readyState = "loading";
|
|
99
|
+
roots = [];
|
|
100
|
+
pending += 1;
|
|
101
|
+
setTimeout(() => {
|
|
102
|
+
readyState = "interactive";
|
|
103
|
+
roots = [root];
|
|
104
|
+
}, 5);
|
|
105
|
+
setTimeout(() => {
|
|
106
|
+
root.__vue_app__ = {};
|
|
107
|
+
pending -= 1;
|
|
108
|
+
}, 25);
|
|
109
|
+
};
|
|
110
|
+
const done = async () => undefined;
|
|
111
|
+
/** @param {string} input The input */
|
|
112
|
+
const receive = (input) => async () => {
|
|
113
|
+
inputs.push({ input, hydrated: mounted() });
|
|
114
|
+
if (input !== "click") return;
|
|
115
|
+
if (options.landing === "later") {
|
|
116
|
+
pending += 1;
|
|
117
|
+
setTimeout(() => {
|
|
118
|
+
region.childElementCount = 1;
|
|
119
|
+
pending -= 1;
|
|
120
|
+
}, 25);
|
|
121
|
+
}
|
|
122
|
+
if (!options.networkChangeOnClick) return;
|
|
123
|
+
roots = [{}];
|
|
124
|
+
networkChange();
|
|
125
|
+
};
|
|
126
|
+
const control = {
|
|
127
|
+
fill: receive("fill"),
|
|
128
|
+
click: receive("click"),
|
|
129
|
+
waitFor: done,
|
|
130
|
+
};
|
|
131
|
+
const page = {
|
|
132
|
+
url: () => url,
|
|
133
|
+
goto: async () => {
|
|
134
|
+
if (options.failGoto) throw new Error("net::ERR_CONNECTION_REFUSED");
|
|
135
|
+
load();
|
|
136
|
+
},
|
|
137
|
+
reload: async () => load(),
|
|
138
|
+
getByRole: () => control,
|
|
139
|
+
on: (
|
|
140
|
+
/** @type {string} */ _event,
|
|
141
|
+
/** @type {(request: object) => void} */ listener,
|
|
142
|
+
) => {
|
|
143
|
+
listeners.push(listener);
|
|
144
|
+
},
|
|
145
|
+
off: (
|
|
146
|
+
/** @type {string} */ _event,
|
|
147
|
+
/** @type {(request: object) => void} */ listener,
|
|
148
|
+
) => {
|
|
149
|
+
listeners = listeners.filter((other) => other !== listener);
|
|
150
|
+
},
|
|
151
|
+
waitForURL: done,
|
|
152
|
+
waitForLoadState: done,
|
|
153
|
+
waitForTimeout: done,
|
|
154
|
+
waitForFunction: async (
|
|
155
|
+
/** @type {string} */ expression,
|
|
156
|
+
/** @type {unknown} */ _arg,
|
|
157
|
+
/** @type {{ polling: number }} */ { polling },
|
|
158
|
+
) => {
|
|
159
|
+
const document = () => ({
|
|
160
|
+
readyState,
|
|
161
|
+
querySelectorAll: (/** @type {string} */ selector) =>
|
|
162
|
+
selector === "[data-server-rendered]" ? roots : [{}, ...roots],
|
|
163
|
+
querySelector: (/** @type {string} */ selector) =>
|
|
164
|
+
selector === "[data-dms-page-content]" ? region : null,
|
|
165
|
+
});
|
|
166
|
+
const globals = () => ({ document: document(), location: new URL(url) });
|
|
167
|
+
if (await cameToHold(expression, polling, globals, () => pending > 0))
|
|
168
|
+
return;
|
|
169
|
+
giveUps += 1;
|
|
170
|
+
throw new Error("page.waitForFunction: Timeout");
|
|
171
|
+
},
|
|
172
|
+
locator: () => ({ ariaSnapshot: async () => "- document" }),
|
|
173
|
+
screenshot: async (/** @type {{ path: string }} */ { path }) => {
|
|
174
|
+
shots.push(path);
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
return {
|
|
178
|
+
page,
|
|
179
|
+
shots,
|
|
180
|
+
inputs,
|
|
181
|
+
load,
|
|
182
|
+
loads: () => loads,
|
|
183
|
+
hydrated: mounted,
|
|
184
|
+
landed: () => region.childElementCount > 0,
|
|
185
|
+
giveUps: () => giveUps,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* @param {import("node:test").TestContext} t The test
|
|
191
|
+
* @returns {JourneyContext} A journey context over a scratch evidence folder, with an `admin` account
|
|
192
|
+
*/
|
|
193
|
+
function journeyContext(t) {
|
|
194
|
+
const dir = mkdtempSync(join(tmpdir(), "dms-control-evidence-test-"));
|
|
195
|
+
t.after(() => rmSync(dir, { recursive: true, force: true }));
|
|
196
|
+
return new JourneyContext(
|
|
197
|
+
{
|
|
198
|
+
evidence: dir,
|
|
199
|
+
webUrl: "http://web",
|
|
200
|
+
accounts: { admin: { email: "a@verify.local", password: "pw" } },
|
|
201
|
+
},
|
|
202
|
+
"feature",
|
|
203
|
+
"journey",
|
|
204
|
+
null,
|
|
205
|
+
null,
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* @param {JourneyContext} context The journey
|
|
211
|
+
* @param {string} shot A screenshot path
|
|
212
|
+
* @returns {string} The step folder the screenshot is in, relative to the evidence
|
|
213
|
+
*/
|
|
214
|
+
function stepOf(context, shot) {
|
|
215
|
+
return relative(context.state.evidence, dirname(shot));
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
await test("a succeeding action writes no screenshot", async (t) => {
|
|
219
|
+
const context = journeyContext(t);
|
|
220
|
+
const { page, shots } = fakePage("http://web/");
|
|
221
|
+
const outcome = await new Tab(context, page, "admin").goto("/");
|
|
222
|
+
assert.equal(outcome.ok, true);
|
|
223
|
+
assert.deepEqual(shots, []);
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
await test("a failing action writes a screenshot into its own step folder", async (t) => {
|
|
227
|
+
const context = journeyContext(t);
|
|
228
|
+
const { page, shots } = fakePage("http://web/", { failGoto: true });
|
|
229
|
+
await assert.rejects(
|
|
230
|
+
new Tab(context, page, "admin").goto("/"),
|
|
231
|
+
/critical step/,
|
|
232
|
+
);
|
|
233
|
+
assert.deepEqual(
|
|
234
|
+
shots.map((shot) => stepOf(context, shot)),
|
|
235
|
+
[context.steps[0].folder],
|
|
236
|
+
);
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
await test("a succeeding action records its ARIA snapshot's time and no screenshot time", async (t) => {
|
|
240
|
+
const context = journeyContext(t);
|
|
241
|
+
const { page } = fakePage("http://web/");
|
|
242
|
+
const outcome = await new Tab(context, page, "admin").goto("/");
|
|
243
|
+
assert.deepEqual(
|
|
244
|
+
readTimings(context.state.evidence).map((entry) => [
|
|
245
|
+
entry.phase,
|
|
246
|
+
entry.step,
|
|
247
|
+
]),
|
|
248
|
+
[["aria", relative(context.state.evidence, outcome.folder)]],
|
|
249
|
+
);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
await test("a failing action's screenshot is timed under screenshot, for its step", async (t) => {
|
|
253
|
+
const context = journeyContext(t);
|
|
254
|
+
const { page } = fakePage("http://web/", { failGoto: true });
|
|
255
|
+
await assert.rejects(
|
|
256
|
+
new Tab(context, page, "admin").goto("/"),
|
|
257
|
+
/critical step/,
|
|
258
|
+
);
|
|
259
|
+
assert.deepEqual(
|
|
260
|
+
readTimings(context.state.evidence)
|
|
261
|
+
.filter((entry) => entry.phase === "screenshot")
|
|
262
|
+
.map((entry) => entry.step),
|
|
263
|
+
[context.steps[0].folder],
|
|
264
|
+
);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
await test("a snapshot step and the screenshot action write one screenshot each", async (t) => {
|
|
268
|
+
const context = journeyContext(t);
|
|
269
|
+
const { page, shots } = fakePage("http://web/");
|
|
270
|
+
const tab = new Tab(context, page, "admin");
|
|
271
|
+
const snapshot = await tab.snapshot("record the page");
|
|
272
|
+
const explicit = await tab.act({ do: "screenshot" }, "look");
|
|
273
|
+
assert.deepEqual(
|
|
274
|
+
shots.map((shot) => stepOf(context, shot)),
|
|
275
|
+
[snapshot, explicit].map((outcome) =>
|
|
276
|
+
relative(context.state.evidence, outcome.folder),
|
|
277
|
+
),
|
|
278
|
+
);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
await test("a verify step writes one screenshot of the tab driven last, whatever the checks say", async (t) => {
|
|
282
|
+
const context = journeyContext(t);
|
|
283
|
+
const first = fakePage("http://web/first");
|
|
284
|
+
const second = fakePage("http://web/second");
|
|
285
|
+
const firstTab = new Tab(context, first.page, "first");
|
|
286
|
+
await firstTab.goto("/first");
|
|
287
|
+
await new Tab(context, second.page, "second").goto("/second");
|
|
288
|
+
await context.verify("passes", [context.holds("true", true, "")]);
|
|
289
|
+
await context.verify("fails", [context.holds("false", false, "")]);
|
|
290
|
+
assert.deepEqual(first.shots, []);
|
|
291
|
+
assert.deepEqual(
|
|
292
|
+
second.shots.map((shot) => stepOf(context, shot)),
|
|
293
|
+
context.steps.slice(2).map((step) => step.folder),
|
|
294
|
+
);
|
|
295
|
+
await firstTab.goto("/again");
|
|
296
|
+
await context.verify("back on the first tab", []);
|
|
297
|
+
assert.equal(first.shots.length, 1);
|
|
298
|
+
assert.equal(second.shots.length, 2);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
await test("a verify step before any tab was driven writes no screenshot and still records", async (t) => {
|
|
302
|
+
const context = journeyContext(t);
|
|
303
|
+
const passed = await context.verify("api only", [
|
|
304
|
+
context.holds("true", true, ""),
|
|
305
|
+
]);
|
|
306
|
+
assert.equal(passed, true);
|
|
307
|
+
assert.equal(context.steps.length, 1);
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
await test("signing in writes no screenshot and makes its tab the one a verify step shows", async (t) => {
|
|
311
|
+
const context = journeyContext(t);
|
|
312
|
+
const other = fakePage("http://web/other");
|
|
313
|
+
await new Tab(context, other.page, "other").goto("/other");
|
|
314
|
+
const admin = fakePage("http://web/home");
|
|
315
|
+
const outcome = await new Tab(context, admin.page, "admin").signIn("admin");
|
|
316
|
+
assert.equal(outcome.ok, true);
|
|
317
|
+
assert.deepEqual(admin.shots, []);
|
|
318
|
+
await context.verify("signed in", [context.holds("true", true, "")]);
|
|
319
|
+
assert.equal(admin.shots.length, 1);
|
|
320
|
+
assert.deepEqual(other.shots, []);
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
await test("input reaches a page only once it has parsed and hydrated, a document that starts loading after the previous action included", async (t) => {
|
|
324
|
+
const context = journeyContext(t);
|
|
325
|
+
const fake = fakePage("http://web/members", { hydration: "later" });
|
|
326
|
+
const tab = new Tab(context, fake.page, "admin");
|
|
327
|
+
await tab.goto("/members");
|
|
328
|
+
assert.equal(
|
|
329
|
+
fake.hydrated(),
|
|
330
|
+
true,
|
|
331
|
+
"a navigation ends once its page has hydrated",
|
|
332
|
+
);
|
|
333
|
+
await tab.click({ role: "button", name: "Invite members" });
|
|
334
|
+
fake.load();
|
|
335
|
+
await tab.fill(
|
|
336
|
+
{ role: "textbox", name: "Email addresses" },
|
|
337
|
+
"a@verify.local",
|
|
338
|
+
);
|
|
339
|
+
assert.deepEqual(fake.inputs, [
|
|
340
|
+
{ input: "click", hydrated: true },
|
|
341
|
+
{ input: "fill", hydrated: true },
|
|
342
|
+
]);
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
await test("a page with no server-rendered root takes input without waiting for a hydration", async (t) => {
|
|
346
|
+
const context = journeyContext(t);
|
|
347
|
+
const fake = fakePage("http://web/api/unknown", { hydration: "none" });
|
|
348
|
+
const tab = new Tab(context, fake.page, "admin");
|
|
349
|
+
await tab.goto("/api/unknown");
|
|
350
|
+
await tab.click({ role: "button", name: "Retry" });
|
|
351
|
+
assert.equal(fake.inputs.length, 1);
|
|
352
|
+
assert.equal(fake.giveUps(), 0);
|
|
353
|
+
});
|
|
354
|
+
|
|
355
|
+
await test("a page that never hydrates still gets the action, which succeeds or fails on its own", async (t) => {
|
|
356
|
+
const context = journeyContext(t);
|
|
357
|
+
const fake = fakePage("http://web/members", { hydration: "never" });
|
|
358
|
+
const tab = new Tab(context, fake.page, "admin");
|
|
359
|
+
await tab.goto("/members");
|
|
360
|
+
const outcome = await tab.click({ role: "button", name: "Invite members" });
|
|
361
|
+
assert.equal(outcome.ok, true);
|
|
362
|
+
assert.deepEqual(fake.inputs, [{ input: "click", hydrated: false }]);
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
await test("a goto or reload starts at once from a page that never hydrates, and waits only for the page it loads", async (t) => {
|
|
366
|
+
const context = journeyContext(t);
|
|
367
|
+
const fake = fakePage("http://web/members", { hydration: "never" });
|
|
368
|
+
const tab = new Tab(context, fake.page, "admin");
|
|
369
|
+
await tab.goto("/members");
|
|
370
|
+
const before = fake.giveUps();
|
|
371
|
+
await tab.goto("/other");
|
|
372
|
+
await tab.reload();
|
|
373
|
+
assert.equal(fake.loads(), 3);
|
|
374
|
+
assert.equal(fake.giveUps() - before, 2, "one wait per page loaded");
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
await test("signing in returns once the page it lands on has rendered its content", async (t) => {
|
|
378
|
+
const context = journeyContext(t);
|
|
379
|
+
const fake = fakePage("http://web/home", { landing: "later" });
|
|
380
|
+
const outcome = await new Tab(context, fake.page, "admin").signIn("admin");
|
|
381
|
+
assert.equal(outcome.ok, true);
|
|
382
|
+
assert.equal(fake.landed(), true);
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
await test("a landing page that never renders its content leaves the sign-in to succeed after one wait", async (t) => {
|
|
386
|
+
const context = journeyContext(t);
|
|
387
|
+
const fake = fakePage("http://web/home", { landing: "never" });
|
|
388
|
+
const outcome = await new Tab(context, fake.page, "admin").signIn("admin");
|
|
389
|
+
assert.equal(outcome.ok, true);
|
|
390
|
+
assert.equal(fake.giveUps(), 1);
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
await test("a sign-in that stays on /auth writes a screenshot into its last step folder", async (t) => {
|
|
394
|
+
const context = journeyContext(t);
|
|
395
|
+
const fake = fakePage("http://web/auth");
|
|
396
|
+
await assert.rejects(
|
|
397
|
+
new Tab(context, fake.page, "admin").signIn("admin"),
|
|
398
|
+
/critical step .*signed-in-as-admin failed/,
|
|
399
|
+
);
|
|
400
|
+
assert.equal(fake.shots.length, 1);
|
|
401
|
+
assert.match(
|
|
402
|
+
stepOf(context, fake.shots[0]),
|
|
403
|
+
/\/\d+-admin-sign-in-click-login$/,
|
|
404
|
+
);
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
await test("a page load that a network change left unhydrated is loaded once more", async (t) => {
|
|
408
|
+
const context = journeyContext(t);
|
|
409
|
+
const fake = fakePage("http://web/members", { networkChanges: 1 });
|
|
410
|
+
const tab = new Tab(context, fake.page, "admin");
|
|
411
|
+
await tab.goto("/members");
|
|
412
|
+
await tab.click({ role: "button", name: "Invite members" });
|
|
413
|
+
assert.equal(fake.loads(), 2);
|
|
414
|
+
assert.deepEqual(fake.inputs, [{ input: "click", hydrated: true }]);
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
await test("a page loaded again after a network change notes what was seen: the page not hydrated and the requests that failed with it", async (t) => {
|
|
418
|
+
const context = journeyContext(t);
|
|
419
|
+
const fake = fakePage("http://web/members", { networkChanges: 1 });
|
|
420
|
+
const outcome = await new Tab(context, fake.page, "admin").goto("/members");
|
|
421
|
+
const note = evidenceText(outcome.folder, "network-changed.txt");
|
|
422
|
+
assert.match(note, /not hydrated/);
|
|
423
|
+
assert.match(note, /net::ERR_NETWORK_CHANGED/);
|
|
424
|
+
assert.match(note, /^http:\/\/web\/assets\/changed\.js$/m);
|
|
425
|
+
assert.doesNotMatch(note, /aborted\.js/);
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
await test("a page load that network changes keep breaking is loaded twice at most, then left to its action", async (t) => {
|
|
429
|
+
const context = journeyContext(t);
|
|
430
|
+
const fake = fakePage("http://web/members", { networkChanges: 3 });
|
|
431
|
+
const outcome = await new Tab(context, fake.page, "admin").goto("/members");
|
|
432
|
+
assert.equal(outcome.ok, true);
|
|
433
|
+
assert.equal(fake.loads(), 2);
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
await test("a click is never repeated, whatever a network change did meanwhile", async (t) => {
|
|
437
|
+
const context = journeyContext(t);
|
|
438
|
+
const fake = fakePage("http://web/members", { networkChangeOnClick: true });
|
|
439
|
+
const tab = new Tab(context, fake.page, "admin");
|
|
440
|
+
await tab.goto("/members");
|
|
441
|
+
fake.load();
|
|
442
|
+
await tab.click({ role: "button", name: "Send invitations" });
|
|
443
|
+
assert.equal(fake.inputs.length, 1);
|
|
444
|
+
});
|