fix(web/m7-364): vitest failures — exact-match query, inert prop, -0, user guard
CI test-web was blocking on:
- QueueDrawer.test close-button query: getByLabelText(/close queue/i)
matched BOTH the backdrop button (aria-label="Close queue backdrop")
and the close button (aria-label="Close queue"). Switched to exact
string match.
- QueueDrawer.test inert assertion: Svelte 5 + jsdom uses property
binding for `inert`, not attribute, so hasAttribute('inert') returns
false. Check the DOM property (with attribute fallback for
robustness) instead.
- queue-row-math.ts -0 normalization: Math.round(-0.5) returns -0,
and Object.is(-0, 0) is false — vitest's .toBe(0) fails. Added
`|| 0` to normalize -0 to +0 at the function boundary so consumers
never see -0.
- player/store.svelte.ts user import guard: persistence $effect.root
reads `user.value?.id` at module-init, but in test files where
auth/store.svelte.ts is imported transitively (auth/store.test,
playlists/playlists.test), the player module loads via auth's
import chain before auth's `user` binding is assigned. `user?.value`
guards against that init-order race. The proper fix is to invert
the auth↔player import dep (filed as I2 follow-up under #375).
This commit is contained in:
@@ -397,7 +397,10 @@ $effect.root(() => {
|
||||
// queue/index changes drive it. The throttled-write effect below
|
||||
// covers position drift.
|
||||
$effect(() => {
|
||||
const userId = user.value?.id;
|
||||
// `user?.value` (not `user.value`) guards against module-init order during
|
||||
// tests: auth/store.svelte.ts imports from this file, so when this module
|
||||
// loads via that chain, `user` may not yet be assigned. See I2 follow-up.
|
||||
const userId = user?.value?.id;
|
||||
if (!userId) return;
|
||||
// Reading these registers the reactive dependency; the values
|
||||
// themselves are unused — writePersistedQueue re-reads live state.
|
||||
@@ -413,7 +416,7 @@ $effect.root(() => {
|
||||
|
||||
// Throttled write on position changes.
|
||||
$effect(() => {
|
||||
const userId = user.value?.id;
|
||||
const userId = user?.value?.id;
|
||||
if (!userId) return;
|
||||
const _p = _position;
|
||||
void _p;
|
||||
|
||||
Reference in New Issue
Block a user