You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
virt/web/tests/AdminMaintenanceNoticeBehav...

23 lines
1.2 KiB
JavaScript

import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
const source = await readFile(
new URL('../public/cloud/admin-maintenance-notices.js', import.meta.url),
'utf8',
);
assert.match(source, /state\.preview = null;[\s\S]*maintenance-schedule/,
'Changing the scope must invalidate the reviewed audience.');
assert.match(source, /maintenance_starts_at: starts, maintenance_ends_at: ends, scheduled_at: scheduled/,
'Browser-local inputs must be converted to epoch seconds for UTC delivery.');
assert.match(source, /audience_digest: state\.preview\.audience_digest/,
'Scheduling must send the reviewed audience digest.');
assert.match(source, /if \(!error\?\.mutationMayHaveApplied\) return false;[\s\S]*state\.mutationLocked = true/,
'An uncertain write must lock the composer instead of replaying it.');
assert.match(source, /VenixAdminDangerDialog\.confirm/,
'Cancellation must use the shared administrator danger dialog.');
assert.doesNotMatch(source, /\bfetch\s*\(|innerHTML|window\.confirm/,
'The page must not bypass the request runtime or safe DOM rendering.');
console.log('Maintenance notice browser behavior checks passed.');