okami.mom/strata

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

Niko1221rc1 merge ds-coder (d6a5a7837)4fb068a8c

main
4.8 KiB62 linesraw
1/** Owner test round 6: short model names, one logs button, the Monitor sentence and screenshot, Tasks without the deleted list and the suggestions. */
2import test from 'node:test';
3import assert from 'node:assert/strict';
4import { readFile } from 'node:fs/promises';
5import { build } from 'esbuild';
6import { fileURLToPath } from 'node:url';
7
8const src = f => fileURLToPath(new URL(`../src/${f}`, import.meta.url));
9const read = f => readFile(src(f), 'utf8');
10async function load(file) {
11  const result = await build({ entryPoints: [src(`lib/${file}`)], bundle: true, format: 'esm', platform: 'node', write: false, alias: { react: fileURLToPath(new URL('./helpers/react-stub.mjs', import.meta.url)) }, logLevel: 'silent', loader: { '.json': 'json' } });
12  return import(`data:text/javascript;base64,${Buffer.from(result.outputFiles[0].text).toString('base64')}`);
13}
14globalThis.window ??= globalThis; globalThis.localStorage ??= { getItem: () => null, setItem: () => {} };
15globalThis.navigator ??= { language: 'en' };
16
17test('item 1: downloaded models get a short name, family and quantization', async () => {
18  const { nativeShortName } = await load('native-names.ts');
19  assert.equal(nativeShortName('swift-iq2_xs'), 'Swift IQ2_XS');
20  assert.equal(nativeShortName('iq3_s'), 'IQ3_S');
21  assert.equal(nativeShortName('unsloth-ud-q4_k_xl'), 'Unsloth UD-Q4_K_XL');
22  assert.equal(nativeShortName('gyro-gyro-s'), 'Gyro-S');
23  assert.equal(nativeShortName('coder-iq1_m'), 'Coder IQ1_M');
24  assert.equal(nativeShortName('nvfp4-nvfp4'), 'NVFP4 (Strata’s version)');
25  assert.equal(nativeShortName('nvfp4-nvfp4-nvidia'), 'NVFP4 (NVIDIA’s version)');
26  assert.equal(nativeShortName('nvfp4-nvfp4-qad'), 'NVFP4 (NVIDIA, trained for FP4)');
27  const storage = await read('components/SettingsStorage.tsx');
28  assert.match(storage, /title=\{m\.model_name \|\| m\.model\}/, 'the full name is the tooltip');
29});
30
31test('item 2: Diagnostics has one button, View logs; Save logs lives in the logs view', async () => {
32  const ops = await read('components/NativeOperations.tsx');
33  const card = ops.slice(ops.indexOf('tr("Diagnostics")'), ops.indexOf('<Dialog open={showLogs}'));
34  assert.equal((card.match(/<Btn /g) ?? []).length, 1, 'one button in the Diagnostics card');
35  assert.match(card, /View logs/); assert.ok(!/Save logs/.test(card));
36  const dialog = ops.slice(ops.indexOf('<Dialog open={showLogs}'), ops.indexOf('</Dialog>', ops.indexOf('<Dialog open={showLogs}')));
37  assert.match(dialog, /Save logs/);
38});
39
40test('item 4: the Monitor sentence is plain words; the screenshot leaves out the model state and the conversation cache', async () => {
41  const { requestSummary } = await load('monitor-summary.ts');
42  const f = { number: (n, d = 0) => n.toLocaleString('en', { maximumFractionDigits: d, minimumFractionDigits: d }), tokens: n => n >= 1000 ? `${Math.round(n / 1000)}K` : String(n) };
43  assert.equal(requestSummary({ requests: 18, output: 47.4, reading: 1332, reused: 91000 }, f), 'In 18 requests your average output was 47.4 tok/s and prompt reading 1,332 tok/s, reusing 91K tokens.');
44  assert.equal(requestSummary({ requests: 3, output: 40 }, f), 'In 3 requests your average output was 40.0 tok/s.');
45  assert.equal(requestSummary({ requests: 2 }, f), '2 requests so far.');
46  const monitor = await read('screens/Monitor.tsx');
47  assert.match(monitor, /monitor-state" aria-label=\{tr\("Model state"\)\} data-snapshot-skip/);
48  assert.match(monitor, /monitor-cache" data-snapshot-skip/);
49  assert.match(await read('lib/snapshot.ts'), /querySelectorAll\('\[data-snapshot-skip\]'\)/);
50});
51
52test('items 6, 7, 8: Bypass permissions everywhere, no deleted-tasks list or suggestions, a + icon, and a plain "Task removed"', async () => {
53  const tasks = await read('screens/Tasks.tsx'), detail = await read('components/TaskDetail.tsx'), editor = await read('components/TaskEditor.tsx'), tree = await read('app/TaskTree.tsx'), lib = await read('lib/tasks.ts');
54  for (const [name, text] of [['Tasks', tasks], ['TaskDetail', detail], ['TaskEditor', editor], ['TaskTree', tree]]) assert.ok(!/Allowed to make changes/.test(text), `${name} still says it`);
55  assert.match(detail, /Bypass permissions/); assert.match(editor, /Bypass permissions/);
56  assert.match(lib, /mode:'bypass'/, 'a new task starts as Bypass permissions');
57  assert.ok(!/Deleted tasks|task-templates|Restore/.test(tasks), 'no deleted list, suggestions or restore on the Tasks screen');
58  assert.match(tasks, /IconBtn name="plus"/);
59  assert.ok(!/back=\{/.test(tasks) && /titleDetail=\{currentTask \? undefined/.test(tasks), 'nothing on the left of the navbar of an opened task (the help lines show only on the list views)');
60  assert.ok(!/modelName|"Model"/.test(detail), 'no Model section');
61  assert.match(tree, /pushToast\('success', 'Task removed'\)/); assert.match(tasks, /pushToast\('success', 'Task removed'\)/);
62});