Skip to content

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

test: 稳定画布测试的语言和点击时机

Zhehui Bi76b4a4ff47eb
diff --git a/scripts/testing/team-canvas-ui.e2e.test.ts b/scripts/testing/team-canvas-ui.e2e.test.ts
index 1ad3223e3f..6ba9f10f25 100644
--- a/scripts/testing/team-canvas-ui.e2e.test.ts
+++ b/scripts/testing/team-canvas-ui.e2e.test.ts
@@ -191,6 +191,12 @@ type BotRecord = {
expect(await evaluate("Boolean(document.querySelector('[data-team-canvas]'))")).toBe(true);
await expect.poll(() => evaluate("[...document.querySelectorAll('[data-team-canvas] [aria-label^=\"Desktop for \"]')].map(button => button.getAttribute('aria-label'))"))
.toEqual(["Desktop for Ben"]);
+ // Opening settings resizes the canvas. Wait until the recentered card can receive a real pointer click.
+ await expect.poll(() => evaluate(`(() => {
+ const button = document.querySelector('[aria-label="Desktop for Ben"]');
+ const rect = button?.getBoundingClientRect();
+ return Boolean(rect && button.contains(document.elementFromPoint(rect.x + rect.width / 2, rect.y + rect.height / 2)));
+ })()`), { timeout: 10_000 }).toBe(true);
await click("Desktop for Ben");
await expect.poll(() => evaluate("document.querySelector('[data-bot-settings-section=access] > button')?.getAttribute('aria-expanded')")).toBe("true");
await click("Close settings");
diff --git a/scripts/testing/threads-preview.tsx b/scripts/testing/threads-preview.tsx
index 0d70eb50a9..8acc631aed 100644
--- a/scripts/testing/threads-preview.tsx
+++ b/scripts/testing/threads-preview.tsx
@@ -2,6 +2,7 @@ import { createRoot } from "react-dom/client";
import App from "../../src/App";
import { setAnalyticsEnabled, setEmailGateDone } from "../../src/lib/analytics";
import { ADVANCED_MODE_KEY, setAdvancedMode } from "../../src/lib/interface-mode";
+import { languageChoice, setLanguageChoice } from "../../src/lib/language-preference";
import { BOAT_OFFER_NOTICE, GROK_MOVE_NOTICE, MODELGO_OFFER_NOTICE } from "../../src/lib/notices";
import { markSimpleModePromptSeen } from "../../src/lib/simple-mode-prompt";
import { applySkinChoice, readSkinChoice } from "../../src/lib/skins";
@@ -14,6 +15,8 @@ if (new URLSearchParams(location.search).has("ombVoiceProbe")) {
(window as typeof window & { __ombVoiceProbe?: unknown[] }).__ombVoiceProbe = [];
}
setAnalyticsEnabled(false);
+// Tests use English accessibility names from the first render, including after a reload.
+if (languageChoice() === null) setLanguageChoice("en");
// Every launch is a new browser, so it opens in Simple mode as a new install does, unless a test chose a mode first.
// ?onboarding=1 plays a brand-new install.
if (localStorage.getItem(ADVANCED_MODE_KEY) == null) setAdvancedMode(false);