okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
e5476b0e1
main
1// QA report F03: a dialog opened from the narrow-window menu closes the menu and takes the keyboard. 2// (The real behaviour is checked in a browser by scripts/qa2-flows.mjs; these keep the pieces from being taken out again.) 3import test from 'node:test' ; 4import assert from 'node:assert/strict' ; 5import { readFile } from 'node:fs/promises' ; 6 7const read = path => readFile ( new URL ( path , import . meta. url ), 'utf8' ). then ( s => s . replace ( / \r\n / g , '\n' )); 8 9test ( 'every dialog the menu opens closes the menu first, and the task dialogs stay mounted while it is closed' , async () => { 10const tree = await read ( '../src/app/TaskTree.tsx' ); 11assert . match ( tree , / import \{ pushToast, setNavOpen \} from '\.\.\/lib\/store' / ); 12for ( const opener of [ 'setEditor(blankTask())' , 'setEditor({ ...t })' , 'setRemove(t)' ]) assert . ok ( tree . includes ( `setNavOpen(false); ${ opener } ` ), ` ${ opener } closes the menu` ); 13assert . match ( tree , / if \(collapsed\)\n\s + return dialogs; / , 'a closed menu still renders the dialogs' ); 14const side = await read ( '../src/app/Sidebar.tsx' ); 15for ( const opener of [ 'setRenameId(menuId)' , 'setDeleteId(menuId)' , 'setRecentOpen(true)' , 'setRemoveWorkspaceId(w.id)' , 'setRenameWsId(w.id)' , 'setQuitOpen(true)' ]) assert . ok ( side . includes ( `setNavOpen(false); ${ opener } ` ), ` ${ opener } closes the menu` ); 16}); 17 18test ( 'a surface that opens moves the keyboard in even when animation frames are held back' , async () => { 19const focus = await read ( '../src/lib/focus.ts' ); 20assert . match ( focus , / const fallback = setTimeout\( / ); 21assert . match ( focus , / clearTimeout\(fallback\) / ); 22assert . match ( focus , / !el\.contains\(document\.activeElement\) && isTopSurface\(el\) / ); 23});