waygraph 0.12.24 → 0.12.25
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/dist/cli.js
CHANGED
|
@@ -1139,18 +1139,40 @@ async function ensureSelectorInView(page, selector) {
|
|
|
1139
1139
|
const loc = page.locator(selector).first();
|
|
1140
1140
|
await loc.scrollIntoViewIfNeeded().catch(() => {});
|
|
1141
1141
|
await page
|
|
1142
|
-
.evaluate((sel) => {
|
|
1142
|
+
.evaluate(async (sel) => {
|
|
1143
1143
|
const el = document.querySelector(sel);
|
|
1144
1144
|
if (!el) return;
|
|
1145
|
+
const waitScroll = (node, ms) =>
|
|
1146
|
+
new Promise((resolve) => {
|
|
1147
|
+
let done = false;
|
|
1148
|
+
const finish = () => {
|
|
1149
|
+
if (done) return;
|
|
1150
|
+
done = true;
|
|
1151
|
+
node.removeEventListener("scrollend", finish);
|
|
1152
|
+
clearTimeout(t);
|
|
1153
|
+
resolve();
|
|
1154
|
+
};
|
|
1155
|
+
const t = setTimeout(finish, ms);
|
|
1156
|
+
try {
|
|
1157
|
+
node.addEventListener("scrollend", finish, { once: true });
|
|
1158
|
+
} catch {
|
|
1159
|
+
/* scrollend unsupported - timeout only */
|
|
1160
|
+
}
|
|
1161
|
+
});
|
|
1145
1162
|
try {
|
|
1146
|
-
el.scrollIntoView({ block: "center", inline: "center", behavior: "
|
|
1163
|
+
el.scrollIntoView({ block: "center", inline: "center", behavior: "smooth" });
|
|
1147
1164
|
} catch {
|
|
1148
1165
|
try {
|
|
1149
|
-
el.scrollIntoView(
|
|
1166
|
+
el.scrollIntoView({ block: "center", inline: "center" });
|
|
1150
1167
|
} catch {
|
|
1151
|
-
|
|
1168
|
+
try {
|
|
1169
|
+
el.scrollIntoView(true);
|
|
1170
|
+
} catch {
|
|
1171
|
+
/* ignore */
|
|
1172
|
+
}
|
|
1152
1173
|
}
|
|
1153
1174
|
}
|
|
1175
|
+
await waitScroll(document.scrollingElement || document.documentElement, 500);
|
|
1154
1176
|
let p = el.parentElement;
|
|
1155
1177
|
while (p && p !== document.documentElement && p !== document.body) {
|
|
1156
1178
|
const st = getComputedStyle(p);
|
|
@@ -1160,8 +1182,15 @@ async function ensureSelectorInView(page, selector) {
|
|
|
1160
1182
|
const er = el.getBoundingClientRect();
|
|
1161
1183
|
const pr = p.getBoundingClientRect();
|
|
1162
1184
|
if (er.left < pr.left || er.right > pr.right || er.top < pr.top || er.bottom > pr.bottom) {
|
|
1163
|
-
p.scrollLeft
|
|
1164
|
-
p.scrollTop
|
|
1185
|
+
const left = p.scrollLeft + (er.left + er.width / 2 - (pr.left + pr.width / 2));
|
|
1186
|
+
const top = p.scrollTop + (er.top + er.height / 2 - (pr.top + pr.height / 2));
|
|
1187
|
+
try {
|
|
1188
|
+
p.scrollTo({ left, top, behavior: "smooth" });
|
|
1189
|
+
} catch {
|
|
1190
|
+
p.scrollLeft = left;
|
|
1191
|
+
p.scrollTop = top;
|
|
1192
|
+
}
|
|
1193
|
+
await waitScroll(p, 500);
|
|
1165
1194
|
}
|
|
1166
1195
|
}
|
|
1167
1196
|
p = p.parentElement;
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"../..": {
|
|
20
|
-
"version": "0.12.
|
|
20
|
+
"version": "0.12.24",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"tsx": "^4.0.0"
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"waygraph": "bin/waygraph"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@playwright/test": "^1.
|
|
29
|
+
"@playwright/test": "^1.63.0",
|
|
30
30
|
"@types/node": "^26.0.0",
|
|
31
31
|
"typescript": "^5.6.0"
|
|
32
32
|
},
|
|
@@ -45,20 +45,29 @@ export const SubmitLoginActionBlock = defineMethodBlock<LoginPage, LoginSubmitOu
|
|
|
45
45
|
out.__state === "LoggedIn"
|
|
46
46
|
? [Trait.url({ pathname: "/inventory.html" })]
|
|
47
47
|
: [Trait.visible('[data-test="error"]')],
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
// Open lifecycle: set fixtures + rings inside the fn (not a closed slot object).
|
|
49
|
+
stubBefore: (ctx) => {
|
|
50
|
+
ctx.todos(["Enter username", "Enter password", "Click Login"]);
|
|
51
|
+
ctx.todoIndex(0);
|
|
52
|
+
ctx.highlights({
|
|
53
|
+
username: { selector: "#user-name", label: "Username" },
|
|
54
|
+
password: { selector: "#password", label: "Password" },
|
|
55
|
+
submit: { selector: "#login-button", label: "Login" },
|
|
56
|
+
});
|
|
57
|
+
},
|
|
58
|
+
stubAfter: (ctx) => {
|
|
59
|
+
// Sequential plan: bump index after a successful submit beat.
|
|
60
|
+
ctx.todos(["Enter username", "Enter password", "Click Login"]);
|
|
61
|
+
ctx.todoIndex(2);
|
|
52
62
|
},
|
|
53
|
-
stubAfter: {},
|
|
54
63
|
// Fail-path rings (demo step throw only) - locked-out / wrong-password
|
|
55
64
|
// bug-repro narration; success never shows these.
|
|
56
|
-
stubOnError: {
|
|
57
|
-
error
|
|
65
|
+
stubOnError: (ctx) => {
|
|
66
|
+
ctx.ring("error", {
|
|
58
67
|
selector: '[data-test="error"]',
|
|
59
68
|
label: "Login error banner",
|
|
60
69
|
duration: true,
|
|
61
|
-
}
|
|
70
|
+
});
|
|
62
71
|
},
|
|
63
72
|
},
|
|
64
73
|
});
|
package/package.json
CHANGED
|
@@ -45,18 +45,25 @@ export const SubmitLoginActionBlock = defineMethodBlock<LoginPage, LoginSubmitOu
|
|
|
45
45
|
out.__state === "LoggedIn"
|
|
46
46
|
? [Trait.url({ pathname: "/inventory.html" })]
|
|
47
47
|
: [Trait.visible('[data-test="error"]')],
|
|
48
|
-
stubBefore: {
|
|
49
|
-
username
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
stubBefore: (ctx) => {
|
|
49
|
+
ctx.todos(["Enter username", "Enter password", "Click Login"]);
|
|
50
|
+
ctx.todoIndex(0);
|
|
51
|
+
ctx.highlights({
|
|
52
|
+
username: { selector: "#user-name", label: "Username" },
|
|
53
|
+
password: { selector: "#password", label: "Password" },
|
|
54
|
+
submit: { selector: "#login-button", label: "Login" },
|
|
55
|
+
});
|
|
52
56
|
},
|
|
53
|
-
stubAfter: {
|
|
54
|
-
|
|
55
|
-
|
|
57
|
+
stubAfter: (ctx) => {
|
|
58
|
+
ctx.todos(["Enter username", "Enter password", "Click Login"]);
|
|
59
|
+
ctx.todoIndex(2);
|
|
60
|
+
},
|
|
61
|
+
stubOnError: (ctx) => {
|
|
62
|
+
ctx.ring("error", {
|
|
56
63
|
selector: '[data-test="error"]',
|
|
57
64
|
label: "Login error banner",
|
|
58
65
|
duration: true,
|
|
59
|
-
}
|
|
66
|
+
});
|
|
60
67
|
},
|
|
61
68
|
},
|
|
62
69
|
});
|