Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: sync main and retain upstream cancellation tests
  • Loading branch information
shoyann committed Oct 23, 2026
commit 9d81b1eaa7ffccb6e1148285b5726e8306d1991b
43 changes: 20 additions & 23 deletions tests/process-global/commandFinalizationCancellation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { join } from "node:path";
import { Cli } from "incur";
import { afterEach, expect, it, vi } from "vitest";

import * as analysisViewService from "../../src/application/analysisView/AnalysisViewService.js";
import * as evidenceInputResolver from "../../src/application/EvidenceInputResolver.js";
import { WasmArtifactService } from "../../src/application/wasm/WasmArtifactService.js";
import { registerAnalysisViewCommands } from "../../src/cli/analysisViewCommands.js";
Expand Down Expand Up @@ -216,23 +215,16 @@ it.each([
});
});
};
const projected = analysisViewService.inspectAnalysisViewValidated(
{
source: { kind: "retained-evidence", evidence_id: parent.evidence_id },
view: { kind: "summary" },
},
() => parent,
);
// Source resolution is an imported boundary used by both successful and
// failed projections. A spy on the service's own export cannot intercept
// its internal calls after request/source ownership moved into that module.
const originalResolve = evidenceInputResolver.resolveEvidenceInput;
const resolveSource = vi
.spyOn(evidenceInputResolver, "resolveEvidenceInput")
// Observe imported production boundaries: spying on the service's own
// export cannot intercept its lexical calls to that same function.
const originalProject = analysisView.projectAnalysisView;
let projected: ReturnType<typeof originalProject> | undefined;
const project = vi
.spyOn(analysisView, "projectAnalysisView")
.mockImplementation((...args) => {
const resolved = originalResolve(...args);
if (phase.startsWith("projection")) queueInterrupt();
return resolved;
projected = originalProject(...args);
if (phase === "projection") queueInterrupt();
return projected;
});
const originalResolve = evidenceInputResolver.resolveEvidenceInput;
vi.spyOn(evidenceInputResolver, "resolveEvidenceInput").mockImplementation(
Expand Down Expand Up @@ -288,13 +280,18 @@ it.each([
signal === "SIGINT" ? 130 : signal === "SIGTERM" ? 143 : 0,
);
if (signal !== "control") expect(interruptHandled).toBe(true);
if (phase.startsWith("authentication"))
expect(resolveSource).not.toHaveBeenCalled();
if (phase.startsWith("projection"))
expect(resolveSource).toHaveBeenCalledOnce();
expect(project).toHaveBeenCalledTimes(
Number(signal === "control" || phase === "projection"),
);
if (phase === "projection") {
if (!projected.ok) throw new Error("Expected a completed page");
expect(result.details.partial_observation).toEqual(projected.value);
if (!projected?.ok) throw new Error("Expected a completed page");
const partial = parseEvidence(result.details.partial_observation);
expect(partial.normalized_result).toEqual(projected.value);
expect(partial).toMatchObject({
operation: "inspect_analysis_view",
evidence_links: [parent.evidence_id],
subject: parent.subject,
});
}
} finally {
await pendingInterrupt;
Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.