repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by admin
quickshell/nuguland/features/clock/fixtures/load.qml
Rawimport QtQuick
import QtQuick.Window
import Quickshell
import "../../.." as N
import "../../../features/clock" as ClockFeature
// `just load-test clock`: the registry entry's own panel and bar control, bound
// to the Time and CalDav doubles the load harness overlays. The control renders
// the entry's label in both bar orientations; opening and dismissal switch the
// time service's seconds and the calendar's refresh gate on and off, and only
// opening fetches; the panel shows and edits the
// service's setup drafts, leaves setup after a save, lists the double's appointment, follows the time service, formats timed
// agenda entries, wraps a long summary inside the agenda column, and starts
// multi-day bands on today's grid cell. No network,
// keyring, compositor, input, or pixels.
ShellRoot {
id: root
readonly property N.FeatureEntry feature: featureRegistry.popup("clock")
property int step: 0
// The overlaid double's fixture surface; production CalDav has no updateEvents.
readonly property var calendarDouble: featureRegistry.clock
readonly property var timeDouble: featureRegistry.time
readonly property string longSummary: "fixture trip across three days to the far coast with every museum on the way"
// Setup field placeholder -> the service draft it shows and edits.
readonly property var drafts: ({
"server url": "setupUrlDraft",
"username": "setupUsernameDraft",
"app password": "setupPasswordDraft"
})
function find(item: var, predicate: var): var {
if (predicate(item))
return item;
const children = item.children || [];
for (let i = 0; i < children.length; i++) {
const found = root.find(children[i], predicate);
if (found)
return found;
}
return null;
}
function shows(item: var, text: string): bool {
return root.find(item, child => child.visible && child.text === text) !== null;
}
function setupField(item: var, placeholder: string): var {
return Array.from(root.feature.configuration.rows).find(row => row.label === placeholder);
}
function draftsAre(panel: var, suffix: string, inFields: bool): bool {
return Object.keys(root.drafts).every(placeholder => {
const draft = root.drafts[placeholder];
return root.calendarDouble[draft] === draft + suffix && (!inFields || root.setupField(panel, placeholder).value === draft + suffix);
});
}
function finish(): void {
const panel = panelLoader.item as ClockFeature.ClockPanel;
const control = controlLoader.item as ClockFeature.ClockBarControl;
if (!panel || !control)
return;
if (root.step === 0 && root.calendarDouble.status === "needs-setup" && root.calendarDouble.refreshes === 0 && !root.calendarDouble.popupOpen && root.feature.width === 760 && root.feature.height === 580 && /^\d\d:\d\d$/.test(root.feature.barLabel) && featureRegistry.barControls.length === 1 && featureRegistry.barControls[0] === root.feature) {
root.step = 1;
root.feature.opening();
control.label = root.feature.barLabel;
for (const draft of Object.values(root.drafts))
root.calendarDouble[draft] = draft + " from service";
} else if (root.step === 1 && root.timeDouble.secondsShown && root.calendarDouble.popupOpen && root.calendarDouble.refreshes === 1 && root.draftsAre(panel, " from service", true) && `${control.hh}:${control.mm}` === root.feature.barLabel && control.implicitWidth > control.implicitHeight) {
root.step = 2;
root.feature.dismissed();
control.vertical = true;
for (const placeholder of Object.keys(root.drafts))
root.setupField(panel, placeholder).edited(root.drafts[placeholder] + " typed");
} else if (root.step === 2 && !root.timeDouble.secondsShown && !root.calendarDouble.popupOpen && root.draftsAre(panel, " typed", false) && control.implicitHeight > control.implicitWidth) {
root.step = 3;
root.calendarDouble.setupUrlDraft = "https://fixture.invalid/dav";
root.calendarDouble.setupUsernameDraft = "fixture-user";
root.calendarDouble.setupPasswordDraft = "fixture-only";
root.calendarDouble.failSave = false;
root.feature.configuration.rows[3].activated();
root.calendarDouble.finishSave();
} else if (root.step === 3 && root.calendarDouble.status !== "needs-setup" && panel.todayItems.length === 0) {
root.step = 4;
root.calendarDouble.updateEvents();
} else if (root.step === 4 && panel.todayItems.length === 1 && root.calendarDouble.refreshes === 1) {
root.step = 5;
root.timeDouble.now = new Date(2026, 0, 5, 9, 8, 7);
root.calendarDouble.events = [
{
startMs: new Date(2026, 0, 5, 9, 5).getTime(),
allDay: false,
color: "#3ec5e3",
summary: "fixture timed",
kind: "event"
},
{
date: "2026-01-05",
endDate: "2026-01-07",
allDay: true,
color: "#3ec5e3",
summary: root.longSummary,
kind: "event"
}
];
} else if (root.step === 5 && root.feature.barLabel === "09:08" && root.shows(panel, "09:08:07") && root.shows(panel, "mon 5 jan") && root.shows(panel, "09:05 fixture timed")) {
const today = panel.days.findIndex(day => day.today);
const band = panel.bandLayout.segments[0];
if (panel.bandLayout.segments.length < 1 || band.row !== Math.floor(today / 7) || band.colStart !== today % 7)
return;
const summary = root.find(panel, child => child.visible && child.text === root.longSummary);
if (!summary || summary.width > panel.gridW - 12 || summary.lineCount !== 2)
return;
root.step = 6;
root.calendarDouble.events = [
{
date: "2026-01-31",
allDay: true,
color: "#3ec5e3",
summary: "before midnight",
kind: "event"
},
{
date: "2026-02-01",
allDay: true,
color: "#3ec5e3",
summary: "after midnight",
kind: "event"
}
];
root.timeDouble.now = new Date(2026, 0, 31, 23, 59, 59);
} else if (root.step === 6 && panel.todayIso === "2026-01-31" && panel.days.find(day => day.today)?.iso === "2026-01-31" && root.shows(panel, "before midnight")) {
root.step = 7;
root.timeDouble.now = new Date(2026, 1, 1, 0, 0, 0);
} else if (root.step === 7 && panel.todayIso === "2026-02-01" && panel.days.find(day => day.today)?.iso === "2026-02-01" && panel.todayItems.length === 1 && root.shows(panel, "after midnight") && !root.shows(panel, "before midnight")) {
console.log("load clock: PASS");
Qt.quit();
}
}
N.Theme {
id: nuguTheme
}
N.Registry {
id: featureRegistry
theme: nuguTheme
}
// Plain Window: Quickshell windows set input masks the offscreen platform rejects.
Window {
width: 728
height: 548
visible: true
color: "transparent"
Loader {
id: panelLoader
anchors.fill: parent
sourceComponent: root.feature ? root.feature.panel : null
}
Loader {
id: controlLoader
sourceComponent: root.feature ? root.feature.barControl : null
}
}
Timer {
interval: 25
running: true
repeat: true
onTriggered: root.finish()
}
Timer {
interval: 5000
running: true
onTriggered: {
console.error("ERROR load clock: the entry never followed the doubles through setup and events");
Qt.quit();
}
}
}