okami.mom/strata

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

Niko1221Merge f-0243-guifix into f-0243-rel9caf39495

main
1.1 KiB21 linesraw
1import test from 'node:test';
2import assert from 'node:assert/strict';
3import { build } from 'esbuild';
4
5const compiled = await build({ stdin: { contents: "export * from './src/lib/native';", resolveDir: process.cwd() }, bundle: true, write: false, platform: 'node', format: 'esm' });
6const lib = await import(`data:text/javascript;base64,${Buffer.from(compiled.outputFiles[0].text).toString('base64')}`);
7
8test('the Models page waits for the first native answer before it picks a model (#3740)', async () => {
9  let release;
10  globalThis.fetch = () => new Promise(resolve => { release = () => resolve({ ok: true, status: 200, statusText: 'OK', text: async () => JSON.stringify({ available: true, jobs: [], instances: [] }) }); });
11  let heard = 0;
12  const off = lib.subscribeNative(() => { heard++; });
13  assert.equal(lib.nativeSettled(), false, 'nothing read yet: show a placeholder, not the Starter');
14  const reading = lib.refreshNative();
15  assert.equal(lib.nativeSettled(), false);
16  release();
17  await reading;
18  assert.equal(lib.nativeSettled(), true);
19  assert.ok(heard >= 1, 'the page is told');
20  off();
21});