// `just ui-test launcher`: the registry launcher feature in the real Bar inside // nested niri, driven by real pointer and keyboard against the feature's // Launcher double. Query, selection, scroll and the details disclosure live in // the host's session object. Closing without a launch (Escape, outside click, // the chip) keeps the query, which the reopened field holds fully selected, so // typing replaces it; a launch (app or desktop action, keyboard or pointer) // clears query and selection and closes the popup through the panel's // `closeRequested` intent; the disclosure survives both. Without matches one // empty state replaces results and actions. Apps start in title order; a // launched app leads the empty query on reopen (the double's frecency stand-in). // The suite contract (snapshot shape, helpers) is documented in .system/RULES.md. export default async function launcherSuite({ assert, open, check, click, input, key, screenshot, within, call }) { const launcher = value => value.features.launcher; const service = value => launcher(value).service; const retained = value => launcher(value).retained; const item = (value, name) => launcher(value).items[name]; const control = (value, name) => launcher(value).controls[name]; const texts = value => launcher(value).texts; const search = value => item(value, 'searchField'); const filtered = value => retained(value).query === 'terminal' && control(value, 'fixture terminal') && !control(value, 'fixture editor'); const launched = (value, reason = 'launcher-activated') => !value.popup.open && value.popup.lastCloseReason === reason; const entryDetails = value => item(value, 'launcherEntryDetails'); const emptyState = value => item(value, 'launcherEmptyState'); // The empty state replaces both panes: no rows, no launch or detail controls. const emptied = value => !!emptyState(value)?.rect && !item(value, 'launcherDetails') && !control(value, 'open') && !control(value, 'fixture terminal') && !control(value, 'fixture editor'); // A reopen after dismissal: the focused field holds the kept query. const restored = (value, query) => retained(value).query === query && search(value)?.focused && search(value).filled; // A reopen after a launch: the focused field is empty. const fresh = value => retained(value).query === '' && search(value)?.focused && !search(value).filled; // The terminal row sits above the editor row. const terminalFirst = value => control(value, 'fixture terminal')?.rect.y < control(value, 'fixture editor')?.rect.y; // A point on the output but off the popup card, for outside dismissal. function outsideRect(state) { const card = state.popup.card; const candidates = [ { x: state.width - 14, y: state.height - 14, width: 6, height: 6 }, { x: 8, y: state.height - 14, width: 6, height: 6 }, { x: state.width - 14, y: 40, width: 6, height: 6 }, ]; const result = candidates.find(rect => rect.x + rect.width < card.x || rect.x > card.x + card.width || rect.y + rect.height < card.y || rect.y > card.y + card.height); assert(result && within(result, state.width, state.height), 'mapped output must contain an outside-click target'); return result; } let state = await open('launcher', value => search(value)?.rect); assert(search(state).focused, 'launcher search must receive initial focus'); assert(control(state, 'fixture terminal') && control(state, 'fixture editor'), 'both apps render'); assert(!terminalFirst(state), 'without launches apps keep title order'); assert.equal(retained(state).selectedId, 'editor', 'the first app is selected'); assert(within(item(state, 'launcherDetails').rect, state.width, state.height), 'details inside output'); assert.equal(service(state).rows, 2, 'the double serves two apps'); assert(!control(state, 'expand details'), 'an app without desktop-entry facts offers no disclosure'); assert(!emptyState(state), 'apps hide the empty state'); assert(item(state, 'launcherDetailIcon')?.rect && texts(state).filter(text => text === 'fixture editor').length === 1 && !texts(state).includes('editor'), 'the detail pane shows the icon and actions without repeating the selected row'); await screenshot('launcher-apps'); // An entry named by its desktop id reads as the app, its missing kind as app. call('launcher', 'setMachineNames', true); state = await check('a desktop id renders as the app name, never the id', value => control(value, 'nautilus') && texts(value).includes('nautilus') && !texts(value).some(text => /org\.gnome|\.desktop/.test(text))); await screenshot('launcher-desktop-id'); call('launcher', 'setMachineNames', false); state = await check('the desktop-id entry leaves the list', value => !control(value, 'nautilus') && control(value, 'fixture editor') && retained(value).selectedId === 'editor'); // Escape keeps query and selection; the reopened query is selected, so arrows // still move the selection and a typed character replaces the query. input('type', 'fixture'); state = await check('a query matching both apps keeps title order', value => retained(value).query === 'fixture' && control(value, 'fixture terminal') && control(value, 'fixture editor') && retained(value).selectedId === 'editor'); key('Down'); state = await check('Down selects the next app from the search field', value => retained(value).selectedId === 'terminal' && search(value).focused); assert(control(state, 'expand details') && !entryDetails(state) && !texts(state).includes('category'), 'desktop-entry facts wait behind a collapsed disclosure'); key('Escape'); await check('Escape closes launcher without launching', value => launched(value, 'escape-key') && service(value).activations === 0); state = await open('launcher', value => search(value)?.rect); state = await check('Escape kept the query and selection for the reopen', value => restored(value, 'fixture') && retained(value).selectedId === 'terminal'); await screenshot('launcher-restored'); key('Up'); state = await check('Up works on the restored query', value => retained(value).query === 'fixture' && retained(value).selectedId === 'editor'); key('Down'); state = await check('Down returns to the terminal', value => retained(value).query === 'fixture' && retained(value).selectedId === 'terminal'); input('type', 'd'); state = await check('a typed character replaces the selected query instead of appending', value => retained(value).query === 'd' && control(value, 'fixture editor') && !control(value, 'fixture terminal') && retained(value).selectedId === 'editor' && !emptyState(value)); await screenshot('launcher-replaced'); key('BackSpace'); input('type', 'term'); state = await check('a typed query filters to the terminal', value => retained(value).query === 'term' && control(value, 'fixture terminal') && !control(value, 'fixture editor')); key('Return'); state = await check('Enter launches the typed match once and closes', value => service(value).activations === 1 && service(value).launches.terminal === 1 && launched(value)); state = await open('launcher', value => search(value)?.rect); state = await check('a keyboard launch cleared the query: the launched app leads the empty query on reopen', value => fresh(value) && terminalFirst(value) && retained(value).selectedId === 'terminal'); await screenshot('launcher-frecent'); click(control(state, 'expand details').rect); state = await check('the disclosure reveals desktop-entry facts', value => retained(value).detailsExpanded === true && control(value, 'collapse details') && within(entryDetails(value)?.rect, value.width, value.height) && texts(value).includes('category')); await screenshot('launcher-details'); click(search(state).rect); await check('a click returns focus to the search field', value => search(value).focused); input('type', 'term'); state = await check('a query keeps the disclosure open', value => retained(value).query === 'term' && control(value, 'fixture terminal') && !control(value, 'fixture editor') && entryDetails(value)); key('ctrl+1'); state = await check('Ctrl+1 runs the first desktop action and closes', value => service(value).actionActivations === 1 && service(value).activations === 1 && service(value).launches.terminal === 2 && launched(value)); state = await open('launcher', value => search(value)?.rect); state = await check('a desktop action cleared the query; the disclosure stays open', value => fresh(value) && terminalFirst(value) && retained(value).selectedId === 'terminal' && entryDetails(value) && control(value, 'collapse details')); input('type', 'terminal'); state = await check('launcher query filters without exposing editable text', value => filtered(value) && retained(value).selectedId === 'terminal'); await screenshot('launcher-filtered'); click(outsideRect(state)); await check('outside click closes launcher without launching', value => launched(value, 'outside') && service(value).activations === 1); state = await open('launcher', value => search(value)?.rect); state = await check('the outside click kept the query', value => restored(value, 'terminal') && filtered(value)); key('Return'); state = await check('Enter launches the selected match of the restored query once and closes', value => service(value).activations === 2 && service(value).launches.terminal === 3 && launched(value)); state = await open('launcher', value => search(value)?.rect); state = await check('launching the restored query cleared it', value => fresh(value) && terminalFirst(value)); input('type', 'terminal'); state = await check('typing filters before a pointer launch', value => filtered(value)); click(control(state, 'open').rect); state = await check('pointer open launches once and closes', value => service(value).activations === 3 && service(value).actionActivations === 1 && launched(value)); state = await open('launcher', value => search(value)?.rect); state = await check('a pointer launch cleared the query', value => fresh(value) && terminalFirst(value) && retained(value).selectedId === 'terminal'); input('type', 'terminal'); state = await check('typing filters the fresh query', value => filtered(value)); click(state.chips.launcher.rect); await check('same Bar chip closes launcher without launching', value => launched(value, 'bar-toggle') && service(value).activations === 3); state = await open('launcher', value => search(value)?.rect); state = await check('the chip toggle kept the query', value => restored(value, 'terminal') && filtered(value)); click(search(state).rect); input('type', 'x'); state = await check('a click places the caret, so typing appends; the miss shows one empty state with clear search', value => retained(value).query === 'terminalx' && retained(value).selectedId === '' && emptied(value) && texts(value).includes('no apps match "terminalx"') && control(value, 'clear search')?.enabled === true); assert(within(control(state, 'clear search').rect, state.width, state.height), 'clear search inside output'); await screenshot('launcher-no-matches'); key('Return'); state = await check('Enter without matches launches nothing and stays open', value => value.popup.open && value.popup.name === 'launcher' && service(value).activations === 3 && retained(value).query === 'terminalx'); key('BackSpace'); state = await check('clearing the extra character restores the match', value => filtered(value) && control(value, 'open')?.enabled === true && !emptyState(value)); input('type', 'x'); state = await check('the empty state returns for the miss', value => emptied(value) && search(value).focused); key('Tab'); state = await check('Tab reaches clear search', value => control(value, 'clear search')?.focused === true); key('Return'); state = await check('Enter on clear search empties the query and refocuses search', value => retained(value).query === '' && search(value).focused && control(value, 'fixture terminal') && control(value, 'fixture editor') && !emptyState(value)); input('type', 'terminal'); state = await check('typing after clearing filters again', value => filtered(value)); click(control(state, 'collapse details').rect); state = await check('the disclosure collapses desktop-entry facts', value => retained(value).detailsExpanded === false && control(value, 'expand details') && !entryDetails(value)); click(state.chips.launcher.rect); await check('same Bar chip closes launcher', value => launched(value, 'bar-toggle')); state = await open('launcher', value => search(value)?.rect); assert(restored(state, 'terminal') && filtered(state), 'launcher draft must survive close and reopen'); assert(control(state, 'expand details') && !entryDetails(state), 'the collapsed disclosure survives close and reopen'); call('launcher', 'setEmpty', true); state = await check('losing every app shows the miss for the retained query', value => service(value).empty === true && emptied(value) && texts(value).includes('no apps match "terminal"')); click(control(state, 'clear search').rect); state = await check('without a query the empty state says no apps exist and offers no action', value => retained(value).query === '' && emptied(value) && texts(value).includes('no apps found') && texts(value).includes('installed apps appear here') && !control(value, 'clear search') && search(value).focused); await screenshot('launcher-no-apps'); call('launcher', 'setEmpty', false); state = await check('apps returning replace the empty state', value => control(value, 'fixture terminal') && control(value, 'fixture editor') && !emptyState(value) && retained(value).selectedId === 'terminal'); key('Escape'); await check('Escape closes launcher without launching', value => launched(value, 'escape-key') && service(value).activations === 3 && !launcher(value).open); }