okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
aff3a132f
main
1import test from 'node:test' ; 2import { readFileSync as read } from 'node:fs' ; 3import assert from 'node:assert/strict' ; 4 5const src = name => read ( new URL ( `../ ${ name } ` , import . meta. url ), 'utf8' ); 6 7test ( 'the host passes the kept update check to the app without asking the network' , () => { 8const host = src ( 'server/native-control.mjs' ); 9assert . match ( host , / updateAvailable:engine\.update_available\?\?null / , 'the snapshot carries what `components engine` kept' ); 10assert . match ( src ( 'src/lib/native.ts' ), / updateAvailable\?:\{engine\?:string\|null;app\?:string\|null\}\|null / ); 11}); 12 13test ( 'one card, one button, only when an engine is offered, and it runs the existing Update engine job' , () => { 14const card = src ( 'src/components/EngineUpdateCard.tsx' ); 15assert . match ( card , / offer && offer\.engine\) / ); 16assert . match ( card , / nativeAction\('operations', \{ kind: 'update-engine' \}\) / ); 17assert . equal (( card . match ( / <Btn / g ) ?? []). length , 1 , 'one button' ); 18assert . doesNotMatch ( card , / fetch\( | api\.get | api\.post | XMLHttpRequest / , 'showing the card reads no network: only the kept state' ); 19assert . match ( card , / disabled=\{busy \|\| pending \|\| running\} / , 'not while a job runs or a model is loaded' ); 20assert . doesNotMatch ( card , / process\.env | STRATA_ | environment variable / i , 'no environment variables in the words' ); 21}); 22 23test ( 'the card is on the Models screen once and nowhere else' , () => { 24const models = src ( 'src/components/NativeModels.tsx' ); 25assert . equal (( models . match ( / <EngineUpdateCard / g ) ?? []). length , 1 ); 26assert . match ( models , / <EngineUpdateCard native=\{native\} busy=\{!!active\}\/> / ); 27assert . doesNotMatch ( src ( 'src/components/GuidedSetup.tsx' ), / EngineUpdateCard / ); 28}); 29 30test ( 'an updated engine is reported as an engine, not as "Strata is updated"' , () => { 31const host = src ( 'server/native-control.mjs' ); 32assert . match ( host , / x\.component==='engine'\?'The engine is updated and ready\.' / ); 33});