repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by admin
quickshell/nuguland/features/notifications/fixtures/suite.mjs
Raw// `just ui-test notifications`: the registry notifications feature in the real Bar
// inside nested niri, driven by real pointer and keyboard against the feature's
// Notifications double. A reply draft lives in the service, so it survives an
// external update, close and reopen, and a failed send; the snapshot reports it
// only as `filled`, never its text. Do not disturb turns the chip strong, with
// the crossed bell on the vertical bar. Clearing all arms a confirmation that
// every dismissal and cancel disarm; confirming leaves the empty state.
// An unread card takes the accent and its rail; closing the popup marks it read,
// so it turns neutral and the chip loses its dot. A critical card takes the
// error tint, a low one stays untinted with its message subdued.
// The suite contract (snapshot shape, helpers) is documented in .system/RULES.md.
export default async function notificationsSuite({ assert, open, check, click, input, key, screenshot, within, call, fixture }) {
const notifications = value => value.features.notifications;
const service = value => notifications(value).service;
const control = (value, name) => notifications(value).controls[name];
const reply = value => control(value, 'reply to fixture');
const drafted = value => reply(value)?.filled && reply(value).text === '' && service(value).hasDraft && service(value).knownDraft;
let state = await open('notifications', value => reply(value)?.rect);
state = await check('opening focuses the newest notification reply', value => reply(value)?.focused);
assert(state.chips.notifications.active, 'an unread notification lights the bar chip');
assert.equal(state.chips.notifications.label, 'alerts');
const card = value => control(value, 'notification');
const summary = value => notifications(value).items.notificationSummary;
assert(card(state).highlighted && card(state).selected && !card(state).destructive, 'an unread normal card takes the accent and its rail');
assert.equal(summary(state).opacity, 1, 'a normal card message is not subdued');
const quiet = value => control(value, 'do not disturb');
assert(control(state, 'notification') && control(state, 'copy notification body') && quiet(state), 'card, copy and do not disturb render');
const close = control(state, 'close notification');
assert(close && close.opacity >= 0.7, 'the close control shows at rest, not only on hover');
for (const name of ['close notification', 'copy notification body'])
assert(control(state, name).rect.width >= 24 && control(state, name).rect.height >= 24, `${name} keeps a 24 px target`);
assert(!quiet(state).checked, 'do not disturb starts off');
const texts = value => notifications(value).texts;
assert(texts(state).includes('1 unread') && !texts(state).some(text => text.startsWith('notifications')), 'the header shows the unread count, not the chip name');
const send = value => control(value, 'send reply');
assert(send(state) && send(state).enabled === false, 'an empty reply cannot be sent');
assert(send(state).rect.width >= 24 && send(state).rect.height >= 24, 'send reply keeps a 24 px target');
assert(within(notifications(state).surface, state.width, state.height), 'panel inside output');
await screenshot('notifications-history');
// A sender that names itself by desktop id and titles by file uri reads as an app and a file.
call('notifications', 'setMachineNames', true);
state = await check('a desktop id and a file uri render as an app name and a file name', value =>
texts(value).includes('nautilus') && texts(value).includes('report.pdf') && !texts(value).some(text => /org\.gnome|file:/.test(text)));
await screenshot('notifications-human-names');
call('notifications', 'setMachineNames', false);
state = await check('the sender names itself again', value => texts(value).includes('fixture chat') && texts(value).includes('fixture message'));
click(reply(state).rect);
state = await check('pointer focuses the reply editor', value => reply(value).focused);
const editor = reply(state).id;
input('type', 'fixture-only');
state = await check('reply draft reaches the service and is reported only as filled', value => drafted(value) && service(value).edits > 0);
call('notifications', 'externalUpdate');
state = await check('external update keeps the live reply editor and its draft', value => service(value).externalUpdates === 1 && drafted(value) && reply(value).id === editor && reply(value).focused);
click(state.chips.notifications.rect);
await check('same Bar chip closes notifications and keeps the draft', value => !value.popup.open && value.popup.lastCloseReason === 'bar-toggle' && service(value).hasDraft && service(value).knownDraft);
await check('closing marks the notification read and quiets the chip', value => service(value).unreadCount === 0 && !value.chips.notifications.active && value.chips.notifications.mark === '');
state = await open('notifications', value => reply(value)?.rect);
assert(drafted(state), 'reply draft must survive close and reopen');
assert(!card(state).highlighted && !card(state).selected && !card(state).destructive, 'a read normal card stays neutral');
assert(!texts(state).some(text => text.endsWith('unread')), 'the header drops the unread count once read');
await screenshot('notifications-read');
click(reply(state).rect);
await check('reopened reply editor accepts focus', value => reply(value).focused);
key('Return');
state = await check('failed reply keeps the draft and names the retry', value => service(value).sends === 1 && service(value).failed && drafted(value) && texts(value).includes('reply not sent · press enter to retry'));
click(send(state).rect);
state = await check('the send button retries the kept draft', value => service(value).sends === 2 && service(value).failed && drafted(value) && send(value).enabled);
await screenshot('notifications-reply-retry');
key('Escape');
await check('Escape closes notifications without discarding the draft', value => !value.popup.open && value.popup.lastCloseReason === 'escape-key' && service(value).knownDraft);
state = await open('notifications', value => quiet(value)?.rect);
click(quiet(state).rect);
state = await check('pointer turns do not disturb on and the chip strong', value => service(value).dnd && quiet(value)?.checked && value.chips.notifications.strong && value.chips.notifications.label === 'alerts' && value.chips.notifications.title === 'do not disturb on');
await screenshot('notifications-do-not-disturb');
key('Escape');
await check('Escape closes notifications and do not disturb stays on the chip', value => !value.popup.open && value.chips.notifications.strong);
await screenshot('notifications-do-not-disturb-bar');
fixture('vertical');
await check('the vertical chip shows the crossed bell while do not disturb is on', value => value.orientation === 'vertical' && value.chips.notifications.icon === '\u{F009B}' && value.chips.notifications.strong);
await screenshot('notifications-do-not-disturb-vertical-bar');
fixture('horizontal');
await check('real Bar returns to horizontal layout', value => value.orientation === 'horizontal');
state = await open('notifications', value => quiet(value)?.rect);
click(quiet(state).rect);
state = await check('pointer turns do not disturb off again and quiets the chip', value => !service(value).dnd && quiet(value) && !quiet(value).checked && !value.chips.notifications.strong && value.chips.notifications.title === 'notifications');
// Urgency: critical takes the error tint, low stays untinted and subdued.
call('notifications', 'receive', 'critical');
state = await check('a critical notification takes the error tint and lights the chip', value => service(value).urgency === 'critical' && card(value)?.destructive && card(value).highlighted && value.chips.notifications.active && texts(value).includes('1 unread'));
await screenshot('notifications-critical');
call('notifications', 'receive', 'low');
state = await check('a low notification stays untinted with its message subdued', value => service(value).urgency === 'low' && card(value) && !card(value).highlighted && !card(value).destructive && summary(value)?.opacity < 1 && value.chips.notifications.active);
await screenshot('notifications-low');
call('notifications', 'receive', 'normal');
state = await check('a new normal notification takes the accent again', value => service(value).urgency === 'normal' && card(value)?.highlighted && !card(value).destructive && summary(value).opacity === 1);
// Clearing all is armed first; leaving or cancelling disarms it.
const confirm = value => control(value, 'confirm clear all');
const armed = value => confirm(value)?.rect && control(value, 'clear all')?.checked && texts(value).includes('clear 1 notification?') && within(notifications(value).items.clearConfirmation.rect, value.width, value.height);
click(control(state, 'clear all').rect);
state = await check('clear all arms a confirmation and keeps history', value => armed(value) && service(value).discards === 0 && !!reply(value));
await screenshot('notifications-clear-armed');
key('Escape');
await check('Escape closes notifications and disarms clearing', value => !value.popup.open && service(value).discards === 0);
state = await open('notifications', value => control(value, 'clear all')?.rect);
assert(!confirm(state) && !control(state, 'clear all').checked, 'notifications reopen unarmed');
click(control(state, 'clear all').rect);
state = await check('clear all arms again', value => armed(value));
click(control(state, 'cancel').rect);
state = await check('cancel disarms and returns focus to clear all', value => !confirm(value) && control(value, 'clear all')?.focused && !control(value, 'clear all').checked && service(value).discards === 0);
click(control(state, 'clear all').rect);
state = await check('clear all arms once more', value => armed(value));
call('notifications', 'receive', 'normal');
state = await check('a notification arriving while armed lights the chip again', value => armed(value) && value.chips.notifications.active);
click(confirm(state).rect);
state = await check('confirming clears the panel and the bar chip', value => service(value).discards === 1 && notifications(value).items.notificationsEmptyState?.rect && !reply(value) && !send(value) && !control(value, 'clear all') && !value.chips.notifications.active && !texts(value).some(text => text.endsWith('unread')));
await screenshot('notifications-empty');
key('Escape');
await check('Escape closes the empty notifications popup', value => !value.popup.open && !notifications(value).open);
await open('notifications', value => quiet(value)?.rect);
await check('opening empty notifications focuses do not disturb', value => quiet(value)?.focused);
key('Escape');
await check('Escape closes the reopened empty notifications popup', value => !value.popup.open);
}