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)

This commit was merged in pull request #2018.
This commit is contained in:
jason.woltje committed 2026-11-20 10:26:35 -06:00
1 parent ca7f46e5d4
commit 4aa008e9fe
3 files changed
+15 -2

No files matched your search

@@ -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";
@@ -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");
});
@@ -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`);
});