repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by admin
quickshell/nuguland/test-fixtures/ui/popups.mjs
Rawimport assert from 'node:assert/strict';
export default async function runPopups({ ipc, snapshot, input, key, click, check, screenshot, opened, hasText }) {
let state;
for (const orientation of ['horizontal', 'vertical']) {
ipc('external', orientation);
state = snapshot();
click(state.buttons.clock);
state = await opened('clock');
if (orientation === 'horizontal') {
await screenshot('clock-unconfigured');
click(state.calendar.configure);
state = await opened('config');
click(state.calendar.url);
input('type', 'https://fixture.invalid/dav');
click(state.calendar.user);
input('type', 'fixture-user');
key('Tab');
input('type', 'fixture-only');
state = await check('calendar draft edits stay in the service until save', s => s.calendar.draftsEdited && s.calendar.saves === 0);
click(state.calendar.save);
ipc('external', 'stored');
await check('calendar save receives literal drafts through Config', s => s.calendar.saves === 1 && s.calendar.savedDrafts);
state = snapshot();
click(state.buttons.clock);
state = await opened('clock');
await check('stored account returns to local empty agenda', s => s.calendar.saves === 1 && s.calendar.savedDrafts && hasText(s.text, 'no events today'));
await screenshot('clock-empty');
ipc('external', 'events');
await check('external calendar events render while open without another save', s => s.calendar.todayItems === 1 && hasText(s.text, 'fixture appointment') && s.calendar.saves === 1);
}
await screenshot(`clock-${orientation}`);
state = snapshot();
let opens = state.resources.opens;
click(state.buttons.system);
state = await opened('system');
assert.equal(state.resources.open, true);
assert.equal(state.resources.opens, opens + 1);
await screenshot(`system-${orientation}`);
click(state.buttons.clock);
state = await opened('clock');
assert.equal(state.resources.open, false, 'switching away must release resource gate');
assert.equal(state.resources.opens, state.resources.closes);
click(state.buttons.system);
state = await opened('system');
assert.equal(state.resources.opens, opens + 2);
key('Escape');
state = await check('Escape closes popup and releases resource lifecycle gate', s => !s.popup.open && !s.resources.open && s.popup.lastCloseReason === 'escape-key');
assert.equal(state.resources.opens, state.resources.closes);
click(state.buttons.system);
state = await opened('system');
assert.equal(state.resources.opens, opens + 3);
click({ x: 1200, y: 680, width: 10, height: 10 });
state = await check('outside pointer closes reopened system and releases gate', s => !s.popup.open && !s.resources.open && s.popup.lastCloseReason === 'outside');
assert.equal(state.resources.opens, state.resources.closes);
const refreshes = state.calendar.refreshes;
click(state.buttons.clock);
state = await opened('clock');
assert.equal(state.calendar.refreshes, refreshes + 1);
assert(hasText(state.text, 'fixture appointment'));
click(state.buttons.clock);
await check('bar pointer closes reopened clock', s => !s.popup.open && s.popup.lastCloseReason === 'bar-toggle');
}
}