feat: split presentation run proof panels
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { cleanup, render, screen } from "@testing-library/react";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import type { DemoRunFacts } from "./demo-run-facts.js";
|
||||
|
||||
afterEach(() => cleanup());
|
||||
import {
|
||||
InterruptPayloadFacts,
|
||||
RunInputFacts,
|
||||
RunOutputFacts,
|
||||
RunResumeFacts,
|
||||
RunTraceFacts,
|
||||
} from "./RunFactsPanel.js";
|
||||
|
||||
@@ -24,6 +28,36 @@ const baseFacts: DemoRunFacts = {
|
||||
trace: { frames: [] },
|
||||
};
|
||||
|
||||
const makeCreatedFacts = (markdown: string): DemoRunFacts => ({
|
||||
...baseFacts,
|
||||
output: {
|
||||
state: "created",
|
||||
output: {
|
||||
approved: true,
|
||||
markdown,
|
||||
created_issues: [{ id: "ISSUE-001", title: "Prepare defense", url: "local://issue-board/ISSUE-001" }],
|
||||
selected_issue_ids: ["risk-1"],
|
||||
comment: "Create the selected issue.",
|
||||
},
|
||||
createdIssues: [{ id: "ISSUE-001", title: "Prepare defense", url: "local://issue-board/ISSUE-001" }],
|
||||
markdownPreview: markdown,
|
||||
},
|
||||
});
|
||||
|
||||
const makeTraceFacts = (count: number): DemoRunFacts => ({
|
||||
...baseFacts,
|
||||
trace: {
|
||||
frames: Array.from({ length: count }, (_, index) => ({
|
||||
nodeId: `node-${index}`,
|
||||
stepType: index === 3 ? "interrupt" : "node",
|
||||
outcome: index === 3 ? "submitted" : "ok",
|
||||
resolvedInputLabel: "captured as empty object",
|
||||
outputLabel: "captured as empty object",
|
||||
stateChangesLabel: "captured as empty object",
|
||||
})),
|
||||
},
|
||||
});
|
||||
|
||||
describe("RunInputFacts", () => {
|
||||
it("renders workflow input facts with selected documents and board path", () => {
|
||||
render(<RunInputFacts facts={baseFacts} />);
|
||||
@@ -35,6 +69,50 @@ describe("RunInputFacts", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("InterruptPayloadFacts", () => {
|
||||
it("renders interrupt payload as a scrollable report and proposed issue list", () => {
|
||||
const facts: DemoRunFacts = {
|
||||
...baseFacts,
|
||||
interrupt: {
|
||||
...baseFacts.interrupt,
|
||||
reportMarkdownPreview: "# Long report\n\nThe workflow substrate is ready.\n\n## Evidence\n\n- Draft\n- Artifact\n- Deployment\n- Run",
|
||||
proposedIssues: [
|
||||
{ id: "risk-1", title: "Prepare defense", body: "Rehearse.", severity: "medium" },
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
render(<InterruptPayloadFacts facts={facts} />);
|
||||
|
||||
expect(screen.getByRole("region", { name: /interrupt report markdown/i })).toHaveTextContent("Long report");
|
||||
expect(screen.getByText("risk-1")).toBeInTheDocument();
|
||||
expect(screen.getByText(/submitted/)).toBeInTheDocument();
|
||||
expect(screen.getByText(/cancelled/)).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe("RunResumeFacts", () => {
|
||||
it("renders resume payload separately from output", () => {
|
||||
const facts: DemoRunFacts = {
|
||||
...baseFacts,
|
||||
resume: {
|
||||
outcome: "submitted",
|
||||
payload: {
|
||||
approved: true,
|
||||
selected_issue_ids: ["risk-1"],
|
||||
comment: "Create the selected issue.",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
render(<RunResumeFacts facts={facts} />);
|
||||
|
||||
expect(screen.getByText("submitted")).toBeInTheDocument();
|
||||
expect(screen.getByText("risk-1")).toBeInTheDocument();
|
||||
expect(screen.getByText("Create the selected issue.")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe("RunOutputFacts", () => {
|
||||
it("renders output not created yet before resume", () => {
|
||||
render(<RunOutputFacts facts={baseFacts} />);
|
||||
@@ -70,6 +148,15 @@ describe("RunOutputFacts", () => {
|
||||
expect(screen.getByText("Create the selected issue.")).toBeDefined();
|
||||
expect(screen.getByRole("region", { name: /workflow markdown output/i })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("renders output report as the primary scroll region", () => {
|
||||
const createdFacts = makeCreatedFacts("# Report\n\n" + "body\n".repeat(40));
|
||||
|
||||
render(<RunOutputFacts facts={createdFacts} priority="report" />);
|
||||
|
||||
expect(screen.getByRole("region", { name: /workflow markdown output/i })).toHaveClass("run-facts-scroll-region");
|
||||
expect(screen.getByText("ISSUE-001")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe("RunTraceFacts", () => {
|
||||
@@ -116,4 +203,13 @@ describe("RunTraceFacts", () => {
|
||||
expect(screen.getByText("review_issues")).toBeDefined();
|
||||
expect(screen.getAllByText("captured as empty object").length).toBeGreaterThanOrEqual(2);
|
||||
});
|
||||
|
||||
it("renders trace frames inside a scrollable list", () => {
|
||||
const traceFacts = makeTraceFacts(8);
|
||||
|
||||
render(<RunTraceFacts facts={traceFacts} />);
|
||||
|
||||
expect(screen.getByRole("region", { name: /workflow trace frames/i })).toHaveClass("run-facts-scroll-region");
|
||||
expect(screen.getByText("node-7")).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user