mirror of
https://github.com/civitai/civitai.git
synced 2026-09-20 22:08:18 +08:00
ed6e17ac7d
* fix(test): await the async cleanup() in the component-setup afterEach
vitest-browser-react 2.2.0 `cleanup()` is `async` (dist/pure-*.js:112): per
mounted root it does `await act(async () => root.unmount())` and only THEN
`document.body.removeChild(container)`, so the container detaches in a later
microtask.
The hook was `afterEach(() => { cleanup(); })` — a block body with no return, so
the promise floated and Vitest received `undefined` and did not wait. Container
removal could therefore race the next test's render, leaving two mounted
containers in `document.body`. `page.getByTestId(...)` is document-scoped, so a
testid rendered exactly once per mount would resolve to 2 and fail strict mode.
Adds a deterministic source gate in the `unit` project (the suite CI runs)
asserting the hook awaits or returns `cleanup()`, with a positive control for the
comment-stripper so the assertions cannot go vacuously green. Mutation-checked:
reverting the hook to the bare form fails both assertions with their own
messages.
🔴 SCOPE — what this does NOT claim.
This fixes a real dropped-promise defect. It is NOT established that it is the
cause of the long-running `AppListingDetailBody > the "Browse all apps" link is
present even when the rail is empty` flake, which has the matching signature
(strict-mode violation, `apps-browse-all` resolving to 2 elements across two
vitest containers, red on loaded CI pods and green on quiet ones — pod history
3549 red / 3550 green / 3551 green / 3552 red / 3553 red, with #3552 touching
only AppsPageLayout* as the discriminating control).
A local probe — render in one test, count leftover containers in the next — was
written specifically as a negative control and FAILED TO REPRODUCE: with the
broken hook restored it reported 0 leftover containers on 3 consecutive runs.
So the probe cannot discriminate, and the causal claim is unproven in both
directions. Awaiting the promise is correct regardless and costs nothing; if the
flake persists after this lands, look elsewhere rather than assuming this was it.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* style: prettier the new source gate (CI blocking gate on added files)
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>