Files
fusion/packages/dashboard/app/components/__tests__/ProjectHealthBadge.test.tsx
gsxdsm f20c37471d FN-5881: guard project status badges against unknown states
Prevent Projects view status rendering from crashing on unknown or missing project states.

- add fallback status config helpers to ProjectCard, ProjectHealthBadge, and ProjectSelector
- format unknown status strings into readable labels and default missing values to Unknown
- add regression tests for unknown and missing statuses across project dashboard components
- document graceful degradation for transient registry or health status mismatches

Files changed:
 docs/multi-project.md                              |  1 +
 packages/dashboard/app/components/ProjectCard.tsx  | 36 ++++++++++++++++-
 .../app/components/ProjectHealthBadge.tsx          | 36 ++++++++++++++++-
 .../dashboard/app/components/ProjectSelector.tsx   | 15 ++++++-
 .../app/components/__tests__/ProjectCard.test.tsx  | 31 +++++++++++++-
 .../__tests__/ProjectHealthBadge.test.tsx          | 47 ++++++++++++++++++++++
 .../components/__tests__/ProjectSelector.test.tsx  | 24 ++++++++++-
 7 files changed, 182 insertions(+), 8 deletions(-)

Fusion-Task-Id: FN-5881

Fusion-Task-Lineage: 55a9df6f-3fcb-46e8-9e83-3494312b4c24
2026-06-02 08:49:25 -07:00

48 lines
1.6 KiB
TypeScript

import { describe, it, expect, vi } from "vitest";
import { render, screen } from "@testing-library/react";
import { ProjectHealthBadge } from "../ProjectHealthBadge";
import type { ProjectHealth, ProjectStatus } from "@fusion/core";
vi.mock("lucide-react", () => ({
Play: () => <span data-testid="play-icon"></span>,
Pause: () => <span data-testid="pause-icon"></span>,
AlertCircle: () => <span data-testid="alert-icon"></span>,
Loader2: () => <span data-testid="loader-icon"></span>,
}));
function makeHealth(overrides: Partial<ProjectHealth> = {}): ProjectHealth {
return {
projectId: "proj_abc123",
status: "active",
activeTaskCount: 2,
inFlightAgentCount: 1,
totalTasksCompleted: 10,
totalTasksFailed: 0,
updatedAt: "2026-01-01T00:00:00.000Z",
...overrides,
};
}
describe("ProjectHealthBadge", () => {
it("renders a fallback badge for unknown or missing statuses", () => {
expect(() => {
render(
<>
<ProjectHealthBadge
status={"removing" as ProjectStatus}
health={makeHealth({ status: "removing" as ProjectStatus })}
/>
<ProjectHealthBadge
status={undefined as unknown as ProjectStatus}
health={makeHealth({ projectId: "proj_missing", status: undefined as unknown as ProjectStatus })}
/>
</>
);
}).not.toThrow();
expect(screen.getByText("Removing")).toBeDefined();
expect(screen.getByText("Unknown")).toBeDefined();
expect(screen.getAllByTestId("alert-icon")).toHaveLength(2);
});
});