okami.mom/strata

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

Niko1221Merge f-split-int (a3024ed10) into f-split-qa1: qa2's s3237-s3238 kept, my 21 strings renumbered s3260-s32808667a3dbf

main
2.0 KiB29 linesraw
1// The saved Monitor picture when a model is loaded (the normal case) starts with the Strata logo alone and the models/time line.
2// (QA follow-up: it was checked with a loaded model through the real page; the picture is the one of the Monitor screen, which shows the
3// loaded models. NativeMonitor.tsx is not used by any screen, so it needs no header.)
4import test from 'node:test';
5import assert from 'node:assert/strict';
6import { readFile } from 'node:fs/promises';
7import { readdir } from 'node:fs/promises';
8
9const read = path => readFile(new URL(path, import.meta.url), 'utf8').then(s => s.replace(/\r\n/g, '\n'));
10
11test('with a model loaded the picture is headed by the logo and the line "<model> · <time>"; with none, "N loaded models"', async () => {
12  const source = await read('../src/screens/Monitor.tsx');
13  assert.match(source, /const scopeLabel = selectedInstance \? instanceLabel\(selectedInstance\) : `\$\{runtime\?\.instances\.length \?\? 0\} loaded models`;/);
14  const header = /\{tr\(frozen \? <header className="section-toolbar">(.*?)<\/header> : null\)\}/s.exec(source)?.[1];
15  assert.ok(header);
16  assert.match(header, /<Brand variant="lockup"/); assert.doesNotMatch(header, /<h1/);
17  assert.match(header, /frozen\.modelLabel.*frozen\.time/s);
18  assert.match(source, /setFrozen\(\{ data: structuredClone\(scoped \?\? live\), hardware: structuredClone\(inventory\), time: new Date\(\)\.toLocaleString\(localeTag\(\)\), modelLabel: scopeLabel \}\)/);
19});
20
21test('no screen renders NativeMonitor, so the Monitor screen is the only picture source', async () => {
22  const dirs = ['../src/screens/', '../src/app/', '../src/components/'];
23  for (const dir of dirs) {
24    for (const name of await readdir(new URL(dir, import.meta.url))) {
25      if (!/\.tsx?$/.test(name) || name === 'NativeMonitor.tsx') continue;
26      assert.doesNotMatch(await read(dir + name), /<NativeMonitor\b|from '\.\/NativeMonitor'|from '\.\.\/components\/NativeMonitor'/, `${dir}${name}`);
27    }
28  }
29});