From 1f9a4a1376d7b64d53cec0b849c7f3a9147697c4 Mon Sep 17 00:00:00 2001 From: Michael Yong Date: Tue, 3 Nov 2026 13:04:29 -0800 Subject: [PATCH] Prune low-value tests in @bb/app Audit apps/app's 657 test files with the test-audit skill and remove tests whose failures are already caught elsewhere: duplicate copies of the same contract, wiring-only and constant-pin tests, tests of a third-party library whose patch was removed, and vacuous assertions. Every removal was checked by mutating the production owner: the old test failed on main, and a remaining test fails on this branch. Removals that left a gap were restored. Strengthen tests that could not fail (conditional assertions, toBeDefined on non-optional values, real-timer races, names promising unchecked behaviour), and drop test-only exports and one dead parameter in production code. Co-Authored-By: Claude Opus 5.5 --- .../app/src/components/code/DiffHost.test.tsx | 29 +-- .../commands/CommandPalette.test.tsx | 62 +----- .../dialogs/AddMachineDialog.expiry.test.tsx | 16 -- .../layout/app-chrome-selection.test.tsx | 9 +- .../onboarding/OnboardingGate.test.tsx | 23 --- .../pickers/EnvironmentPicker.test.tsx | 40 +--- .../pickers/ModelReasoningPicker.test.tsx | 26 --- .../pickers/environment-picker-value.test.ts | 8 +- .../pickers/modelPickerToggle.test.ts | 7 + .../plugin/PluginBranchPicker.test.tsx | 7 - .../promptbox/FollowUpPromptBox.test.tsx | 14 -- .../promptbox/PromptBoxInternal.test.tsx | 91 ++++---- .../banner/QueuedMessagesList.test.tsx | 11 - .../promptbox/composer-contract.test.tsx | 3 + .../secondary-panel/BrowserTabDeck.test.ts | 11 - .../ThreadMetadataContent.test.tsx | 1 - .../ThreadSecondaryPanel.test.ts | 17 +- .../secondary-panel/ThreadSecondaryPanel.tsx | 7 +- .../secondary-panel/terminalPanelTabs.test.ts | 29 --- .../settings/KeyboardSettingsSection.test.tsx | 19 +- .../sidebar/SidebarUpdatesBadge.test.tsx | 13 -- .../components/thread/ThreadTitle.test.tsx | 4 +- .../ThreadTitleMentions.resources.test.ts | 124 +++-------- .../thread/ThreadTitleMentions.test.tsx | 49 ----- .../components/thread/ThreadTitleMentions.tsx | 2 +- .../terminal/ThreadTerminalView.test.ts | 28 ++- .../thread/timeline/MessageActionBar.test.ts | 10 - .../useTimelineWorkRowFullOutput.test.ts | 10 - .../user-questions/QuestionForm.test.tsx | 23 --- .../tools/detail-page-recipes.test.tsx | 51 ----- .../ui/markdown-message-directives.test.ts | 13 -- .../thread-state-cache-owner.test.ts | 62 ------ .../mutations/thread-pin-mutations.test.tsx | 21 -- .../thread-runtime-mutations.test.ts | 23 +-- .../queries/plugin-settings-queries.test.ts | 2 +- .../src/hooks/queries/thread-queries.test.ts | 20 +- .../src/hooks/realtime-cache-effects.test.ts | 46 +---- .../lib/audio-input-device-preference.test.ts | 8 - .../src/lib/audio-input-device-preference.ts | 2 +- apps/app/src/lib/composer-submissions.test.ts | 22 -- apps/app/src/lib/dev-websocket-url.test.ts | 18 +- apps/app/src/lib/dev-websocket-url.ts | 2 +- .../lib/environment-workspace-display.test.ts | 8 - .../in-app-browser-link-preference.test.ts | 194 ++++++++---------- .../src/lib/in-app-browser-link-preference.ts | 2 +- apps/app/src/lib/lifecycle-errors.test.ts | 64 ++---- apps/app/src/lib/lifecycle-errors.ts | 2 +- .../app-toast-title-overflow.test.tsx | 34 --- .../notification-center.test.tsx | 4 + .../src/lib/pierre-worker-pool-theme.test.ts | 8 - apps/app/src/lib/plugin-bound-sdk.test.ts | 18 +- apps/app/src/lib/plugin-sdk-hooks.test.ts | 24 +-- .../app/src/lib/plugin-sidebar-hooks.test.tsx | 12 -- .../src/lib/plugin-sidebar-threads.test.ts | 42 +--- apps/app/src/lib/plugin-slots.test.ts | 49 +---- apps/app/src/lib/provider-icon.test.tsx | 64 +----- .../lib/retired-sidebar-pull-request.test.tsx | 11 - apps/app/src/lib/split-layout/ops.test.ts | 15 +- apps/app/src/lib/use-composers.test.tsx | 4 + apps/app/src/lib/ws.plugin-signal.test.ts | 19 -- apps/app/src/lib/ws.test.ts | 3 + .../virtualizer-scroll-lifecycle.test.tsx | 65 ------ .../views/ToolsView.plugin-detail.test.tsx | 22 +- .../thread-detail/PaneMaximizeButton.test.tsx | 27 +-- .../thread-detail/PaneMaximizeButton.tsx | 2 +- 65 files changed, 298 insertions(+), 1378 deletions(-) delete mode 100644 apps/app/src/components/thread/ThreadTitleMentions.test.tsx delete mode 100644 apps/app/src/lib/composer-submissions.test.ts delete mode 100644 apps/app/src/lib/notifications/app-toast-title-overflow.test.tsx delete mode 100644 apps/app/src/test/virtualizer-scroll-lifecycle.test.tsx diff --git a/apps/app/src/components/code/DiffHost.test.tsx b/apps/app/src/components/code/DiffHost.test.tsx index 1e701a340b2..ec90fe43eb6 100644 --- a/apps/app/src/components/code/DiffHost.test.tsx +++ b/apps/app/src/components/code/DiffHost.test.tsx @@ -121,31 +121,6 @@ afterEach(() => { }); describe("DiffHost", () => { - it("skips BB's renderer and passes full-file contents when a replacement never delegates", async () => { - registerDiffRenderer((props) => { - receivedProps.push(props); - return
plugin diff
; - }); - - render( - , - ); - - expect(await screen.findByTestId("plugin-diff")).toBeDefined(); - await act(async () => { - await Promise.resolve(); - }); - expect(bbDiff.lastProps).toBeNull(); - expect(receivedProps.at(-1)?.experimental_fullFileContents).toBe( - FULL_FILE_CONTENTS, - ); - }); - it("hands the replacement resolved semantic props, not BB's host-only inputs", async () => { registerDiffRenderer((props) => { receivedProps.push(props); @@ -165,6 +140,10 @@ describe("DiffHost", () => { ); await screen.findByTestId("plugin-diff"); + await act(async () => { + await Promise.resolve(); + }); + expect(bbDiff.lastProps).toBeNull(); const props = receivedProps.at(-1); expect(props?.patch).toBe(PATCH); expect(props?.path).toBe("src/app.ts"); diff --git a/apps/app/src/components/commands/CommandPalette.test.tsx b/apps/app/src/components/commands/CommandPalette.test.tsx index e7fa97a2d7b..e0075271b3b 100644 --- a/apps/app/src/components/commands/CommandPalette.test.tsx +++ b/apps/app/src/components/commands/CommandPalette.test.tsx @@ -631,6 +631,15 @@ describe("CommandPalette", () => { expect(screen.queryByRole("combobox")).toBeNull(); expect(testState.targets).toEqual([screen.getByTestId("origin")]); expect(document.activeElement).toBe(screen.getByTestId("origin")); + + fireEvent.keyDown(screen.getByTestId("origin"), { + key: "o", + ctrlKey: true, + shiftKey: true, + }); + await waitFor(() => + expect(testState.calls).toEqual(["thread.new", "thread.new"]), + ); }, ); @@ -873,6 +882,7 @@ describe("CommandPalette", () => { fireEvent.keyDown(screen.getByRole("combobox"), { key: "Escape" }); await waitFor(() => expect(screen.queryByRole("combobox")).toBeNull()); + expect(testState.calls).toEqual([]); }); it("uses the shared tab-pill clear affordance without running the mode command", async () => { @@ -2099,38 +2109,6 @@ describe("CommandPalette", () => { expect(optionTitles()).toEqual(initialTitles); }); - it("closes on Escape without running anything", async () => { - renderPalette(); - openPalette(); - await waitFor(() => expect(searchField()).toBeTruthy()); - - fireEvent.keyDown(searchField(), { key: "Escape" }); - - await waitFor(() => expect(screen.queryByRole("combobox")).toBeNull()); - expect(testState.calls).toEqual([]); - }); - - it("keeps app shortcuts working after a shortcut closes the palette", async () => { - renderPalette(); - const pressThreadNew = () => - fireEvent.keyDown(document.activeElement ?? window, { - key: "o", - ctrlKey: true, - shiftKey: true, - bubbles: true, - }); - - openPalette(); - await waitFor(() => expect(searchField()).toBeTruthy()); - pressThreadNew(); - await waitFor(() => expect(testState.calls).toEqual(["thread.new"])); - await waitFor(() => expect(screen.queryByRole("combobox")).toBeNull()); - pressThreadNew(); - await waitFor(() => - expect(testState.calls).toEqual(["thread.new", "thread.new"]), - ); - }); - it("scrolls the highlighted row into view when arrowing, but not on hover", async () => { const scrollIntoView = vi.spyOn( Element.prototype, @@ -2277,26 +2255,6 @@ describe("CommandPalette", () => { }, ); - it("opens a specific settings page", async () => { - renderPalette(); - openPalette(); - await waitFor(() => expect(searchField()).toBeTruthy()); - - fireEvent.change(searchField(), { - target: { value: "keyboard settings" }, - }); - await waitFor(() => - expect(selectedOption()?.textContent).toContain("Keyboard settings"), - ); - fireEvent.keyDown(searchField(), { key: "Enter" }); - - await waitFor(() => - expect(screen.getByTestId("location").textContent).toBe( - "/settings/keyboard", - ), - ); - }); - it("only includes Files settings when local helper access is available", async () => { renderPalette(); openPalette(); diff --git a/apps/app/src/components/dialogs/AddMachineDialog.expiry.test.tsx b/apps/app/src/components/dialogs/AddMachineDialog.expiry.test.tsx index 16285db957a..d4d6b557bc9 100644 --- a/apps/app/src/components/dialogs/AddMachineDialog.expiry.test.tsx +++ b/apps/app/src/components/dialogs/AddMachineDialog.expiry.test.tsx @@ -84,20 +84,4 @@ describe("MachineLaunchCommand", () => { screen.getByRole("button", { name: "Generate a new command" }).click(); expect(onRegenerate).toHaveBeenCalledTimes(1); }); - - it("stops offering a copy after the server withdraws the command", () => { - render( - {}} - />, - ); - expect(screen.getByRole("status").textContent).toBe("Command used"); - expect( - screen.getByRole("button", { name: "Copy" }).hasAttribute("disabled"), - ).toBe(true); - }); }); diff --git a/apps/app/src/components/layout/app-chrome-selection.test.tsx b/apps/app/src/components/layout/app-chrome-selection.test.tsx index 721ff4b9482..9b9b9bcda45 100644 --- a/apps/app/src/components/layout/app-chrome-selection.test.tsx +++ b/apps/app/src/components/layout/app-chrome-selection.test.tsx @@ -62,13 +62,8 @@ describe("app chrome opts out of text selection", () => { expect(getPanel().classList.contains("select-none")).toBe(true); }); - it("marks the right panel's top chrome with and without the diff toolbar", () => { - expect(getSecondaryPanelChromeStackClassName(false)).toContain( - "select-none", - ); - expect(getSecondaryPanelChromeStackClassName(true)).toContain( - "select-none", - ); + it("marks the right panel's top chrome", () => { + expect(getSecondaryPanelChromeStackClassName()).toContain("select-none"); }); it("restores native selection on editable controls inside opted-out chrome", () => { diff --git a/apps/app/src/components/onboarding/OnboardingGate.test.tsx b/apps/app/src/components/onboarding/OnboardingGate.test.tsx index d5fefc36936..24247e0b727 100644 --- a/apps/app/src/components/onboarding/OnboardingGate.test.tsx +++ b/apps/app/src/components/onboarding/OnboardingGate.test.tsx @@ -92,29 +92,6 @@ describe("OnboardingGate", () => { ); }); - it("shows the guide again when the completion time is cleared after a close in the same session", async () => { - configWith({ onboardingCompletedAt: null }); - const { view } = renderGate(); - fireEvent.click(await screen.findByText("Setup guide at agent")); - - configWith({ onboardingCompletedAt: COMPLETED_AT }); - view.rerender( - -
App shell
-
, - ); - expect(screen.getByText("App shell")).toBeTruthy(); - - configWith({ onboardingCompletedAt: null }); - view.rerender( - -
App shell
-
, - ); - - expect(await screen.findByText("Setup guide at agent")).toBeTruthy(); - }); - it("holds a first-time browser blank until settings load, but boots a returning browser straight into the app", () => { mocks.useSystemConfig.mockReturnValue({ data: undefined, isError: false }); const first = renderGate(); diff --git a/apps/app/src/components/pickers/EnvironmentPicker.test.tsx b/apps/app/src/components/pickers/EnvironmentPicker.test.tsx index fdf0e708f59..cc749aef239 100644 --- a/apps/app/src/components/pickers/EnvironmentPicker.test.tsx +++ b/apps/app/src/components/pickers/EnvironmentPicker.test.tsx @@ -278,8 +278,10 @@ describe("EnvironmentPickerUI", () => { screen.queryByRole("option", { name: /New branch workspace/u }), ).toBeNull(); expect( - screen.getByRole("option", { name: /Optional sandbox/u }), - ).toBeTruthy(); + screen + .getByRole("option", { name: /Optional sandbox/u }) + .getAttribute("aria-disabled"), + ).toBe("false"); expect(screen.getByText("Configure credentials")).toBeTruthy(); }); it("omits a projectless-only provider from a project picker", () => { @@ -393,40 +395,6 @@ describe("EnvironmentPickerUI", () => { ).toBeTruthy(); }); - it("shows a setup-required provider enabled with its message", () => { - render( - , - ); - - fireEvent.click(screen.getByRole("button", { name: "Environment" }), { - button: 0, - }); - - const branchItem = screen.getByRole("option", { - name: /New branch workspace/u, - }); - expect(branchItem.getAttribute("aria-disabled")).toBe("false"); - expect(screen.getByText("Configure credentials")).toBeTruthy(); - }); - it("selects a setup-required composed provider without navigating away", () => { const onSelectProvider = vi.fn(); const setupRequiredProvider: SystemEnvironmentProvider = { diff --git a/apps/app/src/components/pickers/ModelReasoningPicker.test.tsx b/apps/app/src/components/pickers/ModelReasoningPicker.test.tsx index eab8b801e47..34403ef16fa 100644 --- a/apps/app/src/components/pickers/ModelReasoningPicker.test.tsx +++ b/apps/app/src/components/pickers/ModelReasoningPicker.test.tsx @@ -1138,25 +1138,6 @@ describe("ModelReasoningPicker", () => { expect(onModelChange).toHaveBeenCalledWith(apiModel); }); - it("uses picker search policy and selects the match by keyboard", () => { - const { onModelChange } = renderPicker({ modelOptions: manyCodexModels }); - - fireEvent.click( - screen.getByRole("button", { name: "Provider, model and reasoning" }), - ); - - const search = screen.getByPlaceholderText("Search models"); - fireEvent.change(search, { target: { value: "o4m" } }); - - expect(screen.getByText("o4-mini")).not.toBeNull(); - expect(screen.queryByText("Sonnet")).toBeNull(); - - fireEvent.keyDown(search, { key: "ArrowDown" }); - fireEvent.keyDown(search, { key: "Enter" }); - - expect(onModelChange).toHaveBeenCalledWith("o4-mini"); - }); - it("ranks primary and selected-only model matches together", () => { const looseMatch = "Super GPT-4 Compatibility"; const directMatch = "GPT-4 Turbo"; @@ -1619,13 +1600,6 @@ describe("ModelReasoningPicker service tiers", () => { ).toEqual(["flex", true]); }); - it("shows no agent options when the provider reports none", () => { - renderPicker(); - openPicker(); - - expect(screen.queryByRole("switch")).toBeNull(); - }); - it("greys out a model the chosen options rule out and never selects it", () => { const { onModelChange } = renderPicker({ modelOptions: [ diff --git a/apps/app/src/components/pickers/environment-picker-value.test.ts b/apps/app/src/components/pickers/environment-picker-value.test.ts index 9635dc979bd..fef43d42393 100644 --- a/apps/app/src/components/pickers/environment-picker-value.test.ts +++ b/apps/app/src/components/pickers/environment-picker-value.test.ts @@ -5,18 +5,14 @@ import { } from "./environment-picker-value"; describe("provider environment values", () => { - it("round-trips a provider id containing dashes", () => { + it("round-trips provider ids with dashes, underscores, and digits", () => { const value = encodeProviderValue("docker-sandbox"); expect(value).toBe("provider:docker-sandbox"); expect(parseEnvironmentValue(value)).toEqual({ type: "provider", environmentProviderId: "docker-sandbox", }); - }); - - it("round-trips provider ids with underscores and digits", () => { - const value = encodeProviderValue("wt_2"); - expect(parseEnvironmentValue(value)).toEqual({ + expect(parseEnvironmentValue(encodeProviderValue("wt_2"))).toEqual({ type: "provider", environmentProviderId: "wt_2", }); diff --git a/apps/app/src/components/pickers/modelPickerToggle.test.ts b/apps/app/src/components/pickers/modelPickerToggle.test.ts index 85d843c3ac1..2922b714638 100644 --- a/apps/app/src/components/pickers/modelPickerToggle.test.ts +++ b/apps/app/src/components/pickers/modelPickerToggle.test.ts @@ -106,6 +106,13 @@ describe("ownsModelPickerCycleChord", () => { ); } } + const unrelatedEditable = { + ...base, + caretInThisComposer: false, + editableOutsideComposer: true, + }; + expect(ownsModelPickerToggleChord(unrelatedEditable)).toBe(true); + expect(ownsModelPickerCycleChord(unrelatedEditable)).toBe(false); }); it("owns the chord while the picker is open and the caret is nowhere", () => { diff --git a/apps/app/src/components/plugin/PluginBranchPicker.test.tsx b/apps/app/src/components/plugin/PluginBranchPicker.test.tsx index 6f7a600c87a..1630caafd14 100644 --- a/apps/app/src/components/plugin/PluginBranchPicker.test.tsx +++ b/apps/app/src/components/plugin/PluginBranchPicker.test.tsx @@ -46,13 +46,6 @@ function renderPicker(props: { } describe("PluginBranchPicker", () => { - it("shows the placeholder while nothing is picked", () => { - renderPicker({ value: null, placeholder: "Pick a base" }); - expect( - screen.getByRole("combobox", { name: "Branch" }).textContent, - ).toContain("Pick a base"); - }); - it.each(["Compare with:", "Checkout:", "Branch from:"])( "uses %s for the trigger prefix and menu heading", (label) => { diff --git a/apps/app/src/components/promptbox/FollowUpPromptBox.test.tsx b/apps/app/src/components/promptbox/FollowUpPromptBox.test.tsx index 4b39b7538bd..4d5e3f8990d 100644 --- a/apps/app/src/components/promptbox/FollowUpPromptBox.test.tsx +++ b/apps/app/src/components/promptbox/FollowUpPromptBox.test.tsx @@ -1558,18 +1558,4 @@ describe("FollowUpPromptBox", () => { expect(screen.getByTestId("prompt-box")).toBe(initialPromptBox); }); - - it("uses the caller-specific compact placeholder", () => { - mocks.isCompactViewport = true; - mocks.isPointerCoarse = true; - const props = createFollowUpPromptBoxProps({ - kind: "queue-while-stopping", - }); - if (props.composer === null) throw new Error("Missing composer"); - props.composer.compactPromptPlaceholder = "Stopping side chat..."; - props.composer.promptPlaceholder = "Stopping side chat..."; - render(); - - expect(screen.getByText("Stopping side chat...")).toBeTruthy(); - }); }); diff --git a/apps/app/src/components/promptbox/PromptBoxInternal.test.tsx b/apps/app/src/components/promptbox/PromptBoxInternal.test.tsx index 6ecf89074be..0322c91e96b 100644 --- a/apps/app/src/components/promptbox/PromptBoxInternal.test.tsx +++ b/apps/app/src/components/promptbox/PromptBoxInternal.test.tsx @@ -1367,7 +1367,7 @@ describe("ComposerBox controlled value sync", () => { try { render(); - await waitForPromptFocus(); + expect(document.activeElement).toBe(getPromptEditorElement()); } finally { restoreMatchMedia(); } @@ -1684,13 +1684,11 @@ describe("ComposerBox programmatic submit", () => { send = vi.fn(), running = true, text = "Ship it", - sendsOnEnter = true, }: { swapSubmitActions: boolean; send?: () => void | Promise; running?: boolean; text?: string; - sendsOnEnter?: boolean; }) { const steer = vi.fn(); const submitted: string[] = []; @@ -1748,7 +1746,7 @@ describe("ComposerBox programmatic submit", () => { subscribeDraft: () => () => {}, setDraft: vi.fn(), focus: vi.fn(), - sendsOnEnter, + sendsOnEnter: true, }; render( @@ -1819,22 +1817,6 @@ describe("ComposerBox programmatic submit", () => { }); }); - it("rejects on a composer whose Enter does not send", async () => { - const { send, steer, rejected } = renderThreadComposerWithSubmitter({ - swapSubmitActions: false, - sendsOnEnter: false, - }); - - fireEvent.click(screen.getByRole("button", { name: "Plugin submit" })); - await waitFor(() => - expect(rejected).toEqual([ - "This composer cannot submit programmatically.", - ]), - ); - expect(send).not.toHaveBeenCalled(); - expect(steer).not.toHaveBeenCalled(); - }); - it("rejects an empty draft where Enter would steer the next queued message", async () => { const { send, steer, rejected } = renderThreadComposerWithSubmitter({ swapSubmitActions: true, @@ -4311,6 +4293,7 @@ describe("ComposerBox compact layout", () => { }); it("does not delay transcript insertion while the document is hidden", async () => { + vi.useFakeTimers(); const originalVisibilityState = Object.getOwnPropertyDescriptor( document, "visibilityState", @@ -4330,10 +4313,18 @@ describe("ComposerBox compact layout", () => { />, ); - await expect( - promptBoxRef.current?.voice?.playCompletionTransition(), - ).resolves.toBeUndefined(); + let transitionFinished = false; + act(() => { + void promptBoxRef.current?.voice + ?.playCompletionTransition() + ?.then(() => { + transitionFinished = true; + }); + }); + await act(async () => {}); + expect(transitionFinished).toBe(true); } finally { + vi.useRealTimers(); if (originalVisibilityState) { Object.defineProperty( document, @@ -4347,6 +4338,7 @@ describe("ComposerBox compact layout", () => { }); it("does not delay transcript insertion for reduced motion", async () => { + vi.useFakeTimers(); const originalMatchMedia = window.matchMedia; window.matchMedia = vi.fn().mockImplementation((query: string) => ({ matches: query === "(prefers-reduced-motion: reduce)", @@ -4369,26 +4361,21 @@ describe("ComposerBox compact layout", () => { />, ); - await expect( - promptBoxRef.current?.voice?.playCompletionTransition(), - ).resolves.toBeUndefined(); + let transitionFinished = false; + act(() => { + void promptBoxRef.current?.voice + ?.playCompletionTransition() + ?.then(() => { + transitionFinished = true; + }); + }); + await act(async () => {}); + expect(transitionFinished).toBe(true); } finally { + vi.useRealTimers(); window.matchMedia = originalMatchMedia; } }); - - it("keeps prompt actions in the full mobile layout", () => { - render( - , - ); - - expect(screen.getByRole("button", { name: "Prompt actions" })).toBeTruthy(); - }); }); describe("ComposerBox mention triggers", () => { @@ -4720,18 +4707,6 @@ describe("ComposerBox mention triggers", () => { ); }); - it("reports hash mention queries with the active trigger", async () => { - const { onMentionQueryChange, promptBoxRef } = renderPromptBox("#42", { - mentionTriggers: ["@", "#"], - }); - - await focusPromptEnd(promptBoxRef); - - await waitFor(() => - expect(onMentionQueryChange).toHaveBeenCalledWith("42", "#"), - ); - }); - it("does not open the menu for a bare non-at mention trigger", async () => { const { onMentionQueryChange, promptBoxRef } = renderPromptBox("#", { mentionTriggers: ["@", "#"], @@ -4762,12 +4737,18 @@ describe("ComposerBox mention triggers", () => { ], ]), ); - const { changes, promptBoxRef } = renderPromptBox("#42", { - mentionTriggers: ["@", "#"], - mentionSuggestions: [githubIssueSuggestion], - }); + const { changes, onMentionQueryChange, promptBoxRef } = renderPromptBox( + "#42", + { + mentionTriggers: ["@", "#"], + mentionSuggestions: [githubIssueSuggestion], + }, + ); await focusPromptEnd(promptBoxRef); + await waitFor(() => + expect(onMentionQueryChange).toHaveBeenCalledWith("42", "#"), + ); const suggestion = await screen.findByRole("button", { name: /#42 Fix login bug/u, }); diff --git a/apps/app/src/components/promptbox/banner/QueuedMessagesList.test.tsx b/apps/app/src/components/promptbox/banner/QueuedMessagesList.test.tsx index 55ffc1e7181..b00a3419cd2 100644 --- a/apps/app/src/components/promptbox/banner/QueuedMessagesList.test.tsx +++ b/apps/app/src/components/promptbox/banner/QueuedMessagesList.test.tsx @@ -1499,17 +1499,6 @@ describe("QueuedMessagesList", () => { expect(container.textContent).not.toContain("`code`"); }); - it("does not add hard-break elements for multi-line queued markdown", () => { - const { container } = renderQueuedMessages([ - makeQueuedMessage("q_multiline", "first line\nsecond line"), - ]); - - expect(container.querySelector("br")).toBeNull(); - expect(container.textContent?.replace(/\s+/gu, " ")).toContain( - "first line second line", - ); - }); - it("does not render full markdown preview controls in queued rows", () => { const { container, queryByLabelText } = renderQueuedMessages([ makeQueuedMessage("q_code_block", "```ts\nconst value = 1;\n```"), diff --git a/apps/app/src/components/promptbox/composer-contract.test.tsx b/apps/app/src/components/promptbox/composer-contract.test.tsx index 5b4647e4cdc..65e0bf0f4ba 100644 --- a/apps/app/src/components/promptbox/composer-contract.test.tsx +++ b/apps/app/src/components/promptbox/composer-contract.test.tsx @@ -572,6 +572,9 @@ describe.each(COMPOSERS)("$name", (composer) => { ); expect(rejected).toBe(surface.pluginSubmit === "rejects"); if (surface.pluginSubmit === "rejects") { + await expect(handle.submit()).rejects.toThrow( + "This composer cannot submit programmatically.", + ); expect(onSubmit).not.toHaveBeenCalled(); expect(onModifierSubmit).not.toHaveBeenCalled(); return; diff --git a/apps/app/src/components/secondary-panel/BrowserTabDeck.test.ts b/apps/app/src/components/secondary-panel/BrowserTabDeck.test.ts index 1e9a93e488d..b425bec5976 100644 --- a/apps/app/src/components/secondary-panel/BrowserTabDeck.test.ts +++ b/apps/app/src/components/secondary-panel/BrowserTabDeck.test.ts @@ -27,12 +27,6 @@ describe("selectActiveBrowserTab", () => { expect(selected).not.toBe(tabs[2]); }); - it("returns null when there is no active browser tab id", () => { - const tabs = [makeBrowserTab("tab-a", "https://a.example")]; - - expect(selectActiveBrowserTab(tabs, null)).toBeNull(); - }); - it("returns null when the active id is not an open browser tab", () => { const tabs = [ makeBrowserTab("tab-a", "https://a.example"), @@ -41,9 +35,4 @@ describe("selectActiveBrowserTab", () => { expect(selectActiveBrowserTab(tabs, "tab-missing")).toBeNull(); }); - - it("returns null for an empty tab list regardless of active id", () => { - expect(selectActiveBrowserTab([], "tab-a")).toBeNull(); - expect(selectActiveBrowserTab([], null)).toBeNull(); - }); }); diff --git a/apps/app/src/components/secondary-panel/ThreadMetadataContent.test.tsx b/apps/app/src/components/secondary-panel/ThreadMetadataContent.test.tsx index f63b1d87d7d..c36d3ae1939 100644 --- a/apps/app/src/components/secondary-panel/ThreadMetadataContent.test.tsx +++ b/apps/app/src/components/secondary-panel/ThreadMetadataContent.test.tsx @@ -222,7 +222,6 @@ describe("EnvironmentRow", () => { const markup = renderEnvironmentRow( makeEnvironment({ status: "provisioning", - path: null, }), ); diff --git a/apps/app/src/components/secondary-panel/ThreadSecondaryPanel.test.ts b/apps/app/src/components/secondary-panel/ThreadSecondaryPanel.test.ts index 8bd49fd1875..c044fed8ec0 100644 --- a/apps/app/src/components/secondary-panel/ThreadSecondaryPanel.test.ts +++ b/apps/app/src/components/secondary-panel/ThreadSecondaryPanel.test.ts @@ -1,25 +1,10 @@ import { describe, expect, it } from "vitest"; +import { resolveCollapsedPanelTrafficLightReserveClassName } from "./ThreadSecondaryPanel"; import { - getSecondaryPanelChromeStackClassName, - resolveCollapsedPanelTrafficLightReserveClassName, -} from "./ThreadSecondaryPanel"; -import { - CHROME_ROW_HEIGHT_CLASS, MACOS_COLLAPSED_TOP_LEFT_RESERVE_CLASS, MACOS_TITLE_BAR_COLLAPSED_SIDEBAR_RESERVE_CLASS, } from "@/lib/bb-desktop"; -describe("getSecondaryPanelChromeStackClassName", () => { - it("reserves the combined navigation and active Diff toolbar height", () => { - const className = getSecondaryPanelChromeStackClassName(true); - - expect(className).toContain("flex"); - expect(className).toContain("flex-col"); - expect(className).toContain("shrink-0"); - expect(className).not.toContain(CHROME_ROW_HEIGHT_CLASS); - }); -}); - describe("resolveCollapsedPanelTrafficLightReserveClassName", () => { const base = { isConversationCollapsed: true, diff --git a/apps/app/src/components/secondary-panel/ThreadSecondaryPanel.tsx b/apps/app/src/components/secondary-panel/ThreadSecondaryPanel.tsx index 1d5f57d1911..a162b84bad2 100644 --- a/apps/app/src/components/secondary-panel/ThreadSecondaryPanel.tsx +++ b/apps/app/src/components/secondary-panel/ThreadSecondaryPanel.tsx @@ -122,12 +122,9 @@ function getScopedFilePreviewScrollPositions( return positions; } -export function getSecondaryPanelChromeStackClassName( - hasGitDiffToolbar: boolean, -): string { +export function getSecondaryPanelChromeStackClassName(): string { return cn( "shrink-0 select-none", - hasGitDiffToolbar && "flex flex-col", SECONDARY_PANEL_TOP_CHROME_BACKGROUND_CLASS, ); } @@ -710,7 +707,7 @@ function ThreadSecondaryPanelContent({ >
diff --git a/apps/app/src/components/secondary-panel/terminalPanelTabs.test.ts b/apps/app/src/components/secondary-panel/terminalPanelTabs.test.ts index e419c5cf615..fb61c298c84 100644 --- a/apps/app/src/components/secondary-panel/terminalPanelTabs.test.ts +++ b/apps/app/src/components/secondary-panel/terminalPanelTabs.test.ts @@ -165,35 +165,6 @@ describe("terminalPanelTabs", () => { expect(tabIds(tabs)).toEqual(["terminal:term_1:none"]); }); - it("keeps disconnected terminal tabs", () => { - const disconnectedTerminal = createTerminalFixedPanelTab({ - terminalId: "term_disconnected", - }); - const runningTerminal = createTerminalFixedPanelTab({ - terminalId: "term_running", - }); - const sessions = [ - terminalSession({ - id: "term_disconnected", - status: "disconnected", - }), - terminalSession({ id: "term_running" }), - ]; - - expect( - tabIds( - buildTerminalSyncedSecondaryFileTabs({ - orderedTabs: [disconnectedTerminal, runningTerminal], - pendingTerminalIds: NO_PENDING_TERMINALS, - terminalSessions: sessions, - }), - ), - ).toEqual([ - "terminal:term_disconnected:none", - "terminal:term_running:none", - ]); - }); - it("syncs missing server terminal sessions into fixed panel state", () => { const fileTab = createHostFilePreviewFixedPanelTab({ environmentId: "env_1", diff --git a/apps/app/src/components/settings/KeyboardSettingsSection.test.tsx b/apps/app/src/components/settings/KeyboardSettingsSection.test.tsx index f0e5c5f9f56..d24bd580044 100644 --- a/apps/app/src/components/settings/KeyboardSettingsSection.test.tsx +++ b/apps/app/src/components/settings/KeyboardSettingsSection.test.tsx @@ -419,23 +419,6 @@ describe("KeyboardSettingsSection", () => { ).toBe(true); }); - it("ranks visible label matches ahead of description matches across groups", () => { - render(); - - fireEvent.change( - screen.getByRole("textbox", { name: "Search keyboard shortcuts" }), - { - target: { value: " SiDeBaR " }, - }, - ); - - expect( - screen - .getAllByRole("button", { name: /^Record shortcut for / })[0] - ?.getAttribute("aria-label"), - ).toMatch(/^Record shortcut for Toggle sidebar,/); - }); - it("ranks exact labels, label prefixes, label substrings, IDs, and descriptions in order", () => { setPluginSlotRegistrations( "test-shortcuts", @@ -458,7 +441,7 @@ describe("KeyboardSettingsSection", () => { fireEvent.change( screen.getByRole("textbox", { name: "Search keyboard shortcuts" }), { - target: { value: "sidebar" }, + target: { value: " SiDeBaR " }, }, ); diff --git a/apps/app/src/components/sidebar/SidebarUpdatesBadge.test.tsx b/apps/app/src/components/sidebar/SidebarUpdatesBadge.test.tsx index 9434e7895c4..d58ffe329a8 100644 --- a/apps/app/src/components/sidebar/SidebarUpdatesBadge.test.tsx +++ b/apps/app/src/components/sidebar/SidebarUpdatesBadge.test.tsx @@ -343,19 +343,6 @@ describe("SidebarUpdatesBadge", () => { expect(providerChip.querySelector('[data-icon="Download"]')).toBeTruthy(); }); - it("renders no provider chip when a CLI is not installed", () => { - renderBadge({ - machines: [ - machine({ - issues: [missingInstallIssue("claude-code", "Claude Code")], - }), - ], - }); - - expect(screen.queryByTestId("sidebar-updates-badge-providers")).toBeNull(); - expect(screen.queryByTestId("sidebar-updates-badge-bb")).toBeNull(); - }); - it("still shows the bb chip when the only provider issue is a missing CLI", () => { renderBadge({ appUpdateAvailable: true, diff --git a/apps/app/src/components/thread/ThreadTitle.test.tsx b/apps/app/src/components/thread/ThreadTitle.test.tsx index db1b354c405..9bb7086ff3d 100644 --- a/apps/app/src/components/thread/ThreadTitle.test.tsx +++ b/apps/app/src/components/thread/ThreadTitle.test.tsx @@ -35,7 +35,9 @@ describe("ThreadTitle", () => { , ); - expect(screen.getByText("Design review")).not.toBeNull(); + expect( + screen.getByText("Design review").closest("a, [role='link']"), + ).toBeNull(); expect(container.textContent).not.toContain("@thread:thr_mentioned"); expect(container.querySelector("mark")?.textContent).toBe("auth"); expect(screen.getByTitle("Follow up on Design review auth")).not.toBeNull(); diff --git a/apps/app/src/components/thread/ThreadTitleMentions.resources.test.ts b/apps/app/src/components/thread/ThreadTitleMentions.resources.test.ts index 0b79e63a3a1..691c3f4355d 100644 --- a/apps/app/src/components/thread/ThreadTitleMentions.resources.test.ts +++ b/apps/app/src/components/thread/ThreadTitleMentions.resources.test.ts @@ -3,7 +3,7 @@ import { makeThreadListEntry } from "@bb/test-helpers/domain-fixtures"; import { buildThreadTitleMentionResources, EMPTY_TITLE_MENTION_RESOURCES, - threadTitleTextSegments, + resolveThreadTitleDisplayText, type ThreadTitleMentionNavigationSource, } from "./ThreadTitleMentions"; @@ -97,7 +97,7 @@ describe("buildThreadTitleMentionResources", () => { }); }); -describe("threadTitleTextSegments", () => { +describe("resolveThreadTitleDisplayText", () => { const rawId = "thr_dcwivn5n8w"; function resourcesWithThread(title: string) { @@ -117,105 +117,31 @@ describe("threadTitleTextSegments", () => { }; } - it("renders serialized mentions in the thread title as pills", () => { - const segments = threadTitleTextSegments( - "Review @docs/foo.test.ts with @thread:thr_worker", - EMPTY_TITLE_MENTION_RESOURCES, - ); - - expect(segments.map((segment) => segment.text)).toEqual([ - "Review ", - "foo.test.ts", - " with ", - "thr_worker", - ]); - expect(segments[1]?.resource).toMatchObject({ - kind: "path", - path: "docs/foo.test.ts", - }); - expect(segments[3]?.resource).toMatchObject({ - kind: "thread", - threadId: "thr_worker", - }); - }); - - it("renders a raw thread id in the title as a mention pill", () => { - const segments = threadTitleTextSegments( - `Continue from ${rawId} docs/foo.ts`, - resourcesWithThread("Raw title target"), - ); - - expect(segments.map((segment) => segment.text)).toEqual([ - "Continue from ", - "Raw title target", - " docs/foo.ts", - ]); - expect(segments[1]?.resource).toMatchObject({ - kind: "thread", - threadId: rawId, - }); - }); - it.each([ - ["straight closing quote", `Review "${rawId}."`], - ["curly closing quote", `Review β€œ${rawId}.”`], + [ + "mid-title", + `Continue from ${rawId} docs/foo.ts`, + "Continue from Raw title target docs/foo.ts", + ], + [ + "before a straight closing quote", + `Review "${rawId}."`, + 'Review "Raw title target."', + ], + [ + "before a curly closing quote", + `Review \u201c${rawId}.\u201d`, + "Review \u201cRaw title target.\u201d", + ], ])( - "renders a sentence-final raw id before a %s in a title", - (_label, title) => { - const segments = threadTitleTextSegments( - title, - resourcesWithThread("Quoted title target"), - ); - - expect(segments.find((segment) => segment.resource !== null)?.text).toBe( - "Quoted title target", - ); + "shows a known raw thread id %s as its title", + (_label, title, expected) => { + expect( + resolveThreadTitleDisplayText( + title, + resourcesWithThread("Raw title target"), + ), + ).toBe(expected); }, ); - - it("leaves raw-id path, extension, and overlong continuations literal in titles", () => { - const title = [ - `${rawId}.md`, - `${rawId}/path`, - `${rawId}2`, - `/tmp/${rawId}`, - `docs/${rawId}`, - `C:\\tmp\\${rawId}`, - `docs\\${rawId}`, - `${rawId}\\logs`, - ].join(" "); - - expect( - threadTitleTextSegments(title, resourcesWithThread("Should not render")), - ).toEqual([ - { - resource: null, - serializedText: null, - text: title, - unresolvedThreadId: null, - }, - ]); - }); - - it("leaves an unresolvable raw thread id literal and requests it", () => { - expect( - threadTitleTextSegments( - "Unknown thr_2222222222", - EMPTY_TITLE_MENTION_RESOURCES, - ), - ).toEqual([ - { - resource: null, - serializedText: null, - text: "Unknown ", - unresolvedThreadId: null, - }, - { - resource: null, - serializedText: "thr_2222222222", - text: "thr_2222222222", - unresolvedThreadId: "thr_2222222222", - }, - ]); - }); }); diff --git a/apps/app/src/components/thread/ThreadTitleMentions.test.tsx b/apps/app/src/components/thread/ThreadTitleMentions.test.tsx deleted file mode 100644 index f2a75c1f025..00000000000 --- a/apps/app/src/components/thread/ThreadTitleMentions.test.tsx +++ /dev/null @@ -1,49 +0,0 @@ -// @vitest-environment jsdom - -import { cleanup, render, screen } from "@testing-library/react"; -import { afterEach, describe, expect, it } from "vitest"; -import { makeThreadListEntry } from "@bb/test-helpers/domain-fixtures"; -import { - ThreadTitle, - ThreadTitleMentionResourcesProvider, - useThreadTitleDisplayText, -} from "./ThreadTitleMentions"; - -afterEach(cleanup); - -function DisplayText({ title }: { title: string }) { - return ( - {useThreadTitleDisplayText(title)} - ); -} - -describe("ThreadTitle", () => { - it("renders serialized thread mentions in a title as non-interactive pills", () => { - const mentionedThread = makeThreadListEntry({ - id: "thr_mentioned", - projectId: "proj_mentioned", - title: "Mention target", - titleFallback: "Mention target", - }); - const title = "Continue from @thread:thr_mentioned"; - - render( - - - - , - ); - - expect(screen.queryByText(/@thread:thr_mentioned/)).toBeNull(); - const pill = screen.getByText("Mention target"); - expect(pill.closest("a")).toBeNull(); - expect(pill.closest("[role='link']")).toBeNull(); - expect(screen.getByTestId("display-text").textContent).toBe( - "Continue from Mention target", - ); - }); -}); diff --git a/apps/app/src/components/thread/ThreadTitleMentions.tsx b/apps/app/src/components/thread/ThreadTitleMentions.tsx index f93405a67d8..45f14ac6f3e 100644 --- a/apps/app/src/components/thread/ThreadTitleMentions.tsx +++ b/apps/app/src/components/thread/ThreadTitleMentions.tsx @@ -588,7 +588,7 @@ function serializedThreadMentionId(token: string): string | null { return token.startsWith(prefix) ? token.slice(prefix.length) : null; } -export function threadTitleTextSegments( +function threadTitleTextSegments( title: string, resources: ThreadTitleMentionResources, ): ThreadTitleTextSegment[] { diff --git a/apps/app/src/components/thread/terminal/ThreadTerminalView.test.ts b/apps/app/src/components/thread/terminal/ThreadTerminalView.test.ts index 2d137aefa90..df4f27a46d9 100644 --- a/apps/app/src/components/thread/terminal/ThreadTerminalView.test.ts +++ b/apps/app/src/components/thread/terminal/ThreadTerminalView.test.ts @@ -228,19 +228,25 @@ describe("terminal output encoding", () => { expect(decoded.toString("utf8")).toBe(input); }); - it("keeps UTF-8 bytes intact when a glyph spans output chunks", () => { + it("keeps UTF-8 bytes intact when a glyph spans output chunks", async () => { + const terminal = new Terminal({ cols: 80, rows: 24 }); + const replayWriteState = { suppressedWriteCount: 0 }; const encoded = new TextEncoder().encode("πŸ™‚"); - const first = decodeBase64Bytes( - Buffer.from(encoded.subarray(0, 2)).toString("base64"), - ); - const second = decodeBase64Bytes( - Buffer.from(encoded.subarray(2)).toString("base64"), - ); - const decoder = new TextDecoder(); + for (const chunk of [encoded.subarray(0, 2), encoded.subarray(2)]) { + writeTerminalOutput({ + data: decodeBase64Bytes(Buffer.from(chunk).toString("base64")), + isReplay: false, + onParsed: () => undefined, + replayWriteState, + terminal, + }); + } + await new Promise((resolve) => terminal.write("", resolve)); - expect( - decoder.decode(first, { stream: true }) + decoder.decode(second), - ).toBe("πŸ™‚"); + expect(terminal.buffer.active.getLine(0)?.translateToString(true)).toBe( + "πŸ™‚", + ); + terminal.dispose(); }); it("does not send terminal protocol replies generated by replayed output", async () => { diff --git a/apps/app/src/components/thread/timeline/MessageActionBar.test.ts b/apps/app/src/components/thread/timeline/MessageActionBar.test.ts index d18ed0f5fbf..09cfb94cd12 100644 --- a/apps/app/src/components/thread/timeline/MessageActionBar.test.ts +++ b/apps/app/src/components/thread/timeline/MessageActionBar.test.ts @@ -48,16 +48,6 @@ describe("computeMessageActionRowLayout", () => { ).toEqual({ inlineCount: 1, overflowCount: 2 }); }); - it("puts every candidate in the menu when none fit beside the trigger", () => { - expect( - computeMessageActionRowLayout({ - actionCount: 3, - availableWidth: 30, - ...metrics, - }), - ).toEqual({ inlineCount: 0, overflowCount: 3 }); - }); - it("returns an empty layout for zero candidates", () => { expect( computeMessageActionRowLayout({ diff --git a/apps/app/src/components/thread/timeline/useTimelineWorkRowFullOutput.test.ts b/apps/app/src/components/thread/timeline/useTimelineWorkRowFullOutput.test.ts index f1999abac25..7507615ad4b 100644 --- a/apps/app/src/components/thread/timeline/useTimelineWorkRowFullOutput.test.ts +++ b/apps/app/src/components/thread/timeline/useTimelineWorkRowFullOutput.test.ts @@ -88,16 +88,6 @@ describe("resolveTimelineWorkRowFullOutput", () => { ).toEqual({ output: PREVIEW_OUTPUT, state: "streaming-preview" }); }); - it("keeps the preview when the full-output load fails", () => { - expect( - resolveTimelineWorkRowFullOutput({ - row: bigCommandRow(), - data: undefined, - isError: true, - }), - ).toEqual({ output: PREVIEW_OUTPUT, state: "error" }); - }); - it.each([ { availability: "detail-limit", state: "limited-preview" }, { availability: "retention-expired", state: "expired-preview" }, diff --git a/apps/app/src/components/thread/user-questions/QuestionForm.test.tsx b/apps/app/src/components/thread/user-questions/QuestionForm.test.tsx index 54f345eecb7..f8c59cb165b 100644 --- a/apps/app/src/components/thread/user-questions/QuestionForm.test.tsx +++ b/apps/app/src/components/thread/user-questions/QuestionForm.test.tsx @@ -390,21 +390,6 @@ describe("answering a single-select question", () => { } satisfies InteractionResponse); }); - it("selects an option with its number-key shortcut", () => { - const submit = vi.fn<(value: InteractionResponse) => Promise>( - async () => undefined, - ); - const slot = render(singleSelect, { submit }); - - fireEvent.keyDown(window, { key: "2" }); - fireEvent.click(getButtonByText(slot, "Submit answer")); - - expect(submit).toHaveBeenCalledTimes(1); - expect(submit.mock.calls[0]?.[0]).toEqual({ - answers: { q0: { selected: ["q0o1"] } }, - } satisfies InteractionResponse); - }); - it("ignores number keys typed into the free-text box", () => { const slot = render(singleSelect); fireEvent.click(getButtonByText(slot, "Other…")); @@ -725,14 +710,6 @@ describe("multi-select and multi-question flows", () => { composer.remove(); } }); - - it("cancels the request instead of submitting", () => { - const cancel = vi.fn(async () => undefined); - const slot = render(multi, { cancel }); - - fireEvent.click(getButtonByText(slot, "Cancel")); - expect(cancel).toHaveBeenCalledTimes(1); - }); }); describe("question answer dictation", () => { diff --git a/apps/app/src/components/tools/detail-page-recipes.test.tsx b/apps/app/src/components/tools/detail-page-recipes.test.tsx index d3a107e5ace..550993c13ca 100644 --- a/apps/app/src/components/tools/detail-page-recipes.test.tsx +++ b/apps/app/src/components/tools/detail-page-recipes.test.tsx @@ -171,57 +171,6 @@ describe("Plugin detail recipe", () => { ).toBeTruthy(); }); - it("lists declared capabilities without category chrome", () => { - const { container } = renderPlugin({ - ...PLUGIN, - cliCommand: { name: "gh", summary: "Work with GitHub" }, - capabilities: [ - { - kind: "skill", - id: "review", - label: "review", - detail: "Skill this plugin adds to your agents", - }, - { - kind: "theme", - id: "github.dark", - label: "GitHub Dark", - detail: null, - }, - { - kind: "agent-tool", - id: "gh_search", - label: "gh_search", - detail: "Search GitHub", - }, - { - kind: "thread-integration", - id: "mention:pr", - label: "Pull requests", - detail: "Mentions with #", - }, - ], - }); - - const capabilities = container.querySelector( - '[data-resource-detail-section="includes"]', - ); - expect(capabilities?.querySelector("table")).not.toBeNull(); - expect( - capabilities?.querySelector("[data-plugin-capability-group]"), - ).toBeNull(); - - for (const item of [ - "bb gh", - "review", - "gh_search", - "Pull requests", - "GitHub Dark", - ] as const) { - expect(screen.getByText(item)).toBeTruthy(); - } - }); - it("collapses long capability descriptions until requested", () => { const description = "Long capability guidance ".repeat(20).trim(); const { container } = renderPlugin({ diff --git a/apps/app/src/components/ui/markdown-message-directives.test.ts b/apps/app/src/components/ui/markdown-message-directives.test.ts index e3929bfeaed..c5252ce47df 100644 --- a/apps/app/src/components/ui/markdown-message-directives.test.ts +++ b/apps/app/src/components/ui/markdown-message-directives.test.ts @@ -27,19 +27,6 @@ afterEach(() => { }); describe("buildMessageDirectiveRegistry", () => { - it("maps a unique directive id to its slot", () => { - const registry = buildMessageDirectiveRegistry([ - slot({ id: "inline-vis", pluginId: "demo" }), - ]); - expect(registry.get("inline-vis")).toEqual({ - status: "ok", - slot: expect.objectContaining({ - id: "inline-vis", - pluginId: "demo", - }), - }); - }); - it("records cross-plugin collisions with no winner and warns once", () => { const warn = vi.fn(); const registry = buildMessageDirectiveRegistry( diff --git a/apps/app/src/hooks/cache-owners/thread-state-cache-owner.test.ts b/apps/app/src/hooks/cache-owners/thread-state-cache-owner.test.ts index 3388da0416f..bdc56196d5c 100644 --- a/apps/app/src/hooks/cache-owners/thread-state-cache-owner.test.ts +++ b/apps/app/src/hooks/cache-owners/thread-state-cache-owner.test.ts @@ -313,68 +313,6 @@ describe("thread state cache owner", () => { }, ); - it("optimistically renames thread in thread, list, and sidebar caches", async () => { - const { queryClient } = createQueryClientTestHarness(); - const threadId = "thread-1"; - const thread = makeThreadWithRuntime({ - id: threadId, - title: "Old title", - }); - const listEntry = makeThreadListEntry({ - id: threadId, - title: "Old title", - }); - const threadListKey = threadListQueryKey({ - archived: false, - projectId: "project-1", - }); - - queryClient.setQueryData(threadQueryKey(threadId), thread); - queryClient.setQueryData(threadListKey, [listEntry]); - queryClient.setQueryData( - sidebarNavigationQueryKey(), - makeSidebarNavigation([listEntry]), - ); - - const transaction = await beginThreadMetadataTransaction({ - queryClient, - threadId, - title: "New title", - }); - - expect( - queryClient.getQueryData(threadQueryKey(threadId)) - ?.title, - ).toBe("New title"); - expect( - queryClient.getQueryData(threadListKey)?.[0]?.title, - ).toBe("New title"); - expect( - queryClient.getQueryData( - sidebarNavigationQueryKey(), - )?.projects[0]?.threads[0]?.title, - ).toBe("New title"); - - rollbackThreadListMutationTransaction({ - queryClient, - threadId, - transaction, - }); - - expect( - queryClient.getQueryData(threadQueryKey(threadId)) - ?.title, - ).toBe("Old title"); - expect( - queryClient.getQueryData(threadListKey)?.[0]?.title, - ).toBe("Old title"); - expect( - queryClient.getQueryData( - sidebarNavigationQueryKey(), - )?.projects[0]?.threads[0]?.title, - ).toBe("Old title"); - }); - it("optimistically marks read state in thread, list, and sidebar caches", async () => { const { queryClient } = createQueryClientTestHarness(); const threadId = "thread-1"; diff --git a/apps/app/src/hooks/mutations/thread-pin-mutations.test.tsx b/apps/app/src/hooks/mutations/thread-pin-mutations.test.tsx index 621872aec24..487ba4caf81 100644 --- a/apps/app/src/hooks/mutations/thread-pin-mutations.test.tsx +++ b/apps/app/src/hooks/mutations/thread-pin-mutations.test.tsx @@ -273,27 +273,6 @@ it("keeps the latest pin toggle through stale reads until every write settles", ); }); -it("shows the server's pinnedAt as soon as the pin is acknowledged", async () => { - const server = serve([entry("t1", null)]); - await waitFor(() => - expect(server.pinnedAt("t1")).toEqual([null, null, null]), - ); - const pin = createDeferredPromise>(); - vi.mocked(sdk.threads.pin).mockReturnValue(pin.promise); - act(() => server.view.result.current.pin.mutate({ id: "t1" })); - await waitFor(() => expect(typeof server.pinnedAt("t1")[0]).toBe("number")); - const never = new Promise(() => {}); - vi.mocked(sdk.threads.list).mockReturnValue(never); - vi.mocked(sdk.threads.get).mockReturnValue(never); - vi.mocked(request).mockReturnValue(never); - - await act(async () => - pin.resolve(makeThreadResponse({ ...entry("t1", 777) })), - ); - - await waitFor(() => expect(server.pinnedAt("t1")).toEqual([777, 777, 777])); -}); - it("predicts on a thread list mounted while the pin is pending", async () => { const server = serve([entry("t1", null)]); await waitFor(() => diff --git a/apps/app/src/hooks/mutations/thread-runtime-mutations.test.ts b/apps/app/src/hooks/mutations/thread-runtime-mutations.test.ts index 72d846cde43..b65362763f6 100644 --- a/apps/app/src/hooks/mutations/thread-runtime-mutations.test.ts +++ b/apps/app/src/hooks/mutations/thread-runtime-mutations.test.ts @@ -343,7 +343,7 @@ describe("thread runtime mutations", () => { } }); - it("forwards execution input sources when sending a thread message", async () => { + it("forwards execution input sources and compactFirst when sending a thread message", async () => { const queryClient = createTestQueryClient(); const mutation = new MutationObserver( queryClient, @@ -355,35 +355,18 @@ describe("thread runtime mutations", () => { mode: "auto", input: [{ type: "text", text: "Run this", mentions: [] }], executionInputSources, + compactFirst: true, }); expect(sdk.threads.send).toHaveBeenCalledWith( expect.objectContaining({ executionInputSources, + compactFirst: true, threadId: "thread-1", }), ); }); - it("forwards compactFirst when sending a thread message", async () => { - const queryClient = createTestQueryClient(); - const mutation = new MutationObserver( - queryClient, - sendThreadMessageMutationOptions(queryClient), - ); - - await mutation.mutate({ - id: "thread-1", - mode: "queue-if-active", - input: [{ type: "text", text: "Resume", mentions: [] }], - compactFirst: true, - }); - - expect(sdk.threads.send).toHaveBeenCalledWith( - expect.objectContaining({ compactFirst: true, threadId: "thread-1" }), - ); - }); - it("restores a queued-row steer when provisioning keeps it queued", async () => { const queuedMessage = makeQueuedMessage({ waitingOn: { kind: "thread-busy" }, diff --git a/apps/app/src/hooks/queries/plugin-settings-queries.test.ts b/apps/app/src/hooks/queries/plugin-settings-queries.test.ts index 2e129002a9d..b60e92330af 100644 --- a/apps/app/src/hooks/queries/plugin-settings-queries.test.ts +++ b/apps/app/src/hooks/queries/plugin-settings-queries.test.ts @@ -242,7 +242,7 @@ describe("plugin list envelope", () => { ).rejects.toThrow(); }); - it("drops a row with a partial lastFailure rather than showing the quiet state", async () => { + it("rejects a list whose row has a partial lastFailure rather than showing the quiet state", async () => { const partialFailure = { ...ROW, updateState: { lastFailure: { version: "1.7.0", label: "1.7.0" } }, diff --git a/apps/app/src/hooks/queries/thread-queries.test.ts b/apps/app/src/hooks/queries/thread-queries.test.ts index 2045788bfb4..4a79ccdd727 100644 --- a/apps/app/src/hooks/queries/thread-queries.test.ts +++ b/apps/app/src/hooks/queries/thread-queries.test.ts @@ -1159,28 +1159,18 @@ describe("thread open cache retention", () => { }); describe("palette lifecycle queries", () => { - it("loads bounded archived recents only while selected before typing", async () => { + it("requests a bounded archived list only when enabled", async () => { const { queryClient } = createQueryClientTestHarness(); const archived = makeThreadListEntry({ id: "archived", archivedAt: 1 }); vi.mocked(sdk.threads.list).mockResolvedValue([archived]); - const options = ({ - recent, - selected, - }: { - recent: boolean; - selected: boolean; - }) => - paletteRecentArchivedThreadsQueryOptions({ - enabled: recent && selected, - }); const observer = observe( queryClient, - options({ recent: true, selected: false }), + paletteRecentArchivedThreadsQueryOptions({ enabled: false }), ); expect(sdk.threads.list).not.toHaveBeenCalled(); - observer.setOptions(options({ recent: false, selected: true })); - expect(sdk.threads.list).not.toHaveBeenCalled(); - observer.setOptions(options({ recent: true, selected: true })); + observer.setOptions( + paletteRecentArchivedThreadsQueryOptions({ enabled: true }), + ); await vi.waitFor(() => expect(observer.getCurrentResult().data).toEqual([archived]), ); diff --git a/apps/app/src/hooks/realtime-cache-effects.test.ts b/apps/app/src/hooks/realtime-cache-effects.test.ts index 0dabdcde389..5ed07d7e015 100644 --- a/apps/app/src/hooks/realtime-cache-effects.test.ts +++ b/apps/app/src/hooks/realtime-cache-effects.test.ts @@ -43,14 +43,7 @@ import { } from "./queries/query-keys"; import { afterEach, describe, expect, it, vi } from "vitest"; import { QueryObserver, type QueryClient } from "@tanstack/react-query"; -import { - ENVIRONMENT_CHANGE_KINDS, - HOST_CHANGE_KINDS, - PROJECT_CHANGE_KINDS, - SYSTEM_CHANGE_KINDS, - THREAD_CHANGE_KINDS, - defaultExperiments, -} from "@bb/domain"; +import { SYSTEM_CHANGE_KINDS, defaultExperiments } from "@bb/domain"; import { makeEnvironment } from "@bb/test-helpers/domain-fixtures"; import { createAppQueryClient } from "@/lib/query-client"; import { makeSystemConfig } from "@/test/fixtures/system-config"; @@ -61,13 +54,7 @@ import { resolveThreadInvalidationDebounce, type RealtimeCacheEffectsVisibility, } from "./realtime-cache-effects"; -import { - REALTIME_ENVIRONMENT_CHANGE_REGISTRY, - REALTIME_HOST_CHANGE_REGISTRY, - REALTIME_PROJECT_CHANGE_REGISTRY, - REALTIME_SYSTEM_CHANGE_REGISTRY, - REALTIME_THREAD_CHANGE_REGISTRY, -} from "./cache-owners/realtime-cache-registry"; +import { REALTIME_SYSTEM_CHANGE_REGISTRY } from "./cache-owners/realtime-cache-registry"; const PROJECT_PROMPT_HISTORY_THREAD_CHANGES = [ "thread-created", @@ -406,30 +393,11 @@ describe("createRealtimeCacheEffects", () => { vi.useRealTimers(); }); - it.each< - [ - string, - readonly string[], - Record, - ] - >([ - ["thread", THREAD_CHANGE_KINDS, REALTIME_THREAD_CHANGE_REGISTRY], - [ - "environment", - ENVIRONMENT_CHANGE_KINDS, - REALTIME_ENVIRONMENT_CHANGE_REGISTRY, - ], - ["project", PROJECT_CHANGE_KINDS, REALTIME_PROJECT_CHANGE_REGISTRY], - ["host", HOST_CHANGE_KINDS, REALTIME_HOST_CHANGE_REGISTRY], - ["system", SYSTEM_CHANGE_KINDS, REALTIME_SYSTEM_CHANGE_REGISTRY], - ])( - "maps every realtime %s change to a registry entry", - (_entity, changeKinds, registry) => { - for (const changeKind of changeKinds) { - expect(registry[changeKind]).toBeDefined(); - } - }, - ); + it("maps every realtime system change to a registry entry", () => { + for (const changeKind of SYSTEM_CHANGE_KINDS) { + expect(REALTIME_SYSTEM_CHANGE_REGISTRY[changeKind]).toBeDefined(); + } + }); it("refreshes only the server move status when a move changes", () => { const { effects, queryClient } = createRealtimeEffectsTestContext(); diff --git a/apps/app/src/lib/audio-input-device-preference.test.ts b/apps/app/src/lib/audio-input-device-preference.test.ts index b94d9e0fcff..1bb46c0608d 100644 --- a/apps/app/src/lib/audio-input-device-preference.test.ts +++ b/apps/app/src/lib/audio-input-device-preference.test.ts @@ -1,6 +1,5 @@ import { describe, expect, it, vi } from "vitest"; import { - buildAudioInputConstraints, parsePreferredAudioInputDeviceId, requestAudioInputStream, } from "./audio-input-device-preference"; @@ -14,13 +13,6 @@ describe("audio input device preference", () => { "studio-mic", ); }); - - it("builds default and exact-device getUserMedia constraints", () => { - expect(buildAudioInputConstraints(null)).toEqual({ audio: true }); - expect(buildAudioInputConstraints("studio-mic")).toEqual({ - audio: { deviceId: { exact: "studio-mic" } }, - }); - }); }); describe("requestAudioInputStream", () => { diff --git a/apps/app/src/lib/audio-input-device-preference.ts b/apps/app/src/lib/audio-input-device-preference.ts index b156818fb0a..b536115b515 100644 --- a/apps/app/src/lib/audio-input-device-preference.ts +++ b/apps/app/src/lib/audio-input-device-preference.ts @@ -40,7 +40,7 @@ const audioInputDevicePreferenceAtom = { getOnInit: true }, ); -export function buildAudioInputConstraints( +function buildAudioInputConstraints( preferredDeviceId: PreferredAudioInputDeviceId, ): MediaStreamConstraints { if (preferredDeviceId === null) { diff --git a/apps/app/src/lib/composer-submissions.test.ts b/apps/app/src/lib/composer-submissions.test.ts deleted file mode 100644 index 7e2f1306962..00000000000 --- a/apps/app/src/lib/composer-submissions.test.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { describe, expect, it, vi } from "vitest"; -import { - notifyComposerSubmitted, - subscribeComposerSubmitted, -} from "./composer-submissions"; - -describe("composer submissions", () => { - it("scopes notifications and disposes listeners", () => { - const listener = vi.fn(); - const dispose = subscribeComposerSubmitted( - { kind: "thread", threadId: "one" }, - listener, - ); - notifyComposerSubmitted({ kind: "thread", threadId: "two" }); - expect(listener).not.toHaveBeenCalled(); - notifyComposerSubmitted({ kind: "thread", threadId: "one" }); - expect(listener).toHaveBeenCalledOnce(); - dispose(); - notifyComposerSubmitted({ kind: "thread", threadId: "one" }); - expect(listener).toHaveBeenCalledOnce(); - }); -}); diff --git a/apps/app/src/lib/dev-websocket-url.test.ts b/apps/app/src/lib/dev-websocket-url.test.ts index e01783eae9d..1881324a0ec 100644 --- a/apps/app/src/lib/dev-websocket-url.test.ts +++ b/apps/app/src/lib/dev-websocket-url.test.ts @@ -1,5 +1,5 @@ import { afterEach, describe, expect, it, vi } from "vitest"; -import { buildDevWebSocketUrl } from "./dev-websocket-url"; +import { buildBrowserWebSocketUrl } from "./dev-websocket-url"; function installWindowLocation(url: string): void { const location = new URL(url); @@ -13,7 +13,7 @@ function installWindowLocation(url: string): void { }); } -describe("buildDevWebSocketUrl", () => { +describe("buildBrowserWebSocketUrl", () => { afterEach(() => { vi.unstubAllGlobals(); }); @@ -23,9 +23,7 @@ describe("buildDevWebSocketUrl", () => { vi.stubGlobal("__BB_DEV_APP_BROWSER_HOST_PORT__", 15_802); installWindowLocation("http://devbox.local:15802/threads/thr_1"); - expect(buildDevWebSocketUrl({ path: "/ws" })).toBe( - "ws://devbox.local:23802/ws", - ); + expect(buildBrowserWebSocketUrl("/ws")).toBe("ws://devbox.local:23802/ws"); }); it("uses the proxied app origin for HTTPS bb connect shares", () => { @@ -35,7 +33,7 @@ describe("buildDevWebSocketUrl", () => { "https://sawyer--15802.getbb.app/threads/thr_jew2ruik89", ); - expect(buildDevWebSocketUrl({ path: "/ws" })).toBe( + expect(buildBrowserWebSocketUrl("/ws")).toBe( "wss://sawyer--15802.getbb.app/ws", ); }); @@ -45,7 +43,7 @@ describe("buildDevWebSocketUrl", () => { vi.stubGlobal("__BB_DEV_APP_BROWSER_HOST_PORT__", 15_802); installWindowLocation("http://sawyer.localhost:35802/threads/thr_1"); - expect(buildDevWebSocketUrl({ path: "/ws" })).toBe( + expect(buildBrowserWebSocketUrl("/ws")).toBe( "ws://sawyer.localhost:35802/ws", ); }); @@ -55,14 +53,14 @@ describe("buildDevWebSocketUrl", () => { vi.stubGlobal("__BB_DEV_APP_BROWSER_HOST_PORT__", 15_802); installWindowLocation("https://dev.example.test:15802/threads/thr_1"); - expect(buildDevWebSocketUrl({ path: "/ws/terminals/term_1" })).toBe( + expect(buildBrowserWebSocketUrl("/ws/terminals/term_1")).toBe( "wss://dev.example.test:15802/ws/terminals/term_1", ); }); - it("returns undefined outside the dev build", () => { + it("uses the page origin outside the dev build", () => { installWindowLocation("https://app.example.test/threads/thr_1"); - expect(buildDevWebSocketUrl({ path: "/ws" })).toBeUndefined(); + expect(buildBrowserWebSocketUrl("/ws")).toBe("wss://app.example.test/ws"); }); }); diff --git a/apps/app/src/lib/dev-websocket-url.ts b/apps/app/src/lib/dev-websocket-url.ts index 036f68044b7..7793c0d7d9c 100644 --- a/apps/app/src/lib/dev-websocket-url.ts +++ b/apps/app/src/lib/dev-websocket-url.ts @@ -32,7 +32,7 @@ function resolveDevWebSocketBaseUrl(): string | undefined { return undefined; } -export function buildDevWebSocketUrl( +function buildDevWebSocketUrl( args: BuildDevWebSocketUrlArgs, ): string | undefined { const baseUrl = resolveDevWebSocketBaseUrl(); diff --git a/apps/app/src/lib/environment-workspace-display.test.ts b/apps/app/src/lib/environment-workspace-display.test.ts index 17760a3cf51..e7a30d27698 100644 --- a/apps/app/src/lib/environment-workspace-display.test.ts +++ b/apps/app/src/lib/environment-workspace-display.test.ts @@ -11,14 +11,6 @@ import { } from "./environment-workspace-display"; describe("isHostAmbiguous", () => { - it("treats a lone persistent machine as unambiguous", () => { - expect(isHostAmbiguous(false, "persistent")).toBe(false); - }); - - it("treats more than one persistent machine as ambiguous", () => { - expect(isHostAmbiguous(true, "persistent")).toBe(true); - }); - it("treats a machine that is not persistent as ambiguous", () => { expect(isHostAmbiguous(false, "ephemeral")).toBe(true); expect(isHostAmbiguous(false, null)).toBe(true); diff --git a/apps/app/src/lib/in-app-browser-link-preference.test.ts b/apps/app/src/lib/in-app-browser-link-preference.test.ts index f287d40929a..f56026aad3a 100644 --- a/apps/app/src/lib/in-app-browser-link-preference.test.ts +++ b/apps/app/src/lib/in-app-browser-link-preference.test.ts @@ -1,131 +1,99 @@ import { describe, expect, it } from "vitest"; -import { - openUrlByPreference, - resolveUrlOpenTarget, -} from "./in-app-browser-link-preference"; +import { openUrlByPreference } from "./in-app-browser-link-preference"; -describe("resolveUrlOpenTarget", () => { - it("routes http(s) links into the in-app browser on desktop when enabled", () => { - expect( - resolveUrlOpenTarget({ - desktopBrowserAvailable: true, - openLinksInAppBrowser: true, - url: "https://example.com/docs", - }), - ).toBe("in-app-browser"); - expect( - resolveUrlOpenTarget({ - desktopBrowserAvailable: true, - openLinksInAppBrowser: true, - url: "HTTP://EXAMPLE.COM", - }), - ).toBe("in-app-browser"); - }); - - it("routes http(s) links to the external browser when the preference is off", () => { - expect( - resolveUrlOpenTarget({ - desktopBrowserAvailable: true, - openLinksInAppBrowser: false, - url: "https://example.com/docs", - }), - ).toBe("external-browser"); - }); - - it("routes http(s) links to the external browser when the desktop browser is unavailable (web)", () => { - expect( - resolveUrlOpenTarget({ - desktopBrowserAvailable: false, - openLinksInAppBrowser: true, - url: "https://example.com/docs", - }), - ).toBe("external-browser"); - }); +describe("openUrlByPreference", () => { + it.each([ + { + name: "opens http(s) URLs in the in-app browser when enabled on desktop", + desktopBrowserAvailable: true, + openLinksInAppBrowser: true, + url: "https://example.com/docs", + handled: true, + inApp: ["https://example.com/docs"], + external: [], + }, + { + name: "matches the http scheme case-insensitively", + desktopBrowserAvailable: true, + openLinksInAppBrowser: true, + url: "HTTP://EXAMPLE.COM", + handled: true, + inApp: ["HTTP://EXAMPLE.COM"], + external: [], + }, + { + name: "opens http(s) URLs externally when the preference is off", + desktopBrowserAvailable: true, + openLinksInAppBrowser: false, + url: "https://example.com/docs", + handled: true, + inApp: [], + external: ["https://example.com/docs"], + }, + { + name: "opens http(s) URLs externally when the desktop browser is unavailable (web)", + desktopBrowserAvailable: false, + openLinksInAppBrowser: true, + url: "https://example.com/docs", + handled: true, + inApp: [], + external: ["https://example.com/docs"], + }, + { + name: "routes application links externally even when the in-app browser is preferred", + desktopBrowserAvailable: true, + openLinksInAppBrowser: true, + url: "reflect://note/Project%20X", + handled: true, + inApp: [], + external: ["reflect://note/Project%20X"], + }, + ])( + "$name", + ({ + desktopBrowserAvailable, + openLinksInAppBrowser, + url, + handled, + inApp, + external, + }) => { + const openedInApp: string[] = []; + const openedExternally: string[] = []; - it("does not handle non-http links, even on desktop with the preference on", () => { - for (const url of [ - "mailto:hi@example.com", - "file:///Users/me/app.ts", - "/projects/abc", - "#section", - "//example.com", - "javascript:alert(1)", - ]) { expect( - resolveUrlOpenTarget({ - desktopBrowserAvailable: true, - openLinksInAppBrowser: true, + openUrlByPreference({ + desktopBrowserAvailable, + openLinksInAppBrowser, + openExternalBrowser: (opened) => openedExternally.push(opened), + openInAppBrowser: (opened) => openedInApp.push(opened), url, }), - ).toBe("unhandled"); - } - }); -}); + ).toBe(handled); -describe("openUrlByPreference", () => { - it("routes application links externally even when the in-app browser is preferred", () => { - const openedInApp: string[] = []; - const openedExternally: string[] = []; - expect( - openUrlByPreference({ - desktopBrowserAvailable: true, - openLinksInAppBrowser: true, - openExternalBrowser: (url) => openedExternally.push(url), - openInAppBrowser: (url) => openedInApp.push(url), - url: "reflect://note/Project%20X", - }), - ).toBe(true); - expect(openedInApp).toEqual([]); - expect(openedExternally).toEqual(["reflect://note/Project%20X"]); - }); - - it("opens http(s) URLs in the in-app browser when enabled", () => { - const openedInApp: string[] = []; - const openedExternally: string[] = []; - - expect( - openUrlByPreference({ - desktopBrowserAvailable: true, - openExternalBrowser: (url) => openedExternally.push(url), - openInAppBrowser: (url) => openedInApp.push(url), - openLinksInAppBrowser: true, - url: "https://example.com/docs", - }), - ).toBe(true); - - expect(openedInApp).toEqual(["https://example.com/docs"]); - expect(openedExternally).toEqual([]); - }); - - it("opens http(s) URLs externally when disabled", () => { - const openedInApp: string[] = []; - const openedExternally: string[] = []; - - expect( - openUrlByPreference({ - desktopBrowserAvailable: true, - openExternalBrowser: (url) => openedExternally.push(url), - openInAppBrowser: (url) => openedInApp.push(url), - openLinksInAppBrowser: false, - url: "https://example.com/docs", - }), - ).toBe(true); - - expect(openedInApp).toEqual([]); - expect(openedExternally).toEqual(["https://example.com/docs"]); - }); + expect(openedInApp).toEqual(inApp); + expect(openedExternally).toEqual(external); + }, + ); - it("leaves file links and non-web schemes to their dedicated handlers", () => { + it.each([ + "mailto:hi@example.com", + "file:///Users/me/app.ts", + "/projects/abc", + "#section", + "//example.com", + "javascript:alert(1)", + ])("leaves %s to its dedicated handler", (url) => { const openedInApp: string[] = []; const openedExternally: string[] = []; expect( openUrlByPreference({ desktopBrowserAvailable: true, - openExternalBrowser: (url) => openedExternally.push(url), - openInAppBrowser: (url) => openedInApp.push(url), openLinksInAppBrowser: true, - url: "file:///Users/me/app.ts", + openExternalBrowser: (opened) => openedExternally.push(opened), + openInAppBrowser: (opened) => openedInApp.push(opened), + url, }), ).toBe(false); diff --git a/apps/app/src/lib/in-app-browser-link-preference.ts b/apps/app/src/lib/in-app-browser-link-preference.ts index bd518362f02..27496695841 100644 --- a/apps/app/src/lib/in-app-browser-link-preference.ts +++ b/apps/app/src/lib/in-app-browser-link-preference.ts @@ -25,7 +25,7 @@ function isHttpOrHttpsUrl(url: string): boolean { return HTTP_URL_SCHEME_PATTERN.test(url); } -export function resolveUrlOpenTarget({ +function resolveUrlOpenTarget({ desktopBrowserAvailable, openLinksInAppBrowser, url, diff --git a/apps/app/src/lib/lifecycle-errors.test.ts b/apps/app/src/lib/lifecycle-errors.test.ts index 66a24ddb4f4..c7dbc8f4faa 100644 --- a/apps/app/src/lib/lifecycle-errors.test.ts +++ b/apps/app/src/lib/lifecycle-errors.test.ts @@ -4,7 +4,6 @@ import { HttpError } from "./api"; import { describeLifecycleError, formatLifecycleErrorDescription, - parseLifecycleError, type LifecycleErrorDescription, type LifecycleErrorOperation, } from "./lifecycle-errors"; @@ -58,22 +57,6 @@ const descriptionCases: DescriptionCase[] = [ severity: "warning", }, }, - { - name: "environment_not_ready ready with path", - body: { - code: "environment_not_ready", - message: "Environment unavailable", - details: { - environmentStatus: "ready", - hasPath: true, - }, - }, - expected: { - title: "Workspace unavailable", - body: "Workspace is unavailable.", - severity: "warning", - }, - }, { name: "environment_not_ready error", body: { @@ -537,36 +520,6 @@ const descriptionCases: DescriptionCase[] = [ }, ]; -describe("parseLifecycleError", () => { - it("parses HttpError bodies that match the lifecycle union", () => { - const body: LifecycleApiError = { - code: "environment_not_ready", - message: "Environment unavailable", - details: { - environmentStatus: "provisioning", - hasPath: false, - }, - }; - - expect(parseLifecycleError(httpError(body))).toEqual(body); - }); - - it("returns null for non-lifecycle errors", () => { - const genericError = new HttpError({ - body: { - code: "invalid_request", - message: "Request failed", - }, - code: "invalid_request", - message: "Request failed", - status: 400, - }); - - expect(parseLifecycleError(new Error("Nope"))).toBeNull(); - expect(parseLifecycleError(genericError)).toBeNull(); - }); -}); - describe("describeLifecycleError", () => { it.each(descriptionCases)("$name", ({ body, expected, operation }) => { expect( @@ -610,11 +563,18 @@ describe("describeLifecycleError", () => { }); it("returns null for non-lifecycle errors", () => { - expect( - describeLifecycleError({ - error: new Error("Failed"), - }), - ).toBeNull(); + const genericError = new HttpError({ + body: { + code: "invalid_request", + message: "Request failed", + }, + code: "invalid_request", + message: "Request failed", + status: 400, + }); + + expect(describeLifecycleError({ error: new Error("Failed") })).toBeNull(); + expect(describeLifecycleError({ error: genericError })).toBeNull(); }); it("keeps a gate rejection readable under an operation title", () => { diff --git a/apps/app/src/lib/lifecycle-errors.ts b/apps/app/src/lib/lifecycle-errors.ts index 756aaba9f77..fd9251fc73a 100644 --- a/apps/app/src/lib/lifecycle-errors.ts +++ b/apps/app/src/lib/lifecycle-errors.ts @@ -427,7 +427,7 @@ function describeDispatchHookFailed({ }); } -export function parseLifecycleError(error: unknown): LifecycleApiError | null { +function parseLifecycleError(error: unknown): LifecycleApiError | null { if (!(error instanceof HttpError) && !(error instanceof BbHttpError)) { return null; } diff --git a/apps/app/src/lib/notifications/app-toast-title-overflow.test.tsx b/apps/app/src/lib/notifications/app-toast-title-overflow.test.tsx deleted file mode 100644 index 52b8fa46633..00000000000 --- a/apps/app/src/lib/notifications/app-toast-title-overflow.test.tsx +++ /dev/null @@ -1,34 +0,0 @@ -// @vitest-environment jsdom -import { cleanup, fireEvent, render, screen } from "@testing-library/react"; -import { afterEach, expect, it, vi } from "vitest"; -import { AppToastContent } from "@/components/ui/app-toast"; -import { - getNotificationCenterState, - resetNotificationStore, -} from "./notification-store"; - -afterEach(() => { - cleanup(); - vi.restoreAllMocks(); - resetNotificationStore(); -}); - -it("opens the recorded notification when a title-only toast is truncated", () => { - vi.spyOn(HTMLElement.prototype, "scrollWidth", "get").mockReturnValue(600); - vi.spyOn(HTMLElement.prototype, "clientWidth", "get").mockReturnValue(300); - - render( - , - ); - - fireEvent.click(screen.getByRole("button", { name: "Show more" })); - - expect(getNotificationCenterState()).toEqual({ - open: true, - focusedId: "notification-7", - }); -}); diff --git a/apps/app/src/lib/notifications/notification-center.test.tsx b/apps/app/src/lib/notifications/notification-center.test.tsx index d02b1e02ffa..ef61282c92e 100644 --- a/apps/app/src/lib/notifications/notification-center.test.tsx +++ b/apps/app/src/lib/notifications/notification-center.test.tsx @@ -13,6 +13,7 @@ import { NotificationCenter } from "@/components/notifications/NotificationCente import { appToast } from "@/components/ui/app-toast"; import { getNotificationCenterState, + getNotifications, openNotificationCenter, resetNotificationStore, } from "./notification-store"; @@ -55,6 +56,9 @@ it("keeps notification details open when dismissing the toast restores composer }); fireEvent.click(showMore); expect(getNotificationCenterState().open).toBe(true); + expect(getNotificationCenterState().focusedId).toBe( + getNotifications()[0]?.id, + ); await act(async () => { await vi.advanceTimersByTimeAsync(5000); }); diff --git a/apps/app/src/lib/pierre-worker-pool-theme.test.ts b/apps/app/src/lib/pierre-worker-pool-theme.test.ts index d2ace3f5b89..aa94d77f820 100644 --- a/apps/app/src/lib/pierre-worker-pool-theme.test.ts +++ b/apps/app/src/lib/pierre-worker-pool-theme.test.ts @@ -12,14 +12,6 @@ function createFakePool() { } describe("syncPierreWorkerPoolTheme", () => { - it("does not call setRenderOptions when the pool already has the current theme", () => { - const { pool, setRenderOptions } = createFakePool(); - - syncPierreWorkerPoolTheme(pool, { ...CURRENT }, CURRENT); - - expect(setRenderOptions).not.toHaveBeenCalled(); - }); - it("pushes a theme change once, then stays quiet until the next change", () => { const { pool, setRenderOptions } = createFakePool(); const next = { dark: "github-dark", light: CURRENT.light }; diff --git a/apps/app/src/lib/plugin-bound-sdk.test.ts b/apps/app/src/lib/plugin-bound-sdk.test.ts index d228e60c5e3..fe1ee04dd18 100644 --- a/apps/app/src/lib/plugin-bound-sdk.test.ts +++ b/apps/app/src/lib/plugin-bound-sdk.test.ts @@ -185,13 +185,23 @@ describe("bindSdkToPlugin", () => { }); }); - it("preserves SDK arguments while applying cache updates", async () => { - const { sdk, queryClient, threads, threadSections } = makeSdk(); + it("adds a created section to the sidebar before resolving", async () => { + const { sdk, queryClient, threadSections } = makeSdk(); + const sidebarKey = sidebarNavigationQueryKey(); + queryClient.setQueryData( + sidebarKey, + makeSidebarBootstrapResponse({ sections: [] }), + ); const bound = bindSdkToPlugin(sdk, "thread-list", queryClient); - await bound.threads.pin({ threadId: "thr_1" }); + await bound.threadSections.create({ name: "Later" }); - expect(threads.pin).toHaveBeenCalledWith({ threadId: "thr_1" }); + expect(threadSections.create).toHaveBeenCalledWith({ name: "Later" }); + expect( + queryClient + .getQueryData(sidebarKey) + ?.sections.map((section) => section.id), + ).toEqual(["sec_created"]); }); it("batches synchronous plugin thread metadata updates into one optimistic transaction", async () => { diff --git a/apps/app/src/lib/plugin-sdk-hooks.test.ts b/apps/app/src/lib/plugin-sdk-hooks.test.ts index 04fe2b6f946..34392be7c12 100644 --- a/apps/app/src/lib/plugin-sdk-hooks.test.ts +++ b/apps/app/src/lib/plugin-sdk-hooks.test.ts @@ -78,6 +78,7 @@ describe("callPluginRpc", () => { ["not_found", 404], ["conflict", 409], ["invalid", 422], + ["invalid_input", 400], ])( "preserves refusal %s and HTTP %s for useRpc and query hooks", async (code, status) => { @@ -135,29 +136,6 @@ describe("callPluginRpc", () => { }); }); - it("surfaces structured wire failures with stable code and issues", async () => { - const fetchImpl = vi.fn(async () => - jsonResponse( - { - ok: false, - error: { - code: "invalid_input", - message: "rpc input validation failed", - issues: [{ path: ["id"], message: "Required" }], - }, - }, - false, - 400, - ), - ); - const promise = callPluginRpc(fetchImpl, "demo", "lookup", {}); - await expect(promise).rejects.toMatchObject({ - code: "invalid_input", - message: "rpc input validation failed", - issues: [{ path: ["id"], message: "Required" }], - }); - }); - it("rejects cyclic and non-finite inputs before fetch", async () => { const fetchImpl = vi.fn(); const cyclic: { self?: unknown } = {}; diff --git a/apps/app/src/lib/plugin-sidebar-hooks.test.tsx b/apps/app/src/lib/plugin-sidebar-hooks.test.tsx index 6c250289477..7e3731fa12b 100644 --- a/apps/app/src/lib/plugin-sidebar-hooks.test.tsx +++ b/apps/app/src/lib/plugin-sidebar-hooks.test.tsx @@ -18,7 +18,6 @@ import { useSidebarThreadRowStatuses, useSidebarThreadShortcut, useSidebarThreads, - useSidebarThreadEntry, } from "./plugin-sidebar-hooks"; import { clearPluginThreadRowStatuses, @@ -275,17 +274,6 @@ describe("sidebar lifecycle selection", () => { expect(result.current.threads).toHaveLength(1); expect(result.current.experimental_archived?.status).toBe("error"); }); - - it("resolves archived entries for host-owned row actions and status", () => { - const archived = makeThreadListEntry({ - id: "thr_archived", - archivedAt: 42, - }); - state.data = payload([]); - archiveQuery.data = { pages: [[archived]] }; - const { result } = renderHook(() => useSidebarThreadEntry(archived.id)); - expect(result.current).toBe(archived); - }); }); describe("useSidebarThreads sections", () => { diff --git a/apps/app/src/lib/plugin-sidebar-threads.test.ts b/apps/app/src/lib/plugin-sidebar-threads.test.ts index 9aef539124c..87b23f17bcb 100644 --- a/apps/app/src/lib/plugin-sidebar-threads.test.ts +++ b/apps/app/src/lib/plugin-sidebar-threads.test.ts @@ -21,8 +21,9 @@ describe("toPluginSidebarThread", () => { it("resolves the display title through the same rules bb's row uses", () => { expect(toPluginSidebarThread(makeThread()).displayTitle).toBe("A thread"); expect( - toPluginSidebarThread(makeThread({ title: null, titleFallback: "Fallback" })) - .displayTitle, + toPluginSidebarThread( + makeThread({ title: null, titleFallback: "Fallback" }), + ).displayTitle, ).toBe("Fallback"); expect( toPluginSidebarThread( @@ -65,43 +66,6 @@ describe("toPluginSidebarThread", () => { }); }); - it("resolves the indicator with the host's precedence", () => { - expect( - toPluginSidebarThread( - makeThread({ - hasPendingInteraction: true, - runtime: { - displayStatus: "active", - }, - }), - ).indicator, - ).toBe("waiting-for-input"); - - expect( - toPluginSidebarThread( - makeThread({ - runtime: { - displayStatus: "active", - }, - }), - ).indicator, - ).toBe("runtime"); - - expect( - toPluginSidebarThread( - makeThread({ - activity: { - activeWorkflowCount: 1, - activeBackgroundAgentCount: 0, - activeBackgroundCommandCount: 0, - activePlanModeCount: 0, - activeGoalCount: 0, - }, - }), - ).indicator, - ).toBe("workflow"); - }); - it("carries the host's accessible label, and null for none", () => { expect( toPluginSidebarThread(makeThread({ hasPendingInteraction: true })) diff --git a/apps/app/src/lib/plugin-slots.test.ts b/apps/app/src/lib/plugin-slots.test.ts index 22d55d6be12..2ea2a367d25 100644 --- a/apps/app/src/lib/plugin-slots.test.ts +++ b/apps/app/src/lib/plugin-slots.test.ts @@ -43,6 +43,7 @@ describe("plugin slot store", () => { registrationSet({ homepageSections: [ { id: "a", title: "Alpha", component: SectionComponent }, + { id: "b", title: "Beta", component: SectionComponent }, ], composerCustomizations: [ { @@ -55,8 +56,15 @@ describe("plugin slot store", () => { const snapshot = getPluginSlotSnapshot(); expect( - snapshot.homepageSections.map((section) => section.pluginId), - ).toEqual(["alpha", "zeta"]); + snapshot.homepageSections.map((section) => [ + section.pluginId, + section.id, + ]), + ).toEqual([ + ["alpha", "a"], + ["alpha", "b"], + ["zeta", "z"], + ]); expect(snapshot.composerCustomizations).toHaveLength(1); expect(snapshot.composerCustomizations[0]?.pluginId).toBe("alpha"); }); @@ -139,43 +147,6 @@ describe("plugin slot store", () => { expect(listener).toHaveBeenCalledTimes(2); unsubscribe(); }); - - it("returns a stable snapshot object between changes", () => { - setPluginSlotRegistrations("demo", registrationSet()); - const first = getPluginSlotSnapshot(); - expect(getPluginSlotSnapshot()).toBe(first); - }); - - it("flattens messageDirectives sorted by plugin id with generation metadata", () => { - setPluginSlotRegistrations( - "zeta", - registrationSet({ - messageDirectives: [{ id: "z-vis", component: DirectiveComponent }], - }), - ); - setPluginSlotRegistrations( - "alpha", - registrationSet({ - messageDirectives: [ - { id: "inline-vis", component: DirectiveComponent }, - { id: "chart", component: DirectiveComponent }, - ], - }), - ); - - const snapshot = getPluginSlotSnapshot(); - expect( - snapshot.messageDirectives.map((directive) => ({ - pluginId: directive.pluginId, - id: directive.id, - generation: directive.generation, - })), - ).toEqual([ - { pluginId: "alpha", id: "inline-vis", generation: 1 }, - { pluginId: "alpha", id: "chart", generation: 1 }, - { pluginId: "zeta", id: "z-vis", generation: 1 }, - ]); - }); }); describe("plugin slot store structural sharing", () => { diff --git a/apps/app/src/lib/provider-icon.test.tsx b/apps/app/src/lib/provider-icon.test.tsx index bde6efe359f..bf16dadea20 100644 --- a/apps/app/src/lib/provider-icon.test.tsx +++ b/apps/app/src/lib/provider-icon.test.tsx @@ -145,6 +145,7 @@ describe("getProviderIconInfo", () => { it("renders a generic fallback for a provider known only by id", () => { const info = getProviderIconInfo("agent", "codex"); + expect(info.ariaLabel).toBe("codex"); const view = render(createElement(info.icon)); expect(view.container.querySelector('[data-icon="Code"]')).not.toBeNull(); act(() => @@ -209,65 +210,6 @@ describe("getProviderIconInfo", () => { bothView.container.querySelector("[data-provider-logo]"), ).not.toBeNull(); bothView.unmount(); - - expect( - getProviderIconInfo("agent", "echo-agent", { logoUrl: null }), - ).toBeDefined(); - }); - - it("lets a plugin-registered component win, and falls back when it goes away", () => { - const iconInfo = getProviderIconInfo("agent", "codex", { - logoUrl: "/api/v1/system/providers/codex/logo", - }); - if (iconInfo === undefined) { - throw new Error("Expected icon info for codex"); - } - const view = render(createElement(iconInfo.icon, { className: "size-4" })); - expect(view.container.querySelector("[data-testid]")).toBeNull(); - expect(view.container.querySelector("[data-provider-logo]")).not.toBeNull(); - - act(() => { - setPluginSlotRegistrations("provider-codex", { - ...EMPTY_REGISTRATIONS, - providerIcons: [ - { providerKind: "agent", providerId: "codex", icon: PluginCodexIcon }, - ], - }); - }); - - const pluginMark = view.container.querySelector( - '[data-testid="plugin-codex-icon"]', - ); - expect(pluginMark).not.toBeNull(); - expect(view.container.querySelector("[data-provider-logo]")).toBeNull(); - - act(() => { - removePluginSlotRegistrations("provider-codex"); - }); - expect( - view.container.querySelector('[data-testid="plugin-codex-icon"]'), - ).toBeNull(); - expect(view.container.querySelector("[data-provider-logo]")).not.toBeNull(); - view.unmount(); - }); - - it("renders a plugin icon for a provider that has no vendored mark", () => { - setPluginSlotRegistrations("provider-thing", { - ...EMPTY_REGISTRATIONS, - providerIcons: [ - { providerKind: "agent", providerId: "thing", icon: PluginCodexIcon }, - ], - }); - const iconInfo = getProviderIconInfo("agent", "thing"); - if (iconInfo === undefined) { - throw new Error("Expected plugin icon info for thing"); - } - expect(iconInfo.ariaLabel).toBe("thing"); - const view = render(createElement(iconInfo.icon, {})); - expect( - view.container.querySelector('[data-testid="plugin-codex-icon"]'), - ).not.toBeNull(); - view.unmount(); }); it("keeps the first plugin by id when two claim one provider", () => { @@ -316,6 +258,8 @@ describe("getProviderIconInfo", () => { expect(byFamily.ariaLabel).toBe("ACP provider"); familyView.unmount(); - expect(getProviderIconInfo("agent", "acp-unregistered")).toBeDefined(); + expect(getProviderIconInfo("agent", "acp-unregistered").ariaLabel).toBe( + "acp-unregistered", + ); }); }); diff --git a/apps/app/src/lib/retired-sidebar-pull-request.test.tsx b/apps/app/src/lib/retired-sidebar-pull-request.test.tsx index fcfffb6d216..3370804466d 100644 --- a/apps/app/src/lib/retired-sidebar-pull-request.test.tsx +++ b/apps/app/src/lib/retired-sidebar-pull-request.test.tsx @@ -19,17 +19,6 @@ vi.mock("@tanstack/react-query", async (importOriginal) => ({ useQuery: () => ({ data: keyedQuery.pluginEnabled }), })); -vi.mock("@get-bb/plugin-sdk/app", () => ({ - experimental_useRpcKeyedQuery: (options: { keys: readonly string[] }) => ({ - data: keyedQuery.data, - error: null, - isLoading: false, - isFetching: false, - refetch: () => keyedQuery.refetch(options.keys), - }), - experimental_useRpcMutation: () => ({ mutate: vi.fn(), isPending: false }), -})); - vi.mock("@/lib/plugin-sdk-hooks", () => ({ experimental_useRpcKeyedQuery: (options: { keys: readonly string[] }) => ({ data: keyedQuery.data, diff --git a/apps/app/src/lib/split-layout/ops.test.ts b/apps/app/src/lib/split-layout/ops.test.ts index 0816e71b98a..e980ef42e57 100644 --- a/apps/app/src/lib/split-layout/ops.test.ts +++ b/apps/app/src/lib/split-layout/ops.test.ts @@ -217,15 +217,14 @@ describe("split layout operations", () => { const low = resizeSplit(two, [], 0, -10); const high = resizeSplit(low, [], 0, 10); - if (low.root.type === "split") { - expect(low.root.sizes[0]).toBeCloseTo(0.15, 12); - expect(low.root.sizes[1]).toBeCloseTo(0.85, 12); - } - if (high.root.type === "split") { - expect(high.root.sizes[0]).toBeCloseTo(0.85, 12); - expect(high.root.sizes[1]).toBeCloseTo(0.15, 12); - expect(high.root.sizes.reduce((sum, size) => sum + size, 0)).toBe(1); + if (low.root.type !== "split" || high.root.type !== "split") { + throw new Error("Expected split roots"); } + expect(low.root.sizes[0]).toBeCloseTo(0.15, 12); + expect(low.root.sizes[1]).toBeCloseTo(0.85, 12); + expect(high.root.sizes[0]).toBeCloseTo(0.85, 12); + expect(high.root.sizes[1]).toBeCloseTo(0.15, 12); + expect(high.root.sizes.reduce((sum, size) => sum + size, 0)).toBe(1); expect(resizeSplit(high, [], 1, 0.5)).toBe(high); expect(resizeSplit(high, [0], 0, 0.5)).toBe(high); }); diff --git a/apps/app/src/lib/use-composers.test.tsx b/apps/app/src/lib/use-composers.test.tsx index 512873d2a2b..7df4d8ac322 100644 --- a/apps/app/src/lib/use-composers.test.tsx +++ b/apps/app/src/lib/use-composers.test.tsx @@ -139,8 +139,12 @@ describe("useComposers", () => { const { result } = renderHook(() => useComposers(), { wrapper }); result.current[0]!.setInputLock(true); + result.current[0]!.setTextEffect({ className: "listed-effect" }); expect(warn).toHaveBeenCalledWith( expect.stringContaining("useComposers() composer.setInputLock"), ); + expect(warn).toHaveBeenCalledWith( + expect.stringContaining("useComposers() composer.setTextEffect"), + ); }); }); diff --git a/apps/app/src/lib/ws.plugin-signal.test.ts b/apps/app/src/lib/ws.plugin-signal.test.ts index cea20a4378a..d77e3fcb8dc 100644 --- a/apps/app/src/lib/ws.plugin-signal.test.ts +++ b/apps/app/src/lib/ws.plugin-signal.test.ts @@ -42,23 +42,4 @@ describe("WebSocketManager plugin-signal routing", () => { expect(received).toHaveBeenCalledTimes(1); expect(received.mock.calls[0]?.[0]).not.toHaveProperty("futureField"); }); - - it("does not misroute other message types to plugin subscribers", () => { - const manager = new WebSocketManager(); - const pluginSignals = vi.fn(); - const changed = vi.fn(); - manager.onPluginSignal(pluginSignals); - manager.onChanged(changed); - - manager.handleIncomingMessage( - JSON.stringify({ - type: "changed", - entity: "system", - changes: ["plugins-changed"], - }), - ); - - expect(pluginSignals).not.toHaveBeenCalled(); - expect(changed).toHaveBeenCalledTimes(1); - }); }); diff --git a/apps/app/src/lib/ws.test.ts b/apps/app/src/lib/ws.test.ts index 9363d2b4659..702890d66e6 100644 --- a/apps/app/src/lib/ws.test.ts +++ b/apps/app/src/lib/ws.test.ts @@ -394,8 +394,10 @@ describe("WebSocketManager thread-open signals", () => { const { manager } = createConnectedManager(); const changed = vi.fn(); const threadOpen = vi.fn(); + const pluginSignals = vi.fn(); manager.onChanged(changed); manager.onThreadOpen(threadOpen); + manager.onPluginSignal(pluginSignals); dispatchRaw({ type: "changed", @@ -406,6 +408,7 @@ describe("WebSocketManager thread-open signals", () => { expect(changed).toHaveBeenCalledTimes(1); expect(threadOpen).not.toHaveBeenCalled(); + expect(pluginSignals).not.toHaveBeenCalled(); }); it("routes typed thread-pane actions separately", () => { diff --git a/apps/app/src/test/virtualizer-scroll-lifecycle.test.tsx b/apps/app/src/test/virtualizer-scroll-lifecycle.test.tsx deleted file mode 100644 index 8db778dacac..00000000000 --- a/apps/app/src/test/virtualizer-scroll-lifecycle.test.tsx +++ /dev/null @@ -1,65 +0,0 @@ -// @vitest-environment jsdom - -import { useVirtualizer, useWindowVirtualizer } from "@tanstack/react-virtual"; -import { cleanup, fireEvent, render } from "@testing-library/react"; -import { afterEach, describe, expect, it, vi } from "vitest"; - -function ElementVirtualizer({ - scrollElement, - onChange, -}: { - scrollElement: HTMLElement; - onChange: () => void; -}) { - useVirtualizer({ - count: 100, - estimateSize: () => 32, - getScrollElement: () => scrollElement, - onChange, - }); - return null; -} - -function WindowVirtualizer({ onChange }: { onChange: () => void }) { - useWindowVirtualizer({ - count: 100, - estimateSize: () => 32, - onChange, - }); - return null; -} - -afterEach(() => { - cleanup(); - vi.clearAllTimers(); - vi.useRealTimers(); -}); - -describe("virtualizer scroll lifecycle", () => { - it.each(["element", "window"] as const)( - "cancels the pending scroll reset when the %s virtualizer unmounts", - (target) => { - vi.useFakeTimers(); - const onChange = vi.fn(); - const scrollElement = document.createElement("div"); - const rendered = render( - target === "element" ? ( - - ) : ( - - ), - ); - fireEvent.scroll(target === "element" ? scrollElement : window); - expect(vi.getTimerCount()).toBeGreaterThan(0); - - rendered.unmount(); - onChange.mockClear(); - expect(vi.getTimerCount()).toBe(0); - vi.advanceTimersByTime(300); - expect(onChange).not.toHaveBeenCalled(); - }, - ); -}); diff --git a/apps/app/src/views/ToolsView.plugin-detail.test.tsx b/apps/app/src/views/ToolsView.plugin-detail.test.tsx index 8742d2ecc60..5f4e47d9ba5 100644 --- a/apps/app/src/views/ToolsView.plugin-detail.test.tsx +++ b/apps/app/src/views/ToolsView.plugin-detail.test.tsx @@ -1998,6 +1998,7 @@ describe("PluginDetail banner precedence", () => { expect(alerts[0]?.textContent).toContain("Wait, then reload."); expect(alerts[0]?.textContent).not.toContain("issue-sync"); expect(alerts[0]?.textContent).not.toContain("handler"); + expect(alerts[0]?.textContent).not.toContain("Restart bb"); expect(screen.getByRole("button", { name: "Reload" })).toBeTruthy(); expect(screen.queryByRole("button", { name: "Update" })).toBeNull(); }); @@ -2131,27 +2132,6 @@ describe("PluginDetail runtime health", () => { ).toBeTruthy(); }); - it("offers Reload for degraded runtime status and keeps diagnostics out of the banner", () => { - renderRuntimeStatus("degraded", { - statusDetail: "service issue-sync did not stop", - handlerStats: { - ...GITHUB_PLUGIN.handlerStats, - errorCount: 3, - }, - }); - - const alerts = screen.getAllByRole("alert"); - expect(alerts).toHaveLength(1); - const alertText = alerts[0]?.textContent; - expect(alertText).toContain("Degraded"); - expect(alertText).toContain("A service is still stopping."); - expect(alertText).toContain("Wait, then reload."); - expect(alertText).not.toContain("issue-sync"); - expect(alertText).not.toContain("handler"); - expect(alertText).not.toContain("Restart bb"); - expect(screen.getByRole("button", { name: "Reload" })).toBeTruthy(); - }); - it.each([ ["incompatible", "This version is incompatible with bb.", "Update bb."], ["missing", "Plugin files are missing.", "Update or reinstall bb."], diff --git a/apps/app/src/views/thread-detail/PaneMaximizeButton.test.tsx b/apps/app/src/views/thread-detail/PaneMaximizeButton.test.tsx index da4a1b792c1..a9b553ac62e 100644 --- a/apps/app/src/views/thread-detail/PaneMaximizeButton.test.tsx +++ b/apps/app/src/views/thread-detail/PaneMaximizeButton.test.tsx @@ -15,10 +15,7 @@ import { createBbDesktopApi } from "@/test/bb-desktop-test-utils"; import { focusWithKeyboard } from "@/test/keyboard-focus"; import { useIsBrowserDimmingModalOpen } from "@/hooks/useBrowserDimmingModal"; import { PaneContext, type PaneContextValue } from "./PaneContext"; -import { - PaneMaximizeButton, - resolvePaneArrangementLabel, -} from "./PaneMaximizeButton"; +import { PaneMaximizeButton } from "./PaneMaximizeButton"; vi.mock("@/components/commands/AppCommandProvider", () => ({ useAppCommandShortcut: () => ({ @@ -208,6 +205,12 @@ describe("PaneMaximizeButton", () => { screen.getByRole("menuitem", { name: /Full Screen/ }), ).not.toBeNull(); expect(menu.textContent).not.toContain("Maximize pane"); + + cleanup(); + renderButton(true); + expect( + screen.getByRole("button", { name: "Exit Full Screen (βŒ˜β‡§E)" }), + ).not.toBeNull(); }); it("hides the native desktop browser while the arrangement menu can cover it", () => { @@ -275,19 +278,3 @@ describe("PaneMaximizeButton", () => { expect(screen.queryByRole("button")).toBeNull(); }); }); - -describe("resolvePaneArrangementLabel", () => { - it.each([ - [false, false, "Maximize pane"], - [false, true, "Restore split"], - [true, false, "Full Screen"], - [true, true, "Exit Full Screen"], - ] as const)( - "resolves desktop=%s fullScreen=%s as %s", - (isDesktopApp, isFullScreen, expected) => { - expect(resolvePaneArrangementLabel({ isDesktopApp, isFullScreen })).toBe( - expected, - ); - }, - ); -}); diff --git a/apps/app/src/views/thread-detail/PaneMaximizeButton.tsx b/apps/app/src/views/thread-detail/PaneMaximizeButton.tsx index e75a3a98ec7..a96f82726f4 100644 --- a/apps/app/src/views/thread-detail/PaneMaximizeButton.tsx +++ b/apps/app/src/views/thread-detail/PaneMaximizeButton.tsx @@ -35,7 +35,7 @@ const ARRANGEMENT_REGION_CLASS: Record = { bottom: "inset-x-[3px] bottom-[3px] h-1.5", }; -export function resolvePaneArrangementLabel({ +function resolvePaneArrangementLabel({ isDesktopApp, isFullScreen, }: {