okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
64b48c0d0
main
1/** 2* QAGUI 0213 #2: in the first seconds after a start the engine is there but Control's installed list has not arrived, so a downloaded 3* model must not be offered as "Download & load". The per-model buttons wait (existing "Checking…" label, disabled) until the list is in. 4*/ 5import test from 'node:test' ; 6import assert from 'node:assert/strict' ; 7import { build } from 'esbuild' ; 8import { readFileSync } from 'node:fs' ; 9import { fileURLToPath } from 'node:url' ; 10 11const here = ( p ) => fileURLToPath ( new URL ( p , import . meta. url )); 12const result = await build ({ 13entryPoints :[ here ( '../src/lib/native.ts' )], bundle :true , format :'esm' , platform :'node' , write :false , logLevel :'silent' , 14alias :{ react :here ( './helpers/react-stub.mjs' ) }, loader :{ '.json' :'json' }, 15}); 16const { installedListPending} = await import ( `data:text/javascript;base64, ${ Buffer . from ( result . outputFiles [ 0 ]. text ). toString ( 'base64' )} ` ); 17 18test ( 'the list is pending only while the engine answered and the installed list is still missing' , () => { 19assert . equal ( installedListPending ( null ), false , 'nothing read yet: the buttons are already off (engine not available)' ); 20assert . equal ( installedListPending ({ available :false , installed :null , error :null }), false ); 21assert . equal ( installedListPending ({ available :true , installed :null , error :null }), true , 'the flash: engine up, list not here' ); 22assert . equal ( installedListPending ({ available :true , installed :{ models :[] }, error :null }), false , 'an empty list is an answer: Download & load is right' ); 23assert . equal ( installedListPending ({ available :true , installed :{ models :[{ model :'a' , ready :true }] }, error :null }), false ); 24assert . equal ( installedListPending ({ available :true , installed :null , error :'boom' }), false , 'a failed read does not hold the buttons for ever' ); 25}); 26 27test ( 'the Models page waits on it for the download size, Tune model and the primary button, and uses the existing Checking label' , () => { 28const src = readFileSync ( here ( '../src/components/NativeModels.tsx' ), 'utf8' ); 29assert . match ( src , / listPending = installedListPending\(native\) / ); 30assert . match ( src , / !loadedSelected && !listPending && !installed\?\.ready && selectedSize\?\.download_gb / ); 31assert . match ( src , / <Btn icon="gauge" disabled=\{listPending \|\| / ); 32assert . match ( src , / <Btn variant="primary" icon="models" disabled=\{pending \|\| listPending \|\| / ); 33assert . match ( src , / tr\(pending \|\| listPending \? 'Checking…' : installed\?\.ready \? 'Load model' : 'Download & load'\) / ); 34});