Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,37 @@ it("expands and collapses step when toggled", async () => {

unmount();
});

it("expanded steps remain expanded", async () => {
window.history.pushState({}, "", "/?selected-node=step-1&start-byte=0");

let currentSteps = [
{ id: "step-1", title: "Step 1", stageId: "stage-1", state: "running" },
{ id: "step-2", title: "Step 2", stageId: "stage-1", state: "queued" },
];
(model.getRunSteps as Mock).mockResolvedValue({ steps: currentSteps });

const props = { currentRunPath: "/run/1" };
const { result, unmount } = renderHook(() => useStepsPoller(props));
await waitFor(() => expect(result.current.expandedSteps).toContain("step-1"));

expect(result.current.expandedSteps).toContain("step-1");
act(() => result.current.onStepToggle("step-2"));
expect(result.current.expandedSteps).toContain("step-1");
expect(result.current.expandedSteps).toContain("step-2");

// Simulate step-1 finishing and step-2 becoming active
currentSteps = [
{ id: "step-1", title: "Step 1", stageId: "stage-1", state: "success" },
{ id: "step-2", title: "Step 2", stageId: "stage-1", state: "running" },
];
(model.getRunSteps as Mock).mockResolvedValue({ steps: currentSteps });

await waitFor(() =>
expect(result.current.openStageSteps).to.deep.equal(currentSteps),
);
expect(result.current.expandedSteps).toContain("step-1");
expect(result.current.expandedSteps).toContain("step-2");

unmount();
});
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,12 @@ export function useStepsPoller(props: RunPollerProps) {
setUserManuallySetNode(true);

const step = steps.find((s) => s.id === selected);
const expanded: string[] = [];

if (step) {
selected = step.stageId;
expanded.push(step.id);
setExpandedSteps((prev) => {
if (prev.includes(step.id)) return prev;
return [...prev, step.id];
});

updateStepConsoleOffset(
step.id,
Expand All @@ -81,7 +82,6 @@ export function useStepsPoller(props: RunPollerProps) {
}

setOpenStage(selected);
setExpandedSteps(expanded);
return true;
},
[updateStepConsoleOffset, collapsedSteps],
Expand Down