cat / goq
clone

turns a linux box into a private steam streaming appliance: plug in, tap your key, play from another computer

fix/website-download-wiring
goq / portal / enrollment-ui.test.mjs
enrollment-ui.test.mjs 2.1K
1import assert from 'node:assert/strict';2import { readFile } from 'node:fs/promises';3import test from 'node:test';45const html = await readFile(new URL('./index.html', import.meta.url), 'utf8');6const main = await readFile(new URL('./main.js', import.meta.url), 'utf8');78test('onboarding and confirmation actions are controller reachable', () => {9 for (const id of ['enrollment-pin', 'derive-portal-id', 'choose-invitation', 'confirm-invitation', 'reset-enrollment', 'reset-enrollment-intro', 'confirm-reset-enrollment']) {10 assert.match(html, new RegExp(`id="${id}"[^>]*data-controller-focus`));11 }12 assert.match(main, /const invitation = document\.getElementById\('invitation-overlay'\)/);13 assert.match(main, /const enrollment = document\.getElementById\('enrollment-overlay'\)/);14 assert.match(main, /const resetEnrollment = document\.getElementById\('reset-enrollment-overlay'\)/);15});1617test('disconnected intro keeps enrollment reset inside the active controller scope', () => {18 const introStart = html.indexOf('<div class="overlay-screen hidden" id="intro">');19 const topbarStart = html.indexOf('<div class="topbar">');20 assert.notEqual(introStart, -1);21 assert.ok(topbarStart > introStart);22 const intro = html.slice(introStart, topbarStart);23 assert.match(intro, /id="reset-enrollment-intro"[^>]*data-controller-focus/);24 assert.match(main, /getElementById\('reset-enrollment-intro'\)\.classList\.toggle\('hidden', !enrollmentReady\)/);25});2627test('enrollment reset is explicit and native', () => {28 assert.match(html, /Only continue after revoking enrollment on Sigil/);29 assert.match(main, /portal_reset_enrollment/);30 assert.match(main, /expectedHostNodeId: hostNodeId/);31});3233test('raw invitation bytes stay in native commands instead of the DOM', () => {34 assert.doesNotMatch(html, /invitation-token|goq-invite-v1/);35 assert.match(main, /portal_import_invitation_file/);36 assert.doesNotMatch(main, /readAsText|FileReader/);37});3839test('invitation grants distinguish view-only and input-capable access', () => {40 assert.match(main, /summary\.viewOnly \? 'view only' : 'input-capable'/);41 assert.match(main, /summary\.grants\.map\(grantLabel\)/);42});