wacrm/src/lib/broadcast-status.test.ts
Arnas Donauskas 32022c13fe
feat(theme): sweep remaining violet-* → primary across all surfaces
PR #132 (color themes) only tokenized the high-visibility chrome.
Inbox / contacts / pipelines / broadcasts / automations / auth /
settings sub-forms still had ~150 hard-coded `violet-*` classes
across ~32 files, so picking a non-violet theme felt half-broken —
sidebar and header changed colour, but message bubbles, deal cards,
and the broadcast wizard all stayed violet.

This is the mechanical follow-up: replace every `violet-N(/N)?`
with `primary(/N)?` so the theme picker themes the whole app.

Two non-trivial swaps inside the pass:
- `text-white` on a `bg-primary` button → `text-primary-foreground`.
  Emerald and Amber define a *dark* `--primary-foreground` because
  their primaries are bright; `text-white` over those would tank
  contrast.
- `bg-primary hover:bg-primary` (hover identical to base — original
  code had this latent bug from `hover:bg-violet-500`) → adds `/90`
  on hover so the lift is visible.

Test update:
- `broadcast-status.test.ts` asserted shade numbers (`bg-X-N/10`).
  Relaxed the regex to also accept token form (`bg-X/10`) since
  brand-accent status badges now ride the active theme.

Files touched: 49. Lint clean (existing warnings only), 173/173
tests, typecheck + build green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-22 17:00:32 +03:00

52 lines
1.8 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
broadcastStatusConfig,
getBroadcastStatus,
getRecipientStatus,
recipientStatusConfig,
} from "./broadcast-status";
describe("getBroadcastStatus", () => {
it("returns the matching config for known statuses", () => {
expect(getBroadcastStatus("sending")).toBe(broadcastStatusConfig.sending);
expect(getBroadcastStatus("sent")).toBe(broadcastStatusConfig.sent);
expect(getBroadcastStatus("failed")).toBe(broadcastStatusConfig.failed);
});
it("flags `sending` as a live/pulsing state", () => {
expect(getBroadcastStatus("sending").pulse).toBe(true);
expect(getBroadcastStatus("sent").pulse).toBeFalsy();
});
it("falls back to draft on an unknown status string", () => {
expect(getBroadcastStatus("not-a-real-status")).toBe(
broadcastStatusConfig.draft,
);
expect(getBroadcastStatus("")).toBe(broadcastStatusConfig.draft);
});
it("each variant has the dark-theme class triple", () => {
// Accept both fixed-shade Tailwind names (bg-red-500/10) and
// token-backed names without a shade number (bg-primary/10) since
// the brand-accent statuses now ride the active color theme.
for (const v of Object.values(broadcastStatusConfig)) {
expect(v.classes).toMatch(/bg-[a-z]+(-\d+)?\/10/);
expect(v.classes).toMatch(/text-[a-z]+(-\d+)?/);
expect(v.classes).toMatch(/border-[a-z]+(-\d+)?\/20/);
}
});
});
describe("getRecipientStatus", () => {
it("returns the matching config for known statuses", () => {
expect(getRecipientStatus("delivered")).toBe(
recipientStatusConfig.delivered,
);
expect(getRecipientStatus("read")).toBe(recipientStatusConfig.read);
});
it("falls back to pending on an unknown status string", () => {
expect(getRecipientStatus("???")).toBe(recipientStatusConfig.pending);
});
});