Project dashboard cards now describe engine lifecycle actions directly. - Change project card Pause/Resume controls to Stop engine/Start engine while preserving existing behavior. - Replace the pause icon with a stop-square glyph for the stop action. - Update project card i18n resources, generated resource types, tests, and the release changeset. Files changed: .changeset/fn-7153-stop-engine-label.md | 7 ++ packages/dashboard/app/components/ProjectCard.tsx | 20 ++-- .../app/components/__tests__/ProjectCard.test.tsx | 103 ++++++++++++++++++--- .../__tests__/ProjectThemeTokens.test.tsx | 1 + packages/i18n/locales/en/app.json | 10 +- packages/i18n/locales/es/app.json | 10 +- packages/i18n/locales/fr/app.json | 10 +- packages/i18n/locales/ko/app.json | 10 +- packages/i18n/locales/zh-CN/app.json | 10 +- packages/i18n/locales/zh-TW/app.json | 10 +- packages/i18n/src/resources.d.ts | 74 +++++++++++++-- 11 files changed, 208 insertions(+), 57 deletions(-) Fusion-Task-Id: FN-7153 Fusion-Task-Lineage: 14a4efe7-7538-425e-9759-ded550438df2 Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
136 lines
4.7 KiB
TypeScript
136 lines
4.7 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
|
|
// Import STATUS_CONFIG objects by reading source module internals.
|
|
// Each component exports the config as a module-level constant.
|
|
// We re-import the raw source to inspect the token strings.
|
|
|
|
// ProjectHealthBadge STATUS_CONFIG
|
|
import type { ProjectStatus } from "@fusion/core";
|
|
|
|
// We need to read the actual source to access STATUS_CONFIG.
|
|
// Since STATUS_CONFIG is module-scoped (not exported), we read the source
|
|
// at build time and assert on the token patterns via rendered output.
|
|
|
|
// Instead, we test the rendered output of each component for correct CSS tokens.
|
|
import { render } from "@testing-library/react";
|
|
import { ProjectHealthBadge } from "../ProjectHealthBadge";
|
|
import { ProjectCard } from "../ProjectCard";
|
|
import { ProjectSelector } from "../ProjectSelector";
|
|
import type { RegisteredProject, ProjectHealth } from "@fusion/core";
|
|
import type { ProjectInfo } from "../../../app/api";
|
|
|
|
// Mock lucide-react icons
|
|
vi.mock("lucide-react", () => ({
|
|
Play: () => <span>Play</span>,
|
|
Pause: () => <span>Pause</span>,
|
|
Square: () => <span>Square</span>,
|
|
AlertCircle: () => <span>AlertCircle</span>,
|
|
Loader2: () => <span>Loader2</span>,
|
|
ChevronDown: () => <span>ChevronDown</span>,
|
|
Check: () => <span>Check</span>,
|
|
Folder: () => <span>Folder</span>,
|
|
Grid3X3: () => <span>Grid3X3</span>,
|
|
Search: () => <span>Search</span>,
|
|
Clock: () => <span>Clock</span>,
|
|
X: () => <span>X</span>,
|
|
MoreHorizontal: () => null,
|
|
Trash2: () => <span>Trash2</span>,
|
|
ArrowRight: () => <span>ArrowRight</span>,
|
|
}));
|
|
|
|
describe("Project component CSS theme tokens", () => {
|
|
it("ProjectHealthBadge uses var(--color-error) for errored status, not var(--error)", () => {
|
|
const { container } = render(<ProjectHealthBadge status="errored" />);
|
|
|
|
const badge = container.querySelector("[data-status='errored']") as HTMLElement;
|
|
expect(badge).toBeTruthy();
|
|
|
|
const style = badge.style;
|
|
// The color property should use the correct token
|
|
expect(style.color).toBe("var(--color-error)");
|
|
// Must NOT use the undefined bare token
|
|
expect(style.color).not.toBe("var(--error)");
|
|
expect(style.borderColor).toBe("var(--color-error)");
|
|
expect(style.borderColor).not.toBe("var(--error)");
|
|
});
|
|
|
|
it("ProjectCard uses var(--color-error) for errored status, not var(--error)", () => {
|
|
const project: RegisteredProject = {
|
|
id: "proj_test",
|
|
name: "Test Project",
|
|
path: "/test/path",
|
|
status: "errored",
|
|
isolationMode: "in-process",
|
|
createdAt: "2026-01-01T00:00:00.000Z",
|
|
updatedAt: "2026-01-01T00:00:00.000Z",
|
|
};
|
|
|
|
const { container } = render(
|
|
<ProjectCard
|
|
project={project}
|
|
health={null}
|
|
onSelect={() => {}}
|
|
onPause={() => {}}
|
|
onResume={() => {}}
|
|
onRemove={() => {}}
|
|
/>
|
|
);
|
|
|
|
const statusBadge = container.querySelector(".project-card-status-badge") as HTMLElement;
|
|
expect(statusBadge).toBeTruthy();
|
|
|
|
const style = statusBadge.style;
|
|
expect(style.color).toBe("var(--color-error)");
|
|
expect(style.color).not.toBe("var(--error)");
|
|
expect(style.borderColor).toBe("var(--color-error)");
|
|
expect(style.borderColor).not.toBe("var(--error)");
|
|
});
|
|
|
|
it("ProjectSelector uses var(--color-error) for errored status, not var(--error)", () => {
|
|
const erroredProject: ProjectInfo = {
|
|
id: "proj_errored",
|
|
name: "Errored Project",
|
|
path: "/test/errored",
|
|
status: "errored",
|
|
isolationMode: "in-process",
|
|
createdAt: "2026-01-01T00:00:00.000Z",
|
|
updatedAt: "2026-01-01T00:00:00.000Z",
|
|
lastActivityAt: new Date().toISOString(),
|
|
};
|
|
|
|
const { container } = render(
|
|
<ProjectSelector
|
|
projects={[
|
|
erroredProject,
|
|
{ ...erroredProject, id: "proj_other", status: "active", name: "Other" },
|
|
]}
|
|
currentProject={erroredProject}
|
|
onSelect={() => {}}
|
|
onViewAll={() => {}}
|
|
/>
|
|
);
|
|
|
|
// ProjectSelector returns null when only 1 project, so we provide 2
|
|
// The trigger shows current project — we check that no var(--error) exists in rendered output
|
|
const html = container.innerHTML;
|
|
expect(html).not.toContain("var(--error)");
|
|
});
|
|
|
|
it("shared project status config uses canonical error tokens only", async () => {
|
|
const fs = await import("fs");
|
|
const path = await import("path");
|
|
|
|
const source = fs.readFileSync(
|
|
path.resolve(__dirname, "../../utils/projectStatusConfig.ts"),
|
|
"utf-8"
|
|
);
|
|
|
|
expect(source, "projectStatusConfig.ts should not contain var(--error)").not.toMatch(
|
|
/var\(--error\)(?!\w)/
|
|
);
|
|
expect(source, "projectStatusConfig.ts should contain var(--color-error)").toContain(
|
|
"var(--color-error)"
|
|
);
|
|
});
|
|
});
|