okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
361c8d94a
main
1/** The line shown while a download server has not answered yet (lane NET, W14): in all nine languages, the host and the seconds filled in from 2* setup's English label (strata_control/netpolicy.py WORDS["waiting"], handed over as the install step's label). */ 3import test from 'node:test' ; 4import assert from 'node:assert/strict' ; 5import { build } from 'esbuild' ; 6import { fileURLToPath } from 'node:url' ; 7import { readFileSync } from 'node:fs' ; 8 9const here = ( p ) => fileURLToPath ( new URL ( p , import . meta. url )); 10async function bundle ( entry ) { 11const result = await build ({ 12entryPoints :[ here ( entry )], bundle :true , format :'esm' , platform :'node' , write :false , logLevel :'silent' , 13alias :{ react :here ( './helpers/react-stub.mjs' ) }, loader :{ '.json' :'json' }, 14}); 15return import ( `data:text/javascript;base64, ${ Buffer . from ( result . outputFiles [ 0 ]. text ). toString ( 'base64' )} ` ); 16} 17 18const LINE = 'Waiting for {0} to answer ({1} s so far)' ; 19 20test ( 'the waiting line exists in all nine languages with both placeholders' , () => { 21for ( const lang of [ 'en' , 'zh' , 'ja' , 'de' , 'es' , 'ru' , 'pt' , 'ko' , 'fr' ]) { 22const file = JSON . parse ( readFileSync ( here ( `../src/locales/net- ${ lang } .json` ), 'utf8' )); 23assert . deepEqual ( Object . keys ( file ), [ 'net01' ], lang ); 24assert . ok ( / \{0\} / . test ( file . net01 ) && / \{1\} / . test ( file . net01 ), ` ${ lang } keeps {0} and {1}` ); 25if ( lang === 'en' ) assert . equal ( file . net01 , LINE , 'the approved wording' ); 26else assert . notEqual ( file . net01 , LINE , ` ${ lang } is translated` ); 27} 28}); 29 30test ( 'the first-run screen takes the waiting line in place of the stage text, only while setup waits' , async () => { 31const eta = await bundle ( '../src/lib/download-eta.ts' ); 32const i18n = await bundle ( '../src/lib/i18n.ts' ); 33assert . equal ( eta . waitingText ({ phase :'waiting' , label :'Waiting for github.com to answer (5 s so far)' }), 'Waiting for github.com to answer (5 s so far)' ); 34assert . equal ( eta . waitingText ({ phase :'download' , label :'Getting the model files' }), undefined ); 35assert . equal ( eta . waitingText ( undefined ), undefined ); 36const src = readFileSync ( here ( '../src/components/GuidedSetup.tsx' ), 'utf8' ); 37// the wizard's status line is guidedStatusText (DL99): the waiting line first, then setup's own sentence, then the stage text 38assert . match ( src , / <strong className="onboard-download-status">\{tr\(guidedStatusText\(installJob\?\.result\?\.install, progress\)\)\} / , 39'the same element as the stage text: no new element, no new style' ); 40assert . equal ( eta . guidedStatusText ({ phase :'waiting' , label :'Waiting for github.com to answer (5 s so far)' }, { percent :3 }), 'Waiting for github.com to answer (5 s so far)' ); 41void i18n ; 42}); 43 44test ( 'setup\'s English label is translated with the host and the seconds kept' , async () => { 45const i18n = await bundle ( '../src/lib/i18n.ts' ); 46await i18n . setTranslationLanguage ( 'de' ); 47assert . equal ( i18n . tr ( 'Waiting for huggingface.co to answer (15 s so far)' ), 'Warten auf eine Antwort von huggingface.co (bisher 15 s)' ); 48await i18n . setTranslationLanguage ( 'en' ); 49assert . equal ( i18n . tr ( 'Waiting for huggingface.co to answer (15 s so far)' ), 'Waiting for huggingface.co to answer (15 s so far)' ); 50});