|
| 1 | +import "~/index.css"; |
| 2 | +import { EnvironmentId, ThreadId, TurnItemId } from "@t3tools/contracts"; |
| 3 | +import * as DateTime from "effect/DateTime"; |
| 4 | +import { expect, it, vi } from "vite-plus/test"; |
| 5 | +import { page } from "vite-plus/test/browser"; |
| 6 | +vi.mock(import("./CommandOutputPanel"), () => ({ |
| 7 | + useCommandOutputStreaming: () => true, |
| 8 | + CommandOutputPanel: () => <div>Command output stream</div>, |
| 9 | +})); |
| 10 | + |
| 11 | +import { render } from "../../../test/render"; |
| 12 | +import { backgroundWorkNowItem } from "./ThreadActivityBanners"; |
| 13 | +import { ThreadNow } from "./ThreadNow"; |
| 14 | + |
| 15 | +it("opens full command details for short labels and keeps pending tasks current", async () => { |
| 16 | + const command = "python3 audit.py -j 6\n> scratch/audit.log 2>&1"; |
| 17 | + const view = (description?: string, status: "running" | "completed" = "completed") => ( |
| 18 | + <ThreadNow |
| 19 | + attention={null} |
| 20 | + syncPhase={null} |
| 21 | + goal={null} |
| 22 | + work={backgroundWorkNowItem({ |
| 23 | + environmentId: EnvironmentId.make("test"), |
| 24 | + threadId: ThreadId.make("thread"), |
| 25 | + tasks: [{ taskId: "bash-1", kind: "command", description, command, awaited: true }], |
| 26 | + turnItems: [ |
| 27 | + { |
| 28 | + id: TurnItemId.make("bash-1"), |
| 29 | + threadId: ThreadId.make("thread"), |
| 30 | + runId: null, |
| 31 | + nodeId: null, |
| 32 | + providerThreadId: null, |
| 33 | + providerTurnId: null, |
| 34 | + nativeItemRef: null, |
| 35 | + parentItemId: null, |
| 36 | + ordinal: 1, |
| 37 | + status, |
| 38 | + title: null, |
| 39 | + startedAt: null, |
| 40 | + completedAt: null, |
| 41 | + updatedAt: DateTime.makeUnsafe("2026-11-09T00:00:00Z"), |
| 42 | + type: "command_execution", |
| 43 | + input: command, |
| 44 | + output: "Command running in background with ID: bash-1", |
| 45 | + }, |
| 46 | + ], |
| 47 | + stopDisabled: false, |
| 48 | + stopping: false, |
| 49 | + onStop: async () => undefined, |
| 50 | + onOpenThread: () => undefined, |
| 51 | + })} |
| 52 | + /> |
| 53 | + ); |
| 54 | + await using screen = await render(view("Audit")); |
| 55 | + await screen.getByRole("button", { name: "Details", exact: true }).click(); |
| 56 | + await vi.waitFor(() => expect(page.getByRole("dialog").element().textContent).toContain(command)); |
| 57 | + await expect.element(page.getByText("Command output stream")).not.toBeInTheDocument(); |
| 58 | + |
| 59 | + await screen.rerender(view(command)); |
| 60 | + await expect.element(page.getByRole("heading", { name: "Command", exact: true })).toBeVisible(); |
| 61 | + await screen.rerender(view()); |
| 62 | + await expect.element(page.getByRole("heading", { name: "Command", exact: true })).toBeVisible(); |
| 63 | + |
| 64 | + await screen.rerender(view("Check remaining modules", "running")); |
| 65 | + await expect |
| 66 | + .element(page.getByRole("heading", { name: "Check remaining modules" })) |
| 67 | + .toBeVisible(); |
| 68 | + await expect.element(page.getByText("Command output stream")).toBeVisible(); |
| 69 | + await page.getByRole("button", { name: "Close", exact: true }).click(); |
| 70 | + await expect.element(page.getByRole("dialog")).not.toBeInTheDocument(); |
| 71 | +}); |
0 commit comments