From ddb711270d4d5b6e2349cc90367dd64c30a4d61b Mon Sep 17 00:00:00 2001 From: morluto <76467478+morluto@users.noreply.github.com> Date: Wed, 18 Nov 2026 12:39:15 +0800 Subject: [PATCH] test(environment): consolidate generated task coverage (#11981) --- .../environmentStateMadeValuesAnswer.test.ts | 40 +++++++++++++++---- .../environmentStateMadeValues.test.ts | 34 +--------------- 2 files changed, 34 insertions(+), 40 deletions(-) diff --git a/src/application/environment/environmentStateMadeValuesAnswer.test.ts b/src/application/environment/environmentStateMadeValuesAnswer.test.ts index f2dd88ce6b..adb2c0f82e 100644 --- a/src/application/environment/environmentStateMadeValuesAnswer.test.ts +++ b/src/application/environment/environmentStateMadeValuesAnswer.test.ts @@ -17,6 +17,30 @@ const objectOf = (body: JsonValue | undefined) => { describe("served creates that count and make values", () => { it("numbers created tasks on from the recorded counter and makes each one's subscription", () => { const tasks = servedFrom(COUNTED_TASK_ROWS); + const plan = tasks.state.writes.get("post_projects_tasks_by_id"); + expect(plan).toMatchObject({ + served: true, + checked_record_ordinals: [4, 7], + }); + expect(plan?.rules.find(({ field }) => field === "index")).toEqual({ + field: "index", + rule: "sequence", + scope: "collection", + start: 15, + }); + expect(plan?.rules.find(({ field }) => field === "identifier")).toEqual({ + field: "identifier", + rule: "template", + from: "index", + }); + expect( + plan?.rules.find(({ field }) => field === "subscription"), + ).toMatchObject({ + rule: "made-object", + clocks: ["created"], + own: ["entity_id"], + counts: [{ member: "id", start: 21 }], + }); const first = objectOf( tasks.answer("post_projects_tasks_by_id", { id: "5", @@ -51,8 +75,14 @@ describe("served creates that count and make values", () => { expect(read["subscription"]).toMatchObject({ entity_id: 99 }); }); - it("answers a bulk create in the envelope it was sent in", () => { + it("answers bulk creates in their envelope and honors the requested project", () => { const tasks = servedFrom(BULK_TASK_ROWS); + expect( + tasks.state.writes.get("post_projects_tasks_bulk_by_id"), + ).toMatchObject({ + served: true, + body: { envelope: "tasks" }, + }); const body = objectOf( tasks.answer("post_projects_tasks_bulk_by_id", { id: "5", @@ -62,16 +92,12 @@ describe("served creates that count and make values", () => { expect(body["tasks"]).toMatchObject([ { title: "Restock the fog-horn spares", index: 15, identifier: "#15" }, ]); - }); - - it("creates into another project when the task stores its project and lands in one collection", () => { - const tasks = servedFrom(BULK_TASK_ROWS); - const body = objectOf( + const other = objectOf( tasks.answer("post_projects_tasks_bulk_by_id", { id: "7", body: { tasks: [{ title: "Paint the gallery rail" }] }, }).body, ); - expect(body["tasks"]).toMatchObject([{ project_id: 7 }]); + expect(other["tasks"]).toMatchObject([{ project_id: 7 }]); }); }); diff --git a/src/domain/analysisView/environmentStateMadeValues.test.ts b/src/domain/analysisView/environmentStateMadeValues.test.ts index 66375613c8..b73368829b 100644 --- a/src/domain/analysisView/environmentStateMadeValues.test.ts +++ b/src/domain/analysisView/environmentStateMadeValues.test.ts @@ -5,8 +5,6 @@ import { type TimedCaptureRow, } from "../../../tests/fixtures/analysisView.js"; import { - BULK_TASK_ROWS, - COUNTED_TASK_ROWS, MISLINKED_TASK_ROWS, ONE_TASK_ROWS, RESPELLED_TASK_ROWS, @@ -52,31 +50,6 @@ describe("values an application counts and makes with each created entity", () = expect(plan).toMatchObject({ served: false }); expect(ruleFor(plan, "index")).toBeUndefined(); }); - it("learns a counter from where the first create stood, a template around it and the object made with each task", () => { - const plan = createOf(COUNTED_TASK_ROWS); - expect(plan).toMatchObject({ - served: true, - checked_record_ordinals: [4, 7], - }); - expect(ruleFor(plan, "index")).toEqual({ - field: "index", - rule: "sequence", - scope: "collection", - start: 15, - }); - expect(ruleFor(plan, "identifier")).toEqual({ - field: "identifier", - rule: "template", - from: "index", - }); - expect(ruleFor(plan, "subscription")).toMatchObject({ - rule: "made-object", - clocks: ["created"], - own: ["entity_id"], - counts: [{ member: "id", start: 21 }], - }); - }); - it("keeps a value one create alone shows past what the type held", () => { const plan = createOf(ONE_TASK_ROWS); expect(ruleFor(plan, "index")).toBeUndefined(); @@ -86,12 +59,7 @@ describe("values an application counts and makes with each created entity", () = }); }); - it("links a create whose answer wraps the entity in a one-element array member", () => { - expect(createOf(BULK_TASK_ROWS)).toMatchObject({ - tool: "post_projects_tasks_bulk_by_id", - served: true, - body: { envelope: "tasks" }, - }); + it("takes an identity from a sole wrapped entity and refuses an ambiguous array", () => { expect(respondedIds({ tasks: [{ id: 14 }] })).toEqual(["14"]); expect(respondedIds({ tasks: [{ id: 14 }, { id: 15 }] })).toEqual([]); });