完成80%
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
const sleep = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
|
||||
const cdpPort = process.env.CDP_PORT || "9222";
|
||||
|
||||
const connect = async () => {
|
||||
const pages = await (await fetch("http://127.0.0.1:9222/json/list")).json();
|
||||
const pages = await (await fetch(`http://127.0.0.1:${cdpPort}/json/list`)).json();
|
||||
const page = pages.find((item) => item.type === "page" && item.url.startsWith("http://localhost:5173"));
|
||||
if (!page) throw new Error("Chrome debugging has no localhost:5173 page");
|
||||
|
||||
@@ -49,7 +50,7 @@ const waitFor = async (send, expression, message) => {
|
||||
const origin = process.argv[2] || "http://localhost:5173";
|
||||
|
||||
const openG03 = async (send, suffix = "") => {
|
||||
const url = `${origin}/?g03CreateAudit=${Date.now()}#${"/pages/genealogy/g03-create-genealogy"}${suffix}`;
|
||||
const url = `${origin}/?g03CreateAudit=${Date.now()}${suffix}#${"/pages/genealogy/g03-create-genealogy"}`;
|
||||
await send("Page.navigate", { url });
|
||||
await waitFor(send, `location.href === ${JSON.stringify(url)}`, "G03 navigation failed");
|
||||
await waitFor(send, "Boolean(document.querySelector('.create-card'))", "G03 create form did not render");
|
||||
@@ -77,6 +78,21 @@ const run = async () => {
|
||||
const fakeControl = await valueOf(send, "Boolean(document.querySelector('.flow-success-dialog'))");
|
||||
if (fakeControl) throw new Error("G03 must not expose the retired local bootstrap flow");
|
||||
|
||||
await valueOf(send, `(() => {
|
||||
const input = document.querySelector('.create-card input');
|
||||
const setter = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value').set;
|
||||
setter.call(input, 'discard-check');
|
||||
input.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
document.querySelector('.header-back')?.click();
|
||||
return true;
|
||||
})()`);
|
||||
await waitFor(send, "Boolean(document.querySelector('.app-dialog-layer'))", "G03 dirty back did not require discard confirmation");
|
||||
await valueOf(send, "document.querySelector('.app-dialog__actions .app-button:first-child')?.click()");
|
||||
await waitFor(send, "!document.querySelector('.app-dialog-layer')", "G03 discard cancellation did not close the dialog");
|
||||
if ((await valueOf(send, "document.querySelector('.create-card input')?.value")) !== "discard-check") {
|
||||
throw new Error("G03 discard cancellation lost the draft");
|
||||
}
|
||||
|
||||
for (const size of [{ width: 320, height: 568 }, { width: 360, height: 800 }, { width: 412, height: 915 }]) {
|
||||
await send("Emulation.setDeviceMetricsOverride", { ...size, deviceScaleFactor: 1, mobile: true });
|
||||
await openG03(send, `&width=${size.width}`);
|
||||
|
||||
Reference in New Issue
Block a user