okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-dl99-fixes: the Qwen3.6 first-run download (no engine-race stop, no cancelled engine download, progress to 100%, the picture reader's real figure, the engine-not-ready sentence)361c8d94a

main
3.1 KiB50 linesraw
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) {
11  const result = await build({
12    entryPoints: [here(entry)], bundle: true, format: 'esm', platform: 'node', write: false, logLevel: 'silent',
13    alias: { react: here('./helpers/react-stub.mjs') }, loader: { '.json': 'json' },
14  });
15  return 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', () => {
21  for (const lang of ['en', 'zh', 'ja', 'de', 'es', 'ru', 'pt', 'ko', 'fr']) {
22    const file = JSON.parse(readFileSync(here(`../src/locales/net-${lang}.json`), 'utf8'));
23    assert.deepEqual(Object.keys(file), ['net01'], lang);
24    assert.ok(/\{0\}/.test(file.net01) && /\{1\}/.test(file.net01), `${lang} keeps {0} and {1}`);
25    if (lang === 'en') assert.equal(file.net01, LINE, 'the approved wording');
26    else 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 () => {
31  const eta = await bundle('../src/lib/download-eta.ts');
32  const i18n = await bundle('../src/lib/i18n.ts');
33  assert.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)');
34  assert.equal(eta.waitingText({ phase: 'download', label: 'Getting the model files' }), undefined);
35  assert.equal(eta.waitingText(undefined), undefined);
36  const 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
38  assert.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');
40  assert.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)');
41  void i18n;
42});
43
44test('setup\'s English label is translated with the host and the seconds kept', async () => {
45  const i18n = await bundle('../src/lib/i18n.ts');
46  await i18n.setTranslationLanguage('de');
47  assert.equal(i18n.tr('Waiting for huggingface.co to answer (15 s so far)'), 'Warten auf eine Antwort von huggingface.co (bisher 15 s)');
48  await i18n.setTranslationLanguage('en');
49  assert.equal(i18n.tr('Waiting for huggingface.co to answer (15 s so far)'), 'Waiting for huggingface.co to answer (15 s so far)');
50});