Files
fusion/packages/dashboard/app/utils/__tests__/prBadgeClass.test.ts
gsxdsm 5b71bdb284 FN-7177: color PR badges by GitHub status
Align dashboard PR badges with live GitHub PR state colors.

- Add a shared PR badge modifier helper for open, draft, merged, closed, and conflict states.\n- Apply the helper to single and multi-PR task card badges so live payload changes repaint correctly.\n- Add token-backed merged/conflict styling, regression coverage, and a patch changeset.

Files changed:\n .changeset/fn-7177-pr-badge-status-color.md        |  7 ++++\n packages/dashboard/app/components/GitHubBadge.tsx  |  8 +++--\n packages/dashboard/app/components/TaskCard.tsx     |  9 +++--\n .../app/components/__tests__/GitHubBadge.test.tsx  |  1 +\n .../app/components/__tests__/TaskCard.test.tsx     | 41 +++++++++++++++++++---\n packages/dashboard/app/styles.css                  | 15 ++++++--\n .../app/utils/__tests__/prBadgeClass.test.ts       | 22 ++++++++++++\n packages/dashboard/app/utils/prBadgeClass.ts       | 28 +++++++++++++++\n 8 files changed, 119 insertions(+), 12 deletions(-)

Fusion-Task-Id: FN-7177

Fusion-Task-Lineage: 23954f1b-d184-49a6-9635-7d9c1d0aea11

Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
2026-06-27 23:47:21 -07:00

23 lines
1.6 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { getPrBadgeModifierClass } from "../prBadgeClass";
describe("getPrBadgeModifierClass", () => {
it.each([
{ name: "open", prInfo: { status: "open" as const }, expectedClass: "card-github-badge--open" },
{ name: "open isDraft", prInfo: { status: "open" as const, isDraft: true }, expectedClass: "card-github-badge--draft" },
{ name: "open draft", prInfo: { status: "open" as const, draft: true }, expectedClass: "card-github-badge--draft" },
{ name: "draft status", prInfo: { status: "draft" as const }, expectedClass: "card-github-badge--draft" },
{ name: "merged", prInfo: { status: "merged" as const }, expectedClass: "card-github-badge--merged" },
{ name: "closed", prInfo: { status: "closed" as const }, expectedClass: "card-github-badge--closed" },
{ name: "conflicting", prInfo: { status: "open" as const, mergeable: "conflicting" as const }, expectedClass: "card-github-badge--conflicting" },
{ name: "blocked", prInfo: { status: "open" as const, mergeable: "blocked" as const }, expectedClass: "card-github-badge--conflicting" },
])("maps $name PR state to $expectedClass", ({ prInfo, expectedClass }) => {
expect(getPrBadgeModifierClass(prInfo)).toBe(expectedClass);
});
it("prioritizes open conflicts over draft and open status colors", () => {
expect(getPrBadgeModifierClass({ status: "open", isDraft: true, mergeable: "conflicting" })).toBe("card-github-badge--conflicting");
expect(getPrBadgeModifierClass({ status: "open", draft: true, mergeable: "blocked" })).toBe("card-github-badge--conflicting");
});
});