Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

test: 等待侧栏菜单和团队消息更新

Zhehui Bibfd89b5d783b
diff --git a/scripts/testing/rail-profile-ui.e2e.test.ts b/scripts/testing/rail-profile-ui.e2e.test.ts
index d51fdca4b9..8970fcb6ed 100644
--- a/scripts/testing/rail-profile-ui.e2e.test.ts
+++ b/scripts/testing/rail-profile-ui.e2e.test.ts
@@ -68,6 +68,7 @@ function harness(get: () => { world: HomeWorld; shots: string }) {
Boolean, 10_000, selector);
/** A right-click on a tile, then its menu as React drew it. */
const menu = async (id: string) => {
+ await until(() => rail<boolean>("!document.querySelector('[data-rail-menu]')"), Boolean, 10_000, "the previous menu to close");
await rail(`document.querySelector('[data-rail-place="${id}"]').dispatchEvent(new MouseEvent("contextmenu", { bubbles: true, cancelable: true }))`);
await until(() => rail<boolean>(`Boolean(document.querySelector('[data-rail-menu="${id}"]'))`), Boolean, 10_000, `${id}'s menu`);
};
diff --git a/scripts/testing/team-map-everyone-ui.e2e.test.ts b/scripts/testing/team-map-everyone-ui.e2e.test.ts
index f47efc21cf..39b79dee81 100644
--- a/scripts/testing/team-map-everyone-ui.e2e.test.ts
+++ b/scripts/testing/team-map-everyone-ui.e2e.test.ts
@@ -52,7 +52,6 @@ type Bot = { id: string; name: string; threadId: string; chiefOfStaff?: boolean;
await call("PATCH", `/api/bots/${first.id}`, { chiefOfStaff: true, acknowledgePeerScope: true });
chief = { ...first, chiefOfStaff: true };
}
- await evaluate("location.reload(); true");
await expect.poll(pageText, { timeout: 20_000 }).toContain("Calendar");
if (!await press("Team map")) await press("Tools");
await expect.poll(() => press("Team map").then(() => evaluate("Boolean(document.querySelector('textarea[aria-label=\"Message bots on the map\"]'))")), { timeout: 20_000 }).toBe(true);
@@ -76,16 +75,14 @@ type Bot = { id: string; name: string; threadId: string; chiefOfStaff?: boolean;
// A stop reaches every bot at once, as its own words, so each bot's own send path stops it.
await say("@everyone stop");
await send();
- for (const bot of await bots()) await expect.poll(() => linesTo(bot), { message: bot.name }).toContain("stop");
+ for (const bot of await bots()) await expect.poll(() => linesTo(bot), { message: bot.name, timeout: 10_000 }).toContain("stop");
await shot("everyone-stop");
// No Chief: everyone gets the line, as before.
await call("PATCH", `/api/bots/${chief.id}`, { chiefOfStaff: false });
- await evaluate("location.reload(); true");
- await expect.poll(() => press("Team map").then(() => evaluate("Boolean(document.querySelector('textarea[aria-label=\"Message bots on the map\"]'))")), { timeout: 20_000 }).toBe(true);
await say("@everyone hello all");
await expect.poll(pageText).not.toContain("who passes it on");
await send();
- for (const bot of await bots()) await expect.poll(() => linesTo(bot), { message: bot.name }).toContain("@everyone hello all");
+ for (const bot of await bots()) await expect.poll(() => linesTo(bot), { message: bot.name, timeout: 10_000 }).toContain("@everyone hello all");
} finally { await waitForExit(child, { signal: "SIGINT", graceMs: 30_000 }); }
}, 720_000);