From 4b8d2406a9a4cb247160715bc43c20b22e6f8f3e Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Thu, 12 Nov 2026 02:39:41 -0800 Subject: [PATCH] test(web): command palette tests clear a leaked last-used project (#35107) Upstream's own fix, cherry-picked unchanged. Browser test files share one origin's localStorage, so a last-used project left by an earlier file hides the "New thread in " row. "New thread in..." then becomes the first row and ArrowDown moves past it, which fails Test Web 2 on fork PRs whenever such a file runs before CommandPalette.browser.test.tsx in the same worker. (cherry picked from commit 5fae2b5124d8c491f242c004a6c6ef8602517719) Co-Authored-By: Claude Opus 5.5 --- apps/web/src/components/CommandPalette.browser.test.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/web/src/components/CommandPalette.browser.test.tsx b/apps/web/src/components/CommandPalette.browser.test.tsx index c7106f0cff289..8292121ac2ceb 100644 --- a/apps/web/src/components/CommandPalette.browser.test.tsx +++ b/apps/web/src/components/CommandPalette.browser.test.tsx @@ -5,6 +5,8 @@ import { page, userEvent } from "vite-plus/test/browser"; import { act, render } from "../../test/render"; import { openCommandPalette } from "../commandPaletteBus"; import { useCommandPaletteStore } from "../commandPaletteStore"; +import { LAST_USED_PROJECT_STORAGE_KEY } from "../hooks/useHandleNewThread"; +import { removeLocalStorageItem } from "../hooks/useLocalStorage"; import { makeThreadFixture } from "../test-fixtures"; import type { Project, Thread } from "../types"; import { CommandPalette } from "./CommandPalette"; @@ -20,6 +22,9 @@ vi.mock("../state/entities", async (original) => ({ })); function setup(state: { projects?: ReadonlyArray; threads?: ReadonlyArray } = {}) { + // Earlier browser test files share this origin's localStorage; a remembered project + // that is not listed here hides the default "New thread in " row. + removeLocalStorageItem(LAST_USED_PROJECT_STORAGE_KEY); useCommandPaletteStore.setState(useCommandPaletteStore.getInitialState(), true); entities.projects = state.projects ?? []; entities.threads = state.threads ?? [];