Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
test(frontend): follow the shared clock and the lazy AI setup page
milind-soniabd4189104f3
diff --git a/src/App.engine-status.test.ts b/src/App.engine-status.test.tsindex 6656fcfaae..db58d8382b 100644--- a/src/App.engine-status.test.ts+++ b/src/App.engine-status.test.ts@@ -14,6 +14,8 @@ vi.mock("./state/store", async (original) => ({vi.mock("./lib/analytics", () => ({ initAnalytics: () => {}, track: () => {}, emailGateDone: () => true }));const { default: App } = await import("./App");const { forgetWorkedEngines } = await import("./lib/onboarding");+// The AI setup page is fetched when it is first shown; fetched ahead here, it draws in the same render, as the checks need.+await (await import("./components/lazy-views")).NoEngines.preload();// Each test is a fresh page: which engines worked is remembered only for a page's own life.afterEach(() => { vi.unstubAllGlobals(); forgetWorkedEngines(); });diff --git a/src/components/SidebarThreadRow.relative-now.test.ts b/src/components/SidebarThreadRow.relative-now.test.tsindex 0b96a03067..d917afbeaa 100644--- a/src/components/SidebarThreadRow.relative-now.test.ts+++ b/src/components/SidebarThreadRow.relative-now.test.ts@@ -46,13 +46,18 @@ describe("relative clock tick", () => {addEventListener: (type, handler) => { (documentStub.listeners[type] ??= []).push(handler); },removeEventListener: (type, handler) => { documentStub.listeners[type] = (documentStub.listeners[type] ?? []).filter((entry) => entry !== handler); },};- vi.stubGlobal("window", {+ // The clock is the shared one in lib/shared-clock, which runs on the global timers (the window's, in the app).+ const timers = {setInterval: (callback: () => void, delay: number) => { const entry = { delay, fire: callback, cleared: false }; intervals.push(entry); return intervals.length; },clearInterval: (id: number) => { const entry = intervals[id - 1]; if (entry) entry.cleared = true; },- });+ };+ vi.stubGlobal("window", timers);+ vi.stubGlobal("setInterval", timers.setInterval);+ vi.stubGlobal("clearInterval", timers.clearInterval);vi.stubGlobal("document", documentStub);});- afterEach(() => { vi.useRealTimers(); vi.unstubAllGlobals(); });+ // Globals first: the timer stubs went on over the fake timers, so they come off before those do.+ afterEach(() => { vi.unstubAllGlobals(); vi.useRealTimers(); });it("starts at the wall clock, re-ticks every 30 seconds, and clears on unmount", () => {const start = Date.now();diff --git a/src/components/settings/settings-index.test.ts b/src/components/settings/settings-index.test.tsindex 3edd63b55c..81f0037cf4 100644--- a/src/components/settings/settings-index.test.ts+++ b/src/components/settings/settings-index.test.ts@@ -6,6 +6,7 @@ import {ADVANCED_PAGES, LEGACY_SETTINGS, SETTINGS_INDEX, SETTINGS_PAGES, fullContext, needsAdvanced, resolveSettingsTarget, searchSettings, visiblePages,type SettingsContext,} from "./settings-index";+import { SETTINGS_PAGE_IDS } from "./settings-pages";beforeEach(() => setLocale("en"));@@ -260,3 +261,7 @@ describe("search", () => {}});});++it("the boot-light page list names every Settings page and no other", () => {+ expect([...SETTINGS_PAGE_IDS].sort()).toEqual(SETTINGS_PAGES.map((page) => page.id).sort());+});