Files
stack/packages/webui/tests/tester-browser.test.mjs
T
jason.woltje 7247d80c7a row 196: human boundary on peer credentials, interpreter receipt and the Console tester socket (#1694)
Candidate 527b9a1e6 (gander/row196-r6-prd19, base f48725cfc), the 39 manifest paths of CANDIDATE.sha256 537d30aef70b6cd1 at ec1e7fad8. Duckworth approved round 1 outside B1/B2 (rev 2973, comment 30145) and round 2 merge-scoped (rev 2986, comment 30156). Gate gander-0066 on grant sage-2145: 2334 pass, 0 fail, 1 skip; mutants 38/38 killed. BUILD-LOG lines and Duckworth's C1 DEFERRED entry follow as a doc-only append.
2026-10-21 15:55:39 -05:00

47 lines
3.8 KiB
JavaScript

import test from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { testerBrowser } from './tester-browser-fixture.mjs';
import { testerFixture, testerChat } from './tester-fixture.mjs';
test('tester Console banner exposes only instance route and name editors and saves a route as tester', { timeout: 60000 }, async t => {
const s = await testerFixture(t), b = await testerBrowser(s.web);
try {
const wait = expr => b.evaluate(`(async()=>{for(let n=0;n<150;n++){if(${expr})return true;await new Promise(r=>setTimeout(r,30));}throw Error('wait failed: '+${JSON.stringify(expr)});})()`);
await b.navigate(`http://mosaic-tester.invalid/#/settings`);
await wait('!!document.querySelector("#tester-banner") && document.querySelector("#routes-form button[type=submit]")?.disabled === false');
assert.match(await b.evaluate('document.querySelector("#tester-banner")?.textContent ?? ""'), /tester/i);
assert.equal(await b.evaluate('document.querySelector("#routes-form button[type=submit]").disabled'), false);
assert.ok(await b.evaluate('!!document.querySelector("#instances-table")'));
assert.ok(await b.evaluate('!!document.querySelector(".tester-name-form")'));
assert.equal(await b.evaluate('!!document.querySelector("#launch-settings-form, .assistant-form, #token-limits-table [data-limit-reset], #send-section")'), false);
const selector = JSON.stringify('[data-route=\'["coder","thinking"]\']');
await b.evaluate(`(()=>{const e=document.querySelector(${selector});e.value='low';e.dispatchEvent(new Event('change',{bubbles:true}));document.querySelector('#routes-form').requestSubmit();return true;})()`);
await wait('document.querySelector("#routes-receipt")?.textContent.startsWith("Routes saved")');
assert.equal(JSON.parse(readFileSync(s.file, 'utf8')).roles.coder.vars.thinking, 'low');
assert.equal(s.history().at(-1).actor, 'tester');
assert.ok(s.lines.some(l => l.includes('routes user="tester"')));
} finally { await b.close(); }
});
test('row 177: the tester Console chat composer is enabled and a send shows in its own thread', { timeout: 60000 }, async t => {
const s = await testerChat(t), b = await testerBrowser(s.web);
try {
const wait = expr => b.evaluate(`(async()=>{for(let n=0;n<150;n++){if(${expr})return true;await new Promise(r=>setTimeout(r,30));}throw Error('wait failed: '+${JSON.stringify(expr)});})()`);
const tester = s.broker.bindTester({ business: 'demo' });
const project = s.broker.request(tester, { verb: 'project.create', args: { name: 'probe work' } }).id;
const thread = s.broker.request(tester, { verb: 'thread.create', args: { project, name: 'probe' } }).id;
await b.navigate(`http://mosaic-tester.invalid/#/chat/threads/${thread}`);
await wait('!!document.querySelector("#tester-banner") && document.querySelector("#chat-body")?.disabled === false');
await b.evaluate(`(()=>{const e=document.querySelector('#chat-body');e.value='from the tester console';e.dispatchEvent(new Event('input',{bubbles:true}));document.querySelector('#chat-send-form').requestSubmit();return true;})()`);
await wait('document.querySelector("#chat-receipt")?.textContent.includes("Accepted")');
// The log shows a send at the next read, as on the human Console; Refresh reads now.
await wait('!document.querySelector("#refresh").disabled');
await b.evaluate('document.querySelector("#refresh").click(),true');
await wait('document.querySelector(".chat-log")?.textContent.includes("from the tester console")');
const m = s.store.get("SELECT * FROM messages WHERE body='from the tester console'");
assert.equal(m.from_role, 'tester'); assert.equal(m.from_run, 'tester-cli');
assert.ok(s.lines.some(l => l.includes('action=send user="tester"')));
} finally { await b.close(); }
});