waygraph 0.11.2 → 0.12.4
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 +6 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +192 -68
- package/dist/engine.d.ts +24 -2
- package/dist/engine.js +56 -2
- package/dist/highlights.d.ts +53 -6
- package/dist/highlights.js +65 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.js +2 -2
- package/dist/trait.js +3 -1
- package/dist/types.d.ts +7 -0
- package/examples/saucedemo/.waygraph-videos/page@35b5c5324773dbfa5232d17a283e1ef8.webm +0 -0
- package/examples/saucedemo/.waygraph-videos/page@78092e8c89a2e7b54444ba6d108c8893.webm +0 -0
- package/examples/saucedemo/package-lock.json +1 -1
- package/examples/saucedemo/package.json +1 -0
- package/examples/saucedemo/src/blocks/saucedemo-web/checkout-step-two/methods/finish-order.method.block.ts +6 -0
- package/examples/saucedemo/src/blocks/saucedemo-web/ff-owner-auth.block.ts +17 -0
- package/examples/saucedemo/src/blocks/saucedemo-web/methods/submit-login.method.block.ts +18 -2
- package/examples/saucedemo/src/flows/checkout.flow.ts +27 -16
- package/examples/saucedemo/src/flows/stub-on-error.flow.ts +48 -0
- package/package.json +1 -1
- package/templates/quickstart/src/blocks/saucedemo-web/checkout-step-two/methods/finish-order.method.block.ts +6 -0
- package/templates/quickstart/src/blocks/saucedemo-web/ff-owner-auth.block.ts +17 -0
- package/templates/quickstart/src/blocks/saucedemo-web/methods/submit-login.method.block.ts +16 -2
- package/templates/quickstart/src/flows/checkout.flow.ts +20 -18
|
@@ -26,6 +26,7 @@ export const FinishOrderBlock = defineMethodBlock<CheckoutOverviewPage, OrderCom
|
|
|
26
26
|
selector: ".complete-header",
|
|
27
27
|
label: "Order confirmed",
|
|
28
28
|
detail: "Thank you for your order!",
|
|
29
|
+
duration: true,
|
|
29
30
|
},
|
|
30
31
|
},
|
|
31
32
|
// Shown AFTER act (order already placed) - selectors must match the
|
|
@@ -35,18 +36,23 @@ export const FinishOrderBlock = defineMethodBlock<CheckoutOverviewPage, OrderCom
|
|
|
35
36
|
caption: "Checkout is a short pipeline",
|
|
36
37
|
detail: "Cart -> info -> overview -> done. You just placed the order.",
|
|
37
38
|
tag: "YAP",
|
|
39
|
+
duration: true,
|
|
38
40
|
},
|
|
39
41
|
{
|
|
40
42
|
caption: "Completion page is the durable proof",
|
|
41
43
|
detail: "The thank-you header is what verify asserts on.",
|
|
42
44
|
tag: "YAP",
|
|
43
45
|
selector: ".complete-header",
|
|
46
|
+
duration: 2500,
|
|
47
|
+
fastMode: 700,
|
|
44
48
|
},
|
|
45
49
|
{
|
|
46
50
|
caption: "Episode continues after this yap",
|
|
47
51
|
detail: "Next step rings the same banner, then you move on.",
|
|
48
52
|
tag: "YAP",
|
|
49
53
|
selector: ".complete-header",
|
|
54
|
+
duration: true,
|
|
55
|
+
fastMode: 500,
|
|
50
56
|
},
|
|
51
57
|
],
|
|
52
58
|
},
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { fastForwardComposeBlock } from "waygraph";
|
|
2
|
+
import { NavLoginBlock } from "./nav-login.block.js";
|
|
3
|
+
import { SubmitLoginForFlow } from "./methods/submit-login-for-flow.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Kind: FFCompose (fast-forward)
|
|
7
|
+
* Helper: fastForwardComposeBlock
|
|
8
|
+
* Route: saucedemo-web/ (auth prefix)
|
|
9
|
+
*
|
|
10
|
+
* Collapses nav-login + submit-login into one opaque demo/run step so
|
|
11
|
+
* checkout demos skip watching auth. Use --ff-expand to gate inners again.
|
|
12
|
+
* loginFlow stays expanded for Sign In episode narration.
|
|
13
|
+
*/
|
|
14
|
+
export const FfOwnerAuthBlock = fastForwardComposeBlock("ff-owner-auth", [
|
|
15
|
+
NavLoginBlock,
|
|
16
|
+
SubmitLoginForFlow,
|
|
17
|
+
]);
|
|
@@ -26,9 +26,16 @@ export const SubmitLoginActionBlock = defineMethodBlock<LoginPage, LoginSubmitOu
|
|
|
26
26
|
await page.locator("#login-button").click({ noWaitAfter: true });
|
|
27
27
|
},
|
|
28
28
|
async observe(page): Promise<LoginObserve> {
|
|
29
|
+
// Race inventory nav vs error banner - locked_out / wrong password show
|
|
30
|
+
// Epic sadface immediately; do not burn the full inventory timeout.
|
|
31
|
+
const inventory = page.waitForURL(/\/inventory\.html/, { timeout: 8_000 }).then(() => "success" as const);
|
|
32
|
+
const errorBanner = page
|
|
33
|
+
.locator('[data-test="error"]')
|
|
34
|
+
.first()
|
|
35
|
+
.waitFor({ state: "visible", timeout: 8_000 })
|
|
36
|
+
.then(() => "failure" as const);
|
|
29
37
|
try {
|
|
30
|
-
await
|
|
31
|
-
return "success";
|
|
38
|
+
return await Promise.race([inventory, errorBanner]);
|
|
32
39
|
} catch {
|
|
33
40
|
return "failure";
|
|
34
41
|
}
|
|
@@ -44,5 +51,12 @@ export const SubmitLoginActionBlock = defineMethodBlock<LoginPage, LoginSubmitOu
|
|
|
44
51
|
submit: { selector: "#login-button", label: "Login" },
|
|
45
52
|
},
|
|
46
53
|
stubAfter: {},
|
|
54
|
+
stubOnError: {
|
|
55
|
+
error: {
|
|
56
|
+
selector: '[data-test="error"]',
|
|
57
|
+
label: "Login error banner",
|
|
58
|
+
duration: true,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
47
61
|
},
|
|
48
62
|
});
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Engine, start, end, withTitle, withHighlightFixtures } from "waygraph";
|
|
2
2
|
import type {
|
|
3
|
-
LoginPage,
|
|
4
3
|
LoggedIn,
|
|
5
4
|
ItemInCart,
|
|
6
5
|
CartPage,
|
|
@@ -8,8 +7,7 @@ import type {
|
|
|
8
7
|
CheckoutOverviewPage,
|
|
9
8
|
OrderComplete,
|
|
10
9
|
} from "../states/checkout.states.js";
|
|
11
|
-
import {
|
|
12
|
-
import { SubmitLoginForFlow } from "../blocks/saucedemo-web/methods/submit-login-for-flow.js";
|
|
10
|
+
import { FfOwnerAuthBlock } from "../blocks/saucedemo-web/ff-owner-auth.block.js";
|
|
13
11
|
import { AddToCartBlock } from "../blocks/saucedemo-web/inventory/methods/add-to-cart.effect.block.js";
|
|
14
12
|
import { NavCartBlock } from "../blocks/saucedemo-web/cart/nav-cart.block.js";
|
|
15
13
|
import { NavCheckoutInfoBlock } from "../blocks/saucedemo-web/cart/nav-checkout-info.block.js";
|
|
@@ -18,18 +16,10 @@ import { FinishOrderBlock } from "../blocks/saucedemo-web/checkout-step-two/meth
|
|
|
18
16
|
|
|
19
17
|
const engine = new Engine({ headless: false, slowMo: 250 });
|
|
20
18
|
|
|
21
|
-
//
|
|
22
|
-
// Explicit type args: AddToCartBlock's In is Checkpoint<string> (wildcard),
|
|
23
|
-
// which trips defineFlow overload inference across a long array.
|
|
24
|
-
//
|
|
25
|
-
// Demo narration showcase (waygraph 0.11+):
|
|
26
|
-
// - Block stubs: submit-login stubBefore, add-to-cart / finish-order stubAfter
|
|
27
|
-
// - Flow fixtures: ticket-style captions (unlimited purposes on .flow.ts)
|
|
28
|
-
// - Slides on finish-order: multi-step yap with Next between slides
|
|
19
|
+
// Auth is one FFCompose step so demo pacing skips login; --ff-expand for inners.
|
|
29
20
|
export const checkoutFlow = withHighlightFixtures(
|
|
30
21
|
withTitle(
|
|
31
22
|
engine.defineFlow<
|
|
32
|
-
LoginPage,
|
|
33
23
|
LoggedIn,
|
|
34
24
|
ItemInCart,
|
|
35
25
|
CartPage,
|
|
@@ -38,8 +28,7 @@ export const checkoutFlow = withHighlightFixtures(
|
|
|
38
28
|
OrderComplete
|
|
39
29
|
>([
|
|
40
30
|
start,
|
|
41
|
-
|
|
42
|
-
SubmitLoginForFlow,
|
|
31
|
+
FfOwnerAuthBlock,
|
|
43
32
|
AddToCartBlock,
|
|
44
33
|
NavCartBlock,
|
|
45
34
|
NavCheckoutInfoBlock,
|
|
@@ -50,15 +39,26 @@ export const checkoutFlow = withHighlightFixtures(
|
|
|
50
39
|
"Owner: Full Checkout",
|
|
51
40
|
),
|
|
52
41
|
{
|
|
42
|
+
"ff-owner-auth": {
|
|
43
|
+
stubAfter: {
|
|
44
|
+
inventory: {
|
|
45
|
+
label: "Signed in (fast-forward)",
|
|
46
|
+
detail: "Auth collapsed via FFCompose - interesting work starts here.",
|
|
47
|
+
tag: "AC",
|
|
48
|
+
duration: true,
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
53
52
|
"submit-login": {
|
|
54
53
|
stubBefore: {
|
|
55
54
|
username: {
|
|
56
55
|
label: "Demo user",
|
|
57
|
-
detail: "standard_user from Mem
|
|
56
|
+
detail: "standard_user from Mem - library block stays neutral.",
|
|
58
57
|
tag: "AC",
|
|
58
|
+
duration: true,
|
|
59
59
|
},
|
|
60
|
-
password: { label: "Password", detail: "Filled from Mem credentials." },
|
|
61
|
-
submit: { label: "Sign in", tag: "GATE" },
|
|
60
|
+
password: { label: "Password", detail: "Filled from Mem credentials.", duration: 1500 },
|
|
61
|
+
submit: { label: "Sign in", tag: "GATE", duration: true, fastMode: 500 },
|
|
62
62
|
},
|
|
63
63
|
},
|
|
64
64
|
"add-to-cart": {
|
|
@@ -67,6 +67,7 @@ export const checkoutFlow = withHighlightFixtures(
|
|
|
67
67
|
label: "Cart now has the item",
|
|
68
68
|
detail: "Badge updates after Add to cart.",
|
|
69
69
|
tag: "AC",
|
|
70
|
+
duration: true,
|
|
70
71
|
},
|
|
71
72
|
},
|
|
72
73
|
},
|
|
@@ -76,9 +77,10 @@ export const checkoutFlow = withHighlightFixtures(
|
|
|
76
77
|
label: "Order placed",
|
|
77
78
|
detail: "Completion header is the durable proof.",
|
|
78
79
|
tag: "GATE",
|
|
80
|
+
duration: 2500,
|
|
81
|
+
fastMode: 700,
|
|
79
82
|
},
|
|
80
83
|
},
|
|
81
|
-
// Optional: fixture can replace block slides; leave unset to use block slides.
|
|
82
84
|
},
|
|
83
85
|
},
|
|
84
86
|
);
|