test(ui): stub toast dismissal in the pending-compaction fixture (#1097)

## Problem

Since #1096, the UI unit job on `dev` fails in two
`instances-pending-compaction.test.ts` tests, with `TypeError:
toast.dismiss is not a function` (also in #1096's own PR run).

#1096 shows one bubble per session, so a later compaction end dismisses
the session's earlier bubble. These tests end several compactions in one
session. Under Node with tsx, `import toast from "solid-toast"` yields
the CommonJS module object, which has no `dismiss`. The fixture replaced
only `toast.custom`, so the dismissal threw.

The app is not affected: Vite resolves the real `toast` function, which
has `dismiss`.

## Fix

The fixture also replaces `toast.dismiss` with a no-op and restores it
after each test, as `session-lifecycle-signals.test.ts` already does.
Test-only change.

## Validation

- Reproduced on unmodified `dev` (`333d73452`): 2 of 7 tests in the file
fail.
- With the fix:
- `instances-pending-compaction`, `compaction-notice` and
`session-lifecycle-signals`: 18/18;
  - full UI unit suite: 1694/1694;
  - UI typecheck.
This commit is contained in:
Pascal André 2026-10-22 16:09:53 +02:00 • committed by GitHub
parent 333d734521
commit 853b14f2f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -34,11 +34,13 @@ async function until(check: () => boolean) {
}
const originalPending = serverApi.getPendingRequests, originalWorktrees = serverApi.fetchWorktrees
const originalClient = sdkManager.createClient
const originalToast = toast.custom
const originalToast = toast.custom, originalDismiss = toast.dismiss
let sequence = 0, brokerReads = 0
const fixtures: ReturnType<typeof harness>[] = []
beforeEach(() => {
toast.custom = () => "fixture-toast"
// A later compaction end replaces the session's earlier bubble.
toast.dismiss = () => {}
brokerReads = 0
serverApi.getPendingRequests = async (id, directories) => {
brokerReads++
@ -51,6 +53,7 @@ beforeEach(() => {
})
afterEach(() => {
toast.custom = originalToast
toast.dismiss = originalDismiss
for (const h of fixtures.splice(0)) {
removeInstance(h.id, { authoritative: false })
setSessions((previous) => { const next = new Map(previous); next.delete(h.id); return next })