waygraph 0.15.52 → 0.15.53
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/README.md +8 -1
- package/dist/analysis/map-check.d.ts +3 -2
- package/dist/cli/flags.js +3 -1
- package/dist/cli/usage.js +4 -1
- package/dist/cli.js +4 -1
- package/dist/commands/agent-dive-scaffold.d.ts +0 -20
- package/dist/commands/agent-dive-scaffold.js +3 -3
- package/dist/commands/init.js +1 -1
- package/dist/commands/upgrade.d.ts +1 -1
- package/dist/commands/upgrade.js +7 -1
- package/dist/config.d.ts +53 -19
- package/dist/config.js +55 -13
- package/dist/core/block.d.ts +7 -2
- package/dist/core/block.js +7 -3
- package/dist/core/engine.d.ts +2 -0
- package/dist/core/engine.js +3 -1
- package/dist/core/flow.d.ts +10 -0
- package/dist/core/flow.js +32 -8
- package/dist/core/map-builder.d.ts +27 -1
- package/dist/core/map-builder.js +42 -4
- package/dist/highlights/demo-pace.d.ts +0 -1
- package/dist/highlights/demo-pace.js +24 -3
- package/dist/index.d.ts +2 -2
- package/dist/pilot-overlay/action-ring.d.ts +0 -9
- package/dist/pilot-overlay/action-ring.js +1 -1
- package/dist/pilot-overlay/panel.d.ts +2 -1
- package/dist/runner/interaction-patch.js +32 -1
- package/dist/runner/main.js +5 -2
- package/dist/runner/step-mode.js +10 -4
- package/dist/session/auto-explore.d.ts +2 -1
- package/dist/session/auto-session-ipc.d.ts +1 -2
- package/dist/session/auto-session-ipc.js +1 -1
- package/dist/session/block-inject.d.ts +0 -13
- package/dist/session/block-inject.js +3 -3
- package/dist/session/pilot.d.ts +0 -2
- package/dist/session/pilot.js +1 -2
- package/dist/traverse/coverage.d.ts +0 -4
- package/dist/traverse/coverage.js +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +11 -5
- package/templates/scaffold/README.md +1 -1
- package/templates/scaffold/STRUCTURE.md +5 -2
- package/templates/scaffold/config/waygraph.config.ts +24 -5
- package/templates/scaffold/package.json +6 -6
- package/templates/scaffold/src/flows/(external)/hoppscotch/auth.flow.ts +36 -0
- package/templates/scaffold/src/flows/(external)/hoppscotch/get.flow.ts +24 -0
- package/templates/scaffold/src/flows/(external)/hoppscotch/post.flow.ts +34 -0
- package/templates/scaffold/src/flows/(user-stories)/email-verification.flow.ts +47 -0
- package/templates/scaffold/src/flows/README.md +35 -14
- package/templates/scaffold/src/flows/{shop.flow.ts → home/cart.flow.ts} +18 -17
- package/templates/scaffold/src/flows/{example.flow.ts → home/hello.flow.ts} +12 -13
- package/templates/scaffold/tests/example.spec.ts +5 -5
- package/templates/scaffold/tests/hoppscotch.spec.ts +3 -3
- package/templates/scaffold/tests/mail-verify.spec.ts +7 -7
- package/templates/skills/waygraph-convention.skill.md +14 -6
- package/templates/scaffold/src/flows/hoppscotch-auth.flow.ts +0 -35
- package/templates/scaffold/src/flows/hoppscotch-get.flow.ts +0 -23
- package/templates/scaffold/src/flows/hoppscotch-post.flow.ts +0 -33
- package/templates/scaffold/src/flows/mail-verify.flow.ts +0 -46
package/dist/session/pilot.js
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* new execution primitive.
|
|
30
30
|
*/
|
|
31
31
|
import { discoverGraph } from "../analysis/graph.js";
|
|
32
|
-
import { requestSession,
|
|
32
|
+
import { requestSession, resolveSessionMeta, } from "./auto-session-ipc.js";
|
|
33
33
|
import { browserStart } from "./browser.js";
|
|
34
34
|
/**
|
|
35
35
|
* Starts a detached session and reads back its own graph + starting
|
|
@@ -77,4 +77,3 @@ export async function pilotAttach(projectDir, sessionId, inject) {
|
|
|
77
77
|
snapshot: status.snapshot,
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
-
export { listBrowserSessions };
|
|
@@ -27,10 +27,6 @@ export interface TraverseCoverageReport {
|
|
|
27
27
|
leaf?: string;
|
|
28
28
|
}>;
|
|
29
29
|
}
|
|
30
|
-
/** Static graph edge key = Block runtime name. */
|
|
31
|
-
export declare function edgeKeyFromGraphEdge(edge: {
|
|
32
|
-
block: string;
|
|
33
|
-
}): string;
|
|
34
30
|
/** Collect unique edge keys from a WaygraphGraph-like edges list. */
|
|
35
31
|
export declare function collectGraphEdgeKeys(edges: ReadonlyArray<{
|
|
36
32
|
block: string;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { mkdirSync, writeFileSync } from "node:fs";
|
|
11
11
|
import { dirname, join } from "node:path";
|
|
12
12
|
/** Static graph edge key = Block runtime name. */
|
|
13
|
-
|
|
13
|
+
function edgeKeyFromGraphEdge(edge) {
|
|
14
14
|
return edge.block;
|
|
15
15
|
}
|
|
16
16
|
/** Collect unique edge keys from a WaygraphGraph-like edges list. */
|
package/dist/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Page } from "@playwright/test";
|
|
|
2
2
|
import type { MemPage, MemKey } from "./mem-page.js";
|
|
3
3
|
import type { Trait } from "./trait.js";
|
|
4
4
|
import type { HighlightStubPhaseOrFn, WaygraphHighlight, WaygraphSlidesOrFn } from "./highlights.js";
|
|
5
|
-
export type { WaygraphHighlight
|
|
5
|
+
export type { WaygraphHighlight } from "./highlights.js";
|
|
6
6
|
/**
|
|
7
7
|
* A Checkpoint is identified solely by its string tag - a phantom marker with no
|
|
8
8
|
* embedded data. Two Checkpoints with the same tag are the same state everywhere.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "waygraph",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.53",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A typed graph of reusable Blocks for driving a browser through E2E flows.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -48,16 +48,18 @@
|
|
|
48
48
|
"clean": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
49
49
|
"build": "npm run clean && tsc -p tsconfig.build.json && node scripts/copy-runner.mjs && node scripts/copy-ui-css.mjs",
|
|
50
50
|
"typecheck": "node bin/waygraph typecheck .",
|
|
51
|
-
"test": "npm run check:structure && npm run test:unit && playwright test",
|
|
51
|
+
"test": "npm run check:structure && npm run knip && npm run test:unit && playwright test",
|
|
52
52
|
"test:ui": "playwright test --ui",
|
|
53
53
|
"test:unit": "node --import tsx/esm --test tests/unit/*.spec.ts",
|
|
54
54
|
"example:saucedemo:install": "npm --prefix examples/saucedemo install",
|
|
55
55
|
"example:saucedemo:test": "npm --prefix examples/saucedemo test",
|
|
56
56
|
"example:saucedemo:auto": "npm --prefix examples/saucedemo run auto",
|
|
57
57
|
"check:structure": "node scripts/check-structure.mjs",
|
|
58
|
-
"docs:dev": "vitepress dev docs",
|
|
59
|
-
"docs:build": "vitepress build docs",
|
|
60
|
-
"docs:preview": "vitepress preview docs"
|
|
58
|
+
"docs:dev": "npm run docs:api && vitepress dev docs",
|
|
59
|
+
"docs:build": "npm run docs:api && vitepress build docs",
|
|
60
|
+
"docs:preview": "vitepress preview docs",
|
|
61
|
+
"docs:api": "typedoc && node scripts/gen-deprecated.mjs",
|
|
62
|
+
"knip": "knip"
|
|
61
63
|
},
|
|
62
64
|
"peerDependencies": {
|
|
63
65
|
"@playwright/test": "^1.40.0"
|
|
@@ -70,6 +72,10 @@
|
|
|
70
72
|
"devDependencies": {
|
|
71
73
|
"@playwright/test": "^1.63.0",
|
|
72
74
|
"@types/node": "^26.0.0",
|
|
75
|
+
"knip": "^6.42.1",
|
|
76
|
+
"typedoc": "^0.28.20",
|
|
77
|
+
"typedoc-plugin-markdown": "^4.14.1",
|
|
78
|
+
"typedoc-vitepress-theme": "^1.1.4",
|
|
73
79
|
"typescript": "^5.6.0",
|
|
74
80
|
"vitepress": "^1.6.4"
|
|
75
81
|
}
|
|
@@ -20,7 +20,7 @@ More: `npm run check` (lint your Blocks), `npm run graph` (see the whole graph),
|
|
|
20
20
|
## Where things live
|
|
21
21
|
|
|
22
22
|
See [STRUCTURE.md](./STRUCTURE.md). Short version: one folder per page under `src/map/`,
|
|
23
|
-
one Block per action,
|
|
23
|
+
one Block per action, one flow per use case in `src/flows/` (a folder per page: its success, its failures, its bad inputs).
|
|
24
24
|
|
|
25
25
|
## Point it at your real app
|
|
26
26
|
|
|
@@ -27,7 +27,10 @@ Next.js route groups) and never appear in a URL or Checkpoint name.
|
|
|
27
27
|
│ │ ├── (external)/mailpit/ # a different origin (mail catcher)
|
|
28
28
|
│ │ └── (external)/hoppscotch/ # API client, REST client, needs the hoppscotch extension
|
|
29
29
|
│ ├── states/ # Checkpoint types + mem keys
|
|
30
|
-
│ └── flows/ #
|
|
30
|
+
│ └── flows/ # use cases, one file per scenario (see flows/README.md)
|
|
31
|
+
│ ├── home/ # a page: hello, cart
|
|
32
|
+
│ ├── (user-stories)/ # flows that cross pages
|
|
33
|
+
│ └── (external)/hoppscotch/ # a tool on another origin
|
|
31
34
|
└── tests/example.spec.ts
|
|
32
35
|
```
|
|
33
36
|
|
|
@@ -41,7 +44,7 @@ page folder uses, so any agent or teammate knows where to look without asking.
|
|
|
41
44
|
| Add a page | copy a folder under `src/map/`, keep the `_nav` / `_page` / `_sel` names |
|
|
42
45
|
| Add an action on a page | one file in that page's `_methods/` |
|
|
43
46
|
| Verify a state (button disabled, error shown) | `defineAssertBlock` + `Trait.disabled` / `Trait.enabled` |
|
|
44
|
-
|
|
|
47
|
+
| Define a use case (success, failed, bad input) | one `*.flow.ts` in `src/flows/<page>/`, or `(user-stories)/` for one that crosses pages |
|
|
45
48
|
| Give a flow fake data | `registerMemStub(key, fake)` + `memStub: true` in the flow's options (docs: docs/REFERENCE.md, "memStub") |
|
|
46
49
|
| Explore by hand | `npm run auto` (headed) or `npm run auto:cli` |
|
|
47
50
|
| Check your work | `npm run check`, `npm run graph`, `waygraph map` |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineConfig } from "waygraph";
|
|
1
|
+
import { Engine, defineConfig } from "waygraph";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const config = defineConfig(({ env }) => ({
|
|
4
4
|
// Where the app under test lives. BASE_URL comes from .env / .env.<mode>: waygraph test --env staging
|
|
5
5
|
baseUrl: env.BASE_URL ?? "__APP_BASE_URL__",
|
|
6
6
|
|
|
@@ -10,11 +10,25 @@ export default defineConfig(({ env }) => ({
|
|
|
10
10
|
// dir: "~/Downloads/waygraph-videos", // where they are saved (default: Downloads/waygraph-videos/<project>)
|
|
11
11
|
// viewport: "1920x1080", // recording size: demo defaults to 1920x1080, run to 1280x720
|
|
12
12
|
// },
|
|
13
|
-
// slowMo: 250, // ms to pause
|
|
14
|
-
// headed: true, // show the browser window (demo and auto already do)
|
|
15
|
-
//
|
|
13
|
+
// slowMo: 250, // shared by run and demo: ms to pause around each browser action
|
|
14
|
+
// headed: true, // shared: show the browser window (demo and auto already do)
|
|
15
|
+
// run: { // `waygraph run` only; overrides the shared values above
|
|
16
|
+
// slowMo: 0,
|
|
17
|
+
// video: { viewport: "1280x720" },
|
|
18
|
+
// },
|
|
19
|
+
// demo: { // `waygraph demo` only; overrides the shared values above
|
|
20
|
+
// pace: "fast", // default pace for steps that set none: "fast" | "slow" | "blitz" | 0.5 | 2
|
|
21
|
+
// speeds: { blitz: 0.05, fast: 0.33, slow: 2 }, // what each pace means, x normal dwell (lower = faster)
|
|
22
|
+
// typingMs: 30, // typing animation, ms per character (0 types instantly)
|
|
23
|
+
// slowMo: 350, // pause after each action, once per action (a step with pace "blitz" skips it)
|
|
24
|
+
// autoNext: true, // advance steps without clicking Next
|
|
25
|
+
// fast: false, // shorter Next / auto-next gates
|
|
26
|
+
// video: { viewport: "1920x1080" },
|
|
27
|
+
// },
|
|
16
28
|
// webServer: { command: "npm start", port: 3000 }, // started around test / run / demo / auto
|
|
17
29
|
|
|
30
|
+
// Another config for another environment: config/waygraph.staging.config.ts, chosen with `waygraph test --config staging`.
|
|
31
|
+
|
|
18
32
|
// ── test runner (Playwright) ──────────────────────────────────────────────────────────────────
|
|
19
33
|
// testDir: "tests",
|
|
20
34
|
// playwright: { // any Playwright test option, merged over waygraph's defaults
|
|
@@ -24,3 +38,8 @@ export default defineConfig(({ env }) => ({
|
|
|
24
38
|
// use: { video: "on", trace: "on", screenshot: "only-on-failure", viewport: { width: 1280, height: 720 } },
|
|
25
39
|
// },
|
|
26
40
|
}));
|
|
41
|
+
|
|
42
|
+
export default config;
|
|
43
|
+
|
|
44
|
+
// Flows import this, so they run with the config above already applied.
|
|
45
|
+
export const engine = new Engine(config);
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"graph:mermaid": "waygraph graph --mermaid",
|
|
14
14
|
"auto": "waygraph auto",
|
|
15
15
|
"auto:cli": "waygraph auto --cli",
|
|
16
|
-
"demo": "waygraph demo --blocks
|
|
17
|
-
"demo:auto-next": "waygraph demo --blocks
|
|
18
|
-
"demo:shop": "waygraph demo --blocks
|
|
19
|
-
"demo:shop:auto-next": "waygraph demo --blocks
|
|
20
|
-
"run": "waygraph run --blocks
|
|
21
|
-
"run:shop": "waygraph run --blocks
|
|
16
|
+
"demo": "waygraph demo --blocks homeHelloFlow",
|
|
17
|
+
"demo:auto-next": "waygraph demo --blocks homeHelloFlow --auto-next",
|
|
18
|
+
"demo:shop": "waygraph demo --blocks homeCartFlow",
|
|
19
|
+
"demo:shop:auto-next": "waygraph demo --blocks homeCartFlow --auto-next",
|
|
20
|
+
"run": "waygraph run --blocks homeHelloFlow",
|
|
21
|
+
"run:shop": "waygraph run --blocks homeCartFlow"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"waygraph": "latest"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { engine } from "../../../../config/waygraph.config.js";
|
|
2
|
+
import { NavHoppscotchSettingsBlock } from "../../../map/(external)/hoppscotch/settings/_nav.block.js";
|
|
3
|
+
import { PickExtensionInterceptorBlock } from "../../../map/(external)/hoppscotch/_methods/pick-extension-interceptor.method.block.js";
|
|
4
|
+
import { NavHoppscotchRestBlock } from "../../../map/(external)/hoppscotch/_nav.block.js";
|
|
5
|
+
import { SetQueryParamsBlock } from "../../../map/(external)/hoppscotch/_methods/set-query-params.method.block.js";
|
|
6
|
+
import { SetUrlBlock } from "../../../map/(external)/hoppscotch/_methods/set-url.method.block.js";
|
|
7
|
+
import { SetBearerTokenBlock } from "../../../map/(external)/hoppscotch/_methods/set-bearer-token.method.block.js";
|
|
8
|
+
import { SendRequestBlock } from "../../../map/(external)/hoppscotch/_methods/send-request.method.block.js";
|
|
9
|
+
import { AssertStatusBlock } from "../../../map/(external)/hoppscotch/_methods/assert-status.method.block.js";
|
|
10
|
+
import { ReadResponseHeadersBlock } from "../../../map/(external)/hoppscotch/_methods/read-response-headers.method.block.js";
|
|
11
|
+
import { AssertResponseHeaderBlock } from "../../../map/(external)/hoppscotch/_methods/assert-response-header.method.block.js";
|
|
12
|
+
import { ReadResponseBodyBlock } from "../../../map/(external)/hoppscotch/_methods/read-response-body.method.block.js";
|
|
13
|
+
import { AssertResponseBodyBlock } from "../../../map/(external)/hoppscotch/_methods/assert-response-body.method.block.js";
|
|
14
|
+
import "../../../map/(external)/hoppscotch/_page.block.js";
|
|
15
|
+
|
|
16
|
+
/** GET with query params and a bearer token, check the status, that the API received them, and a response header. Needs `extensions: ["hoppscotch"]`. */
|
|
17
|
+
export const hoppscotchAuthFlow = engine
|
|
18
|
+
.map()
|
|
19
|
+
.start()
|
|
20
|
+
.gotoExternal(
|
|
21
|
+
NavHoppscotchSettingsBlock.stubBefore((ctx) => {
|
|
22
|
+
ctx.title("Scaffold: Hoppscotch GET with query params and bearer token");
|
|
23
|
+
}),
|
|
24
|
+
)
|
|
25
|
+
.method(PickExtensionInterceptorBlock)
|
|
26
|
+
.gotoExternal(NavHoppscotchRestBlock)
|
|
27
|
+
.method(SetUrlBlock)
|
|
28
|
+
.method(SetQueryParamsBlock)
|
|
29
|
+
.method(SetBearerTokenBlock)
|
|
30
|
+
.method(SendRequestBlock)
|
|
31
|
+
.assert(AssertStatusBlock)
|
|
32
|
+
.method(ReadResponseBodyBlock)
|
|
33
|
+
.assert(AssertResponseBodyBlock)
|
|
34
|
+
.method(ReadResponseHeadersBlock)
|
|
35
|
+
.assert(AssertResponseHeaderBlock)
|
|
36
|
+
.end();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { engine } from "../../../../config/waygraph.config.js";
|
|
2
|
+
import { NavHoppscotchSettingsBlock } from "../../../map/(external)/hoppscotch/settings/_nav.block.js";
|
|
3
|
+
import { PickExtensionInterceptorBlock } from "../../../map/(external)/hoppscotch/_methods/pick-extension-interceptor.method.block.js";
|
|
4
|
+
import { NavHoppscotchRestBlock } from "../../../map/(external)/hoppscotch/_nav.block.js";
|
|
5
|
+
import { SetUrlBlock } from "../../../map/(external)/hoppscotch/_methods/set-url.method.block.js";
|
|
6
|
+
import { SendRequestBlock } from "../../../map/(external)/hoppscotch/_methods/send-request.method.block.js";
|
|
7
|
+
import { AssertStatusBlock } from "../../../map/(external)/hoppscotch/_methods/assert-status.method.block.js";
|
|
8
|
+
import "../../../map/(external)/hoppscotch/_page.block.js";
|
|
9
|
+
|
|
10
|
+
/** GET a URL and check the status. Needs `extensions: ["hoppscotch"]` in waygraph.config.ts. */
|
|
11
|
+
export const hoppscotchGetFlow = engine
|
|
12
|
+
.map()
|
|
13
|
+
.start()
|
|
14
|
+
.gotoExternal(
|
|
15
|
+
NavHoppscotchSettingsBlock.stubBefore((ctx) => {
|
|
16
|
+
ctx.title("Scaffold: Hoppscotch GET");
|
|
17
|
+
}),
|
|
18
|
+
)
|
|
19
|
+
.method(PickExtensionInterceptorBlock)
|
|
20
|
+
.gotoExternal(NavHoppscotchRestBlock)
|
|
21
|
+
.method(SetUrlBlock)
|
|
22
|
+
.method(SendRequestBlock)
|
|
23
|
+
.assert(AssertStatusBlock)
|
|
24
|
+
.end();
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { engine } from "../../../../config/waygraph.config.js";
|
|
2
|
+
import { NavHoppscotchSettingsBlock } from "../../../map/(external)/hoppscotch/settings/_nav.block.js";
|
|
3
|
+
import { PickExtensionInterceptorBlock } from "../../../map/(external)/hoppscotch/_methods/pick-extension-interceptor.method.block.js";
|
|
4
|
+
import { NavHoppscotchRestBlock } from "../../../map/(external)/hoppscotch/_nav.block.js";
|
|
5
|
+
import { SetMethodBlock } from "../../../map/(external)/hoppscotch/_methods/set-method.method.block.js";
|
|
6
|
+
import { SetUrlBlock } from "../../../map/(external)/hoppscotch/_methods/set-url.method.block.js";
|
|
7
|
+
import { SetHeadersBlock } from "../../../map/(external)/hoppscotch/_methods/set-headers.method.block.js";
|
|
8
|
+
import { SetJsonBodyBlock } from "../../../map/(external)/hoppscotch/_methods/set-json-body.method.block.js";
|
|
9
|
+
import { SendRequestBlock } from "../../../map/(external)/hoppscotch/_methods/send-request.method.block.js";
|
|
10
|
+
import { AssertStatusBlock } from "../../../map/(external)/hoppscotch/_methods/assert-status.method.block.js";
|
|
11
|
+
import { ReadResponseBodyBlock } from "../../../map/(external)/hoppscotch/_methods/read-response-body.method.block.js";
|
|
12
|
+
import { AssertResponseBodyBlock } from "../../../map/(external)/hoppscotch/_methods/assert-response-body.method.block.js";
|
|
13
|
+
import "../../../map/(external)/hoppscotch/_page.block.js";
|
|
14
|
+
|
|
15
|
+
/** POST JSON with a header, check the status and the response body. Needs `extensions: ["hoppscotch"]`. */
|
|
16
|
+
export const hoppscotchPostFlow = engine
|
|
17
|
+
.map()
|
|
18
|
+
.start()
|
|
19
|
+
.gotoExternal(
|
|
20
|
+
NavHoppscotchSettingsBlock.stubBefore((ctx) => {
|
|
21
|
+
ctx.title("Scaffold: Hoppscotch POST with header and JSON body");
|
|
22
|
+
}),
|
|
23
|
+
)
|
|
24
|
+
.method(PickExtensionInterceptorBlock)
|
|
25
|
+
.gotoExternal(NavHoppscotchRestBlock)
|
|
26
|
+
.method(SetMethodBlock)
|
|
27
|
+
.method(SetUrlBlock)
|
|
28
|
+
.method(SetHeadersBlock)
|
|
29
|
+
.method(SetJsonBodyBlock)
|
|
30
|
+
.method(SendRequestBlock)
|
|
31
|
+
.assert(AssertStatusBlock)
|
|
32
|
+
.method(ReadResponseBodyBlock)
|
|
33
|
+
.assert(AssertResponseBodyBlock)
|
|
34
|
+
.end();
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { engine } from "../../../config/waygraph.config.js";
|
|
2
|
+
import { NavMailpitInboxBlock } from "../../map/(external)/mailpit/_nav.block.js";
|
|
3
|
+
import { AssertEmailReceivedBlock } from "../../map/(external)/mailpit/_methods/assert-email-received.method.block.js";
|
|
4
|
+
import { OpenMessageBlock } from "../../map/(external)/mailpit/_methods/open-message.method.block.js";
|
|
5
|
+
import { AssertEmailContentBlock } from "../../map/(external)/mailpit/_methods/assert-email-content.method.block.js";
|
|
6
|
+
import { ExtractEmailLinkBlock } from "../../map/(external)/mailpit/_methods/extract-email-link.method.block.js";
|
|
7
|
+
import { NavVerificationLinkBlock } from "../../map/(app_base)/home/nav-verification-link.block.js";
|
|
8
|
+
import "../../map/(external)/mailpit/_page.block.js";
|
|
9
|
+
import { MailpitSel } from "../../map/(external)/mailpit/_sel.js";
|
|
10
|
+
|
|
11
|
+
/** Needs a Mailpit at WAYGRAPH_MAIL_URL (default http://127.0.0.1:8025); tests/mail-verify.spec.ts starts one. */
|
|
12
|
+
export const emailVerificationFlow = engine
|
|
13
|
+
.map()
|
|
14
|
+
.start()
|
|
15
|
+
.gotoExternal(
|
|
16
|
+
NavMailpitInboxBlock.stubBefore((ctx) => {
|
|
17
|
+
ctx.title("Scaffold: Cross-origin mail verification (QA-rich)");
|
|
18
|
+
}),
|
|
19
|
+
)
|
|
20
|
+
.assert(
|
|
21
|
+
AssertEmailReceivedBlock.stubAfter((ctx) => {
|
|
22
|
+
ctx.ring("note", {
|
|
23
|
+
selector: MailpitSel.messageRow,
|
|
24
|
+
label: "AC · email arrived",
|
|
25
|
+
detail: "Confirmed before opening anything.",
|
|
26
|
+
tag: "AC",
|
|
27
|
+
});
|
|
28
|
+
}),
|
|
29
|
+
)
|
|
30
|
+
.method(OpenMessageBlock)
|
|
31
|
+
.assert(
|
|
32
|
+
AssertEmailContentBlock.stubAfter((ctx) => {
|
|
33
|
+
ctx.ring("note", { selector: MailpitSel.previewIframe, label: "AC · email body matches expected copy", tag: "AC" });
|
|
34
|
+
}),
|
|
35
|
+
)
|
|
36
|
+
.method(
|
|
37
|
+
ExtractEmailLinkBlock.stubAfter((ctx) => {
|
|
38
|
+
ctx.ring("note", {
|
|
39
|
+
selector: MailpitSel.previewIframe,
|
|
40
|
+
label: "AC · link found",
|
|
41
|
+
detail: "Read from the message preview iframe.",
|
|
42
|
+
tag: "AC",
|
|
43
|
+
});
|
|
44
|
+
}),
|
|
45
|
+
)
|
|
46
|
+
.gotoPage(NavVerificationLinkBlock)
|
|
47
|
+
.end();
|
|
@@ -1,18 +1,39 @@
|
|
|
1
1
|
# `src/flows/`
|
|
2
2
|
|
|
3
|
-
A
|
|
4
|
-
all point at an export here by name (`waygraph run --blocks
|
|
3
|
+
A flow is one **use case**: a path a user takes through the app, with its own pass or fail. `waygraph run`, `demo` and
|
|
4
|
+
`test` all point at an export here by name (`waygraph run --blocks homeCartFlow`).
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
`.branch()`) over hand-composing raw Blocks - it checks each step's Block kind at runtime and
|
|
8
|
-
the Checkpoint chain at compile time, so a wrong step is a build/test failure, not a
|
|
9
|
-
mid-run surprise.
|
|
10
|
-
- Flow settings go in `.end({ title, memStub, sessionReset })`. No nested `withTitle(withMemStub(...))`.
|
|
11
|
-
- Demo highlights are ctx stubs chained on the Block where the flow uses it:
|
|
12
|
-
`AddItemBlock.stubAfter((ctx) => { ctx.ring("cart", { selector, label }); })`.
|
|
13
|
-
- One flow, one scenario. A flow that needs a genuinely different starting session
|
|
14
|
-
(re-entering the login page mid-chain) sets `sessionReset: true`, rather than hand-clearing
|
|
15
|
-
cookies inside a Block.
|
|
6
|
+
## The folder mocks the front end
|
|
16
7
|
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
`src/flows/` mirrors the app's endpoints the way `src/map/` does, but where the map holds the *pieces* of a page, a flow
|
|
9
|
+
folder holds the *stories* of it. One folder per page or area, one file per use case. The scaffold only has the demo pages, so `auth/login/` below is the shape to copy for a real login page:
|
|
10
|
+
|
|
11
|
+
```text
|
|
12
|
+
src/flows/
|
|
13
|
+
auth/login/
|
|
14
|
+
success.flow.ts # valid credentials -> dashboard
|
|
15
|
+
wrong-password.flow.ts # refused, error banner, stays on login
|
|
16
|
+
empty-fields.flow.ts # each required field flags itself
|
|
17
|
+
home/
|
|
18
|
+
hello.flow.ts
|
|
19
|
+
cart.flow.ts
|
|
20
|
+
(user-stories)/ # not a page: a story that crosses pages
|
|
21
|
+
email-verification.flow.ts
|
|
22
|
+
(external)/hoppscotch/ # a tool on another origin
|
|
23
|
+
post.flow.ts
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
- **`<area>/<page>/`** matches the app URL, like the map. Open the folder and you see every way a user can go through that
|
|
27
|
+
page: the happy path, each failure, each bad input.
|
|
28
|
+
- **`(user-stories)/`** (any `(group)` name) is for flows that don't belong to one page: checkout end to end, onboarding,
|
|
29
|
+
"a viewer is locked out". Parentheses mean organizational only, as in the map.
|
|
30
|
+
- **A file is one scenario**, named for the outcome (`success`, `wrong-password`), not for the Blocks it happens to use.
|
|
31
|
+
An export is `<page><Outcome>Flow` (`loginWrongPasswordFlow`) so `--blocks` names stay unique across the project; a file path works too (`waygraph run src/flows/auth/login/success.flow.ts`).
|
|
32
|
+
|
|
33
|
+
## Writing one
|
|
34
|
+
|
|
35
|
+
- Build it with `engine.map({ memStub })…end()`; nest another with `.flow(sub, { reset: true })`. No `defineFlow([...])`,
|
|
36
|
+
no nested `withTitle(withMemStub(...))`, and `.end()` takes nothing.
|
|
37
|
+
- The flow's name and narration are ctx stubs chained on the Block where they apply: `ctx.title("…")`, `ctx.ring(…)`.
|
|
38
|
+
- A flow expected to fail (a locked-out user) says so in `map({ expectedFailure: "…" })`.
|
|
39
|
+
- A step's speed in the demo is `{ pace }`: `.method(FillBlock, { pace: "blitz" })`.
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import "
|
|
10
|
-
import "../map/(app_base)/home/_page.block.js";
|
|
1
|
+
import { engine } from "../../../config/waygraph.config.js";
|
|
2
|
+
import { DemoSel } from "../../map/(app_base)/home/_sel.js";
|
|
3
|
+
import { NavHomeBlock } from "../../map/(app_base)/home/_nav.block.js";
|
|
4
|
+
import { AddItemBlock } from "../../map/(app_base)/home/_methods/add-item.effect.block.js";
|
|
5
|
+
import { AssertItemAddedBlock } from "../../map/(app_base)/home/_methods/assert-item-added.method.block.js";
|
|
6
|
+
import { RemoveItemBlock } from "../../map/(app_base)/home/_methods/remove-item.effect.block.js";
|
|
7
|
+
import { ClearCartBlock } from "../../map/(app_base)/home/_methods/clear-cart.method.block.js";
|
|
8
|
+
import "../../states/demo.mem-stubs.js";
|
|
9
|
+
import "../../map/(app_base)/home/_page.block.js";
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// `memStub: true` fills SelectedItem (alpha) from src/states/demo.mem-stubs.ts; --data overrides it.
|
|
11
|
+
// `map({ memStub: true })` fills SelectedItem (alpha) from src/states/demo.mem-stubs.ts; --data overrides it.
|
|
15
12
|
const AddShown = AddItemBlock.stubBefore((ctx) => {
|
|
16
13
|
ctx.ring("add", { selector: DemoSel.catalog, label: "Catalog" });
|
|
17
14
|
})
|
|
@@ -38,13 +35,17 @@ const ClearShown = ClearCartBlock.stubBefore((ctx) => {
|
|
|
38
35
|
ctx.ring("cart", { selector: DemoSel.cartCount, label: "Empty cart", duration: true });
|
|
39
36
|
});
|
|
40
37
|
|
|
41
|
-
export const
|
|
42
|
-
.map()
|
|
38
|
+
export const homeCartFlow = engine
|
|
39
|
+
.map({ memStub: true })
|
|
43
40
|
.start()
|
|
44
|
-
.gotoPage(
|
|
41
|
+
.gotoPage(
|
|
42
|
+
NavHomeBlock.stubBefore((ctx) => {
|
|
43
|
+
ctx.title("Scaffold: Shop (Effect + clear)");
|
|
44
|
+
}),
|
|
45
|
+
)
|
|
45
46
|
.method(AddShown)
|
|
46
47
|
.assert(AssertItemAddedBlock)
|
|
47
48
|
.method(RemoveShown)
|
|
48
49
|
.method(AddShown)
|
|
49
50
|
.method(ClearShown)
|
|
50
|
-
.end(
|
|
51
|
+
.end();
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { NavDocsBlock } from "../map/(app_base)/docs/_nav.block.js";
|
|
1
|
+
import { engine } from "../../../config/waygraph.config.js";
|
|
2
|
+
import { DemoSel } from "../../map/(app_base)/home/_sel.js";
|
|
3
|
+
import { NavHomeBlock } from "../../map/(app_base)/home/_nav.block.js";
|
|
4
|
+
import { AssertHelloBlock } from "../../map/(app_base)/home/_methods/assert-hello.method.block.js";
|
|
5
|
+
import { NavDocsBlock } from "../../map/(app_base)/docs/_nav.block.js";
|
|
7
6
|
// Page hubs registered for auto/docs grouping (arrival-only after nav).
|
|
8
|
-
import "
|
|
9
|
-
import "
|
|
10
|
-
|
|
11
|
-
const engine = new Engine(config);
|
|
7
|
+
import "../../map/(app_base)/home/_page.block.js";
|
|
8
|
+
import "../../map/(app_base)/docs/_page.block.js";
|
|
12
9
|
|
|
13
10
|
/** Smoke: nav + assert (no mem), then nav to the sibling docs/ page. Green offline. */
|
|
14
|
-
export const
|
|
11
|
+
export const homeHelloFlow = engine
|
|
15
12
|
.map()
|
|
16
13
|
.start()
|
|
17
14
|
.gotoPage(
|
|
18
|
-
NavHomeBlock.
|
|
15
|
+
NavHomeBlock.stubBefore((ctx) => {
|
|
16
|
+
ctx.title("Scaffold: Hello Waygraph");
|
|
17
|
+
}).stubAfter((ctx) => {
|
|
19
18
|
ctx.ring("title", { selector: DemoSel.title, label: "Home heading", duration: true });
|
|
20
19
|
}).stubOnError((ctx) => {
|
|
21
20
|
ctx.ring("title", { selector: DemoSel.title, label: "Home heading at failure" });
|
|
@@ -40,4 +39,4 @@ export const exampleFlow = engine
|
|
|
40
39
|
}),
|
|
41
40
|
)
|
|
42
41
|
.gotoPage(NavDocsBlock)
|
|
43
|
-
.end(
|
|
42
|
+
.end();
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { test, expect } from "@playwright/test";
|
|
2
2
|
import { MemPage, checkpoint, seedMemStub } from "waygraph";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { homeHelloFlow } from "../src/flows/home/hello.flow.js";
|
|
4
|
+
import { homeCartFlow } from "../src/flows/home/cart.flow.js";
|
|
5
5
|
|
|
6
6
|
test("example flow reaches Docs (home -> assert -> sibling docs/ page)", async ({ context }) => {
|
|
7
|
-
const result = await
|
|
7
|
+
const result = await homeHelloFlow.run(context, new MemPage());
|
|
8
8
|
expect(result).toEqual(checkpoint("Docs"));
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
test("shop flow adds then clears (Effect + Method)", async ({ context }) => {
|
|
12
12
|
const mem = new MemPage();
|
|
13
|
-
seedMemStub(mem,
|
|
14
|
-
const result = await
|
|
13
|
+
seedMemStub(mem, homeCartFlow);
|
|
14
|
+
const result = await homeCartFlow.run(context, mem);
|
|
15
15
|
expect(result).toEqual(checkpoint("CartEmpty"));
|
|
16
16
|
});
|
|
@@ -2,9 +2,9 @@ import { test, expect } from "@playwright/test";
|
|
|
2
2
|
import { createServer, type Server } from "node:http";
|
|
3
3
|
import { MemPage, checkpoint } from "waygraph";
|
|
4
4
|
import config from "../config/waygraph.config.js";
|
|
5
|
-
import { hoppscotchGetFlow } from "../src/flows/hoppscotch
|
|
6
|
-
import { hoppscotchAuthFlow } from "../src/flows/hoppscotch
|
|
7
|
-
import { hoppscotchPostFlow } from "../src/flows/hoppscotch
|
|
5
|
+
import { hoppscotchGetFlow } from "../src/flows/(external)/hoppscotch/get.flow.js";
|
|
6
|
+
import { hoppscotchAuthFlow } from "../src/flows/(external)/hoppscotch/auth.flow.js";
|
|
7
|
+
import { hoppscotchPostFlow } from "../src/flows/(external)/hoppscotch/post.flow.js";
|
|
8
8
|
import {
|
|
9
9
|
ExpectedResponseHeader,
|
|
10
10
|
ExpectedResponseText,
|
|
@@ -2,12 +2,12 @@ import { test, expect } from "@playwright/test";
|
|
|
2
2
|
import { spawnSync } from "node:child_process";
|
|
3
3
|
import net from "node:net";
|
|
4
4
|
import { MemPage, checkpoint } from "waygraph";
|
|
5
|
-
import {
|
|
5
|
+
import { emailVerificationFlow } from "../src/flows/(user-stories)/email-verification.flow.js";
|
|
6
6
|
import { ExpectedRecipient, ExpectedLinkPattern, ExpectedEmailContent } from "../src/states/demo.mem-keys.js";
|
|
7
7
|
import { HOME_URL } from "../src/map/(app_base)/home/_sel.js";
|
|
8
8
|
|
|
9
9
|
// Plays "the app sent a verification email": starts a throwaway Mailpit container, sends a real SMTP message,
|
|
10
|
-
// then runs
|
|
10
|
+
// then runs emailVerificationFlow against it, including the no-email and wrong-content failure paths.
|
|
11
11
|
|
|
12
12
|
function runMailpit(): { containerId: string; smtpPort: number; httpPort: number } {
|
|
13
13
|
const run = spawnSync("docker", ["run", "--rm", "-d", "-p", "0:1025", "-p", "0:8025", "axllent/mailpit"], {
|
|
@@ -80,7 +80,7 @@ async function withMailpit<T>(fn: (opts: { httpPort: number; smtpPort: number })
|
|
|
80
80
|
|
|
81
81
|
const VERIFICATION_CONTENT = "Please confirm your email address to finish setting up your account.";
|
|
82
82
|
|
|
83
|
-
test("
|
|
83
|
+
test("emailVerificationFlow: confirms arrival, confirms content, reads the real link, navigates to it", async ({
|
|
84
84
|
context,
|
|
85
85
|
}) => {
|
|
86
86
|
test.skip(!dockerAvailable(), "Docker not reachable in this environment");
|
|
@@ -100,7 +100,7 @@ test("mailVerifyFlow: confirms arrival, confirms content, reads the real link, n
|
|
|
100
100
|
mem.set(ExpectedRecipient({ email: recipient }));
|
|
101
101
|
mem.set(ExpectedLinkPattern, "verified=1");
|
|
102
102
|
mem.set(ExpectedEmailContent, VERIFICATION_CONTENT);
|
|
103
|
-
const result = await
|
|
103
|
+
const result = await emailVerificationFlow.run(context, mem);
|
|
104
104
|
expect(result).toEqual(checkpoint("HomeVerified"));
|
|
105
105
|
});
|
|
106
106
|
});
|
|
@@ -130,7 +130,7 @@ test("the same four mail-reading Blocks handle a second, unrelated email scenari
|
|
|
130
130
|
mem.set(ExpectedRecipient({ email: recipient }));
|
|
131
131
|
mem.set(ExpectedLinkPattern, "verified=1");
|
|
132
132
|
mem.set(ExpectedEmailContent, resetContent);
|
|
133
|
-
const result = await
|
|
133
|
+
const result = await emailVerificationFlow.run(context, mem);
|
|
134
134
|
expect(result).toEqual(checkpoint("HomeVerified"));
|
|
135
135
|
});
|
|
136
136
|
});
|
|
@@ -149,7 +149,7 @@ test("assert-email-received fails loud, naming itself, when no email ever arrive
|
|
|
149
149
|
// not just the leaf Block - real, useful QA context, not a bug - so this
|
|
150
150
|
// matches the accumulated name ending at assert-email-received, not an
|
|
151
151
|
// exact "failed after \"assert-email-received\"" alone.
|
|
152
|
-
await expect(
|
|
152
|
+
await expect(emailVerificationFlow.run(context, mem)).rejects.toThrow(
|
|
153
153
|
/trait "email-received" failed after ".*assert-email-received"/,
|
|
154
154
|
);
|
|
155
155
|
});
|
|
@@ -175,7 +175,7 @@ test("assert-email-content fails loud, naming itself, when the email's copy does
|
|
|
175
175
|
mem.set(ExpectedRecipient({ email: recipient }));
|
|
176
176
|
mem.set(ExpectedLinkPattern, "verified=1");
|
|
177
177
|
mem.set(ExpectedEmailContent, VERIFICATION_CONTENT);
|
|
178
|
-
await expect(
|
|
178
|
+
await expect(emailVerificationFlow.run(context, mem)).rejects.toThrow(
|
|
179
179
|
/trait "body-contains-expected-text" failed after ".*assert-email-content"/,
|
|
180
180
|
);
|
|
181
181
|
});
|