Skip to content

Prune low-value tests in @bb/app - #6940

Merged
ymichael merged 1 commit into
mainfrom
bb/test-audit-apps-app-thr_myab49tr68
Nov 3, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/test-audit-apps-app-thr_myab49tr68

Conversation

@ymichael

@ymichael ymichael commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

@bb/app had 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 production exports 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

  • Duplicates: the raw-thread-id title tests that Build test databases from one template, share test setup, and move DOM-free tests out of jsdom #5261 copied into ThreadTitleMentions.resources.test.ts but 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.
  • Wiring and constant pins: small helpers tested directly when their only caller is tested (resolveUrlOpenTarget, parseLifecycleError, buildAudioInputConstraints, resolvePaneArrangementLabel); realtime registry rows that satisfies Record<…> already enforces at typecheck; a snapshot-identity check covered by a stricter structural-sharing test.
  • Third-party only: src/test/virtualizer-scroll-lifecycle.test.tsx tested @tanstack/virtual-core and 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.
  • Vacuous: a lifecycle-error row varying hasPath, which no code reads; BrowserTabDeck rows that pass either way; a FollowUpPromptBox placeholder test whose two placeholders were the same string; a dead vi.mock of a module the code under test never imports.
  • Test-only production seams: dropped export from buildAudioInputConstraints, buildDevWebSocketUrl, resolveUrlOpenTarget, parseLifecycleError, threadTitleTextSegments and resolvePaneArrangementLabel. Removed getSecondaryPanelChromeStackClassName's hasGitDiffToolbar parameter; its only caller passed false.

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 before create resolves. 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 real ariaLabel checks.
  • use-composers: the test named "lock or paint" now also exercises setTextEffect.
  • ThreadMetadataContent: path: null let the "provisioning" test pass without its status check.
  • Terminal UTF-8 split glyph: this tested the browser's TextDecoder. It now writes through writeTerminalOutput into a real xterm.
  • Early 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-url now goes through buildBrowserWebSocketUrl, which also covers the production fallback URL.

How you verified

  • Mutation checks. Three independent reviewers worked on dedicated worktrees of main and 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 on main and that a remaining test fails on this branch, then restored the source.
    • About 110 mutations were run. 18 removals turned out to be the only guard on their contract; 16 of those were restored.
    • The most important restoration: a known raw thread id must display as its title through the synchronous resolveThreadTitleDisplayText. The rendered pills hide this bug, but the AppLayout title, archived-threads settings and the parent-thread picker show it.
    • Other restorations: the Meta+Enter aria-keyshortcuts label, 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, the useThreadStorageLocation fetch, the thread invalidation maxWait bounds, and the sidebar info-tab id.
    • Two gaps were left out on purpose: the hasPath lifecycle row (no code reads hasPath) and a single shrink-0 class pin.
    • Each repaired assertion was shown to fail under a mutation that the old assertion let through.
  • Baseline at 51d8ddc: pnpm exec turbo run test --filter=@bb/app ran 6,809 tests, with 6 failures at machine load ~89. All six pass when run alone or at normal load.
  • After rebasing onto origin/main: pnpm exec turbo run lint typecheck test --filter=@bb/app gave 0 lint errors, a clean typecheck, and 6,740 of 6,750 tests passing (9 skipped).
    • The one failure, 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 on main.
    • It passes in five isolated reruns, two of them uncached (--force).

🤖 Generated with Claude Code

AGENT GENERATED

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
ymichael merged commit 60c8a7e into main Nov 3, 2026
30 checks passed
@ymichael
ymichael deleted the bb/test-audit-apps-app-thr_myab49tr68 branch November 3, 2026 21:24
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant