@kurvball/rehearse 0.0.0-stage → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +107 -2
- package/dist/affected/affected.d.ts +22 -0
- package/dist/affected/affected.js +162 -0
- package/dist/affected/index.d.ts +1 -0
- package/dist/affected/index.js +1 -0
- package/dist/args.d.ts +12 -0
- package/dist/args.js +42 -0
- package/dist/cli.d.ts +4 -0
- package/dist/cli.js +100 -0
- package/dist/commands/check.d.ts +2 -0
- package/dist/commands/check.js +42 -0
- package/dist/commands/clean.d.ts +2 -0
- package/dist/commands/clean.js +37 -0
- package/dist/commands/command.d.ts +30 -0
- package/dist/commands/command.js +38 -0
- package/dist/commands/compare.d.ts +4 -0
- package/dist/commands/compare.js +89 -0
- package/dist/commands/drive.d.ts +2 -0
- package/dist/commands/drive.js +244 -0
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.js +32 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.js +19 -0
- package/dist/commands/list.d.ts +2 -0
- package/dist/commands/list.js +69 -0
- package/dist/commands/open.d.ts +2 -0
- package/dist/commands/open.js +60 -0
- package/dist/commands/people.d.ts +2 -0
- package/dist/commands/people.js +49 -0
- package/dist/commands/run.d.ts +4 -0
- package/dist/commands/run.js +84 -0
- package/dist/commands/services.d.ts +28 -0
- package/dist/commands/services.js +51 -0
- package/dist/commands/stage.d.ts +7 -0
- package/dist/commands/stage.js +53 -0
- package/dist/commands/up.d.ts +3 -0
- package/dist/commands/up.js +77 -0
- package/dist/commands/validate.d.ts +2 -0
- package/dist/commands/validate.js +35 -0
- package/dist/commands/worlds.d.ts +2 -0
- package/dist/commands/worlds.js +15 -0
- package/dist/compare/announce.d.ts +6 -0
- package/dist/compare/announce.js +27 -0
- package/dist/compare/compare.d.ts +83 -0
- package/dist/compare/compare.js +335 -0
- package/dist/compare/diff.d.ts +15 -0
- package/dist/compare/diff.js +105 -0
- package/dist/compare/index.d.ts +5 -0
- package/dist/compare/index.js +5 -0
- package/dist/compare/setaside.d.ts +29 -0
- package/dist/compare/setaside.js +121 -0
- package/dist/compare/verdict.d.ts +21 -0
- package/dist/compare/verdict.js +30 -0
- package/dist/drive/aria.d.ts +8 -0
- package/dist/drive/aria.js +12 -0
- package/dist/drive/browser.d.ts +34 -0
- package/dist/drive/browser.js +216 -0
- package/dist/drive/daemon.d.ts +1 -0
- package/dist/drive/daemon.js +171 -0
- package/dist/drive/grammar.d.ts +93 -0
- package/dist/drive/grammar.js +303 -0
- package/dist/drive/index.d.ts +4 -0
- package/dist/drive/index.js +4 -0
- package/dist/drive/names.d.ts +24 -0
- package/dist/drive/names.js +97 -0
- package/dist/drive/state.d.ts +13 -0
- package/dist/drive/state.js +28 -0
- package/dist/errors.d.ts +26 -0
- package/dist/errors.js +32 -0
- package/dist/exec.d.ts +16 -0
- package/dist/exec.js +43 -0
- package/dist/git/checkout.d.ts +11 -0
- package/dist/git/checkout.js +90 -0
- package/dist/git/git.d.ts +7 -0
- package/dist/git/git.js +27 -0
- package/dist/git/index.d.ts +2 -0
- package/dist/git/index.js +2 -0
- package/dist/git/seed.d.ts +3 -0
- package/dist/git/seed.js +115 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +15 -0
- package/dist/kinds/all.d.ts +4 -0
- package/dist/kinds/all.js +4 -0
- package/dist/kinds/call/check.d.ts +29 -0
- package/dist/kinds/call/check.js +187 -0
- package/dist/kinds/call/definition.d.ts +16 -0
- package/dist/kinds/call/definition.js +33 -0
- package/dist/kinds/call/hurl.d.ts +65 -0
- package/dist/kinds/call/hurl.js +333 -0
- package/dist/kinds/call/kind.d.ts +8 -0
- package/dist/kinds/call/kind.js +122 -0
- package/dist/kinds/call/send.d.ts +32 -0
- package/dist/kinds/call/send.js +152 -0
- package/dist/kinds/call/words.d.ts +22 -0
- package/dist/kinds/call/words.js +24 -0
- package/dist/kinds/file/kind.d.ts +44 -0
- package/dist/kinds/file/kind.js +331 -0
- package/dist/kinds/file/layouts.d.ts +14 -0
- package/dist/kinds/file/layouts.js +103 -0
- package/dist/kinds/flow/kind.d.ts +21 -0
- package/dist/kinds/flow/kind.js +412 -0
- package/dist/kinds/flow/literal.d.ts +8 -0
- package/dist/kinds/flow/literal.js +148 -0
- package/dist/kinds/index.d.ts +10 -0
- package/dist/kinds/index.js +8 -0
- package/dist/kinds/kind.d.ts +63 -0
- package/dist/kinds/kind.js +21 -0
- package/dist/kinds/piece/canvas.d.ts +18 -0
- package/dist/kinds/piece/canvas.js +165 -0
- package/dist/kinds/piece/conventions.d.ts +12 -0
- package/dist/kinds/piece/conventions.js +101 -0
- package/dist/kinds/piece/csf.d.ts +10 -0
- package/dist/kinds/piece/csf.js +304 -0
- package/dist/kinds/piece/kind.d.ts +12 -0
- package/dist/kinds/piece/kind.js +297 -0
- package/dist/kinds/piece/server.d.ts +23 -0
- package/dist/kinds/piece/server.js +236 -0
- package/dist/manifest/fill.d.ts +4 -0
- package/dist/manifest/fill.js +7 -0
- package/dist/manifest/index.d.ts +5 -0
- package/dist/manifest/index.js +5 -0
- package/dist/manifest/init.d.ts +1 -0
- package/dist/manifest/init.js +47 -0
- package/dist/manifest/load.d.ts +7 -0
- package/dist/manifest/load.js +245 -0
- package/dist/manifest/types.d.ts +255 -0
- package/dist/manifest/types.js +7 -0
- package/dist/manifest/yaml.d.ts +5 -0
- package/dist/manifest/yaml.js +47 -0
- package/dist/people/index.d.ts +1 -0
- package/dist/people/index.js +1 -0
- package/dist/people/people.d.ts +39 -0
- package/dist/people/people.js +139 -0
- package/dist/run/cache.d.ts +20 -0
- package/dist/run/cache.js +98 -0
- package/dist/run/index.d.ts +5 -0
- package/dist/run/index.js +4 -0
- package/dist/run/observation.d.ts +27 -0
- package/dist/run/observation.js +1 -0
- package/dist/run/parallel.d.ts +28 -0
- package/dist/run/parallel.js +140 -0
- package/dist/run/session.d.ts +35 -0
- package/dist/run/session.js +399 -0
- package/dist/run/vars.d.ts +3 -0
- package/dist/run/vars.js +13 -0
- package/dist/scenarios/area.d.ts +6 -0
- package/dist/scenarios/area.js +37 -0
- package/dist/scenarios/files.d.ts +9 -0
- package/dist/scenarios/files.js +26 -0
- package/dist/scenarios/glob.d.ts +6 -0
- package/dist/scenarios/glob.js +106 -0
- package/dist/scenarios/index.d.ts +4 -0
- package/dist/scenarios/index.js +4 -0
- package/dist/scenarios/read.d.ts +18 -0
- package/dist/scenarios/read.js +54 -0
- package/dist/scenarios/scenario.d.ts +34 -0
- package/dist/scenarios/scenario.js +10 -0
- package/dist/schema.d.ts +14 -0
- package/dist/schema.js +122 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +2 -0
- package/dist/services/registry.d.ts +23 -0
- package/dist/services/registry.js +49 -0
- package/dist/services/service.d.ts +23 -0
- package/dist/services/service.js +313 -0
- package/dist/stage/api.d.ts +30 -0
- package/dist/stage/api.js +206 -0
- package/dist/stage/client/client/api.js +11 -0
- package/dist/stage/client/client/index.js +1 -0
- package/dist/stage/client/features/canvas/call.js +65 -0
- package/dist/stage/client/features/canvas/context.js +1 -0
- package/dist/stage/client/features/canvas/file.js +36 -0
- package/dist/stage/client/features/canvas/flow.js +59 -0
- package/dist/stage/client/features/canvas/index.js +1 -0
- package/dist/stage/client/features/canvas/observed.js +8 -0
- package/dist/stage/client/features/canvas/parts.js +24 -0
- package/dist/stage/client/features/canvas/piece.js +31 -0
- package/dist/stage/client/features/canvas/reach.js +6 -0
- package/dist/stage/client/features/canvas/views.js +16 -0
- package/dist/stage/client/features/list/index.js +1 -0
- package/dist/stage/client/features/list/list.js +53 -0
- package/dist/stage/client/features/list/reach.js +10 -0
- package/dist/stage/client/features/scenario/heading.js +14 -0
- package/dist/stage/client/features/scenario/index.js +1 -0
- package/dist/stage/client/features/scenario/reach.js +9 -0
- package/dist/stage/client/features/scenario/scenario.js +145 -0
- package/dist/stage/client/features/try/index.js +1 -0
- package/dist/stage/client/features/try/reach.js +12 -0
- package/dist/stage/client/features/try/try.js +65 -0
- package/dist/stage/client/index.html +16 -0
- package/dist/stage/client/main.js +24 -0
- package/dist/stage/client/primitives/busy.js +6 -0
- package/dist/stage/client/primitives/focus.js +21 -0
- package/dist/stage/client/primitives/h.js +25 -0
- package/dist/stage/client/primitives/index.js +6 -0
- package/dist/stage/client/primitives/keyed.js +16 -0
- package/dist/stage/client/primitives/say.js +6 -0
- package/dist/stage/client/primitives/state.js +21 -0
- package/dist/stage/client/primitives/types.js +1 -0
- package/dist/stage/client/primitives/verdicts.js +8 -0
- package/dist/stage/client/stage.css +652 -0
- package/dist/stage/compared.d.ts +20 -0
- package/dist/stage/compared.js +58 -0
- package/dist/stage/files.d.ts +4 -0
- package/dist/stage/files.js +59 -0
- package/dist/stage/guard.d.ts +3 -0
- package/dist/stage/guard.js +20 -0
- package/dist/stage/http.d.ts +12 -0
- package/dist/stage/http.js +34 -0
- package/dist/stage/index.d.ts +1 -0
- package/dist/stage/index.js +1 -0
- package/dist/stage/sending.d.ts +18 -0
- package/dist/stage/sending.js +66 -0
- package/dist/stage/server.d.ts +33 -0
- package/dist/stage/server.js +253 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +5 -0
- package/dist/worlds/define.d.ts +16 -0
- package/dist/worlds/define.js +45 -0
- package/dist/worlds/index.d.ts +2 -0
- package/dist/worlds/index.js +2 -0
- package/dist/worlds/worlds.d.ts +15 -0
- package/dist/worlds/worlds.js +46 -0
- package/llms.txt +46 -0
- package/package.json +84 -3
- package/schema/v1/announce.schema.json +28 -0
- package/schema/v1/check.schema.json +67 -0
- package/schema/v1/clean.schema.json +19 -0
- package/schema/v1/common.schema.json +210 -0
- package/schema/v1/comparison.schema.json +298 -0
- package/schema/v1/dependents.schema.json +30 -0
- package/schema/v1/drive.schema.json +112 -0
- package/schema/v1/error.schema.json +26 -0
- package/schema/v1/file-scenario.schema.json +175 -0
- package/schema/v1/flow.schema.json +216 -0
- package/schema/v1/init.schema.json +20 -0
- package/schema/v1/list.schema.json +70 -0
- package/schema/v1/manifest.schema.json +434 -0
- package/schema/v1/observation.schema.json +388 -0
- package/schema/v1/open.schema.json +14 -0
- package/schema/v1/people.schema.json +88 -0
- package/schema/v1/samples/announce.yaml +5 -0
- package/schema/v1/samples/check.json +13 -0
- package/schema/v1/samples/clean.json +1 -0
- package/schema/v1/samples/comparison.json +83 -0
- package/schema/v1/samples/dependents.json +7 -0
- package/schema/v1/samples/drive.json +10 -0
- package/schema/v1/samples/error.json +10 -0
- package/schema/v1/samples/file-scenario.yaml +13 -0
- package/schema/v1/samples/flow.yaml +13 -0
- package/schema/v1/samples/init.json +1 -0
- package/schema/v1/samples/list.json +24 -0
- package/schema/v1/samples/manifest.yaml +55 -0
- package/schema/v1/samples/observation.json +49 -0
- package/schema/v1/samples/open.json +6 -0
- package/schema/v1/samples/people.json +11 -0
- package/schema/v1/samples/services.json +27 -0
- package/schema/v1/samples/stage.json +6 -0
- package/schema/v1/samples/try.json +13 -0
- package/schema/v1/samples/up.json +16 -0
- package/schema/v1/samples/validate.json +7 -0
- package/schema/v1/samples/worlds.json +21 -0
- package/schema/v1/services.schema.json +72 -0
- package/schema/v1/stage.schema.json +14 -0
- package/schema/v1/try.schema.json +56 -0
- package/schema/v1/up.schema.json +55 -0
- package/schema/v1/validate.schema.json +40 -0
- package/schema/v1/worlds.schema.json +33 -0
- package/skill/rehearse/SKILL.md +148 -0
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { jsonDifferences, noCounts, setAsideText, textDifferences, } from '../../compare/index.js';
|
|
4
|
+
import { act, calm, contextFor, driveArgv, errorsOf, FIXED_TIME, launch, signInBySteps, signInOf, stepCommand, stepOf, stepWords, } from '../../drive/index.js';
|
|
5
|
+
import { errorText } from '../../errors.js';
|
|
6
|
+
import { sh, tail } from '../../exec.js';
|
|
7
|
+
import { fill, fillEnv, hashOf, readYaml } from '../../manifest/index.js';
|
|
8
|
+
import { scrub, scrubDeep } from '../../people/index.js';
|
|
9
|
+
import { readScenarios, registerReader } from '../../scenarios/index.js';
|
|
10
|
+
import { validate } from '../../schema.js';
|
|
11
|
+
import { broken, registerRunner } from '../kind.js';
|
|
12
|
+
import { startPieceServer } from '../piece/server.js';
|
|
13
|
+
import { restart, restartable } from '../../services/index.js';
|
|
14
|
+
import { applyWorld } from '../../worlds/index.js';
|
|
15
|
+
import { defaultExportOf, LiteralError } from './literal.js';
|
|
16
|
+
const refuse = (says, line) => {
|
|
17
|
+
throw Object.assign(new Error(says), { says, ...(line !== undefined && { line }) });
|
|
18
|
+
};
|
|
19
|
+
function specOf(text, file) {
|
|
20
|
+
if (/\.ya?ml$/.test(file)) {
|
|
21
|
+
const read = readYaml(text, file);
|
|
22
|
+
const invalid = validate('flow', read.value);
|
|
23
|
+
if (invalid.length)
|
|
24
|
+
refuse(invalid[0].says, read.lineOf(invalid[0].at, invalid[0].key));
|
|
25
|
+
return read.value;
|
|
26
|
+
}
|
|
27
|
+
let raw;
|
|
28
|
+
try {
|
|
29
|
+
raw = defaultExportOf(text);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
refuse(`Rehearse reads a flow module’s default export as plain data, and couldn’t: ${error instanceof LiteralError ? error.message : errorText(error)}.`);
|
|
33
|
+
}
|
|
34
|
+
const s = raw && typeof raw === 'object' && !Array.isArray(raw) ? raw : null;
|
|
35
|
+
if (!s || typeof s.name !== 'string' || !s.name.trim())
|
|
36
|
+
return refuse('A flow module’s default export needs a name.');
|
|
37
|
+
if (!Array.isArray(s.steps) || s.steps.length === 0)
|
|
38
|
+
return refuse('A flow module’s default export needs its steps.');
|
|
39
|
+
let steps;
|
|
40
|
+
try {
|
|
41
|
+
steps = s.steps.map((x, i) => stepOf(x, i + 1));
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
return refuse(errorText(error));
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
name: s.name.trim(),
|
|
48
|
+
steps,
|
|
49
|
+
...(typeof s.service === 'string' && { service: s.service }),
|
|
50
|
+
...(typeof s.piece === 'string' && { piece: s.piece }),
|
|
51
|
+
...(typeof s.start === 'string' && { start: s.start }),
|
|
52
|
+
...(typeof s.world === 'string' && { world: s.world }),
|
|
53
|
+
...(typeof s.person === 'string' && { person: s.person }),
|
|
54
|
+
...(Array.isArray(s.covers) &&
|
|
55
|
+
s.covers.every((c) => typeof c === 'string') && { covers: s.covers }),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
registerReader({
|
|
59
|
+
kind: 'flow',
|
|
60
|
+
read(f, text, ctx) {
|
|
61
|
+
const spec = specOf(text, f.file);
|
|
62
|
+
const m = ctx.manifest;
|
|
63
|
+
const service = spec.piece ? null : (spec.service ?? m.scenarios.flows.service ?? m.defaults.service);
|
|
64
|
+
return [
|
|
65
|
+
{
|
|
66
|
+
id: f.file,
|
|
67
|
+
kind: 'flow',
|
|
68
|
+
name: spec.name,
|
|
69
|
+
file: f.file,
|
|
70
|
+
abs: f.abs,
|
|
71
|
+
line: null,
|
|
72
|
+
from: f.from,
|
|
73
|
+
area: ctx.area,
|
|
74
|
+
definition: hashOf({
|
|
75
|
+
service,
|
|
76
|
+
piece: spec.piece ?? null,
|
|
77
|
+
start: spec.start ?? null,
|
|
78
|
+
world: spec.world ?? null,
|
|
79
|
+
person: spec.person ?? null,
|
|
80
|
+
steps: spec.steps,
|
|
81
|
+
}),
|
|
82
|
+
world: spec.world ?? m.defaults.world,
|
|
83
|
+
person: spec.person ?? m.defaults.person,
|
|
84
|
+
service,
|
|
85
|
+
covers: [...f.covers, ...(spec.covers ?? [])],
|
|
86
|
+
spec,
|
|
87
|
+
},
|
|
88
|
+
];
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
const quote = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
|
|
92
|
+
const idOf = (id) => createHash('sha256').update(id).digest('hex').slice(0, 12);
|
|
93
|
+
async function throughDriver(s, ctx) {
|
|
94
|
+
const spec = s.spec;
|
|
95
|
+
const m = ctx.manifest;
|
|
96
|
+
const svc = m.services[s.service];
|
|
97
|
+
const running = ctx.running.find((r) => r.name === svc.name);
|
|
98
|
+
const cwd = svc.cwd ? path.resolve(ctx.checkout, svc.cwd) : ctx.checkout;
|
|
99
|
+
const env = running.env ?? {
|
|
100
|
+
...fillEnv(svc.env, ctx.variables),
|
|
101
|
+
...(svc.isolate && running.scratch && { [svc.isolate.env]: running.scratch }),
|
|
102
|
+
};
|
|
103
|
+
const drive = async (argv) => {
|
|
104
|
+
const ran = await sh(`${svc.drive} ${argv.map(quote).join(' ')} --json`, { cwd, env, timeoutMs: 60_000 });
|
|
105
|
+
try {
|
|
106
|
+
return {
|
|
107
|
+
v: 1,
|
|
108
|
+
driver: 'service',
|
|
109
|
+
...JSON.parse(ran.stdout.trim().split('\n').at(-1) ?? ''),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return {
|
|
114
|
+
v: 1,
|
|
115
|
+
ok: false,
|
|
116
|
+
command: null,
|
|
117
|
+
ms: ran.ms,
|
|
118
|
+
failure: 'crashed',
|
|
119
|
+
says: `\`${svc.drive}\` answered with no JSON: ${tail(ran.stderr || ran.stdout) || `exit ${ran.code}`}`,
|
|
120
|
+
driver: 'service',
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const steps = [];
|
|
125
|
+
const opened = await drive(['snapshot']);
|
|
126
|
+
steps.push({
|
|
127
|
+
n: 1,
|
|
128
|
+
step: { open: spec.start ?? '/' },
|
|
129
|
+
ok: opened.ok,
|
|
130
|
+
says: opened.ok ? null : opened.says,
|
|
131
|
+
tree: opened.ok ? opened.tree : null,
|
|
132
|
+
screenshot: null,
|
|
133
|
+
});
|
|
134
|
+
let ok = opened.ok;
|
|
135
|
+
for (const [i, step] of spec.steps.entries()) {
|
|
136
|
+
if (!ok)
|
|
137
|
+
break;
|
|
138
|
+
const n = i + 2;
|
|
139
|
+
const command = stepCommand(step);
|
|
140
|
+
if (command.command === 'fill') {
|
|
141
|
+
steps.push({
|
|
142
|
+
n,
|
|
143
|
+
step,
|
|
144
|
+
ok: false,
|
|
145
|
+
says: `${svc.name}'s driver takes no fill step: type into the field instead.`,
|
|
146
|
+
tree: null,
|
|
147
|
+
screenshot: null,
|
|
148
|
+
});
|
|
149
|
+
ok = false;
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
const did = await drive(driveArgv(command));
|
|
153
|
+
let tree = did.ok ? did.tree : null;
|
|
154
|
+
if (did.ok && command.command !== 'snapshot') {
|
|
155
|
+
const after = await drive(['snapshot']);
|
|
156
|
+
tree = after.ok ? after.tree : null;
|
|
157
|
+
}
|
|
158
|
+
steps.push({ n, step, ok: did.ok, says: did.ok ? null : did.says, tree, screenshot: null });
|
|
159
|
+
ok = did.ok;
|
|
160
|
+
}
|
|
161
|
+
const failedAt = steps.find((x) => !x.ok);
|
|
162
|
+
const person = ctx.as ?? s.person;
|
|
163
|
+
return scrubDeep({
|
|
164
|
+
ok,
|
|
165
|
+
failures: failedAt
|
|
166
|
+
? [
|
|
167
|
+
{
|
|
168
|
+
step: failedAt.n,
|
|
169
|
+
text: 'open' in failedAt.step ? 'open' : stepWords(failedAt.step),
|
|
170
|
+
expected: 'it does',
|
|
171
|
+
got: failedAt.says,
|
|
172
|
+
},
|
|
173
|
+
]
|
|
174
|
+
: [],
|
|
175
|
+
observed: {
|
|
176
|
+
kind: 'flow',
|
|
177
|
+
driver: 'service',
|
|
178
|
+
said: person ? `${svc.name}'s driver signs in as no one, so the flow ran without ${person}.` : null,
|
|
179
|
+
steps: steps.map(({ screenshot: _s, ...rest }) => rest),
|
|
180
|
+
},
|
|
181
|
+
artifacts: [],
|
|
182
|
+
broke: null,
|
|
183
|
+
}, ctx.tokens);
|
|
184
|
+
}
|
|
185
|
+
async function throughBrowser(s, ctx, browser, url) {
|
|
186
|
+
const spec = s.spec;
|
|
187
|
+
const person = ctx.as ?? s.person;
|
|
188
|
+
const signIn = signInOf(ctx.manifest, person, ctx.tokens);
|
|
189
|
+
const context = await contextFor(browser, url, signIn);
|
|
190
|
+
const page = await context.newPage();
|
|
191
|
+
await page.clock.setFixedTime(FIXED_TIME);
|
|
192
|
+
const errors = errorsOf(page);
|
|
193
|
+
const steps = [];
|
|
194
|
+
const shots = new Map();
|
|
195
|
+
const shot = (n) => path.join(ctx.keep, `flow-${idOf(s.id)}-${n}.png`);
|
|
196
|
+
try {
|
|
197
|
+
if (signIn?.steps.length && !spec.piece) {
|
|
198
|
+
const stopped = await signInBySteps(page, new URL(url).origin, signIn.steps);
|
|
199
|
+
if (stopped)
|
|
200
|
+
return broken('signIn', scrub(stopped, ctx.tokens));
|
|
201
|
+
}
|
|
202
|
+
let ok = true;
|
|
203
|
+
try {
|
|
204
|
+
await page.goto(url, { waitUntil: 'load', timeout: 30_000 });
|
|
205
|
+
const tree = await calm(page);
|
|
206
|
+
await page.screenshot({ path: shot(1) });
|
|
207
|
+
shots.set(1, shot(1));
|
|
208
|
+
steps.push({
|
|
209
|
+
n: 1,
|
|
210
|
+
step: { open: spec.start ?? (spec.piece ? `piece ${spec.piece}` : '/') },
|
|
211
|
+
ok: true,
|
|
212
|
+
says: null,
|
|
213
|
+
tree,
|
|
214
|
+
screenshot: null,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
catch (error) {
|
|
218
|
+
steps.push({
|
|
219
|
+
n: 1,
|
|
220
|
+
step: { open: spec.start ?? '/' },
|
|
221
|
+
ok: false,
|
|
222
|
+
says: `It didn't open: ${errorText(error)}`,
|
|
223
|
+
tree: null,
|
|
224
|
+
screenshot: null,
|
|
225
|
+
});
|
|
226
|
+
ok = false;
|
|
227
|
+
}
|
|
228
|
+
for (const [i, step] of spec.steps.entries()) {
|
|
229
|
+
if (!ok)
|
|
230
|
+
break;
|
|
231
|
+
const n = i + 2;
|
|
232
|
+
const filled = step.with === undefined
|
|
233
|
+
? step
|
|
234
|
+
: { ...step, with: fill(step.with, { token: person ? (ctx.tokens[person] ?? '') : '' }) };
|
|
235
|
+
const did = await act(page, stepCommand(filled));
|
|
236
|
+
const tree = did.ok ? (did.tree ?? (await calm(page))) : null;
|
|
237
|
+
if (did.ok) {
|
|
238
|
+
await page.screenshot({ path: shot(n) });
|
|
239
|
+
shots.set(n, shot(n));
|
|
240
|
+
}
|
|
241
|
+
steps.push({ n, step, ok: did.ok, says: did.ok ? null : did.says, tree, screenshot: null });
|
|
242
|
+
ok = did.ok;
|
|
243
|
+
}
|
|
244
|
+
const failedAt = steps.find((x) => !x.ok);
|
|
245
|
+
return scrubDeep({
|
|
246
|
+
ok,
|
|
247
|
+
failures: failedAt
|
|
248
|
+
? [
|
|
249
|
+
{
|
|
250
|
+
step: failedAt.n,
|
|
251
|
+
text: 'open' in failedAt.step ? 'open' : stepWords(failedAt.step),
|
|
252
|
+
expected: 'it does',
|
|
253
|
+
got: failedAt.says,
|
|
254
|
+
},
|
|
255
|
+
]
|
|
256
|
+
: [],
|
|
257
|
+
observed: {
|
|
258
|
+
kind: 'flow',
|
|
259
|
+
driver: 'browser',
|
|
260
|
+
said: person && !signIn
|
|
261
|
+
? `${person} has no browser sign-in in the manifest, so the flow ran signed in as no one.`
|
|
262
|
+
: null,
|
|
263
|
+
steps: steps.map(({ screenshot: _s, ...rest }) => rest),
|
|
264
|
+
errors,
|
|
265
|
+
},
|
|
266
|
+
artifacts: [...shots].map(([n, file]) => ({ kind: 'screenshot', path: file, label: `step ${n}` })),
|
|
267
|
+
broke: null,
|
|
268
|
+
}, ctx.tokens);
|
|
269
|
+
}
|
|
270
|
+
finally {
|
|
271
|
+
await context.close();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
async function upAgainWhereTheWorldStarts(ctx, running) {
|
|
275
|
+
const vars = { ...ctx.variables, ...(ctx.world && { world: ctx.world }) };
|
|
276
|
+
try {
|
|
277
|
+
const why = await restart(ctx.manifest, running, async () => {
|
|
278
|
+
if (ctx.world)
|
|
279
|
+
await applyWorld(ctx.manifest, ctx.world, 'before', ctx.checkout, vars);
|
|
280
|
+
});
|
|
281
|
+
if (why)
|
|
282
|
+
return { stopped: broken('driver', why) };
|
|
283
|
+
if (ctx.world)
|
|
284
|
+
await applyWorld(ctx.manifest, ctx.world, 'add', ctx.checkout, vars);
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
return { stopped: broken('world', errorText(error)) };
|
|
288
|
+
}
|
|
289
|
+
try {
|
|
290
|
+
return { signedInAgain: { ...ctx, ...(await ctx.signInAgain()) } };
|
|
291
|
+
}
|
|
292
|
+
catch (error) {
|
|
293
|
+
return { stopped: broken('signIn', scrub(errorText(error), ctx.tokens)) };
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
const cantBeBroughtUpAfresh = (service, afterAnotherFlow) => `${service} can't be brought up afresh (it needs a down command, and an up that hands over to a daemon), so this flow started ${afterAnotherFlow ? 'where the last one left the app' : 'with the app as it found it'}.`;
|
|
297
|
+
registerRunner({
|
|
298
|
+
kind: 'flow',
|
|
299
|
+
version: 'flow/3',
|
|
300
|
+
services: (s) => (s.service ? [s.service] : []),
|
|
301
|
+
async run(scenarios, asGiven) {
|
|
302
|
+
let ctx = asGiven;
|
|
303
|
+
const out = new Map();
|
|
304
|
+
let browser = null;
|
|
305
|
+
const pieces = new Map();
|
|
306
|
+
const driven = new Set();
|
|
307
|
+
try {
|
|
308
|
+
for (const s of scenarios) {
|
|
309
|
+
const spec = s.spec;
|
|
310
|
+
const svc = s.service ? ctx.manifest.services[s.service] : undefined;
|
|
311
|
+
if (svc?.drive) {
|
|
312
|
+
const running = ctx.running.find((r) => r.name === svc.name);
|
|
313
|
+
const afterAnotherFlow = driven.has(svc.name);
|
|
314
|
+
const freshAlready = !afterAnotherFlow && ctx.broughtUpAndUnused.has(svc.name);
|
|
315
|
+
let shared = null;
|
|
316
|
+
if (running && !freshAlready) {
|
|
317
|
+
if (!restartable(running))
|
|
318
|
+
shared = cantBeBroughtUpAfresh(svc.name, afterAnotherFlow);
|
|
319
|
+
else {
|
|
320
|
+
const again = await upAgainWhereTheWorldStarts(ctx, running);
|
|
321
|
+
if ('stopped' in again) {
|
|
322
|
+
out.set(s.id, again.stopped);
|
|
323
|
+
continue;
|
|
324
|
+
}
|
|
325
|
+
ctx = again.signedInAgain;
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
driven.add(svc.name);
|
|
329
|
+
const ran = await throughDriver(s, ctx);
|
|
330
|
+
if (shared && ran.observed)
|
|
331
|
+
ran.observed.said = [ran.observed.said, shared]
|
|
332
|
+
.filter((x) => typeof x === 'string' && x)
|
|
333
|
+
.join(' ');
|
|
334
|
+
out.set(s.id, ran);
|
|
335
|
+
continue;
|
|
336
|
+
}
|
|
337
|
+
try {
|
|
338
|
+
browser ??= await launch();
|
|
339
|
+
}
|
|
340
|
+
catch (error) {
|
|
341
|
+
out.set(s.id, broken('driver', errorText(error)));
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
if (spec.piece) {
|
|
345
|
+
if (pieces.size === 0)
|
|
346
|
+
for (const p of (await readScenarios(ctx.manifest, ctx.checkout, ['piece'])).scenarios)
|
|
347
|
+
pieces.set(p.id, p);
|
|
348
|
+
const piece = pieces.get(spec.piece);
|
|
349
|
+
const pspec = piece?.spec;
|
|
350
|
+
if (!piece || !pspec?.packageDir) {
|
|
351
|
+
out.set(s.id, broken('runner', `The flow opens the piece ${spec.piece}, which isn't in ${ctx.checkout} (or has no package with Vite and React).`));
|
|
352
|
+
continue;
|
|
353
|
+
}
|
|
354
|
+
let server;
|
|
355
|
+
try {
|
|
356
|
+
server = await startPieceServer({
|
|
357
|
+
dir: pspec.packageDir,
|
|
358
|
+
config: ctx.manifest.scenarios.pieces.config ?? null,
|
|
359
|
+
styles: ctx.manifest.scenarios.pieces.styles ?? null,
|
|
360
|
+
preview: ctx.manifest.scenarios.pieces.preview ?? null,
|
|
361
|
+
pieces: [{ file: pspec.inPackage, exportName: pspec.exportName }],
|
|
362
|
+
progress: ctx.progress,
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
catch (error) {
|
|
366
|
+
out.set(s.id, broken('runner', errorText(error)));
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
try {
|
|
370
|
+
out.set(s.id, await throughBrowser(s, ctx, browser, server.canvas(pspec.inPackage, pspec.exportName)));
|
|
371
|
+
}
|
|
372
|
+
finally {
|
|
373
|
+
await server.close();
|
|
374
|
+
}
|
|
375
|
+
continue;
|
|
376
|
+
}
|
|
377
|
+
const running = s.service ? ctx.running.find((r) => r.name === s.service) : undefined;
|
|
378
|
+
if (!running?.url) {
|
|
379
|
+
out.set(s.id, broken('up', `The flow opens ${s.service ?? 'no service'}, which isn't up with a URL.`));
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
382
|
+
out.set(s.id, await throughBrowser(s, ctx, browser, new URL(spec.start ?? '/', running.url).href));
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
finally {
|
|
386
|
+
await browser?.close();
|
|
387
|
+
}
|
|
388
|
+
return out;
|
|
389
|
+
},
|
|
390
|
+
compare(base, head, rules, counts) {
|
|
391
|
+
const a = (base.steps ?? []);
|
|
392
|
+
const b = (head.steps ?? []);
|
|
393
|
+
const diffs = [];
|
|
394
|
+
if (a.length !== b.length)
|
|
395
|
+
diffs.push({ path: 'steps', base: String(a.length), head: String(b.length), count: 1 });
|
|
396
|
+
for (let i = 0; i < Math.min(a.length, b.length); i += 1) {
|
|
397
|
+
const x = a[i];
|
|
398
|
+
const y = b[i];
|
|
399
|
+
const label = `step ${y.n} (${'open' in y.step ? `open ${y.step.open}` : stepWords(y.step)})`;
|
|
400
|
+
if (x.ok !== y.ok)
|
|
401
|
+
diffs.push({
|
|
402
|
+
path: label,
|
|
403
|
+
base: x.ok ? 'it does' : (x.says ?? 'it fails'),
|
|
404
|
+
head: y.ok ? 'it does' : (y.says ?? 'it fails'),
|
|
405
|
+
count: 1,
|
|
406
|
+
});
|
|
407
|
+
diffs.push(...textDifferences(setAsideText(x.tree ?? '', rules, noCounts()), setAsideText(y.tree ?? '', rules, counts), label));
|
|
408
|
+
}
|
|
409
|
+
diffs.push(...jsonDifferences((base.errors ?? []).map((e) => setAsideText(e, rules, noCounts())), (head.errors ?? []).map((e) => setAsideText(e, rules, counts)), 'errors'));
|
|
410
|
+
return diffs;
|
|
411
|
+
},
|
|
412
|
+
});
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
export class LiteralError extends Error {
|
|
2
|
+
name = 'LiteralError';
|
|
3
|
+
}
|
|
4
|
+
export function parseLiteral(code, start) {
|
|
5
|
+
let i = start;
|
|
6
|
+
const space = () => {
|
|
7
|
+
for (;;) {
|
|
8
|
+
while (i < code.length && /\s/.test(code[i]))
|
|
9
|
+
i += 1;
|
|
10
|
+
if (code.startsWith('//', i))
|
|
11
|
+
i = code.indexOf('\n', i) < 0 ? code.length : code.indexOf('\n', i) + 1;
|
|
12
|
+
else if (code.startsWith('/*', i))
|
|
13
|
+
i = code.indexOf('*/', i) < 0 ? code.length : code.indexOf('*/', i) + 2;
|
|
14
|
+
else
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const fail = (what) => {
|
|
19
|
+
const line = code.slice(0, i).split('\n').length;
|
|
20
|
+
throw new LiteralError(`line ${line}: ${what}`);
|
|
21
|
+
};
|
|
22
|
+
const string = () => {
|
|
23
|
+
const q = code[i];
|
|
24
|
+
let out = '';
|
|
25
|
+
i += 1;
|
|
26
|
+
while (i < code.length && code[i] !== q) {
|
|
27
|
+
if (code[i] === '\\') {
|
|
28
|
+
const n = code[i + 1] ?? '';
|
|
29
|
+
const hex = n === 'u'
|
|
30
|
+
? (/^u\{([0-9a-fA-F]+)\}/.exec(code.slice(i + 1)) ?? /^u([0-9a-fA-F]{4})/.exec(code.slice(i + 1)))
|
|
31
|
+
: n === 'x'
|
|
32
|
+
? /^x([0-9a-fA-F]{2})/.exec(code.slice(i + 1))
|
|
33
|
+
: null;
|
|
34
|
+
if (hex) {
|
|
35
|
+
out += String.fromCodePoint(parseInt(hex[1], 16));
|
|
36
|
+
i += 1 + hex[0].length;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
out += n === 'n' ? '\n' : n === 't' ? '\t' : n === 'r' ? '\r' : n;
|
|
40
|
+
i += 2;
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
if (q === '`' && code.startsWith('${', i))
|
|
44
|
+
fail('a template with ${…} is code, not a literal');
|
|
45
|
+
out += code[i];
|
|
46
|
+
i += 1;
|
|
47
|
+
}
|
|
48
|
+
if (code[i] !== q)
|
|
49
|
+
fail('a string is never closed');
|
|
50
|
+
i += 1;
|
|
51
|
+
return out;
|
|
52
|
+
};
|
|
53
|
+
const value = () => {
|
|
54
|
+
space();
|
|
55
|
+
const c = code[i];
|
|
56
|
+
if (c === '{') {
|
|
57
|
+
i += 1;
|
|
58
|
+
const obj = {};
|
|
59
|
+
for (;;) {
|
|
60
|
+
space();
|
|
61
|
+
if (code[i] === '}') {
|
|
62
|
+
i += 1;
|
|
63
|
+
return obj;
|
|
64
|
+
}
|
|
65
|
+
let key;
|
|
66
|
+
if (code[i] === '"' || code[i] === "'")
|
|
67
|
+
key = string();
|
|
68
|
+
else {
|
|
69
|
+
const m = /^[A-Za-z_$][\w$]*/.exec(code.slice(i));
|
|
70
|
+
if (!m)
|
|
71
|
+
return fail('an object key must be a name or a string');
|
|
72
|
+
key = m[0];
|
|
73
|
+
i += key.length;
|
|
74
|
+
}
|
|
75
|
+
space();
|
|
76
|
+
if (code[i] !== ':')
|
|
77
|
+
fail(`“${key}” needs a value after a colon (a shorthand is code, not a literal)`);
|
|
78
|
+
i += 1;
|
|
79
|
+
obj[key] = value();
|
|
80
|
+
space();
|
|
81
|
+
if (code[i] === ',')
|
|
82
|
+
i += 1;
|
|
83
|
+
else if (code[i] !== '}')
|
|
84
|
+
fail('an object’s fields are separated by commas');
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (c === '[') {
|
|
88
|
+
i += 1;
|
|
89
|
+
const arr = [];
|
|
90
|
+
for (;;) {
|
|
91
|
+
space();
|
|
92
|
+
if (code[i] === ']') {
|
|
93
|
+
i += 1;
|
|
94
|
+
return arr;
|
|
95
|
+
}
|
|
96
|
+
arr.push(value());
|
|
97
|
+
space();
|
|
98
|
+
if (code[i] === ',')
|
|
99
|
+
i += 1;
|
|
100
|
+
else if (code[i] !== ']')
|
|
101
|
+
fail('an array’s items are separated by commas');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
if (c === '"' || c === "'" || c === '`')
|
|
105
|
+
return string();
|
|
106
|
+
const word = /^(?:-?\d+(?:\.\d+)?(?:e[+-]?\d+)?|true|false|null)/.exec(code.slice(i));
|
|
107
|
+
if (word) {
|
|
108
|
+
i += word[0].length;
|
|
109
|
+
return JSON.parse(word[0]);
|
|
110
|
+
}
|
|
111
|
+
return fail('only strings, numbers, booleans, null, arrays and objects can be read');
|
|
112
|
+
};
|
|
113
|
+
const out = value();
|
|
114
|
+
return { value: out, end: i };
|
|
115
|
+
}
|
|
116
|
+
const commentsBlankedInPlace = (code) => code
|
|
117
|
+
.replace(/\/\*[\s\S]*?\*\//g, (c) => c.replace(/[^\n]/g, ' '))
|
|
118
|
+
.replace(/(^|[^:'"`\\])(\/\/[^\n]*)/g, (_, a, c) => a + ' '.repeat(c.length));
|
|
119
|
+
function refuseCodeAfterTheObject(code, end) {
|
|
120
|
+
const rest = code.slice(end);
|
|
121
|
+
if (!/^[\s)]*(?:(?:satisfies|as)\s+[\w$.<>[\], ]+?)?[\s)]*(?:;|\n|$)/.test(rest)) {
|
|
122
|
+
const line = code.slice(0, end).split('\n').length;
|
|
123
|
+
throw new LiteralError(`line ${line}: code follows the object, so it isn't plain data`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
export function defaultExportOf(source) {
|
|
127
|
+
const code = commentsBlankedInPlace(source);
|
|
128
|
+
const direct = /\bexport\s+default\s+/.exec(code);
|
|
129
|
+
if (!direct)
|
|
130
|
+
throw new LiteralError('it has no default export');
|
|
131
|
+
let at = direct.index + direct[0].length;
|
|
132
|
+
while (code[at] === '(')
|
|
133
|
+
at += 1;
|
|
134
|
+
if (code[at] === '{') {
|
|
135
|
+
const read = parseLiteral(source, at);
|
|
136
|
+
refuseCodeAfterTheObject(code, read.end);
|
|
137
|
+
return read.value;
|
|
138
|
+
}
|
|
139
|
+
const name = /^[A-Za-z_$][\w$]*/.exec(code.slice(at))?.[0];
|
|
140
|
+
if (!name)
|
|
141
|
+
throw new LiteralError('its default export isn’t an object');
|
|
142
|
+
const declared = new RegExp(`\\b(?:const|let|var)\\s+${name.replace(/\$/g, '\\$')}\\s*(?::[^=]+)?=\\s*`).exec(code);
|
|
143
|
+
if (!declared)
|
|
144
|
+
throw new LiteralError(`its default export ${name} isn’t declared in the file`);
|
|
145
|
+
const read = parseLiteral(source, declared.index + declared[0].length);
|
|
146
|
+
refuseCodeAfterTheObject(code, read.end);
|
|
147
|
+
return read.value;
|
|
148
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { broken, loadKinds, runnerOf, type Artifact, type Broke, type Failure, type KindRunner, type Ran, type RunContext, type SignedInAgain, type StandinUse, } from './kind.ts';
|
|
2
|
+
export { callDefinition } from './call/definition.ts';
|
|
3
|
+
export { parseHurl, Refusal } from './call/hurl.ts';
|
|
4
|
+
export { sendFile, type Fetcher } from './call/send.ts';
|
|
5
|
+
export { entryLayout, parseDelimited, parseFixed, readZip } from './file/layouts.ts';
|
|
6
|
+
export { defaultExportOf } from './flow/literal.ts';
|
|
7
|
+
export { statementAt, storyExportsOf } from './piece/csf.ts';
|
|
8
|
+
export { startPieceServer, type PieceServer } from './piece/server.ts';
|
|
9
|
+
export type { CallSpec } from './call/kind.ts';
|
|
10
|
+
export type { PieceSpec } from './piece/kind.ts';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { broken, loadKinds, runnerOf, } from './kind.js';
|
|
2
|
+
export { callDefinition } from './call/definition.js';
|
|
3
|
+
export { parseHurl, Refusal } from './call/hurl.js';
|
|
4
|
+
export { sendFile } from './call/send.js';
|
|
5
|
+
export { entryLayout, parseDelimited, parseFixed, readZip } from './file/layouts.js';
|
|
6
|
+
export { defaultExportOf } from './flow/literal.js';
|
|
7
|
+
export { statementAt, storyExportsOf } from './piece/csf.js';
|
|
8
|
+
export { startPieceServer } from './piece/server.js';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { AsideCounts as Counts, Difference, Rules } from '../compare/index.ts';
|
|
2
|
+
import type { Kind, Manifest } from '../manifest/index.ts';
|
|
3
|
+
import type { Scenario } from '../scenarios/index.ts';
|
|
4
|
+
import type { Running } from '../services/index.ts';
|
|
5
|
+
export interface Failure {
|
|
6
|
+
line?: number;
|
|
7
|
+
step?: number;
|
|
8
|
+
text: string;
|
|
9
|
+
expected: string | null;
|
|
10
|
+
got: string | null;
|
|
11
|
+
}
|
|
12
|
+
export interface Artifact {
|
|
13
|
+
kind: string;
|
|
14
|
+
path: string;
|
|
15
|
+
label?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface Broke {
|
|
18
|
+
step: string;
|
|
19
|
+
says: string;
|
|
20
|
+
}
|
|
21
|
+
export interface Ran {
|
|
22
|
+
ok: boolean;
|
|
23
|
+
failures: Failure[];
|
|
24
|
+
observed: Record<string, unknown> | null;
|
|
25
|
+
artifacts: Artifact[];
|
|
26
|
+
broke: Broke | null;
|
|
27
|
+
}
|
|
28
|
+
export interface StandinUse {
|
|
29
|
+
name: string;
|
|
30
|
+
replaces: string;
|
|
31
|
+
by: string | null;
|
|
32
|
+
fidelity: string;
|
|
33
|
+
real: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface SignedInAgain {
|
|
36
|
+
tokens: Record<string, string>;
|
|
37
|
+
variables: Record<string, string>;
|
|
38
|
+
}
|
|
39
|
+
export interface RunContext {
|
|
40
|
+
manifest: Manifest;
|
|
41
|
+
checkout: string;
|
|
42
|
+
world: string | null;
|
|
43
|
+
as: string | null;
|
|
44
|
+
tokens: Record<string, string>;
|
|
45
|
+
variables: Record<string, string>;
|
|
46
|
+
running: Running[];
|
|
47
|
+
broughtUpAndUnused: ReadonlySet<string>;
|
|
48
|
+
signInAgain(): Promise<SignedInAgain>;
|
|
49
|
+
keep: string;
|
|
50
|
+
progress(line: string): void;
|
|
51
|
+
}
|
|
52
|
+
export interface KindRunner {
|
|
53
|
+
kind: Kind;
|
|
54
|
+
version: string;
|
|
55
|
+
services(s: Scenario, m: Manifest): string[];
|
|
56
|
+
run(scenarios: readonly Scenario[], ctx: RunContext): Promise<Map<string, Ran>>;
|
|
57
|
+
compare(base: Record<string, unknown>, head: Record<string, unknown>, rules: Rules, counts: Counts, s: Scenario, m: Manifest): Difference[];
|
|
58
|
+
unordered?(s: Scenario, m: Manifest): boolean;
|
|
59
|
+
}
|
|
60
|
+
export declare function registerRunner(r: KindRunner): void;
|
|
61
|
+
export declare function loadKinds(): Promise<void>;
|
|
62
|
+
export declare function runnerOf(kind: Kind): Promise<KindRunner>;
|
|
63
|
+
export declare const broken: (step: string, says: string) => Ran;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const runners = new Map();
|
|
2
|
+
export function registerRunner(r) {
|
|
3
|
+
runners.set(r.kind, r);
|
|
4
|
+
}
|
|
5
|
+
export async function loadKinds() {
|
|
6
|
+
await import('./all.js');
|
|
7
|
+
}
|
|
8
|
+
export async function runnerOf(kind) {
|
|
9
|
+
await loadKinds();
|
|
10
|
+
const r = runners.get(kind);
|
|
11
|
+
if (!r)
|
|
12
|
+
throw new Error(`Rehearse has no runner for ${kind} scenarios.`);
|
|
13
|
+
return r;
|
|
14
|
+
}
|
|
15
|
+
export const broken = (step, says) => ({
|
|
16
|
+
ok: false,
|
|
17
|
+
failures: [],
|
|
18
|
+
observed: null,
|
|
19
|
+
artifacts: [],
|
|
20
|
+
broke: { step, says },
|
|
21
|
+
});
|