test(frontend): harness expansion + utility coverage push (F0 + F6) (#539)

* test(frontend): expand harness for store/component/contract tests

- factories: makeSubsonicSong, makeServer, makeAuthState, makeQueueState
- storeReset.ts: per-test reset for player/auth/preview/orbit stores
- mocks/subsonic.ts: realistic fixtures + stream/cover URL helpers
- mocks/browser.ts: ResizeObserver/IntersectionObserver/matchMedia/clipboard/object URLs
- mocks/tauri.ts: tauriMockListenerCount for listener-lifecycle regression tests
- renderWithProviders: pin i18n language to 'en' by default; { language } opt-out
- vitest.config: pool 'forks' + isolate to avoid module-mock + Zustand-global flake
- README: documented patterns, store-reset policy, i18n rule, isolation rationale

* test(frontend): bump utility coverage + expand hot-path gate

serverMagicString: 71→100% (encode/decode rejection branches, clipboard
fallback paths). shareLink: 69→97% (all entity kinds, queue trim, orbit
decoder, findServerIdForShareUrl). dynamicColors: 44→100% (extractCoverColors
DOM paths via Image / canvas / fetch mocks).

Gate adds shareLink.ts and dynamicColors.ts — both stable above 95%.
Comments updated for the new floor and the M4 hard-gate handoff.
This commit is contained in:
Frank Stellmacher
2026-05-11 21:11:23 +02:00
committed by GitHub
parent a228ce1c91
commit 4f9ad07d65
13 changed files with 990 additions and 35 deletions
+10 -1
View File
@@ -1,6 +1,7 @@
import '@testing-library/jest-dom/vitest';
import { afterEach, vi } from 'vitest';
import { afterEach, beforeEach, vi } from 'vitest';
import { cleanup } from '@testing-library/react';
import { installBrowserMocks, resetBrowserMocks } from './mocks/browser';
// ─────────────────────────────────────────────────────────────────────────────
// Node 25 ships a native `localStorage` global that is broken on this
@@ -65,6 +66,10 @@ function installStorage(globalKey: 'localStorage' | 'sessionStorage', store: Sto
installStorage('localStorage', memLocal);
installStorage('sessionStorage', memSession);
// Install jsdom-gap browser API mocks (ResizeObserver / IntersectionObserver /
// matchMedia / clipboard / object URLs) so components don't crash on import.
installBrowserMocks();
// ─────────────────────────────────────────────────────────────────────────────
// Global Tauri mocks.
//
@@ -93,6 +98,10 @@ vi.mock('@tauri-apps/plugin-shell', () => ({
open: vi.fn(async () => {}),
}));
beforeEach(() => {
resetBrowserMocks();
});
afterEach(() => {
cleanup();
memLocal.clear();