Stage 0: manifest gains id "/" (what Chrome already derives from start_url), scope, a 512 maskable
icon, and drops the portrait lock. The service worker keeps the session ({baseUrl, accessToken}) in
IndexedDB `ratatoskr-sw` so a push can wake a worker with no tab; the page's existing logout message
deletes it.
Stage 1: `push` and `notificationclick` handlers (src/app/features/push), a pusher toggle in
notification settings, `push` block in config.json shipped empty (off). Tested against a mock
homeserver and Matrix gateway body.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
24 lines
994 B
TypeScript
24 lines
994 B
TypeScript
import { readFileSync } from 'node:fs';
|
|
import { join } from 'node:path';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { activePushConfig } from './config';
|
|
|
|
describe('activePushConfig', () => {
|
|
it('is off unless all three keys are filled', () => {
|
|
expect(activePushConfig(undefined)).toBeUndefined();
|
|
expect(activePushConfig({})).toBeUndefined();
|
|
expect(
|
|
activePushConfig({ vapidPublicKey: 'k', gatewayUrl: 'https://g/_matrix/push/v1/notify' })
|
|
).toBeUndefined();
|
|
expect(activePushConfig({ vapidPublicKey: 'k', gatewayUrl: 'u', appId: 'a' })).toEqual({
|
|
vapidPublicKey: 'k',
|
|
gatewayUrl: 'u',
|
|
appId: 'a',
|
|
});
|
|
});
|
|
it('the shipped config.json carries the block empty, so push is off', () => {
|
|
const cfg = JSON.parse(readFileSync(join(__dirname, '../../../../config.json'), 'utf8'));
|
|
expect(cfg.push).toEqual({ vapidPublicKey: '', gatewayUrl: '', appId: '' });
|
|
expect(activePushConfig(cfg.push)).toBeUndefined();
|
|
});
|
|
});
|