okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
2e8fb221c
main
1import test from 'node:test' ; 2import assert from 'node:assert/strict' ; 3import { plainUpdateError , plainError } from '../server/update-messages.mjs' ; 4 5// #4853: an engine that was downloaded and checked, then could not be put in place, used to read "The update didn't finish and nothing was 6// changed" with no reason. The reason is now said in plain words and the technical text stays in details. 7 8const moved = new Error ( 'the new engine could not be moved into place (Strata could not use C:\\Users\\x\\AppData\\Local\\Strata\\components\\.s\\ab12\\engine (PermissionError)); copying it did not work either (OSError)' ); 9Object . assign ( moved , { exitCode :6 }); 10 11test ( 'an engine that could not be put in place says so and does not blame the download' , () => { 12const plain = plainUpdateError ( moved ); 13assert . match ( plain . message , / downloaded and checked, but Windows or a security program would not let Strata put it in place / ); 14assert . match ( plain . message , / Wait a minute, then press Update engine in Settings / ); 15assert . doesNotMatch ( plain . message , / PermissionError | C:\\ | exit | \.s\\ / ); 16assert . equal ( plain . details , moved . message ); 17}); 18 19test ( 'the unpack and the switch failures are not the generic sentence either' , () => { 20for ( const text of [ 'the package could not be unpacked: Strata could not use X (PermissionError)' , 'the new engine was not accepted after the switch (a start would pick other); the previous engine is unchanged' ]) { 21const plain = plainUpdateError ( new Error ( text )); 22assert . doesNotMatch ( plain . message , / didn't finish and nothing was changed / ); 23assert . match ( plain . message , / put it in place / ); 24} 25}); 26 27test ( 'a disk that is full while unpacking is a disk-space message, not a security-program one' , () => { 28const plain = plainUpdateError ( new Error ( 'the package could not be unpacked: Strata could not use X: No space left on device (OSError)' )); 29assert . match ( plain . message , / not enough free disk space / ); 30}); 31 32test ( 'a path that is too long says that' , () => { 33const plain = plainUpdateError ( new Error ( 'the package could not be unpacked: a file path is longer than Windows allows (300 characters, the limit is 260): X' )); 34assert . match ( plain . message , / too deep for Windows / ); 35assert . match ( plain . next , / Details / ); 36}); 37 38test ( 'the first-run card has no Settings page: the next step names its own Continue button' , () => { 39const plain = plainUpdateError ( moved , 'engine' , 'Continue' ); 40assert . match ( plain . next , / ^Wait a minute, then press Continue\. / ); 41assert . doesNotMatch ( plain . message , / Settings / ); 42const generic = plainUpdateError ( new Error ( 'something unexpected' ), 'engine' , 'Continue' ); 43assert . equal ( generic . next , 'Press Continue to try again.' ); 44assert . equal ( plainError ( new Error ( 'app-1 is serving.' ), 'engine' , 'Continue' ). message , 'A model is running, so nothing was changed. Unload the model in Models, then press Continue.' ); 45assert . match ( plainUpdateError ( new Error ( 'something unexpected' )). next , / Update engine in Settings / ); // elsewhere unchanged 46});