Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(tests): keep DOM storage on Node 25+ and astral underscores on Node 26
Ooi Pin Jun17fa6592846e
diff --git a/shared/plain-preview.ts b/shared/plain-preview.tsindex ec89cc56fe..53305e7ae1 100644--- a/shared/plain-preview.ts+++ b/shared/plain-preview.ts@@ -34,7 +34,7 @@ export function plainPreviewText(text: string): string {// Underscores inside a word (snake_case) and a lone * (2 * 3) are not emphasis.out = out.replace(/(\*{1,3})(?=\S)([\s\S]*?\S)\1/gu, "$2");out = out.replace(/(_{1,3})(?=\S)([\s\S]*?\S)\1(?![\p{L}\p{N}])/gu, (match, _marks: string, inner: string, offset: number, whole: string) => {- if (/[\p{L}\p{N}]$/u.test(whole.slice(0, offset))) return match;+ if (/(?:\p{L}|\p{N})$/u.test(whole.slice(0, offset))) return match;return inner;});out = out.replace(/~~(?=\S)([\s\S]*?\S)~~/g, "$1");diff --git a/src/components/onboarding/WelcomeFlow.test.ts b/src/components/onboarding/WelcomeFlow.test.tsindex 2965640a90..efbb2fea01 100644--- a/src/components/onboarding/WelcomeFlow.test.ts+++ b/src/components/onboarding/WelcomeFlow.test.ts@@ -66,17 +66,13 @@ const toChief = async (label = "Next") => {await tick(CHIEF_GUARD_MS);};const saved = () => f.api.mock.calls.filter(([path, init]) => path === "/api/config" && init?.method === "PUT").map(([, init]) => JSON.parse(init.body));-const memoryStorage = () => {- const values = new Map<string, string>();- return { getItem: (k: string) => values.get(k) ?? null, setItem: (k: string, v: string) => void values.set(k, String(v)), removeItem: (k: string) => void values.delete(k), clear: () => values.clear() };-};beforeEach(() => {vi.useFakeTimers();HTMLElement.prototype.animate = vi.fn(() => ({ onfinish: null, oncancel: null, cancel() {} }) as unknown as Animation);setLocale("en");- vi.stubGlobal("localStorage", memoryStorage());- vi.stubGlobal("sessionStorage", memoryStorage());+ localStorage.clear();+ sessionStorage.clear();f.dispatch.mockReset();f.landed.mockReset();f.onDone.mockReset();diff --git a/src/lib/plain-preview.test.ts b/src/lib/plain-preview.test.tsindex fc3ebe442e..d83adc31ec 100644--- a/src/lib/plain-preview.test.ts+++ b/src/lib/plain-preview.test.ts@@ -25,6 +25,7 @@ describe("plainPreviewText", () => {["a_b_", "a_b_"],["_a_b_c_", "a_b_c"],["π_a_", "π_a_"],+ ["π_a_", "π_a_"],["_a_π", "_a_π"],["\\*a\\*b", "*a*b"],["`*a*b`", "*a*b"],diff --git a/src/state/snapshot-navigation.test.ts b/src/state/snapshot-navigation.test.tsindex a2e7ef5101..cf51b1d398 100644--- a/src/state/snapshot-navigation.test.ts+++ b/src/state/snapshot-navigation.test.ts@@ -71,11 +71,7 @@ beforeEach(async () => {snapshot = deferred();switchResponse = undefined;newTaskResponse = undefined;- const stored = new Map<string, string>();- vi.stubGlobal("localStorage", {- getItem: (key: string) => stored.get(key) ?? null, setItem: (key: string, value: string) => { stored.set(key, String(value)); },- removeItem: (key: string) => { stored.delete(key); }, clear: () => stored.clear(),- });+ localStorage.clear();vi.stubGlobal("EventSource", FixtureEventSource);vi.stubGlobal("fetch", async (path: string, init?: RequestInit) => {if (path.startsWith("/api/bots?")) {diff --git a/src/testing/happy-dom-storage.test.ts b/src/testing/happy-dom-storage.test.tsnew file mode 100644index 0000000000..10e3d6377e--- /dev/null+++ b/src/testing/happy-dom-storage.test.ts@@ -0,0 +1,9 @@+// @vitest-environment happy-dom+import { expect, it } from "vitest";++it("reads a key written on localStorage back through window.localStorage", () => {+ localStorage.setItem("omb", "kept");+ expect(window.localStorage.getItem("omb")).toBe("kept");+ localStorage.removeItem("omb");+ expect(window.localStorage.getItem("omb")).toBeNull();+});diff --git a/vite.config.ts b/vite.config.tsindex 7724f1635e..2daa28416f 100644--- a/vite.config.ts+++ b/vite.config.ts@@ -54,6 +54,9 @@ export default defineConfig({},test: {environment: "node",+ // Node 25+ defines localStorage before happy-dom. Without this flag the getter+ // shadows the DOM storage, so UI tests see an empty or missing store.+ execArgv: ["--no-experimental-webstorage"],include,// OMB_VITEST_E2E=host (CI's Windows and macOS shards) leaves the e2e files that run on Linux only.exclude: [...configDefaults.exclude, ...(hostE2eOnly() ? portableE2eFiles(root, include) : [])],