20 lines
960 B
JavaScript
20 lines
960 B
JavaScript
'use strict';
|
|
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const test = require('node:test');
|
|
|
|
test('PWA offline shell caches no APIs, console data or mutating application shell', () => {
|
|
const root = path.resolve(__dirname, '../..');
|
|
const manifest = JSON.parse(fs.readFileSync(path.join(root, 'renderer', 'manifest.webmanifest'), 'utf8'));
|
|
const worker = fs.readFileSync(path.join(root, 'renderer', 'service-worker.js'), 'utf8');
|
|
const offline = fs.readFileSync(path.join(root, 'renderer', 'offline.html'), 'utf8');
|
|
assert.equal(manifest.name, 'Chimera');
|
|
assert.equal(manifest.display, 'standalone');
|
|
assert.match(worker, /\/offline\.html/);
|
|
assert.doesNotMatch(worker, /\/api\/|pork-cache|payloads\.json|server-login|index\.html/);
|
|
assert.doesNotMatch(offline, /window\.pork|fetch\s*\(|WebSocket|localStorage|indexedDB/);
|
|
assert.match(offline, /no console data/);
|
|
});
|