From 6efd976ec058acdc0cc94a9fa1f3cc129ccef958 Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:15:23 +0800 Subject: [PATCH] test(environment): consolidate later-read and trash replay coverage (#11971) --- .../environmentStateLaterReadsAnswer.test.ts | 17 +++-------------- .../environmentStateLaterReads.test.ts | 8 -------- tests/boundary/mcp/environmentServeMcp.test.ts | 7 ++++++- 3 files changed, 9 insertions(+), 23 deletions(-) diff --git a/src/application/environment/environmentStateLaterReadsAnswer.test.ts b/src/application/environment/environmentStateLaterReadsAnswer.test.ts index cfb0f19f68..62cca58615 100644 --- a/src/application/environment/environmentStateLaterReadsAnswer.test.ts +++ b/src/application/environment/environmentStateLaterReadsAnswer.test.ts @@ -1,7 +1,6 @@ import { describe, expect, it } from "vitest"; import { - INITIAL_TRASH_ROWS, LATER_BULK_ROWS, LATER_FIELD_ROWS, OMITTED_FLAG_ROWS, @@ -24,12 +23,6 @@ const names = (body: JsonValue | undefined): JsonValue[] => { }; describe("served writes modelled on later reads", () => { - it("replays the recorded list when it includes a deleted row", () => { - const contacts = servedFrom(INITIAL_TRASH_ROWS); - expect( - contacts.answer("get_contacts", { maxSize: "20", offset: "0" }).body, - ).toEqual(INITIAL_TRASH_ROWS[0]![2]); - }); it("keeps an initially deleted item readable without treating it as live", () => { const deleted = { id: 4, name: "Gone", deleted: true }; const rows = [ @@ -80,18 +73,13 @@ describe("served writes modelled on later reads", () => { deleted, ); }); - it("removes a soft-deleted contact from the served state", () => { + it("removes a soft-deleted contact from lists and still answers its item read", () => { const contacts = servedFrom(SOFT_DELETED_ROWS); contacts.answer("delete_contacts_by_id", { id: "1" }); expect(names(contacts.answer("get_contacts").body)).toEqual([ "Mina Okafor", "Rui Castellanos", ]); - }); - - it("reads a served-deleted contact back marked deleted, as the application answers", () => { - const contacts = servedFrom(SOFT_DELETED_ROWS); - contacts.answer("delete_contacts_by_id", { id: "1" }); expect(contacts.answer("get_contacts_by_id", { id: "1" }).body).toEqual({ id: 1, name: "Ada Finch", @@ -107,7 +95,8 @@ describe("served writes modelled on later reads", () => { // A removal that keeps nothing, as a delete of a type that hard-deletes is, leaves no read. contacts.store.removeAll(contacts.store.startedWith("/api/contacts")); expect(contacts.refusal("get_contacts_by_id", { id: "1" })).toMatchObject({ - code: expect.any(String), + code: "invalid_request", + message: expect.stringContaining("holds no /api/contacts entity 1"), }); }); diff --git a/src/domain/analysisView/environmentStateLaterReads.test.ts b/src/domain/analysisView/environmentStateLaterReads.test.ts index c7a4ff3d74..1771e4abe8 100644 --- a/src/domain/analysisView/environmentStateLaterReads.test.ts +++ b/src/domain/analysisView/environmentStateLaterReads.test.ts @@ -6,7 +6,6 @@ import { } from "../../../tests/fixtures/analysisView.js"; import { GHOST_DELETED_ROWS, - INITIAL_TRASH_ROWS, LATER_FIELD_ROWS, LATER_MIXED_BULK_ROWS, MAX_SIZE_ROWS, @@ -26,13 +25,6 @@ const planOf = (rows: readonly TimedCaptureRow[], tool: string) => { }; describe("deletes the application answers for afterwards", () => { - it("replays an initial list that includes a deleted entity", () => { - expect( - viewOf(INITIAL_TRASH_ROWS).views.find( - (view) => view.tool === "get_contacts", - ), - ).toMatchObject({ shape: "recorded", reason: "list-differs" }); - }); it("confirms a delete by an item read that shows the entity marked deleted", () => { expect(planOf(SOFT_DELETED_ROWS, "delete_contacts_by_id")).toMatchObject({ served: true, diff --git a/tests/boundary/mcp/environmentServeMcp.test.ts b/tests/boundary/mcp/environmentServeMcp.test.ts index 6db3b835cd..5859428b6b 100644 --- a/tests/boundary/mcp/environmentServeMcp.test.ts +++ b/tests/boundary/mcp/environmentServeMcp.test.ts @@ -141,8 +141,13 @@ processTest( arguments: { maxSize: "20", offset: "0" }, }); expect(response.isError).toBeFalsy(); + expect(response.structuredContent).toHaveProperty( + "body", + INITIAL_TRASH_ROWS[0]![2], + ); expect(response.structuredContent).toMatchObject({ - body: INITIAL_TRASH_ROWS[0]![2], + replay: { record_ordinal: 0 }, + state: { source: "recording", reason: "list-differs" }, }); } finally { await client.close();