test(webui): the Triage drawer's no-Triage-request checks skip the static triage-settings.js script every page loads; it carries no data, and the Settings panel's own test shows a non-owner reads no route (#1873, lane triage-settings)

This commit was merged in pull request #1994.
This commit is contained in:
jason.woltje committed 2026-11-18 15:06:03 -06:00
1 parent dab07f0ff5
commit 0ba50111f6
1 file changed
+6 -3
@@ -98,6 +98,9 @@ async function setup(t, { host = fakeHost(), triage = host.triage, send = true,
// The page focuses its heading when its first render ends (bus.js). Open after that, as a person would, or // The page focuses its heading when its first render ends (bus.js). Open after that, as a person would, or
// that late focus can land after the drawer's own. // that late focus can land after the drawer's own.
// The Settings > Triage panel script (triage-settings, #1873) is a static file every page loads, like
// every other page module; it carries no data. These checks are about Triage traffic, so they skip it.
const SETTINGS_SCRIPT = 'GET /triage-settings.js';
const open = async f => { await f.wait('document.querySelector("#triage-open")'); await f.wait('document.activeElement?.tagName === "H1"', 100).catch(() => {}); await f.click('#triage-open'); await f.wait('["off", "cap", "running", "stopped"].includes(document.querySelector("#triage-drawer #triage-state")?.dataset.kind)'); }; const open = async f => { await f.wait('document.querySelector("#triage-open")'); await f.wait('document.activeElement?.tagName === "H1"', 100).catch(() => {}); await f.click('#triage-open'); await f.wait('["off", "cap", "running", "stopped"].includes(document.querySelector("#triage-drawer #triage-state")?.dataset.kind)'); };
const type = async (f, words) => { await f.b.evaluate('document.querySelector("#triage-text").focus()'); await f.b.call('Input.insertText', { text: words }); }; const type = async (f, words) => { await f.b.evaluate('document.querySelector("#triage-text").focus()'); await f.b.call('Input.insertText', { text: words }); };
const sendAndWait = async (f, before) => { await f.click('#triage-send'); await f.wait(`document.querySelector("#triage-send-status").textContent.trim() && document.querySelector("#triage-send-status").textContent !== ${JSON.stringify(before)} && !document.querySelector("#triage-send").disabled`); return f.text('#triage-send-status'); }; const sendAndWait = async (f, before) => { await f.click('#triage-send'); await f.wait(`document.querySelector("#triage-send-status").textContent.trim() && document.querySelector("#triage-send-status").textContent !== ${JSON.stringify(before)} && !document.querySelector("#triage-send").disabled`); return f.text('#triage-send-status'); };
@@ -109,7 +112,7 @@ test('item 1: a session that is not the instance owner gets no entry, no drawer
await f.wait('document.querySelector("#dashboard-kpis")'); await f.wait('document.querySelector("#dashboard-kpis")');
await sleep(1500); await sleep(1500);
assert.equal(await f.b.evaluate('document.querySelector("#triage-open, #triage-drawer, [id^=triage]")'), null); assert.equal(await f.b.evaluate('document.querySelector("#triage-open, #triage-drawer, [id^=triage]")'), null);
assert.deepEqual(f.requests.filter(r => /triage/i.test(r)), []); assert.deepEqual(f.requests.filter(r => /triage/i.test(r) && r !== SETTINGS_SCRIPT), []);
} }
// A Triage host, but a signed-in session that is not the root owner. // A Triage host, but a signed-in session that is not the root owner.
{ {
@@ -119,7 +122,7 @@ test('item 1: a session that is not the instance owner gets no entry, no drawer
await sleep(1500); await sleep(1500);
assert.equal(await f.b.evaluate('document.querySelector("[id^=triage]")'), null); assert.equal(await f.b.evaluate('document.querySelector("[id^=triage]")'), null);
assert.equal(await f.b.evaluate('document.body.innerHTML.includes("Triage")'), false, 'no Triage words in the page'); assert.equal(await f.b.evaluate('document.body.innerHTML.includes("Triage")'), false, 'no Triage words in the page');
assert.deepEqual(f.requests.filter(r => /triage/i.test(r)), []); assert.deepEqual(f.requests.filter(r => /triage/i.test(r) && r !== SETTINGS_SCRIPT), []);
} }
}); });
@@ -135,7 +138,7 @@ test('item 1: the owner gets one Triage entry in the top bar on the dashboard an
assert.equal(await f.b.evaluate('document.querySelector("#triage-open").getAttribute("aria-expanded")'), 'true'); assert.equal(await f.b.evaluate('document.querySelector("#triage-open").getAttribute("aria-expanded")'), 'true');
// From inside an organization the read is still the system route, never the organization's. // From inside an organization the read is still the system route, never the organization's.
assert.ok(f.triageReads() >= 1); assert.ok(f.triageReads() >= 1);
assert.deepEqual(f.requests.filter(r => /triage/.test(r) && r !== 'GET /api/triage'), []); assert.deepEqual(f.requests.filter(r => /triage/.test(r) && r !== 'GET /api/triage' && r !== SETTINGS_SCRIPT), []);
assert.ok(f.requests.includes('GET /api/config'), 'the unscoped config read'); assert.ok(f.requests.includes('GET /api/config'), 'the unscoped config read');
// The same entry on the system dashboard. // The same entry on the system dashboard.
await f.b.evaluate('location.hash = "#/dashboard"'); await f.b.evaluate('location.hash = "#/dashboard"');