okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
ffb3d9b31
main
1/** 2* QAGUI-STRIX 11-09 finding 4: "Read pictures" unticked and loaded did not hold across an app restart on a model set up without the picture files: 3* the box came back ticked and Load fetched the 866 MB picture reader. The off was saved (ui_vision_enabled false), but the page honoured a saved off 4* only when the picture files were prepared (a guard for the off 0.2.9 saved while the engine had no reader). A choice made with a reader present now 5* carries a marker (ui_vision_chosen) and holds; an old off without the marker behaves exactly as before. 6*/ 7import test from 'node:test' ; 8import assert from 'node:assert/strict' ; 9import { readFileSync , writeFileSync } from 'node:fs' ; 10import { join } from 'node:path' ; 11import { openingVision } from '../src/lib/pictures-choice.ts' ; 12import { nativeFixture , finishJob } from './helpers/native-fixture.mjs' ; 13 14test ( 'the page: an off with the marker holds without the picture files; without the marker nothing changed' , () => { 15assert . equal ( openingVision ({ visionEnabled :false , visionPrepared :false , visionChosen :true , images :'off' }), 'no' , 'the Strix case' ); 16assert . equal ( openingVision ({ visionEnabled :false , visionPrepared :false , images :'off' }), 'yes' , 'an old off (no marker, no files): on, as before' ); 17assert . equal ( openingVision ({ visionEnabled :false , visionPrepared :false , visionChosen :false , images :'off' }), 'yes' ); 18assert . equal ( openingVision ({ visionEnabled :false , visionPrepared :true }), 'no' , 'off with the files: off, as before' ); 19assert . equal ( openingVision ({ visionEnabled :true , visionPrepared :false , visionChosen :true , images :'off' }), 'yes' , 'on stays on' ); 20assert . equal ( openingVision ({ visionEnabled :true , visionPrepared :true , visionChosen :true , visionDevice :'cpu' }), 'cpu' ); 21assert . equal ( openingVision ( undefined ), 'yes' ); 22}); 23 24test ( 'the host: a load with Read pictures off on a model without picture files saves the off with the marker, and reports it after a restart' , async () => { 25const f = nativeFixture (); 26try { 27await f . control . refresh (); 28const path = join ( f . repo , 'strata-iq2_xs.json' ); 29const { vision, ...noFiles } = JSON . parse ( readFileSync ( path , 'utf8' )); 30assert . ok ( vision , 'the fixture had picture files' ); 31writeFileSync ( path , JSON . stringify ( noFiles )); // set up without the picture files (the Strix model) 32await f . control . refresh ( true ); 33const row = () => f . control . state (). installed . models . find ( m => m . model === 'iq2_xs' ); 34assert . equal ( row (). visionPrepared , false ); 35assert . equal ( row (). visionChosen , false , 'no marker before a choice' ); 36const off = await finishJob ( f . control , f . control . operation ( 'load' , { model :'iq2_xs' , vision :'no' }). id ); 37assert . equal ( off . state , 'done' , off . error ); 38const saved = JSON . parse ( readFileSync ( path , 'utf8' )); 39assert . equal ( saved . ui_vision_enabled , false ); 40assert . equal ( saved . ui_vision_chosen , true , 'the marker is saved with the choice' ); 41await f . control . refresh ( true ); 42assert . equal ( row (). visionChosen , true ); 43assert . equal ( openingVision ( row ()), 'no' , 'after a restart the box opens unticked' ); 44} finally { await f . cleanup (); } 45}); 46 47test ( 'the host: a load while the engine has no reader still saves nothing, the marker neither; an old file without the marker reads as before' , async () => { 48const f = nativeFixture (); 49try { 50await f . control . refresh (); 51const path = join ( f . repo , 'strata-iq2_xs.json' ); 52const none = await finishJob ( f . control , f . control . operation ( 'load' , { model :'iq2_xs' , vision :'no' , visionUnavailable :true }). id ); 53assert . equal ( none . state , 'done' , none . error ); 54const saved = JSON . parse ( readFileSync ( path , 'utf8' )); 55assert . equal ( saved . ui_vision_enabled , undefined ); 56assert . equal ( saved . ui_vision_chosen , undefined ); 57const { vision, ...noFiles } = saved ; 58writeFileSync ( path , JSON . stringify ({ ...noFiles , ui_vision_enabled :false , ui_vision_device :'yes' })); // a 0.2.9 file: off, no files, no marker 59await f . control . refresh ( true ); 60const row = f . control . state (). installed . models . find ( m => m . model === 'iq2_xs' ); 61assert . equal ( row . visionChosen , false ); 62assert . equal ( openingVision ( row ), 'yes' ); 63} finally { await f . cleanup (); } 64});