From 4aa008e9fefb0eebfd1c03e65a3923e1bbdc6d78 Mon Sep 17 00:00:00 2001 From: Jason Woltje Date: Fri, 20 Nov 2026 08:59:14 -0600 Subject: [PATCH] test(cli,plugins,webui): harness-watch-w3 re-check: the plugin-root leak test skips when TMPDIR's parent is not writable instead of placing the root under TMPDIR, where it passed with the root left out of the backstop (N1); red and missing lines must be the page's danger colour, not only unlike muted (N2); a usable record after the first 256 is not checked yet (N3) (#1873, lane harness-watch-w3) --- packages/cli/tests/harness-watch-host.test.mjs | 7 +++++-- packages/plugins/tests/harness-watch-view.test.mjs | 8 ++++++++ .../webui/tests/routes-harness-watch-browser.test.mjs | 2 ++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/packages/cli/tests/harness-watch-host.test.mjs b/packages/cli/tests/harness-watch-host.test.mjs index e895a47b2..e00ea57db 100644 --- a/packages/cli/tests/harness-watch-host.test.mjs +++ b/packages/cli/tests/harness-watch-host.test.mjs @@ -468,9 +468,12 @@ test("W3 host watch: the default stat key reads the plugin root's plugins, and a const dataRoot = scratch(t); // The plugin root sits beside TMPDIR, not in it: TMPDIR is an env value the backstop already // knows, so a root under it would be caught without the plugin root as a needle of its own. + // When TMPDIR's parent can't take it, the test skips: a root under TMPDIR would pass with the + // plugin root left out of the backstop. let pluginRoot; - try { pluginRoot = mkdtempSync(join(dirname(tmpdir()), "mosaic-hw-plugins-")); t.after(() => rmSync(pluginRoot, { recursive: true, force: true })); } - catch { pluginRoot = scratch(t); } + try { pluginRoot = mkdtempSync(join(dirname(tmpdir()), "mosaic-hw-plugins-")); } + catch { t.skip("the plugin root must sit beside TMPDIR, and TMPDIR's parent is not writable"); return; } + t.after(() => rmSync(pluginRoot, { recursive: true, force: true })); const clock = fakeClock(); const logs = []; let line = "ok"; diff --git a/packages/plugins/tests/harness-watch-view.test.mjs b/packages/plugins/tests/harness-watch-view.test.mjs index a7000282f..28a5d047d 100644 --- a/packages/plugins/tests/harness-watch-view.test.mjs +++ b/packages/plugins/tests/harness-watch-view.test.mjs @@ -119,3 +119,11 @@ test("W3 readWatchView: a name that is an env value is dropped unless the loader assert.deepEqual([view[0].checkedAt, view[0].changedAt], [null, "2026-11-20T10:00:00Z"], "2026-02-30 is not a time; a real one is kept"); assert.equal(readWatchView({ dataRoot: dir, names: ["w3-secret-name"], env })[0].state, "fit", "a name the loader gives is kept"); }); + +test("W3 readWatchView reads at most the first 256 records: a usable record after them is not checked yet", (t) => { + const dir = root(t); + put(dir, { version: 1, harnesses: [...Array(255).fill(null), rec("pi")] }); + assert.equal(readWatchView({ dataRoot: dir, names: ["pi"] })[0].state, "fit", "the 256th record is read"); + put(dir, { version: 1, harnesses: [...Array(256).fill(null), rec("pi")] }); + assert.deepEqual(readWatchView({ dataRoot: dir, names: ["pi"] }), [unchecked("pi")], "the 257th is not"); +}); diff --git a/packages/webui/tests/routes-harness-watch-browser.test.mjs b/packages/webui/tests/routes-harness-watch-browser.test.mjs index 4ecddd3c6..eb0fff9c8 100644 --- a/packages/webui/tests/routes-harness-watch-browser.test.mjs +++ b/packages/webui/tests/routes-harness-watch-browser.test.mjs @@ -40,6 +40,7 @@ async function routing(view, shot, act = null) { label:f.querySelector("ul.harness-watch")?.getAttribute("aria-label")??null, text:f.textContent, muted:(()=>{const p=document.createElement("p");p.className="small muted";f.append(p);const c=getComputedStyle(p).color;p.remove();return c;})(), + danger:(()=>{const p=document.createElement("p");p.style.color="var(--danger)";f.append(p);const c=getComputedStyle(p).color;p.remove();return c;})(), };})()`); if (shot) { await b.evaluate('document.querySelector("fieldset.harness-control").scrollIntoView({block:"center"});true'); @@ -66,6 +67,7 @@ test('W3 Routing shows one line per harness for each watch state, red and missin for (const l of [red, missing]) assert.ok(l.danger && !l.muted, `${l.state} reads as a problem`); for (const l of [fit, changed, unknown, unchecked, odd]) assert.ok(!l.danger && l.muted, `${l.state} is not a problem line`); assert.notEqual(red.color, page.muted, 'a problem line is not drawn in the muted colour'); + for (const l of [red, missing]) assert.equal(l.color, page.danger, `${l.state} is drawn in the danger colour, as r3 gives can't start`); for (const l of [unknown, unchecked, odd]) assert.doesNotMatch(l.text, /ยท fit\b/, `${l.state} never reads as fit`); });