okami.mom/strata

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

Niko1221Merge f-ds-out ac306afb2 into f-own-intaff3a132f

main
1.9 KiB33 linesraw
1import test from 'node:test';
2import { readFileSync as read } from 'node:fs';
3import assert from 'node:assert/strict';
4
5const src = name => read(new URL(`../${name}`, import.meta.url), 'utf8');
6
7test('the host passes the kept update check to the app without asking the network', () => {
8  const host = src('server/native-control.mjs');
9  assert.match(host, /updateAvailable:engine\.update_available\?\?null/, 'the snapshot carries what `components engine` kept');
10  assert.match(src('src/lib/native.ts'), /updateAvailable\?:\{engine\?:string\|null;app\?:string\|null\}\|null/);
11});
12
13test('one card, one button, only when an engine is offered, and it runs the existing Update engine job', () => {
14  const card = src('src/components/EngineUpdateCard.tsx');
15  assert.match(card, /offer && offer\.engine\)/);
16  assert.match(card, /nativeAction\('operations', \{ kind: 'update-engine' \}\)/);
17  assert.equal((card.match(/<Btn /g) ?? []).length, 1, 'one button');
18  assert.doesNotMatch(card, /fetch\(|api\.get|api\.post|XMLHttpRequest/, 'showing the card reads no network: only the kept state');
19  assert.match(card, /disabled=\{busy \|\| pending \|\| running\}/, 'not while a job runs or a model is loaded');
20  assert.doesNotMatch(card, /process\.env|STRATA_|environment variable/i, 'no environment variables in the words');
21});
22
23test('the card is on the Models screen once and nowhere else', () => {
24  const models = src('src/components/NativeModels.tsx');
25  assert.equal((models.match(/<EngineUpdateCard /g) ?? []).length, 1);
26  assert.match(models, /<EngineUpdateCard native=\{native\} busy=\{!!active\}\/>/);
27  assert.doesNotMatch(src('src/components/GuidedSetup.tsx'), /EngineUpdateCard/);
28});
29
30test('an updated engine is reported as an engine, not as "Strata is updated"', () => {
31  const host = src('server/native-control.mjs');
32  assert.match(host, /x\.component==='engine'\?'The engine is updated and ready\.'/);
33});