diff --git a/tests/unit/http-execution-v3.test.ts b/tests/unit/http-execution-v3.test.ts index 06757200..e9b1ec8b 100644 --- a/tests/unit/http-execution-v3.test.ts +++ b/tests/unit/http-execution-v3.test.ts @@ -761,15 +761,29 @@ describe("descriptor-driven HTTP execution lifetime", () => { await expect(result).resolves.toMatchObject({ kind: "CANCELLED" }); }); - // 1103/10-04 ②. A signal is shared by many requests (a screen, a session - // scope). Every abort listener an execution adds to the caller's and the + // 1103/10-04 ②, 1105/10-02. A signal is shared by many requests (a screen, + // a session scope, one interaction that sends several requests). Every abort + // listener an execution adds to the caller's, the interaction's and the // scope's signal is removed when it ends, however it ends. - it.each(["an answer", "a caller abort"] as const)( - "removes the listeners it added to the caller and scope signals after %s", + it.each(["an answer", "a caller abort", "an interaction cancel"] as const)( + "removes the listeners it added to the caller, interaction and scope signals after %s", async (ending) => { const caller = new AbortController(); const scopeLifetime = new AbortController(); - const watched = [caller.signal, scopeLifetime.signal].map((signal) => ({ + const interaction = createExecutionContext({ + interactionId: "listener-cleanup", + deadlineMs: 10_000, + traffic: { + maxPhysicalRequests: 4, + maxRetries: 2, + maxConcurrentRequests: 1, + }, + }); + const watched = [ + caller.signal, + interaction.cancellation.signal, + scopeLifetime.signal, + ].map((signal) => ({ add: vi.spyOn(signal, "addEventListener"), remove: vi.spyOn(signal, "removeEventListener"), })); @@ -784,8 +798,10 @@ describe("descriptor-driven HTTP execution lifetime", () => { routeId: ROUTE_ID, scope: { ...scope, signal: scopeLifetime.signal }, signal: caller.signal, + execution: interaction, }); if (ending === "a caller abort") caller.abort(); + if (ending === "an interaction cancel") interaction.cancellation.cancel(); await expect(result).resolves.toMatchObject({ kind: ending === "an answer" ? "SUCCESS" : "CANCELLED",