2 2 import assert from "node:assert/strict";
3 3 import { readFileSync } from "node:fs";
5 5 const qml = readFileSync(new URL("./shell.qml", import.meta.url), "utf8");
6 +const privilegeQml = readFileSync(new URL("./Privilege.qml", import.meta.url), "utf8");
6 7 const start = qml.indexOf("component PrivilegeSurface: Rectangle");
7 8 const end = qml.indexOf("component NokoFocusOverlay", start);
8 9 assert.notEqual(start, -1, "PrivilegeSurface component exists");
19 20 assert.match(surface, /secretInput\.forceActiveFocus\(\)/, "password input is explicitly focused");
20 21 assert.match(surface, /id:\s*focusRetry/, "focus retry timer exists for map-time focus races");
21 22 assert.match(qml, /id:\s*privilegeSurface/, "privilege surface instance is addressable from PanelWindow");
23 +assert.match(qml, /visible:\s*privilege\.active \|\| privilege\.error\.length > 0 \|\| privilege\.confirming/, "privilege window stays up for success confirmation");
22 24 assert.match(qml, /onVisibleChanged:\s*if \(visible\)\s*Qt\.callLater\(privilegeSurface\.focusSecret\)/, "PanelWindow asks password input for focus after mapping");
25 +assert.match(privilegeQml, /property bool confirming:\s*false/, "privilege service exposes transient success confirmation state");
26 +assert.match(privilegeQml, /property bool awaitingCompletion:\s*false/, "privilege service tracks submitted flows");
27 +assert.match(privilegeQml, /id:\s*successClose/, "success confirmation auto-closes");
28 +assert.match(privilegeQml, /function onIsCompletedChanged\(\)/, "polkit completed state is handled before flow detaches");
29 +assert.match(privilegeQml, /function onIsActiveChanged\(\)/, "polkit inactive fallback finishes submitted flows");
30 +assert.match(surface, /function onConfirmingChanged\(\)/, "surface refreshes after async success state changes");
31 +assert.match(surface, /id:\s*successBanner/, "success banner exists");
32 +assert.match(surface, /authorization granted/, "success title is rendered");
33 +assert.match(surface, /text:\s*"authorized"/, "success banner text is rendered");
23 34 assert.doesNotMatch(surface, /requestIdentityCard/, "debug identity card is not rendered");
24 35 assert.doesNotMatch(surface, /actionId/, "debug polkit action id is not rendered");