From e8b3e4ca79c6735841aef743f248822d7321bd2b Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Wed, 30 Sep 2026 23:43:10 +0200 Subject: [PATCH] cultcache-ts: test that an envelope without a catalog entry replaces and deletes StrykerJS on 142a2e13 left two OptionalChaining survivors in isSameRecord: nothing wrote through the store with an envelope that has no catalog entry, which is what an external CacheBackingStore caller sends. This test pushes, rewrites and deletes such an envelope. Co-Authored-By: Claude Opus 5.5 --- packages/cultcache-ts/test/cult-cache.test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/cultcache-ts/test/cult-cache.test.ts b/packages/cultcache-ts/test/cult-cache.test.ts index 94ecdbfb..9591be8d 100644 --- a/packages/cultcache-ts/test/cult-cache.test.ts +++ b/packages/cultcache-ts/test/cult-cache.test.ts @@ -1754,3 +1754,14 @@ test("a store keeps a record of another schema at the same key, and the same sch await store.delete(identityEnvelope("j", "label-c", "id-c", "name-c")); assert.deepEqual(await recordsOnDisk(file), [["j", "id-a"], ["k", "id-b"], ["k", "id-a"]]); }); + +test("a store replaces and deletes a record written by an envelope that carries no catalog entry", async () => { + const file = join(await mkdtemp(join(tmpdir(), "cultcache-identity-")), "store.cc"); + const store = new SingleFileMessagePackBackingStore(file); + const raw = (payload: number): CultCacheEnvelope => ({ key: "k", type: "t", payload: Uint8Array.of(payload), storedAt: "2026-09-30T00:00:00Z" }); + await store.push(raw(0x01)); + await store.push(raw(0x02)); + assert.deepEqual((await store.pullAll()).map((record) => [record.key, [...record.payload]]), [["k", [0x02]]]); + await store.delete(raw(0x02)); + assert.deepEqual(await recordsOnDisk(file), []); +});