From 8079a1fc209c2016d0cceeedd345ae2a5b38de65 Mon Sep 17 00:00:00 2001 From: Raphael Amorim Date: Sat, 10 Oct 2026 11:23:15 +0200 Subject: [PATCH] update invalidate tests to the matched-count reply, fix formatting --- e2e/start-rebundle-gate.mjs | 4 +++- e2e/unit/cf-environment-api.test.mjs | 18 ++++++++++++++---- e2e/unit/invalidate-canonical.test.mjs | 6 +++++- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/e2e/start-rebundle-gate.mjs b/e2e/start-rebundle-gate.mjs index b5643cd9..0d8d2134 100644 --- a/e2e/start-rebundle-gate.mjs +++ b/e2e/start-rebundle-gate.mjs @@ -68,7 +68,9 @@ try { await sleep(1500); const bundledAfter = log.split("client bundled").length; if (bundledAfter !== bundledBefore) { - throw new Error(`README edit rebundled the client (${bundledAfter - bundledBefore} run(s)); log tail:\n${log.slice(-3000)}`); + throw new Error( + `README edit rebundled the client (${bundledAfter - bundledBefore} run(s)); log tail:\n${log.slice(-3000)}`, + ); } console.log("gate: README edit skipped the rebundle and the reload"); diff --git a/e2e/unit/cf-environment-api.test.mjs b/e2e/unit/cf-environment-api.test.mjs index 5479133c..5e97fb97 100644 --- a/e2e/unit/cf-environment-api.test.mjs +++ b/e2e/unit/cf-environment-api.test.mjs @@ -232,7 +232,10 @@ test("a source edit sends a targeted update to the accept boundary; dead ends st headers: { "content-type": "application/json" }, body: JSON.stringify({ paths: [path.join(fx.root, rel)] }), }); - assert.equal(res.status, 204); + // Change invalidations answer 200 with a matched count (resyncs keep 204). + assert.equal(res.status, 200); + const { matched } = await res.json(); + assert.ok(matched === null || typeof matched === "number", `matched count in the reply, got ${matched}`); }; const probe = async () => (await fetch(`http://127.0.0.1:${port}/__probe`)).json(); @@ -495,7 +498,10 @@ test("create retries failed resolutions, delete prunes, legacy hooks and hook er headers: { "content-type": "application/json" }, body: JSON.stringify({ changes: [{ path: path.join(fx.root, rel), type }] }), }); - assert.equal(res.status, 204); + // Change invalidations answer 200 with a matched count (resyncs keep 204). + assert.equal(res.status, 200); + const { matched } = await res.json(); + assert.ok(matched === null || typeof matched === "number", `matched count in the reply, got ${matched}`); }; const probe = async () => (await fetch(`http://127.0.0.1:${port}/__probe`)).json(); @@ -633,7 +639,11 @@ test("invalidate dedup: content identity, atomic-save create, read errors", asyn headers: { "content-type": "application/json" }, body: JSON.stringify({ changes: [{ path: p, type }] }), }); - assert.equal(res.status, 204); + // Change invalidations answer 200 with a matched count (resyncs keep + // 204); a deduped repeat send may legitimately report 0. + assert.equal(res.status, 200); + const { matched } = await res.json(); + assert.ok(matched === null || typeof matched === "number", `matched count in the reply, got ${matched}`); }; const probe = async () => (await fetch(`http://127.0.0.1:${port}/__probe`)).json(); @@ -962,7 +972,7 @@ test("resync acks on enqueue and duplicates coalesce behind a slow invalidate qu assert.equal(r2.status, 204); assert.ok(Date.now() - t0 < 500, `resync ACKs on enqueue, took ${Date.now() - t0}ms behind a 700ms queue`); - assert.equal((await slow).status, 204, "the change invalidation still answers on completion"); + assert.equal((await slow).status, 200, "the change invalidation still answers on completion"); await new Promise((r) => setTimeout(r, 300)); const seen = await (await fetch(`http://127.0.0.1:${port}/__probe`)).json(); const reloads = seen.workerSends.filter((p) => p.type === "full-reload"); diff --git a/e2e/unit/invalidate-canonical.test.mjs b/e2e/unit/invalidate-canonical.test.mjs index d25f1720..25b5fb4d 100644 --- a/e2e/unit/invalidate-canonical.test.mjs +++ b/e2e/unit/invalidate-canonical.test.mjs @@ -116,7 +116,11 @@ test("a change spelled through a symlink invalidates the canonically keyed modul headers: { "content-type": "application/json" }, body: JSON.stringify({ paths: [watched] }), }); - assert.equal(res.status, 204); + // A change invalidation answers 200 with how many changes matched a + // runner-backed graph; the symlink spelling resolves to the one + // canonically keyed module. + assert.equal(res.status, 200); + assert.deepEqual(await res.json(), { matched: 1 }); const seen = await (await fetch(`http://127.0.0.1:${port}/__probe`)).json(); assert.ok(