okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
ffb3d9b31
main
1/** 2* Settings > About, the update lines: 3* - QAGUI-STRIX 11-09 finding 2: the first-run card's failed engine update ("A model is running ... then press Continue") stayed under About after 4* Continue installed the engine and after restarts (jobs persist in native-jobs.json). A failure a later finished update of the same component 5* made right is no longer shown there. 6* - Lane 3 finding 6 (11-09): after an in-app update the row kept "Update available" until the next manual check. An update that finished after 7* the check shown makes About check again, once per update. 8*/ 9import test from 'node:test' ; 10import assert from 'node:assert/strict' ; 11import { build } from 'esbuild' ; 12import { readFileSync } from 'node:fs' ; 13import { fileURLToPath } from 'node:url' ; 14 15const out = await build ({ entryPoints :[ fileURLToPath ( new URL ( '../src/lib/native-job-diagnostics.ts' , import . meta. url ))], bundle :true , format :'esm' , platform :'node' , write :false , logLevel :'silent' }); 16const { currentUpdateFailure, updateFinishedAfter} = await import ( `data:text/javascript;base64, ${ Buffer . from ( out . outputFiles [ 0 ]. text ). toString ( 'base64' )} ` ); 17 18const job = ( id , kind , state , startedAt , extra = {}) => ({ id, kind, state, startedAt, summary :state , error :state === 'error' ?'A model is running, so nothing was changed. Unload the model in Models, then press Continue.' :null , result :null , ...extra }); 19 20test ( 'the Strix case: a first-run engine failure, then Continue installed the engine: About shows no failure, also after a restart (same records)' , () => { 21const jobs = [ job ( 'a' , 'update-engine' , 'error' , '2026-11-09T14:10:00Z' ), job ( 'b' , 'update-engine' , 'done' , '2026-11-09T14:10:30Z' )]; 22assert . equal ( currentUpdateFailure ( jobs ), undefined ); 23assert . equal ( currentUpdateFailure ( JSON . parse ( JSON . stringify ( jobs ))), undefined ); 24}); 25 26test ( 'a failure with no later finished update of the same component is still shown, the last one' , () => { 27const a = job ( 'a' , 'update-engine' , 'error' , '2026-11-09T14:10:00Z' ); 28assert . equal ( currentUpdateFailure ([ a ])?. id , 'a' ); 29assert . equal ( currentUpdateFailure ([ a , job ( 'b' , 'update-strata' , 'done' , '2026-11-09T14:20:00Z' )])?. id , 'a' , 'another component does not settle it' ); 30assert . equal ( currentUpdateFailure ([ a , job ( 'b' , 'update-engine' , 'running' , '2026-11-09T14:20:00Z' )])?. id , 'a' , 'a running retry does not' ); 31assert . equal ( currentUpdateFailure ([ a , job ( 'b' , 'update-engine' , 'cancelled' , '2026-11-09T14:20:00Z' )])?. id , 'a' , 'a cancelled retry does not' ); 32assert . equal ( currentUpdateFailure ([ job ( 'b' , 'update-engine' , 'done' , '2026-11-09T14:00:00Z' ), a ])?. id , 'a' , 'a success before it does not' ); 33assert . equal ( currentUpdateFailure ([ a , job ( 'c' , 'update-strata' , 'error' , '2026-11-09T14:30:00Z' )])?. id , 'c' , 'the last failure' ); 34assert . equal ( currentUpdateFailure ([ a , job ( 'd' , 'load' , 'error' , '2026-11-09T14:30:00Z' )])?. id , 'a' , 'not an update: not here' ); 35}); 36 37test ( 'an interrupted update with no later finished one is still shown in About, with its own words; once a later one finished it is not' , async () => { 38const { INTERRUPTED , jobErrorText} = await import ( `data:text/javascript;base64, ${ Buffer . from ( out . outputFiles [ 0 ]. text ). toString ( 'base64' )} ` ); 39const cut = { ...job ( 'i' , 'update-strata' , 'error' , '2026-11-09T14:10:00Z' ), error :INTERRUPTED }; 40const shown = currentUpdateFailure ([ cut ]); 41assert . equal ( shown ?. id , 'i' ); 42assert . equal ( jobErrorText ( shown , [ cut ]), INTERRUPTED ); 43assert . equal ( currentUpdateFailure ([ cut , job ( 'r' , 'update-strata' , 'running' , '2026-11-09T14:20:00Z' )])?. id , 'i' , 'a retry still running: shown' ); 44assert . equal ( currentUpdateFailure ([ cut , job ( 'd' , 'update-strata' , 'done' , '2026-11-09T14:20:00Z' )]), undefined , 'settled by a later finished update: not in About (Diagnostics keeps it)' ); 45}); 46 47test ( 'an update that finished after the check shown asks for one new check; none before it, none without a check' , () => { 48const check = '2026-11-09T14:00:00Z' ; 49assert . equal ( updateFinishedAfter ([ job ( 'u' , 'update-strata' , 'done' , '2026-11-09T14:05:00Z' )], check ), 'u' ); 50assert . equal ( updateFinishedAfter ([ job ( 'u' , 'update-engine' , 'done' , '2026-11-09T13:55:00Z' , { finishedAt :'2026-11-09T14:02:00Z' })], check ), 'u' , 'finished after the check' ); 51assert . equal ( updateFinishedAfter ([ job ( 'u' , 'update-engine' , 'done' , '2026-11-09T13:50:00Z' )], check ), undefined , 'the check is newer' ); 52assert . equal ( updateFinishedAfter ([ job ( 'u' , 'update-engine' , 'error' , '2026-11-09T14:05:00Z' )], check ), undefined , 'a failed update' ); 53assert . equal ( updateFinishedAfter ([ job ( 'u' , 'load' , 'done' , '2026-11-09T14:05:00Z' )], check ), undefined , 'not an update' ); 54assert . equal ( updateFinishedAfter ([ job ( 'u' , 'update-engine' , 'done' , '2026-11-09T14:05:00Z' )], undefined ), undefined , 'no check shown: nothing (no network on opening Settings)' ); 55}); 56 57test ( 'Settings > About uses both: the failure line and the check again, once per finished update' , () => { 58const src = readFileSync ( fileURLToPath ( new URL ( '../src/components/SettingsUpdates.tsx' , import . meta. url )), 'utf8' ); 59assert . match ( src , / currentUpdateFailure\(native\?\.jobs \?\? \[\]\) / ); 60assert . doesNotMatch ( src , / j\.state === 'error' && \['update-strata', 'update-engine'\]\.includes\(j\.kind\)\)\.slice\(-1\) / ); 61assert . match ( src , / updateFinishedAfter\(native\?\.jobs \?\? \[\], result\?\.checkedAt\) / ); 62assert . match ( src , / rechecked\.current !== finished\) \{ rechecked\.current = finished; void check\(\); \} / ); 63});