repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by admin
quickshell/nuguland/shell-composition.test.mjs
Rawimport assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import { createRequire } from "node:module";
const { readSource } = createRequire(import.meta.url)("./test-fixtures/sources.js");
const read = name => readFileSync(new URL(name, import.meta.url), "utf8");
const shell = read("./shell.qml");
const privilege = read("./PrivilegeSurface.qml");
const overlay = readSource("NokoFocusOverlay.qml");
const overlayHost = read("./OverlayHost.qml");
const text = read("./NuguText.qml");
assert.doesNotMatch(shell, /component (?:PrivilegeSurface|PrivilegeFailureShake|NokoFocusOverlay|NuguText):/, "shell delegates extracted trees");
assert.doesNotMatch(shell, /\bNuguText\s*\{/, "no shell-local text callers remain");
assert.match(shell, /PrivilegeSurface\s*\{\s*id: privilegeSurface\s*anchors.fill: parent\s*theme: nuguTheme\s*privilegeService: privilege/, "shell owns privilege geometry and injects dependencies");
assert.doesNotMatch(shell, /NokoFocusOverlay/, "focus overlays come from registry entries");
assert.match(shell, /OverlayHost\s*\{\s*registry: featureRegistry\s*primaryScreenName: shell.primaryScreenName\s*niriService: niri\s*surfaces: surfaceManager\s*\}/, "shell injects the overlay host's focus and bar inputs");
// The host owns focus overlay geometry: the focused output's area outside the bar.
assert.match(overlayHost, /model: root.registry.focusOverlays/);
assert.match(overlayHost, /readonly property int barThickness: root.surfaces && modelData.name === root.primaryScreenName \? root.surfaces.barHeight : 0/);
assert.match(overlayHost, /x: focusWindow.verticalBar \? focusWindow.barThickness : 0\s*y: focusWindow.verticalBar \? 0 : focusWindow.barThickness/);
for (const source of [privilege, overlay]) {
assert.match(source, /required property Theme theme/);
assert.doesNotMatch(source, /\b(?:shell|nuguTheme|surfaceManager)\b/, "no composition-root id capture");
assert.doesNotMatch(source, /childrenRect/, "no child-bounds sizing");
assert.doesNotMatch(source, /\bselected\s*:/, "all extracted text uses shared unselected semantics");
}
assert.match(text, /property bool selected: false/);
assert.match(text, /color: !theme \? "transparent" : \(variant === "title" \? theme.ui.important_global : \(variant === "meta" \? theme.ui.normal : theme.content.normal\)\)/);
assert.match(text, /font.family: variant === "mono" \? theme.fontMono : theme.fontSans/);
assert.match(text, /font.pixelSize: variant === "title" \? theme.textTitle : \(variant === "meta" \? theme.textMeta : theme.textBody\)/);
assert.match(text, /font.bold: variant === "title"/);
assert.match(text, /elide: Text.ElideRight/);
assert.match(privilege, /required property Privilege privilegeService/);
assert.match(privilege, /import "privilege.js" as PrivilegeUi/);
const shake = privilege.slice(privilege.indexOf("component PrivilegeFailureShake:"));
assert.match(shake, /required property Theme theme/);
assert.doesNotMatch(shake, /implicitWidth:|implicitHeight:/, "shake geometry comes only from its caller");
assert.equal((shake.match(/duration: shakeRoot.theme.lowPowerMode \? 0 : /g) || []).length, 5, "all five shake steps use the injected theme");
assert.match(privilege, /PrivilegeFailureShake\s*\{\s*theme: root.theme[\s\S]*?width: parent.width\s*height: inputColumn.implicitHeight/, "shake caller owns both axes");
for (const action of ["submit(secret)", "deny()", "cancel()"])
assert.ok(privilege.includes(`privilegeService.${action};`), `preserved privilege route: ${action}`);
assert.doesNotMatch(privilege, /stateJson\(|parseJson|refreshFrom/, "the surface binds the service's typed state, never its JSON");
assert.match(overlay, /required property Noko nokoService/);
assert.match(overlay, /running: overlay.visible && !overlay.resting && !overlay.theme.lowPowerMode\s*onTriggered: overlay.tick\+\+/, "the capture wave never ticks in low-power mode");
assert.match(overlay, /duration: overlay.theme.lowPowerMode \? 0 : 90/);
console.log("shell-composition.test.mjs: ALL PASS");