Skip to content

Run the hidden sidebar list test, add missing app tests, and shrink brittle setup - #6949

Merged
ymichael merged 2 commits into
mainfrom
bb/apps-app-test-follow-ups-from-the-audit-thr_btf3y7fweh
Nov 3, 2026
Merged

ymichael merged 2 commits into
mainfrom
bb/apps-app-test-follow-ups-from-the-audit-thr_btf3y7fweh

Conversation

@ymichael

@ymichael ymichael commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

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

ymichael and others added 2 commits November 3, 2026 13:45
…rittle setup

- Move the hidden sidebar thread-list test out of the skipped bench file into
  PluginThreadList.hidden.test.tsx; both share src/test/fixtures/sidebar-thread-list.tsx.
- Spy on HTMLElement.prototype.scrollIntoView in ThreadTimelineRows.actions so
  restoreAllMocks undoes it instead of leaking a mock to later tests.
- Test the palette's archived-recents fetch gate and the realtime thread
  invalidation debounce/max-wait timing (fine and coarse pointers) by behaviour.
- Compact the lifecycle-errors table and extract harness helpers in
  plugin-frontend-reload, ui-preferences-sync and ToolsView.plugin-detail.
- Replace regex-over-markup class checks with DOM classList/role assertions,
  anchor theme-preview anatomy on class sets rather than exact strings, and
  derive the eager runtime slot list from RUNTIME_SLOT_BY_SPECIFIER.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ymichael
ymichael merged commit b7a0d5b into main Nov 3, 2026
94 of 95 checks passed
@ymichael
ymichael deleted the bb/apps-app-test-follow-ups-from-the-audit-thr_btf3y7fweh branch November 3, 2026 22:11
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