From 940ac53b65a329db0d9f02bc287b306b4cb0a504 Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Thu, 19 Nov 2026 18:17:54 -0600 Subject: [PATCH] test(webui): settings-s4 review: the picker from Model setup, Appearance and Organizations lands on #/settings/routing?org= (F1); the can't start mark and the step 3 words and Ride all line agree (F2); no paused mark with only a fence to clear (N8); every control under Advanced shows a focus ring before setup, and the fixture service reads healthy (N9); F1, F2 and N8 fail with the display.js and bus.js of e717824c5 (#1873, lane settings-s4) --- .../webui/tests/settings-s4-browser.test.mjs | 66 ++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/packages/webui/tests/settings-s4-browser.test.mjs b/packages/webui/tests/settings-s4-browser.test.mjs index bef18796c..318f9c357 100644 --- a/packages/webui/tests/settings-s4-browser.test.mjs +++ b/packages/webui/tests/settings-s4-browser.test.mjs @@ -57,7 +57,7 @@ async function orgFixture() { // The instance owner's flags on /api/config and the model service status, by path suffix (display.js // scopes some reads under /api/orgs//). Everything else is the real server. const SERVICE_UP = { next: ['accounts'], init: { initialized: true, files: [] }, release: { fetched: true, verified: true, version: '8.0.42', panelVersion: '1.26.7' }, - unit: { unit: 'mosaic-proxy.service', installed: true, active: 'active', port: 18432, listening: true }, fence: { set: false }, initLock: { present: false, blockers: [] }, fetch: { state: 'idle' }, organizations: [], ride: [] }; + unit: { unit: 'mosaic-proxy.service', installed: true, active: 'active', port: 18432, listening: true, healthy: true }, fence: { set: false }, initLock: { present: false, blockers: [] }, fetch: { state: 'idle' }, organizations: [], ride: [] }; const ownerStub = (service = SERVICE_UP, extra = {}) => `(() => { const real = window.fetch.bind(window); window.__s4 = ${JSON.stringify({ service, accounts: [], routes: null, posts: {}, ...extra })}; window.__writes = []; const json = (body, status = 200) => new Response(JSON.stringify(body), { status, headers: { 'content-type': 'application/json' } }); @@ -156,6 +156,51 @@ test('settings-s4: the sidebar marks an organization paused while the model serv assert.equal(await b.evaluate(mark('gamma')), 'bus stopped'); }); +// settings-s4 review F1: the picker on a page that is not an organization's keeps the #/settings/ base. +test('settings-s4 review F1: picking an organization from Model setup opens its Routing page at #/settings/routing?org=', { timeout: 90000 }, async t => { + const { b, wait } = await orgSetup(t, { path: '/#/settings/model-setup' }); + await wait('document.querySelector("#org-pick") && document.querySelector("#proxy-setup")'); + await b.evaluate('(() => { const s = document.querySelector("#org-pick"); s.value = "north"; s.dispatchEvent(new Event("change", { bubbles: true })); return true; })()'); + await wait('location.hash === "#/settings/routing?org=north" && document.querySelector("#settings-nav a[href=\'#/settings/routing?org=north\'][aria-current=page]")'); + await wait('/North Works/.test(document.querySelector("#breadcrumbs")?.textContent ?? "")'); + assert.equal(await b.evaluate('location.hash.includes("#/orgs/")'), false); + for (const from of ['appearance', 'organizations']) { + await b.evaluate(`location.hash = "#/settings/${from}"; true`); + await wait(`document.querySelector("#settings-nav a[href='#/settings/${from}'][aria-current=page]") && document.querySelector("#org-pick")`); + await b.evaluate('(() => { const s = document.querySelector("#org-pick"); s.value = "acme"; s.dispatchEvent(new Event("change", { bubbles: true })); return true; })()'); + await wait('location.hash === "#/settings/routing?org=acme" && document.querySelector("#org-pick")?.value === "acme"'); + await b.evaluate('(() => { const s = document.querySelector("#org-pick"); s.value = "north"; s.dispatchEvent(new Event("change", { bubbles: true })); return true; })()'); + await wait('location.hash === "#/settings/routing?org=north"'); + } +}); + +// settings-s4 review F2: the organization the sidebar marks "can't start" is named on step 3 in the same words. +test('settings-s4 review F2: a stand-in organization with its bus stopped reads "can\'t start" in the sidebar and on Model setup step 3, with the fix', { timeout: 90000 }, async t => { + const service = { ...SERVICE_UP, organizations: [{ id: 'acme', proxy: 'shared', catalogue: { status: 'ready', models: 12 } }, { id: 'north', proxy: 'shared', catalogue: { status: 'ready', models: 12 } }], + ride: [{ id: 'acme', state: 'already' }, { id: 'north', state: 'already' }, { id: 'gamma', state: 'fixture', running: false }] }; + const accounts = [{ accountId: 'a1', provider: 'claude', displayName: 'Claude work', status: 'active', priority: 1 }]; + const { b, wait, text } = await orgSetup(t, { path: '/#/settings/model-setup', service, extra: { accounts } }); + await wait(`${mark('gamma')} === "can't start"`); + await wait(`/can't start/.test(document.querySelector(${JSON.stringify(STEP3)})?.textContent ?? "")`); + assert.equal(await text(STEP3), "The model service is set up. Gamma Home can't start: it uses stand-in models and its bus is stopped. Move it to your models under Use your models in every organization, then start its bus."); + assert.equal(await b.evaluate('document.querySelector("#setup-step-organizations").dataset.state'), 'bad'); + const item = await b.evaluate('document.querySelector("#proxy-ride-fixtures li").firstChild.textContent.trim()'); + assert.equal(item, "Gamma Home can't start: it uses stand-in models and its bus is stopped. Move it to the owner's models, then start its bus."); + assert.equal(await b.evaluate('document.querySelector("[data-ride-move=gamma]").textContent'), 'Move Gamma Home'); + assert.equal(await b.evaluate('document.querySelector("[data-ride-move=gamma]").checkVisibility()'), true); + // The organizations that need nothing get no mark. + assert.equal(await b.evaluate(mark('acme')), 'bus running'); +}); + +// settings-s4 review N8: a fence to clear while the service runs is not "paused". +test('settings-s4 review N8: no paused mark while the service runs and only a fence is left to clear', { timeout: 90000 }, async t => { + const service = { ...SERVICE_UP, next: ['fence-clear'], fence: { set: true }, ride: [{ id: 'acme', state: 'already' }] }; + const { b, wait } = await orgSetup(t, { path: '/#/dashboard', service }); + await wait(`${mark('acme')} === 'bus running' && ${mark('north')} === 'bus running'`); + await new Promise(r => setTimeout(r, 1500)); + assert.equal(await b.evaluate(mark('acme')), 'bus running'); +}); + // ---- Part B: Model setup --------------------------------------------------------------------- const T = '2026-11-11T12:00:00.000Z'; const fresh = { @@ -300,6 +345,25 @@ test('settings-s4: Models offered lists each provider\'s models read-only with a assert.deepEqual(await b.evaluate('window.__writes'), [], 'reading the models writes nothing'); }); +test('settings-s4 review N9: before setup, every control under Advanced takes focus with a visible ring', { timeout: 90000 }, async t => { + const fresh = { ...SERVICE_UP, release: { ...SERVICE_UP.release, fetched: false, verified: false }, init: { initialized: false, partial: false, files: [] }, + unit: { unit: 'mosaic-proxy.service', installed: false, active: 'inactive' }, organizations: [], next: ['fetch'] }; + const { b, wait } = await orgSetup(t, { path: '/#/settings/model-setup', service: fresh }); + await wait('document.querySelector("#proxy-setup-go")?.dataset.next === "fetch" && !document.querySelector("#proxy-setup-advanced").hidden'); + await b.evaluate('(() => { const d = document.querySelector("#proxy-setup-advanced"); d.open = true; d.querySelector("summary").focus(); return true; })()'); + await wait('document.querySelector("#proxy-setup-advanced").open && document.activeElement?.closest("#proxy-setup-advanced")'); + const visited = [], noRing = []; + for (let i = 0; i < 20; i++) { + await b.call('Input.dispatchKeyEvent', { type: 'keyDown', key: 'Tab', code: 'Tab', windowsVirtualKeyCode: 9 }); + await b.call('Input.dispatchKeyEvent', { type: 'keyUp', key: 'Tab', code: 'Tab', windowsVirtualKeyCode: 9 }); + const r = await b.evaluate(`(() => { const e = document.activeElement; if (!e || !e.closest("#proxy-setup-advanced")) return null; const cs = getComputedStyle(e); + return { key: e.id || e.name || e.tagName, ring: (cs.outlineStyle !== 'none' && parseFloat(cs.outlineWidth) > 0) || (cs.boxShadow && cs.boxShadow !== 'none') }; })()`); + if (!r) break; visited.push(r.key); if (!r.ring) noRing.push(r.key); + } + assert.ok(visited.includes('proxy-setup-port') && visited.includes('proxy-setup-first'), JSON.stringify(visited)); + assert.deepEqual(noRing, []); +}); + test('settings-s4 P3: the done line names an organization that turned the model service off and does not count it as waiting', { timeout: 90000 }, async t => { const list = [{ accountId: 'a1', provider: 'claude', displayName: 'Claude work', status: 'active', priority: 0 }]; const done = { ...running, organizations: [{ id: 'acme', proxy: 'shared', catalogue: { status: 'ready', models: 2 } }], ride: [{ id: 'acme', state: 'already' }, { id: 'north', state: 'removed' }] };