diff --git a/web/src/lib/components/QueueDrawer.test.ts b/web/src/lib/components/QueueDrawer.test.ts index abeae2e4..a42cb202 100644 --- a/web/src/lib/components/QueueDrawer.test.ts +++ b/web/src/lib/components/QueueDrawer.test.ts @@ -63,7 +63,7 @@ describe('QueueDrawer', () => { it('clicking the close button calls closeQueueDrawer', async () => { render(QueueDrawer); - const close = screen.getByLabelText(/close queue/i); + const close = screen.getByLabelText('Close queue'); await fireEvent.click(close); expect(closeQueueDrawer).toHaveBeenCalled(); }); @@ -84,12 +84,16 @@ describe('QueueDrawer', () => { expect(aside!.getAttribute('aria-hidden')).toBe('true'); }); - it('drawer has inert attribute when closed', () => { + it('drawer is inert when closed', () => { openValue = false; queueValue = [t('a')]; render(QueueDrawer); const aside = document.querySelector('aside[aria-label="Playback queue"]'); expect(aside).not.toBeNull(); - expect(aside!.hasAttribute('inert')).toBe(true); + // Svelte 5 + jsdom uses property binding for `inert`, not attribute. Check both + // to be robust regardless of which jsdom version handles the mirror. + const inertProp = (aside as unknown as { inert?: boolean }).inert === true; + const inertAttr = aside!.hasAttribute('inert'); + expect(inertProp || inertAttr).toBe(true); }); }); diff --git a/web/src/lib/components/queue-row-math.ts b/web/src/lib/components/queue-row-math.ts index e3cac63a..44cfa154 100644 --- a/web/src/lib/components/queue-row-math.ts +++ b/web/src/lib/components/queue-row-math.ts @@ -4,5 +4,7 @@ // the user's drop intent maps to a clean queue index. export function offsetToDelta(offsetY: number, rowHeight: number): number { if (rowHeight <= 0) return 0; - return Math.round(offsetY / rowHeight); + // `|| 0` normalizes -0 to +0. Math.round(-0.5) === -0; downstream + // consumers (and Object.is in tests) treat -0 and +0 as distinct. + return Math.round(offsetY / rowHeight) || 0; } diff --git a/web/src/lib/player/store.svelte.ts b/web/src/lib/player/store.svelte.ts index 649d482c..f4bf151d 100644 --- a/web/src/lib/player/store.svelte.ts +++ b/web/src/lib/player/store.svelte.ts @@ -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;