@blackbelt-technology/pi-dashboard-flows-plugin 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +13 -5
- package/src/client/FlowAgentCard.tsx +4 -8
- package/src/client/FlowAgentDetail.tsx +1 -1
- package/src/client/FlowDashboard.tsx +6 -2
- package/src/client/FlowInputWiring.tsx +2 -2
- package/src/client/FlowsCommandRoutes.tsx +13 -5
- package/src/client/FlowsSettings.tsx +4 -4
- package/src/client/SessionFlowActions.tsx +9 -4
- package/src/client/format-cost.ts +21 -0
- package/src/client/send-safe.ts +19 -0
- package/src/AGENTS.md +0 -8
- package/src/__tests__/FlowGraph.test.ts +0 -305
- package/src/__tests__/FlowInputWiring.test.tsx +0 -97
- package/src/__tests__/FlowSummary.test.tsx +0 -331
- package/src/__tests__/FlowYamlPreview.test.tsx +0 -75
- package/src/__tests__/FlowsSessionStateContext.test.tsx +0 -223
- package/src/__tests__/FlowsUiStateContext.test.tsx +0 -140
- package/src/__tests__/authoring-renderers.test.tsx +0 -190
- package/src/__tests__/automation-actions.test.ts +0 -117
- package/src/__tests__/flow-agent-card-code-source.test.tsx +0 -190
- package/src/__tests__/flow-agent-cost.test.tsx +0 -160
- package/src/__tests__/flow-agent-error.test.ts +0 -60
- package/src/__tests__/flow-collapse-storage.test.ts +0 -90
- package/src/__tests__/flow-edges.test.ts +0 -195
- package/src/__tests__/flow-inputs.test.ts +0 -69
- package/src/__tests__/flow-reducer-bridge-contract.test.ts +0 -108
- package/src/__tests__/flow-reducer-seed-on-start.test.ts +0 -61
- package/src/__tests__/flow-yaml-parse.test.ts +0 -124
- package/src/__tests__/flows-for-cwd.test.ts +0 -51
- package/src/__tests__/flowsAvailability.test.ts +0 -79
- package/src/__tests__/manifest-discoverability.test.ts +0 -97
- package/src/__tests__/node-kind-reducer.test.ts +0 -135
- package/src/__tests__/plugin-action-handler.test.ts +0 -54
- package/src/__tests__/reducer-parity.test.ts +0 -106
- package/src/__tests__/render-actions.test.ts +0 -63
- package/src/__tests__/session-flow-actions-edit.test.tsx +0 -98
- package/src/bridge/AGENTS.md +0 -8
- package/src/client/AGENTS.md +0 -32
- package/src/server/AGENTS.md +0 -10
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Group 6 (wire-flow-inputs-in-automation) — FlowInputWiring: reads a flow's
|
|
3
|
-
* declared inputs, binds each to a literal or the trigger value, writes only
|
|
4
|
-
* payload.inputs, and drops orphan keys when the selected flow changes.
|
|
5
|
-
*/
|
|
6
|
-
import React, { useState } from "react";
|
|
7
|
-
import { describe, it, expect, afterEach, beforeEach, vi } from "vitest";
|
|
8
|
-
import { render, cleanup, fireEvent, waitFor } from "@testing-library/react";
|
|
9
|
-
import { FlowInputWiring } from "../client/FlowInputWiring.js";
|
|
10
|
-
|
|
11
|
-
const INPUTS: Record<string, Array<{ name: string; type: string; required: boolean }>> = {
|
|
12
|
-
"ns:a": [
|
|
13
|
-
{ name: "invoice", type: "string", required: true },
|
|
14
|
-
{ name: "priority", type: "number", required: false },
|
|
15
|
-
],
|
|
16
|
-
"ns:b": [{ name: "region", type: "string", required: false }],
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
global.fetch = vi.fn((url: string) => {
|
|
21
|
-
const flow = new URL(url, "http://x").searchParams.get("flow") ?? "";
|
|
22
|
-
return Promise.resolve({
|
|
23
|
-
ok: true,
|
|
24
|
-
json: () => Promise.resolve({ inputs: INPUTS[flow] ?? [] }),
|
|
25
|
-
}) as unknown as Promise<Response>;
|
|
26
|
-
}) as unknown as typeof fetch;
|
|
27
|
-
});
|
|
28
|
-
afterEach(() => {
|
|
29
|
-
cleanup();
|
|
30
|
-
vi.restoreAllMocks();
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
/** Controlled harness so onChange feeds back into payload (real re-render loop). */
|
|
34
|
-
function Harness({ startFlow }: { startFlow: string }) {
|
|
35
|
-
const [payload, setPayload] = useState<Record<string, unknown>>({ flow: startFlow });
|
|
36
|
-
return (
|
|
37
|
-
<div>
|
|
38
|
-
<button data-testid="switch-b" onClick={() => setPayload((p) => ({ ...p, flow: "ns:b" }))}>
|
|
39
|
-
switch
|
|
40
|
-
</button>
|
|
41
|
-
<FlowInputWiring payload={payload} onChange={setPayload} cwd="/repo" />
|
|
42
|
-
<pre data-testid="payload">{JSON.stringify(payload)}</pre>
|
|
43
|
-
</div>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function payloadOf(getByTestId: (id: string) => HTMLElement): Record<string, unknown> {
|
|
48
|
-
return JSON.parse(getByTestId("payload").textContent || "{}");
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
describe("FlowInputWiring", () => {
|
|
52
|
-
it("renders one row per declared flow input", async () => {
|
|
53
|
-
const { getByTestId } = render(<Harness startFlow="ns:a" />);
|
|
54
|
-
await waitFor(() => expect(getByTestId("flow-input-invoice")).toBeTruthy());
|
|
55
|
-
expect(getByTestId("flow-input-priority")).toBeTruthy();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("binding a row to the trigger writes ${{trigger}} into payload.inputs", async () => {
|
|
59
|
-
const { getByTestId } = render(<Harness startFlow="ns:a" />);
|
|
60
|
-
await waitFor(() => expect(getByTestId("flow-input-invoice-mode-trigger")).toBeTruthy());
|
|
61
|
-
fireEvent.click(getByTestId("flow-input-invoice-mode-trigger"));
|
|
62
|
-
await waitFor(() => {
|
|
63
|
-
const inputs = payloadOf(getByTestId).inputs as Record<string, unknown>;
|
|
64
|
-
expect(inputs.invoice).toBe("${{trigger}}");
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("a typed number literal persists as a number", async () => {
|
|
69
|
-
const { getByTestId } = render(<Harness startFlow="ns:a" />);
|
|
70
|
-
await waitFor(() => expect(getByTestId("flow-input-priority")).toBeTruthy());
|
|
71
|
-
fireEvent.change(getByTestId("flow-input-priority"), { target: { value: "5" } });
|
|
72
|
-
await waitFor(() => {
|
|
73
|
-
const inputs = payloadOf(getByTestId).inputs as Record<string, unknown>;
|
|
74
|
-
expect(inputs.priority).toBe(5);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it("dropping to a new flow prunes orphan wired keys", async () => {
|
|
79
|
-
const { getByTestId } = render(<Harness startFlow="ns:a" />);
|
|
80
|
-
await waitFor(() => expect(getByTestId("flow-input-invoice-mode-trigger")).toBeTruthy());
|
|
81
|
-
fireEvent.click(getByTestId("flow-input-invoice-mode-trigger"));
|
|
82
|
-
await waitFor(() => expect((payloadOf(getByTestId).inputs as any).invoice).toBe("${{trigger}}"));
|
|
83
|
-
// Switch to a flow that does not declare `invoice`.
|
|
84
|
-
fireEvent.click(getByTestId("switch-b"));
|
|
85
|
-
await waitFor(() => {
|
|
86
|
-
const inputs = (payloadOf(getByTestId).inputs as Record<string, unknown>) ?? {};
|
|
87
|
-
expect(inputs.invoice).toBeUndefined();
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
it("renders nothing for a flow with no declared inputs", async () => {
|
|
92
|
-
const { queryByTestId } = render(<Harness startFlow="ns:none" />);
|
|
93
|
-
await waitFor(() => expect(global.fetch).toHaveBeenCalled());
|
|
94
|
-
await Promise.resolve();
|
|
95
|
-
expect(queryByTestId("flow-input-wiring")).toBeNull();
|
|
96
|
-
});
|
|
97
|
-
});
|
|
@@ -1,331 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for expandable per-agent rows in FlowSummary.
|
|
3
|
-
* Collapsed rows show a truncated peek; expanding reveals full summary
|
|
4
|
-
* (markdown), typed-output chips, and the file list. Failed steps
|
|
5
|
-
* auto-expand. Rows without detail are not interactive. Per-row state
|
|
6
|
-
* is independent. See change: expandable-flow-summary-rows.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { cleanup, fireEvent, render, within } from "@testing-library/react";
|
|
10
|
-
import type React from "react";
|
|
11
|
-
import { afterEach, beforeAll, describe, expect, it } from "vitest";
|
|
12
|
-
|
|
13
|
-
// jsdom does not implement scrollIntoView; the selection effect calls it.
|
|
14
|
-
beforeAll(() => {
|
|
15
|
-
Element.prototype.scrollIntoView = () => {};
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
createUiPrimitiveRegistry,
|
|
20
|
-
registerUiPrimitive,
|
|
21
|
-
UiPrimitiveProvider,
|
|
22
|
-
} from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
23
|
-
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
24
|
-
import type { FlowAgentState, FlowState } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
25
|
-
import { FlowSummary } from "../client/FlowSummary.js";
|
|
26
|
-
|
|
27
|
-
const registry = createUiPrimitiveRegistry();
|
|
28
|
-
registerUiPrimitive(
|
|
29
|
-
registry,
|
|
30
|
-
UI_PRIMITIVE_KEYS.markdownContent,
|
|
31
|
-
(({ content }: { content: string }) => <div data-testid="md">{content}</div>) as never,
|
|
32
|
-
);
|
|
33
|
-
registerUiPrimitive(
|
|
34
|
-
registry,
|
|
35
|
-
UI_PRIMITIVE_KEYS.formatDuration,
|
|
36
|
-
(((ms: number) => `${ms}ms`) as never),
|
|
37
|
-
);
|
|
38
|
-
// FlowGraph (rendered inside FlowSummary) consumes the zoom-controls primitive.
|
|
39
|
-
registerUiPrimitive(
|
|
40
|
-
registry,
|
|
41
|
-
UI_PRIMITIVE_KEYS.zoomControls,
|
|
42
|
-
((() => null) as never),
|
|
43
|
-
);
|
|
44
|
-
// FlowAgentCard (frozen cards) primitives. See change: show-flow-cards-in-summary.
|
|
45
|
-
registerUiPrimitive(
|
|
46
|
-
registry,
|
|
47
|
-
UI_PRIMITIVE_KEYS.agentCard,
|
|
48
|
-
(({ children, selected, onClick }: { children?: React.ReactNode; selected?: boolean; onClick?: () => void }) => (
|
|
49
|
-
<div data-testid="agent-card" data-selected={selected ? "true" : "false"} onClick={onClick}>{children}</div>
|
|
50
|
-
)) as never,
|
|
51
|
-
);
|
|
52
|
-
// ui:dialog is required by FlowAgentCard (detail) + FlowSummary (graph expand).
|
|
53
|
-
registerUiPrimitive(
|
|
54
|
-
registry,
|
|
55
|
-
UI_PRIMITIVE_KEYS.dialog,
|
|
56
|
-
(({ open, children, title, size }: { open: boolean; children?: React.ReactNode; title?: string; size?: string }) =>
|
|
57
|
-
open ? <div data-testid="dialog" data-size={size}>{title}{children}</div> : null) as never,
|
|
58
|
-
);
|
|
59
|
-
registerUiPrimitive(
|
|
60
|
-
registry,
|
|
61
|
-
UI_PRIMITIVE_KEYS.formatTokens,
|
|
62
|
-
(((n: number) => `${n}`) as never),
|
|
63
|
-
);
|
|
64
|
-
registerUiPrimitive(
|
|
65
|
-
registry,
|
|
66
|
-
UI_PRIMITIVE_KEYS.popover,
|
|
67
|
-
(({ children }: { children?: React.ReactNode }) => <>{children}</>) as never,
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
function agent(over: Partial<FlowAgentState>): FlowAgentState {
|
|
71
|
-
return {
|
|
72
|
-
agentName: over.stepId ?? "a",
|
|
73
|
-
stepId: over.stepId ?? "a",
|
|
74
|
-
status: "complete",
|
|
75
|
-
blockedBy: [],
|
|
76
|
-
recentTools: [],
|
|
77
|
-
detailHistory: [],
|
|
78
|
-
...over,
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function makeState(agents: FlowAgentState[]): FlowState {
|
|
83
|
-
return {
|
|
84
|
-
flowName: "demo-flow",
|
|
85
|
-
task: "t",
|
|
86
|
-
status: "success",
|
|
87
|
-
autonomousMode: false,
|
|
88
|
-
agents: new Map(agents.map((a) => [a.stepId, a])),
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function renderSummary(state: FlowState) {
|
|
93
|
-
return render(
|
|
94
|
-
<UiPrimitiveProvider value={registry}>
|
|
95
|
-
<FlowSummary flowState={state} onDismiss={() => {}} sessionId="s1" />
|
|
96
|
-
</UiPrimitiveProvider>,
|
|
97
|
-
);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
afterEach(() => cleanup());
|
|
101
|
-
|
|
102
|
-
describe("FlowSummary frozen cards (show-flow-cards-in-summary)", () => {
|
|
103
|
-
it("renders one frozen agent card per agent, above the collapsible summary section", () => {
|
|
104
|
-
const state = makeState([
|
|
105
|
-
agent({ stepId: "one", label: "step-one", status: "complete", summary: "S1" }),
|
|
106
|
-
agent({ stepId: "two", label: "step-two", status: "complete", summary: "S2" }),
|
|
107
|
-
]);
|
|
108
|
-
const { getAllByTestId, getByTestId } = renderSummary(state);
|
|
109
|
-
const cards = getAllByTestId("agent-card");
|
|
110
|
-
expect(cards).toHaveLength(2);
|
|
111
|
-
// Cards precede the collapsible summaries section in DOM order.
|
|
112
|
-
const section = getByTestId("flow-summaries");
|
|
113
|
-
expect(cards[0].compareDocumentPosition(section) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it("collapsing the summary section keeps the cards visible", () => {
|
|
117
|
-
const state = makeState([
|
|
118
|
-
agent({ stepId: "one", label: "step-one", status: "complete", summary: "S1" }),
|
|
119
|
-
]);
|
|
120
|
-
const { getByTestId, getAllByTestId, queryByTestId } = renderSummary(state);
|
|
121
|
-
expect(getByTestId("flow-summaries")).toBeTruthy();
|
|
122
|
-
fireEvent.click(getByTestId("flow-summary-toggle"));
|
|
123
|
-
// Collapsing removes the summaries rows; cards stay visible.
|
|
124
|
-
expect(queryByTestId("flow-summaries")).toBeNull();
|
|
125
|
-
expect(getAllByTestId("agent-card")).toHaveLength(1);
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
describe("FlowSummary fit-window scroll box (improve-flow-graph-fidelity)", () => {
|
|
130
|
-
it("wraps cards + summaries in one bounded, scrollable box so the panel fits the viewport", () => {
|
|
131
|
-
const state = makeState([
|
|
132
|
-
agent({ stepId: "one", label: "step-one", status: "complete", summary: "S1" }),
|
|
133
|
-
]);
|
|
134
|
-
const { getByTestId } = renderSummary(state);
|
|
135
|
-
const box = getByTestId("flow-summary-scrollbox");
|
|
136
|
-
expect(box.style.maxHeight).toBe("48vh");
|
|
137
|
-
expect(box.className).toMatch(/overflow-y-auto/);
|
|
138
|
-
// cards + summaries live INSIDE the scroll box
|
|
139
|
-
expect(box.querySelector("[data-testid='flow-summaries']")).toBeTruthy();
|
|
140
|
-
expect(box.querySelector("[data-testid='agent-card']")).toBeTruthy();
|
|
141
|
-
});
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
describe("FlowSummary whole-panel collapse (improve-flow-graph-fidelity)", () => {
|
|
145
|
-
it("collapses the whole panel to its header bar, hiding the body but keeping the name", () => {
|
|
146
|
-
const state = makeState([
|
|
147
|
-
agent({ stepId: "one", label: "step-one", status: "complete", summary: "S1" }),
|
|
148
|
-
]);
|
|
149
|
-
const { getByTestId, queryByTestId, queryAllByTestId, getByText } = renderSummary(state);
|
|
150
|
-
// Body present initially (cards + summaries footer).
|
|
151
|
-
expect(queryAllByTestId("agent-card")).toHaveLength(1);
|
|
152
|
-
expect(queryByTestId("flow-summaries")).toBeTruthy();
|
|
153
|
-
// Collapse the whole panel.
|
|
154
|
-
fireEvent.click(getByTestId("flow-summary-panel-toggle"));
|
|
155
|
-
// Body gone; header (flow name) still shown — shrink-to-header, not dismiss.
|
|
156
|
-
expect(queryAllByTestId("agent-card")).toHaveLength(0);
|
|
157
|
-
expect(queryByTestId("flow-summaries")).toBeNull();
|
|
158
|
-
expect(getByText(/demo-flow/)).toBeTruthy();
|
|
159
|
-
// Toggling back restores the body.
|
|
160
|
-
fireEvent.click(getByTestId("flow-summary-panel-toggle"));
|
|
161
|
-
expect(queryAllByTestId("agent-card")).toHaveLength(1);
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
describe("FlowSummary graph⇄card selection (improve-flow-graph-dialog-and-card-interaction)", () => {
|
|
166
|
-
function selectionState() {
|
|
167
|
-
return makeState([
|
|
168
|
-
agent({ stepId: "one", label: "step-one", status: "complete", summary: "S1" }),
|
|
169
|
-
agent({ stepId: "two", label: "step-two", status: "complete", summary: "S2" }),
|
|
170
|
-
]);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
it("clicking a graph node selects the matching card", () => {
|
|
174
|
-
const { container } = renderSummary(selectionState());
|
|
175
|
-
const node = container.querySelector("[data-node='one']") as SVGGElement;
|
|
176
|
-
expect(node).toBeTruthy();
|
|
177
|
-
fireEvent.click(node);
|
|
178
|
-
const card = container.querySelector("[data-step='one'] [data-testid='agent-card']");
|
|
179
|
-
expect(card?.getAttribute("data-selected")).toBe("true");
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it("clicking a card selects the matching graph node", () => {
|
|
183
|
-
const { container } = renderSummary(selectionState());
|
|
184
|
-
const card = container.querySelector("[data-step='two'] [data-testid='agent-card']") as HTMLElement;
|
|
185
|
-
fireEvent.click(card);
|
|
186
|
-
const node = container.querySelector("[data-node='two']");
|
|
187
|
-
expect(node?.getAttribute("class") ?? "").toContain("flow-node-selected");
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it("re-clicking the selected node clears selection", () => {
|
|
191
|
-
const { container } = renderSummary(selectionState());
|
|
192
|
-
const node = container.querySelector("[data-node='one']") as SVGGElement;
|
|
193
|
-
fireEvent.click(node);
|
|
194
|
-
fireEvent.click(node);
|
|
195
|
-
const card = container.querySelector("[data-step='one'] [data-testid='agent-card']");
|
|
196
|
-
expect(card?.getAttribute("data-selected")).toBe("false");
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
it("Esc clears selection", () => {
|
|
200
|
-
const { container } = renderSummary(selectionState());
|
|
201
|
-
fireEvent.click(container.querySelector("[data-node='one']") as SVGGElement);
|
|
202
|
-
expect(container.querySelector("[data-step='one'] [data-testid='agent-card']")?.getAttribute("data-selected")).toBe("true");
|
|
203
|
-
fireEvent.keyDown(document, { key: "Escape" });
|
|
204
|
-
expect(container.querySelector("[data-step='one'] [data-testid='agent-card']")?.getAttribute("data-selected")).toBe("false");
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
describe("FlowSummary graph expand dialog (full size)", () => {
|
|
209
|
-
it("⤢ Expand opens the graph dialog at size=full", () => {
|
|
210
|
-
const state = makeState([agent({ stepId: "one", label: "step-one", status: "complete" })]);
|
|
211
|
-
const { container, getByText, queryByTestId } = renderSummary(state);
|
|
212
|
-
expect(queryByTestId("dialog")).toBeNull();
|
|
213
|
-
fireEvent.click(getByText(/Expand/));
|
|
214
|
-
const dialog = container.querySelector("[data-testid='dialog']");
|
|
215
|
-
expect(dialog).toBeTruthy();
|
|
216
|
-
expect(dialog?.getAttribute("data-size")).toBe("full");
|
|
217
|
-
});
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
describe("FlowAgentCard detail dialog (replaces popover)", () => {
|
|
221
|
-
it("clicking Details opens a dialog and there is no Popout button", () => {
|
|
222
|
-
const state = makeState([agent({ stepId: "one", label: "step-one", status: "complete" })]);
|
|
223
|
-
const { queryByText, queryByTestId, getAllByText } = renderSummary(state);
|
|
224
|
-
expect(queryByText("Popout")).toBeNull();
|
|
225
|
-
expect(queryByTestId("dialog")).toBeNull();
|
|
226
|
-
// "Details" appears once per card; click the card's detail button.
|
|
227
|
-
fireEvent.click(getAllByText("Details")[0]);
|
|
228
|
-
const dialog = queryByTestId("dialog");
|
|
229
|
-
expect(dialog).toBeTruthy();
|
|
230
|
-
expect(dialog?.textContent).toContain("step-one"); // dialog title = displayName
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
describe("FlowSummary expandable rows", () => {
|
|
235
|
-
it("collapsed complete row shows truncated peek; clicking reveals full summary, chips, files", () => {
|
|
236
|
-
const state = makeState([
|
|
237
|
-
agent({
|
|
238
|
-
stepId: "classify",
|
|
239
|
-
label: "classify-intent",
|
|
240
|
-
status: "complete",
|
|
241
|
-
summary: "Decided the request was a refactor of the reducer module.",
|
|
242
|
-
files: ["flow-reducer.ts", "flow-reducer.test.ts"],
|
|
243
|
-
typedOutputs: { intent: "refactor", branch: "refactor" },
|
|
244
|
-
}),
|
|
245
|
-
]);
|
|
246
|
-
const { container } = renderSummary(state);
|
|
247
|
-
// Scope row assertions to the collapsible summary section (the frozen cards
|
|
248
|
-
// above also surface summary/outputs, so global queries are ambiguous now).
|
|
249
|
-
const section = within(container.querySelector("[data-testid='flow-summaries']") as HTMLElement);
|
|
250
|
-
|
|
251
|
-
// Collapsed: full summary not yet rendered through markdown primitive.
|
|
252
|
-
expect(section.queryByTestId("md")).toBeNull();
|
|
253
|
-
|
|
254
|
-
fireEvent.click(section.getByText("classify-intent", { selector: "span" }));
|
|
255
|
-
|
|
256
|
-
// Expanded: full summary via markdown primitive.
|
|
257
|
-
expect(section.getByTestId("md").textContent).toContain("refactor of the reducer module");
|
|
258
|
-
// Typed-output chip (branch filtered out, intent shown).
|
|
259
|
-
expect(section.getByText("intent")).toBeTruthy();
|
|
260
|
-
// File list rendered.
|
|
261
|
-
expect(section.getByText(/flow-reducer\.test\.ts/)).toBeTruthy();
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
it("failed step renders expanded on mount", () => {
|
|
265
|
-
const state = makeState([
|
|
266
|
-
agent({
|
|
267
|
-
stepId: "verify",
|
|
268
|
-
label: "verify-change",
|
|
269
|
-
status: "error",
|
|
270
|
-
outcome: "hard",
|
|
271
|
-
summary: "Coverage gate failed on the new branch path.",
|
|
272
|
-
}),
|
|
273
|
-
]);
|
|
274
|
-
const { getByTestId } = renderSummary(state);
|
|
275
|
-
// Auto-expanded → markdown primitive rendered without any click.
|
|
276
|
-
expect(getByTestId("md").textContent).toContain("Coverage gate failed");
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
it("row without summary text is omitted from the list; section hidden when it is the only agent", () => {
|
|
280
|
-
const state = makeState([
|
|
281
|
-
agent({ stepId: "bare", label: "bare-step", status: "complete" }),
|
|
282
|
-
]);
|
|
283
|
-
const { queryByText, queryByTestId, getAllByTestId } = renderSummary(state);
|
|
284
|
-
// The bare step has no summary text → not listed, and as the only agent the
|
|
285
|
-
// whole Summaries subsection is hidden.
|
|
286
|
-
expect(queryByTestId("flow-summaries")).toBeNull();
|
|
287
|
-
expect(queryByTestId("flow-summary-toggle")).toBeNull();
|
|
288
|
-
expect(queryByText("bare-step", { selector: "span" })).toBeNull();
|
|
289
|
-
// Frozen agent card still present (the filter only affects the Summaries list).
|
|
290
|
-
expect(getAllByTestId("agent-card")).toHaveLength(1);
|
|
291
|
-
});
|
|
292
|
-
|
|
293
|
-
it("Summaries count reflects only summary-bearing agents", () => {
|
|
294
|
-
const state = makeState([
|
|
295
|
-
agent({ stepId: "one", label: "step-one", status: "complete", summary: "S1" }),
|
|
296
|
-
agent({ stepId: "two", label: "step-two", status: "complete" }),
|
|
297
|
-
agent({ stepId: "three", label: "step-three", status: "complete", summary: "S3" }),
|
|
298
|
-
]);
|
|
299
|
-
const { getByText, queryByText } = renderSummary(state);
|
|
300
|
-
expect(getByText("Summaries (2)")).toBeTruthy();
|
|
301
|
-
// The summary-less middle step is not rendered as a row.
|
|
302
|
-
expect(queryByText("step-two", { selector: "span" })).toBeNull();
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
it("hides the whole Summaries section when no agent has summary text", () => {
|
|
306
|
-
const state = makeState([
|
|
307
|
-
agent({ stepId: "a", label: "a", status: "complete", typedOutputs: { verdict: "pass" } }),
|
|
308
|
-
agent({ stepId: "b", label: "b", status: "complete" }),
|
|
309
|
-
]);
|
|
310
|
-
const { queryByTestId, getAllByTestId } = renderSummary(state);
|
|
311
|
-
expect(queryByTestId("flow-summaries")).toBeNull();
|
|
312
|
-
expect(queryByTestId("flow-summary-toggle")).toBeNull();
|
|
313
|
-
// Both still appear as frozen cards.
|
|
314
|
-
expect(getAllByTestId("agent-card")).toHaveLength(2);
|
|
315
|
-
});
|
|
316
|
-
|
|
317
|
-
it("expanding one row leaves siblings collapsed", () => {
|
|
318
|
-
const state = makeState([
|
|
319
|
-
agent({ stepId: "one", label: "step-one", status: "complete", summary: "Summary one." }),
|
|
320
|
-
agent({ stepId: "two", label: "step-two", status: "complete", summary: "Summary two." }),
|
|
321
|
-
]);
|
|
322
|
-
const { getByText, getAllByTestId, queryAllByTestId } = renderSummary(state);
|
|
323
|
-
|
|
324
|
-
expect(queryAllByTestId("md")).toHaveLength(0);
|
|
325
|
-
fireEvent.click(getByText("step-one", { selector: "span" }));
|
|
326
|
-
|
|
327
|
-
const mds = getAllByTestId("md");
|
|
328
|
-
expect(mds).toHaveLength(1);
|
|
329
|
-
expect(mds[0].textContent).toContain("Summary one.");
|
|
330
|
-
});
|
|
331
|
-
});
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests for the flow YAML preview content-view claim's dismissal contract.
|
|
3
|
-
*
|
|
4
|
-
* The claim overlays the chat at the current /session/:id URL, gated by the
|
|
5
|
-
* plugin UI-state predicate. On back it MUST clear its own UI state (revealing
|
|
6
|
-
* the chat) AND invoke the shell-provided onClose. The shell wires onClose to a
|
|
7
|
-
* no-op so dismissal stays on the session instead of navigating to "/".
|
|
8
|
-
*
|
|
9
|
-
* See change: fix-settings-back-to-launching-route.
|
|
10
|
-
*/
|
|
11
|
-
import React from "react";
|
|
12
|
-
import { describe, it, expect, beforeEach, afterEach, vi } from "vitest";
|
|
13
|
-
import { render, act, cleanup, fireEvent } from "@testing-library/react";
|
|
14
|
-
import {
|
|
15
|
-
UiPrimitiveProvider,
|
|
16
|
-
createUiPrimitiveRegistry,
|
|
17
|
-
registerUiPrimitive,
|
|
18
|
-
} from "@blackbelt-technology/dashboard-plugin-runtime";
|
|
19
|
-
import { UI_PRIMITIVE_KEYS } from "@blackbelt-technology/pi-dashboard-shared/dashboard-plugin/ui-primitives.js";
|
|
20
|
-
import type { DashboardSession } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
21
|
-
import { FlowYamlPreviewClaim } from "../client/FlowYamlPreview.js";
|
|
22
|
-
import {
|
|
23
|
-
useFlowsUiActions,
|
|
24
|
-
getFlowsUiStateSnapshot,
|
|
25
|
-
__resetFlowsUiStateForTests,
|
|
26
|
-
} from "../client/FlowsUiStateContext.js";
|
|
27
|
-
|
|
28
|
-
const registry = createUiPrimitiveRegistry();
|
|
29
|
-
// Stub markdownContent primitive — the preview body renders through it.
|
|
30
|
-
registerUiPrimitive(
|
|
31
|
-
registry,
|
|
32
|
-
UI_PRIMITIVE_KEYS.markdownContent,
|
|
33
|
-
(({ content }: { content: string }) => <div data-testid="md">{content}</div>) as never,
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
const session = { id: "abc" } as unknown as DashboardSession;
|
|
37
|
-
|
|
38
|
-
function Harness({ onClose }: { onClose: () => void }) {
|
|
39
|
-
const actions = useFlowsUiActions();
|
|
40
|
-
// Seed the preview content so the claim renders.
|
|
41
|
-
React.useEffect(() => {
|
|
42
|
-
actions.setFlowYamlPreview({ content: "name: demo", title: "demo.yaml" });
|
|
43
|
-
}, [actions]);
|
|
44
|
-
return (
|
|
45
|
-
<UiPrimitiveProvider value={registry}>
|
|
46
|
-
<FlowYamlPreviewClaim session={session} routeParams={{}} onClose={onClose} />
|
|
47
|
-
</UiPrimitiveProvider>
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
describe("FlowYamlPreviewClaim dismissal", () => {
|
|
52
|
-
beforeEach(() => __resetFlowsUiStateForTests());
|
|
53
|
-
afterEach(() => {
|
|
54
|
-
cleanup();
|
|
55
|
-
__resetFlowsUiStateForTests();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("back clears UI state AND calls the shell onClose", () => {
|
|
59
|
-
const onClose = vi.fn();
|
|
60
|
-
const { getByTitle } = render(<Harness onClose={onClose} />);
|
|
61
|
-
|
|
62
|
-
// Preview is active before back.
|
|
63
|
-
expect(getFlowsUiStateSnapshot().flowYamlPreview).not.toBeNull();
|
|
64
|
-
|
|
65
|
-
act(() => {
|
|
66
|
-
fireEvent.click(getByTitle("Back"));
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
// Plugin cleared its own state → predicate goes false → chat reappears.
|
|
70
|
-
expect(getFlowsUiStateSnapshot().flowYamlPreview).toBeNull();
|
|
71
|
-
expect(getFlowsUiStateSnapshot().sourceOpenAgent).toBeNull();
|
|
72
|
-
// Shell onClose invoked (wired to a no-op in App; never navigates to "/").
|
|
73
|
-
expect(onClose).toHaveBeenCalledOnce();
|
|
74
|
-
});
|
|
75
|
-
});
|