|
|
|
@@ -21,6 +21,7 @@ function task(generation: number | null | undefined = 2) {
|
|
|
|
|
const snapshot = { revision: 1, source_session_id: "session", published_at: time, published_by: "agent",
|
|
|
|
|
...(generation === undefined ? {} : { execution_generation: generation }) };
|
|
|
|
|
return {
|
|
|
|
|
execution_scope: "production",
|
|
|
|
|
project_id: id, task_id: id, task_type: "event_investigation", workflow: "water_quality_complaint",
|
|
|
|
|
lifecycle_status: "waiting_human", active_run: null,
|
|
|
|
|
status: "waiting_human", priority: "normal", revision: 1, execution_generation: 2,
|
|
|
|
@@ -42,6 +43,28 @@ function task(generation: number | null | undefined = 2) {
|
|
|
|
|
afterEach(() => vi.unstubAllGlobals());
|
|
|
|
|
|
|
|
|
|
describe("operational task contract", () => {
|
|
|
|
|
it.each(["event_investigation", "external_work_order", "scheduled_flow"])(
|
|
|
|
|
"loads %s summaries and details with the Server execution scope", (taskType) => {
|
|
|
|
|
const detail = { ...task(), task_type: taskType, execution_scope: "production" };
|
|
|
|
|
const {
|
|
|
|
|
latest_plan: _latestPlan, latest_report: _latestReport, evidence: _evidence,
|
|
|
|
|
actions: _actions, permissions: _permissions, ...summary
|
|
|
|
|
} = detail;
|
|
|
|
|
expect(parseOperationalTaskSummary(summary)).toHaveProperty("execution_scope", "production");
|
|
|
|
|
expect(parseOperationalTask(detail)).toHaveProperty("execution_scope", "production");
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
it.each([undefined, null, "", 1])("rejects an invalid execution scope %j", (scope) => {
|
|
|
|
|
const detail = { ...task(), execution_scope: scope };
|
|
|
|
|
const {
|
|
|
|
|
latest_plan: _latestPlan, latest_report: _latestReport, evidence: _evidence,
|
|
|
|
|
actions: _actions, permissions: _permissions, ...summary
|
|
|
|
|
} = detail;
|
|
|
|
|
expect(() => parseOperationalTaskSummary(summary)).toThrow();
|
|
|
|
|
expect(() => parseOperationalTask(detail)).toThrow();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe.each(["event_investigation", "external_work_order", "scheduled_flow"])("%s replay context", (taskType) => {
|
|
|
|
|
const replayContext = { replay_id: id, knowledge_cutoff: time, batch_sequence: 1 };
|
|
|
|
|
|
|
|
|
@@ -170,6 +193,7 @@ describe("operational task contract", () => {
|
|
|
|
|
it("keeps unknown fields and invalid generations rejected", () => {
|
|
|
|
|
expect(() => parseOperationalTask(task(0))).toThrow();
|
|
|
|
|
const value = task();
|
|
|
|
|
expect(() => parseOperationalTask({ ...value, unexpected: true })).toThrow();
|
|
|
|
|
expect(() => parseOperationalTask({ ...value, latest_plan: { ...value.latest_plan, unexpected: true } })).toThrow();
|
|
|
|
|
expect(() => parseOperationalTask({ ...value, latest_report: { ...value.latest_report, unexpected: true } })).toThrow();
|
|
|
|
|
expect(() => parseOperationalTask({ ...value, latest_report: { ...value.latest_report, execution_generation: -1 } })).toThrow();
|
|
|
|
|