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.match(source, /async function openDetail\(key\)[\s\S]*VenixDrawerMotion\?\.openDrawerWithMotion\(dialog\)/, 'Maintenance detail must use the shared drawer opener so transformed dialogs become visible.'); assert.match(source, /async function closeDetail\(\)[\s\S]*VenixDrawerMotion\.closeDrawerWithMotion\(dialog\)/, 'Maintenance detail must use the shared drawer closer so mobile transitions finish safely.'); assert.doesNotMatch(source, /if \(!dialog\.open\) dialog\.showModal\(\)/, 'Opening the maintenance dialog directly leaves the drawer translated off screen.'); 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.');