Repository navigation
Prune low-value tests in @bb/app - #6940
Merged
Merged
Conversation
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 <noreply@anthropic.com>
ymichael
added a commit
that referenced
this pull request
Nov 3, 2026
…rittle setup (#6949) ## Human comments ## What was wrong The `@bb/app` test audit (#6940) found test problems it left for a follow-up: - The "hidden sidebar thread list" test was in `sidebar.bench.test.tsx`, which `vitest.config.ts` excludes unless `BB_SIDEBAR_BENCH=1`, so CI never ran it. - Six tests in `ThreadTimelineRows.actions.test.tsx` replaced `HTMLElement.prototype.scrollIntoView` with `Object.defineProperty` and never put it back, so a `vi.fn()` leaked into later tests in the same worker. - Nothing tested the palette's archived-recents fetch gate (`ThreadSearchPaletteMode.tsx`). - The realtime thread-invalidation debounce and max-wait were checked only by comparing a constants object. - Several files repeated the same setup block many times. - Some class assertions ran a regex over static markup, and some checks matched exact source strings, so harmless refactors broke them. ## What changed - **Hidden sidebar list test now runs.** Moved it to `PluginThreadList.hidden.test.tsx`. Its fixture builders and render wrapper are now in `src/test/fixtures/sidebar-thread-list.tsx`, shared with the bench. The test also now asserts that the recorder actually saw thread ids; before, `every()` over an empty array passed trivially. - **`scrollIntoView` leak fixed.** `ThreadTimelineRows.actions` now uses `vi.spyOn(HTMLElement.prototype, "scrollIntoView")`, which the existing `restoreAllMocks` undoes. - **New test: archived-recents gate** (`CommandPalette.test.tsx`). Archived recents load only while Archived is selected and the trimmed query is empty. - **New test: invalidation timing** (`realtime-cache-effects.test.ts`). For fine and coarse pointers, a single change flushes after `debounceMs`, and a continuous burst flushes at `maxWaitMs`. To support the coarse case, the pointer cadence is now resolved when `createRealtimeCacheEffects` runs instead of at module import. `useWebSocket` creates the effects once per mount, so the app behaves the same. The test-only `resolveThreadInvalidationDebounce` export is removed. - **Setup shrunk:** - `lifecycle-errors.test.ts`: tuple rows with per-code builders (−256 lines) - `plugin-frontend-reload.test.ts`: `reconcileHarness` and module/stylesheet helpers (−220) - `ToolsView.plugin-detail.test.tsx`: `renderPluginDetail` (−189) - `ui-preferences-sync.test.ts`: `startSyncedHarness`, `holdNextWrite` and `responseWithout` (−46) - **Brittle checks replaced:** - DOM `classList` and role queries instead of markup regexes in `route-loading-skeleton`, `scroll-to-bottom-button`, `bottom-anchored-scroll-body.grid`, `ProviderCliBanner`, `ThreadMachineStatus` and `ThreadPromptContextBanner`. - `theme-preview-fixture-anatomy` checks that a class set appears in the file in any order, not exact substrings. It imports the real sidebar row state constants. - The eager runtime-modules test derives its expected keys from `RUNTIME_SLOT_BY_SPECIFIER`. To make that importable from the app test, `@bb/plugin-build` gains a `./runtime-shims` subpath export; the package root pulls in node-only build code. No wire, CLI or protocol changes. ## How you verified - `pnpm exec turbo run typecheck lint --filter=@bb/app`: passes, 0 lint errors, no warnings in changed files. - I ran only the 16 changed test files, not the full suite: 441 tests, all pass. CI runs the full suites. - **Mutation checks.** Each check broke the production code a rewritten or new test guards, confirmed the test fails, then restored the code: - **Hidden list:** forcing windowed rows to realize in a zero-height sidebar fails the moved test. Ignoring the hidden-surface flag in `retainThreadId` and in the bulk retain does not fail it, because no rows mount while hidden. The test had the same gap in the bench file. - **`scrollIntoView`:** a trailing probe asserting it is not a mock fails on the old file and passes on the new one. - **Archived gate:** dropping the query condition, dropping the lifecycle condition, or using the untrimmed query each fail the test. - **Timing:** changing fine max-wait to 400, coarse max-wait to 1000, or coarse debounce to 50, or inverting pointer detection, each fails it. - **`lifecycle-errors`:** 6 mutations, including a severity flip, a title change, `isSenderThread` and the hook-failed message. Each fails the old and new tests alike. - **`ui-preferences-sync`:** 7 mutations (revision tracking, pending-write overwrite, conflict retry, queue merge and drain, default save, toast). Each fails the same tests old and new. - **`plugin-frontend-reload`:** 6 mutations (deactivation cleanup, generation bump, stylesheet wait, stale module, abort signal, old stylesheet kept). Each fails the same tests old and new. - **`ToolsView`:** 7 mutations, including Reload for degraded, capability rows, and ignored `onDelete`, `onOpenSource`, `openSourceDisabled` and `catalogEntry`. All fail. - **Class checks:** about 30 class and structure mutations fail both the old and new tests. - **Theme anatomy:** changing a class or data attribute the mock copies fails the test; reordering classes passes. - **Runtime slots:** adding a fake slot to `RUNTIME_SLOT_BY_SPECIFIER`, or removing `vaul` from `installPluginRuntime`, each fails the test. - `BB_SIDEBAR_BENCH=1 BB_SIDEBAR_BENCH_THREADS=300` still runs the bench end to end. > AGENT GENERATED 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
@bb/apphad grown to 657 test files and 6,809 tests. Many tests checked a contract that another test already covered more strongly. Others only exercised wiring, tested a third-party library, or held assertions that could not fail. A few productionexports and one parameter existed only for these tests. This made the suite slower to run and maintain without catching any extra bugs.What changed
Test files only, apart from removing test-only exports. Net −1,077 test lines across 58 files (+290 / −1,367), four whole files deleted, and 6,809 → 6,750 tests. Production changes are +8 / −11 across 7 files, with no behaviour change.
Removed
ThreadTitleMentions.resources.test.tsbut never removed from the original. Also sibling tests repeating the same setup and assertion, and mocked copies of scenarios that already run through the real code:composer-submissions,app-toast-title-overflow, OnboardingGate, AddMachineDialog expiry, ToolsView banners, provider-icon, plugin-slots, the cache-owner rename, pin acknowledgement, the CommandPalette settings page, QuestionForm, and the PromptBox/composer-contract rejection.resolveUrlOpenTarget,parseLifecycleError,buildAudioInputConstraints,resolvePaneArrangementLabel); realtime registry rows thatsatisfies Record<…>already enforces at typecheck; a snapshot-identity check covered by a stricter structural-sharing test.src/test/virtualizer-scroll-lifecycle.test.tsxtested@tanstack/virtual-coreand guarded a repo patch that Give the timeline's reading position one owner so scrolling stops jumping #5951 removed. Upstream now cancels the timer itself.hasPath, which no code reads; BrowserTabDeck rows that pass either way; a FollowUpPromptBox placeholder test whose two placeholders were the same string; a deadvi.mockof a module the code under test never imports.exportfrombuildAudioInputConstraints,buildDevWebSocketUrl,resolveUrlOpenTarget,parseLifecycleError,threadTitleTextSegmentsandresolvePaneArrangementLabel. RemovedgetSecondaryPanelChromeStackClassName'shasGitDiffToolbarparameter; its only caller passedfalse.Repaired (assertions that could not fail)
plugin-bound-sdk: the test promised cache updates but only checked call shape. It now asserts that a created section reaches the sidebar cache beforecreateresolves. That behaviour (Restore optimistic sidebar updates and group archive Undo #5045) had no test before.split-layout/ops:if (root.type === "split")guards could skip every resize-clamp assertion; they now throw on a non-split root.provider-icon:toBeDefined()on a non-optional return replaced with realariaLabelchecks.use-composers: the test named "lock or paint" now also exercisessetTextEffect.ThreadMetadataContent:path: nulllet the "provisioning" test pass without its status check.TextDecoder. It now writes throughwriteTerminalOutputinto a real xterm.focusEnd, the voice transition while hidden or under reduced motion, and the model-picker cycle-chord exception could all pass with the guarded code removed. They now fail when it is.dev-websocket-urlnow goes throughbuildBrowserWebSocketUrl, which also covers the production fallback URL.How you verified
mainand of this branch. For every removed or merged test, they wrote the bug it caught as a mutation of the production code. They confirmed the old test fails onmainand that a remaining test fails on this branch, then restored the source.resolveThreadTitleDisplayText. The rendered pills hide this bug, but the AppLayout title, archived-threads settings and the parent-thread picker show it.aria-keyshortcutslabel, QueuedMessagesList open/close reporting and overflow toggling, older touch actions at the former width threshold, the touch-selection menu side (Open the selection menu below touch selections on Android #6567), the terminal-view unmount, the plugin update-action icon, the marketplace icon in AddPluginDialog, the ReuseEnvironmentPicker secondary text, the app chrome row-height token, the focused notification on title Show more, the mapper's unread-error indicator, theuseThreadStorageLocationfetch, the thread invalidationmaxWaitbounds, and the sidebar info-tab id.hasPathlifecycle row (no code readshasPath) and a singleshrink-0class pin.pnpm exec turbo run test --filter=@bb/appran 6,809 tests, with 6 failures at machine load ~89. All six pass when run alone or at normal load.pnpm exec turbo run lint typecheck test --filter=@bb/appgave 0 lint errors, a clean typecheck, and 6,740 of 6,750 tests passing (9 skipped).CommandPalette"runs an available shortcut … after closing and restoring focus", timed out opening the palette at load ~79. It failed the same way in the baseline run onmain.--force).🤖 Generated with Claude Code