The Console builds the board context itself (control-board createBoard) and answers the board routes in-process. The standalone control-board HTTP writer and page.html are removed; control-board serve exits 2 as retired, and webui --board is refused. /api/seen and /api/reply need --send and a named human, else 403 read-only. Tests are rewritten against the in-process board (inProcessBoard in the webui fixture; createBoard in control-board). Proxy, unreachable-board and HTTP-only tests are dropped; the dropped set is listed in BUILD.md. UNVERIFIED: committed under Sage's slot hold (Gander run 5). No suite or mutant has run on this commit; do not push before the gate is green.
27 lines
2.0 KiB
JavaScript
27 lines
2.0 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { browser } from './browser.mjs';
|
|
import { startServer } from '../src/serve.mjs';
|
|
import { close } from './fixture.mjs';
|
|
test('REQ-LIMIT-4 Settings shows all token kinds and unknown turns beside every total, as a read-only separate section', { timeout: 60000 }, async () => {
|
|
const count = { input: 2, output: 3, cacheWrite: 4, cacheRead: 5, unknownTurns: 7 };
|
|
const hostile = '<img src=x onerror="window.injected=true">';
|
|
const usage = { total: count, byRun: [{ run: 'run1', ...count }], byInstance: [{ instance: hostile, ...count }],
|
|
byModel: [{ provider: 'provider', model: 'model', ...count }], byProvider: [{ provider: 'provider', ...count }], byAccount: [{ account: null, ...count }] };
|
|
const server = await startServer({ port: 0, board: null,
|
|
bus: { messages: async () => ({ messages: [], unread: 0 }), usage: async () => usage },
|
|
reads: { settings: async () => ({ business: 'demo', notifier: {}, launch: { refused: 'not-configured' } }) },
|
|
});
|
|
const b = await browser();
|
|
try {
|
|
await b.navigate(`http://127.0.0.1:${server.address().port}/#/settings`);
|
|
await b.evaluate(`(async()=>{for(let n=0;n<200;n++){if(document.querySelector('#token-usage-table'))return;await new Promise(r=>setTimeout(r,30));}throw Error('usage table missing');})()`);
|
|
const rows = await b.evaluate("[...document.querySelectorAll('#token-usage-table tbody tr')].map(row=>[...row.querySelectorAll('td')].map(c=>c.textContent))");
|
|
assert.equal(rows.length, 6);
|
|
for (const row of rows) assert.deepEqual(row, ['2', '3', '4', '5', '7']);
|
|
assert.equal(await b.evaluate("document.querySelectorAll('#token-usage-table input, #token-usage-table button, #token-usage-table img').length"), 0);
|
|
assert.equal(await b.evaluate('window.injected===true'), false);
|
|
assert.ok((await b.evaluate("document.querySelector('#token-usage-title').parentElement.textContent")).includes('not proof'));
|
|
} finally { await b.close(); await close(server); }
|
|
});
|