feat(pwa): Online-Status-Store
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 1m31s

Reaktiver Store basierend auf navigator.onLine und den window-
Events online/offline. Kein aktives Heuristik-Probing — für
unseren Offline-PWA-Use-Case reicht der Browser-Status. Wird von
SyncIndicator und require-online-Helper konsumiert.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-18 16:17:11 +02:00
parent 0b12aa027f
commit 04641355df
4 changed files with 571 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
// @vitest-environment jsdom
import { describe, it, expect, beforeEach } from 'vitest';
describe('network store', () => {
beforeEach(() => {
// Reset module state for each test
Object.defineProperty(navigator, 'onLine', { value: true, configurable: true });
});
it('reflects initial navigator.onLine and reacts to events', async () => {
const { network } = await import('../../src/lib/client/network.svelte');
network.init();
expect(network.online).toBe(true);
Object.defineProperty(navigator, 'onLine', { value: false, configurable: true });
window.dispatchEvent(new Event('offline'));
expect(network.online).toBe(false);
Object.defineProperty(navigator, 'onLine', { value: true, configurable: true });
window.dispatchEvent(new Event('online'));
expect(network.online).toBe(true);
});
});