import test from 'node:test'; import { readFileSync as read } from 'node:fs'; import assert from 'node:assert/strict'; const src = name => read(new URL(`../${name}`, import.meta.url), 'utf8'); test('the host passes the kept update check to the app without asking the network', () => { const host = src('server/native-control.mjs'); assert.match(host, /updateAvailable:engine\.update_available\?\?null/, 'the snapshot carries what `components engine` kept'); assert.match(src('src/lib/native.ts'), /updateAvailable\?:\{engine\?:string\|null;app\?:string\|null\}\|null/); }); test('one card, one button, only when an engine is offered, and it runs the existing Update engine job', () => { const card = src('src/components/EngineUpdateCard.tsx'); assert.match(card, /offer && offer\.engine\)/); assert.match(card, /nativeAction\('operations', \{ kind: 'update-engine' \}\)/); assert.equal((card.match(/ { const models = src('src/components/NativeModels.tsx'); assert.equal((models.match(//); assert.doesNotMatch(src('src/components/GuidedSetup.tsx'), /EngineUpdateCard/); }); test('an updated engine is reported as an engine, not as "Strata is updated"', () => { const host = src('server/native-control.mjs'); assert.match(host, /x\.component==='engine'\?'The engine is updated and ready\.'/); });