From f64b4d67b495e1c2ebc004b7c63d5359430cfc9e Mon Sep 17 00:00:00 2001 From: simoleo89 Date: Wed, 2 Sep 2026 19:24:03 +0200 Subject: [PATCH] fix(housekeeping): isolate poll question mutations --- .../services/mutations-production.test.ts | 38 ++++++++++++------- .../content/services/mutations-production.ts | 2 +- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/features/housekeeping/domains/content/services/mutations-production.test.ts b/src/features/housekeeping/domains/content/services/mutations-production.test.ts index 4d52dffe..025fdc21 100644 --- a/src/features/housekeeping/domains/content/services/mutations-production.test.ts +++ b/src/features/housekeeping/domains/content/services/mutations-production.test.ts @@ -101,24 +101,34 @@ describe("Content production mutation adapter", () => { ); }); - it("uses read committed isolation only for poll mutations", async () => { - const pollDeps = dependencies(); - await pollDeps.adapter.execute( - "poll.change", - { action: "delete", id: 7 }, - mutationContext, - ); - expect(pollDeps.transaction).toHaveBeenCalledWith(expect.any(Function), { - isolationLevel: "read committed", - }); + it.each(["poll.change", "poll-question.change"] as const)( + "uses read committed isolation for %s", + async (operation) => { + const deps = dependencies(); + await deps.adapter.execute( + operation, + { action: "update", id: 7 }, + mutationContext, + ); + expect(deps.transaction).toHaveBeenCalledWith(expect.any(Function), { + isolationLevel: "read committed", + }); + }, + ); - const articleDeps = dependencies(); - await articleDeps.adapter.execute( - "article.change", + it.each( + CONTENT_DATABASE_OPERATIONS.filter( + (operation) => + operation !== "poll.change" && operation !== "poll-question.change", + ), + )("keeps configured server isolation for unrelated %s", async (operation) => { + const deps = dependencies(); + await deps.adapter.execute( + operation, { action: "update", id: 7 }, mutationContext, ); - expect(articleDeps.transaction).toHaveBeenCalledWith( + expect(deps.transaction).toHaveBeenCalledWith( expect.any(Function), undefined, ); diff --git a/src/features/housekeeping/domains/content/services/mutations-production.ts b/src/features/housekeeping/domains/content/services/mutations-production.ts index f5eef3ae..3497e45c 100644 --- a/src/features/housekeeping/domains/content/services/mutations-production.ts +++ b/src/features/housekeeping/domains/content/services/mutations-production.ts @@ -132,7 +132,7 @@ export function createContentProductionMutationAdapter( async execute(operation, input, context) { if (includesOperation(CONTENT_DATABASE_OPERATIONS, operation)) { const transactionOptions = - operation === "poll.change" + operation === "poll.change" || operation === "poll-question.change" ? ({ isolationLevel: "read committed" } as const) : undefined; return dependencies.transaction(async (transaction) => {