okami.mom/strata

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

Niko1221Version 0.2.15 / Control 0.1.61: app and Terminal 0.2.15, Control 0.1.61; every engine package stays 0.1.60 (the v0.2.14 files, carried by absolute url)e39a52e33

main
4.3 KiB61 linesraw
1import test from 'node:test';
2import assert from 'node:assert/strict';
3import { readFile } from 'node:fs/promises';
4import { nativeUnloadPlan } from '../server/storage-check.mjs';
5
6const loaded = [{ id: 'a', model: 'gyro-gyro-s' }, { id: 'b', model: 'iq3_s' }];
7
8test('O01: checking the same folder unloads nothing', () => {
9  assert.deepEqual(nativeUnloadPlan({ changed: false, unload: true, instances: loaded }), { refuse: null, ids: [] });
10  assert.deepEqual(nativeUnloadPlan({ changed: false, unload: undefined, instances: loaded }), { refuse: null, ids: [] });
11});
12
13test('O01: changing the folder unloads the loaded models only when the person agreed', () => {
14  assert.match(nativeUnloadPlan({ changed: true, unload: false, instances: loaded }).refuse, /Unload native models/);
15  assert.deepEqual(nativeUnloadPlan({ changed: true, unload: true, instances: loaded }), { refuse: null, ids: ['a', 'b'] });
16  assert.deepEqual(nativeUnloadPlan({ changed: true, unload: false, instances: [] }), { refuse: null, ids: [] });
17  assert.deepEqual(nativeUnloadPlan({ changed: true, unload: true, instances: undefined }), { refuse: null, ids: [] });
18});
19
20test('O01: the route uses that plan and the screen asks for an unload only when the folder differs', async () => {
21  const route = await readFile(new URL('../server/index.mjs', import.meta.url), 'utf8');
22  assert.match(route, /nativeUnloadPlan\(\{changed,unload:body\.unload,instances:native\.state\(\)\.instances\}\)/);
23  assert.doesNotMatch(route, /for\(const instance of native\.state\(\)\.instances\)await native\.unload\(instance\.id\);\}\s*\n\s*storageChanging = true/);
24  const screen = await readFile(new URL('../src/components/SettingsStorage.tsx', import.meta.url), 'utf8');
25  assert.match(screen, /changeModelDirectory\(path, path\.trim\(\) !== currentDirectory\)/);
26});
27
28test('F02: Settings -> Storage has ONE Downloaded models list and one total, with the shared files as a line of their own', async () => {
29  const screen = await readFile(new URL('../src/components/SettingsStorage.tsx', import.meta.url), 'utf8');
30  assert.equal((screen.match(/<Field wide label=\{tr\("Downloaded models"\)\}/g) ?? []).length, 1, 'no second section that contradicts the first');
31  assert.match(screen, /totalGb/);
32  assert.match(screen, /Shared files/);
33  assert.match(screen, /No downloaded models/);
34});
35
36test('item 8: "Strata" in Settings is the app\'s version; Strata Control\'s 0.1.45 is only a fallback; the update check gets the app version too', async () => {
37  const { appVersionToShow } = await import('../server/app-version.mjs');
38  assert.equal(appVersionToShow('0.2.0-beta', '0.1.45'), '0.2.0-beta');
39  assert.equal(appVersionToShow('dev', '0.1.45'), '0.1.45', 'a source checkout has no app version: the next best number');
40  assert.equal(appVersionToShow(undefined, null), null);
41  assert.equal(appVersionToShow('dev', null), 'dev');
42  const { build } = await import('esbuild');
43  const out = await build({ stdin: { contents: "export * from './src/lib/app-version';", resolveDir: process.cwd() }, bundle: true, write: false, platform: 'node', format: 'esm' });
44  const { appVersionLabel } = await import(`data:text/javascript;base64,${Buffer.from(out.outputFiles[0].text).toString('base64')}`);
45  assert.equal(appVersionLabel('0.2.0-beta', '0.1.45'), '0.2.0-beta');
46  assert.equal(appVersionLabel('dev', '0.1.45'), '0.1.45');
47  assert.equal(appVersionLabel(undefined, undefined), undefined);
48  const route = await readFile(new URL('../server/index.mjs', import.meta.url), 'utf8');
49  assert.match(route, /appVersion:appVersionToShow\(setupState\(\)\.app\.version,native\.state\(\)\.version\)/);
50  const updates = await readFile(new URL('../src/components/SettingsUpdates.tsx', import.meta.url), 'utf8');
51  assert.doesNotMatch(updates, /native\?\.version \?\? appVersion/, 'the Strata row no longer prefers Control\'s version');
52  assert.match(updates, /AboutVersions/);
53});
54
55test('Cargo.toml, tauri.conf.json and the desktop package agree on the app version the host reports', async () => {
56  const root = new URL('../../desktop/', import.meta.url);
57  const cargo = /^version\s*=\s*"([^"]+)"/m.exec(await readFile(new URL('src-tauri/Cargo.toml', root), 'utf8'))[1];
58  const pkg = JSON.parse(await readFile(new URL('package.json', root), 'utf8')).version;
59  assert.equal(cargo, pkg);
60  assert.equal(cargo, '0.2.15');
61});