test: retain completed binary observations on late cancellation

This commit is contained in:
morluto committed 2026-11-10 16:02:00 -05:00
1 parent ddb8abf855
commit b899c35419
8 files changed
+88 -32

No files matched your search

@@ -1,3 +1,4 @@
import { parseEvidence } from "../../domain/evidence.js";
import { expect, it } from "vitest";
import { ElfNotesService } from "./ElfNotesService.js";
import { ELF_NOTES_PROVIDER } from "../../domain/investigationProviders.js";
@@ -106,12 +107,13 @@ it("retains an examined empty table and rejects an uncounted table", async () =>
}
});
it("discards an observation if the caller cancels while the provider completes", async () => {
it("retains a completed observation when the caller cancels as the provider completes", async () => {
const controller = new AbortController();
const reason = { request: "late ElfNotes cancellation" };
const service = new ElfNotesService({
identity,
inspect: () => {
controller.abort();
controller.abort(reason);
return Promise.resolve(ok(report));
},
});
@@ -119,6 +121,11 @@ it("discards an observation if the caller cancels while the provider completes",
{ path: report.artifact.path },
{ signal: controller.signal },
);
expect(result.ok).toBe(false);
if (!result.ok) expect(result.error).toBeInstanceOf(AnalysisCancelledError);
if (result.ok) throw new Error("Expected late cancellation");
expect(result.error).toBeInstanceOf(AnalysisCancelledError);
expect(result.error.cause).toBe(reason);
expect(parseEvidence(result.error.partialObservation)).toMatchObject({
operation: "inspect_elf_notes",
normalized_result: report,
});
});