okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
8667a3dbf
main
1// The saved Monitor picture when a model is loaded (the normal case) starts with the Strata logo alone and the models/time line. 2// (QA follow-up: it was checked with a loaded model through the real page; the picture is the one of the Monitor screen, which shows the 3// loaded models. NativeMonitor.tsx is not used by any screen, so it needs no header.) 4import test from 'node:test' ; 5import assert from 'node:assert/strict' ; 6import { readFile } from 'node:fs/promises' ; 7import { readdir } from 'node:fs/promises' ; 8 9const read = path => readFile ( new URL ( path , import . meta. url ), 'utf8' ). then ( s => s . replace ( / \r\n / g , '\n' )); 10 11test ( 'with a model loaded the picture is headed by the logo and the line "<model> · <time>"; with none, "N loaded models"' , async () => { 12const source = await read ( '../src/screens/Monitor.tsx' ); 13assert . match ( source , / const scopeLabel = selectedInstance \? instanceLabel\(selectedInstance\) : `\$\{runtime\?\.instances\.length \?\? 0\} loaded models`; / ); 14const header = / \{tr\(frozen \? <header className="section-toolbar"> ( . * ? ) <\/header> : null\)\} / s . exec ( source )?.[ 1 ]; 15assert . ok ( header ); 16assert . match ( header , / <Brand variant="lockup" / ); assert . doesNotMatch ( header , / <h1 / ); 17assert . match ( header , / frozen\.modelLabel. * frozen\.time / s ); 18assert . match ( source , / setFrozen\(\{ data: structuredClone\(scoped \?\? live\), hardware: structuredClone\(inventory\), time: new Date\(\)\.toLocaleString\(localeTag\(\)\), modelLabel: scopeLabel \}\) / ); 19}); 20 21test ( 'no screen renders NativeMonitor, so the Monitor screen is the only picture source' , async () => { 22const dirs = [ '../src/screens/' , '../src/app/' , '../src/components/' ]; 23for ( const dir of dirs ) { 24for ( const name of await readdir ( new URL ( dir , import . meta. url ))) { 25if ( ! /\.tsx ? $ / . test ( name ) || name === 'NativeMonitor.tsx' ) continue ; 26assert . doesNotMatch ( await read ( dir + name ), / <NativeMonitor\b | from '\.\/NativeMonitor' | from '\.\.\/components\/NativeMonitor' / , ` ${ dir } ${ name } ` ); 27} 28} 29});