feat(FN-4702): complete Step 3 — render worktrunk approval details

Fusion-Task-Id: FN-4702
Fusion-Task-Lineage: 378b46bc-2e71-43bf-9ff7-85e7aed8bf85
This commit is contained in:
Fusion (runfusion.ai)
2026-05-15 23:18:53 -07:00
committed by gsxdsm
parent d733b01925
commit 1eef42a912
5 changed files with 187 additions and 0 deletions

View File

@@ -297,6 +297,47 @@ describe("MailboxView", () => {
});
});
it("renders worktrunk install details for worktrunk approvals", async () => {
const now = new Date().toISOString();
mockFetchInbox.mockResolvedValue({ messages: [], unreadCount: 0, total: 0 });
mockFetchApprovals.mockResolvedValue({
requests: [{ id: "apr-1", status: "pending", actionCategory: "network_api", actionSummary: "Install worktrunk", agentId: "user", createdAt: now, updatedAt: now }],
total: 1,
pendingCount: 1,
});
mockFetchApprovalDetail.mockResolvedValue({
id: "apr-1", status: "pending", actionCategory: "network_api", actionSummary: "Install worktrunk", agentId: "user", createdAt: now, updatedAt: now,
requester: { actorId: "user", actorType: "user", actorName: "User" }, requestedAt: now,
targetAction: {
category: "network_api",
action: "worktrunk_install",
summary: "Install worktrunk",
resourceType: "binary",
resourceId: "~/.fusion/bin/worktrunk",
context: {
version: "v1.2.3",
installPath: "~/.fusion/bin/worktrunk",
assets: {
darwin_arm64: {
url: "https://example.com/worktrunk.tar.gz",
sha256: "abc123",
},
},
},
},
history: [{ id: "evt-1", eventType: "created", actor: { actorId: "user", actorType: "user", actorName: "User" }, createdAt: now }],
});
render(<MailboxView {...defaultProps} />);
await act(async () => { fireEvent.click(screen.getByTestId("mailbox-tab-approvals")); });
await act(async () => { fireEvent.click(await screen.findByTestId("mailbox-approval-item-apr-1")); });
await waitFor(() => {
expect(screen.getByTestId("worktrunk-install-approval-details")).toBeInTheDocument();
expect(screen.getByText("v1.2.3")).toBeInTheDocument();
});
});
it("allows approving a pending approval request", async () => {
const now = new Date().toISOString();
mockFetchInbox.mockResolvedValue({ messages: [], unreadCount: 0, total: 0 });

View File

@@ -0,0 +1,49 @@
import { describe, it, expect } from "vitest";
import { render, screen } from "@testing-library/react";
import { WorktrunkInstallApprovalDetails } from "../WorktrunkInstallApprovalDetails";
import type { ApprovalRequestDetail } from "../../api";
describe("WorktrunkInstallApprovalDetails", () => {
it("renders version, URL, sha, and install path", () => {
const targetAction: ApprovalRequestDetail["targetAction"] = {
category: "network_api",
action: "worktrunk_install",
summary: "Install worktrunk",
resourceType: "binary",
resourceId: "~/.fusion/bin/worktrunk",
context: {
version: "v1.2.3",
installPath: "~/.fusion/bin/worktrunk",
assets: {
darwin_arm64: {
url: "https://example.com/worktrunk.tar.gz",
sha256: "abc123",
},
},
},
};
render(<WorktrunkInstallApprovalDetails targetAction={targetAction} />);
expect(screen.getByText("Worktrunk install request")).toBeInTheDocument();
expect(screen.getByText("v1.2.3")).toBeInTheDocument();
expect(screen.getByText("https://example.com/worktrunk.tar.gz")).toBeInTheDocument();
expect(screen.getByText("abc123")).toBeInTheDocument();
expect(screen.getAllByText("~/.fusion/bin/worktrunk").length).toBeGreaterThan(0);
});
it("gracefully handles missing context fields", () => {
const targetAction: ApprovalRequestDetail["targetAction"] = {
category: "network_api",
action: "worktrunk_install",
summary: "Install worktrunk",
resourceType: "binary",
resourceId: "~/.fusion/bin/worktrunk",
};
render(<WorktrunkInstallApprovalDetails targetAction={targetAction} />);
expect(screen.getByTestId("worktrunk-install-approval-details")).toBeInTheDocument();
expect(screen.getAllByText("Unknown").length).toBeGreaterThan(0);
});
});