|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { readFileSync } from "node:fs"; |
| 3 | +import { resolve } from "node:path"; |
| 4 | + |
| 5 | +const agentsDir = resolve( |
| 6 | + __dirname, |
| 7 | + "../../../apps/desktop/src/features/agents", |
| 8 | +); |
| 9 | +const readSrc = (path: string) => |
| 10 | + readFileSync(resolve(agentsDir, path), "utf-8"); |
| 11 | + |
| 12 | +const specialistCardSrc = readSrc("components/SpecialistCard.tsx"); |
| 13 | + |
| 14 | +// --------------------------------------------------------------------------- |
| 15 | +// Activity status — "ACTIVE" badge for specialists with recent (24h) outputs |
| 16 | +// --------------------------------------------------------------------------- |
| 17 | +describe("SpecialistCard activity status badge", () => { |
| 18 | + it("checks whether outputs are recent (within 24 hours)", () => { |
| 19 | + // Should have logic comparing output timestamps to determine recency |
| 20 | + expect(specialistCardSrc).toMatch(/24\s*\*\s*60\s*\*\s*60\s*\*\s*1000|86[_,]?400[_,]?000/); |
| 21 | + }); |
| 22 | + |
| 23 | + it("renders an ACTIVE badge for specialists with recent activity", () => { |
| 24 | + expect(specialistCardSrc).toContain("ACTIVE"); |
| 25 | + }); |
| 26 | + |
| 27 | + it("uses emerald accent for the active badge", () => { |
| 28 | + // The active badge should use primary/emerald styling |
| 29 | + expect(specialistCardSrc).toMatch(/bg-primary|bg-emerald/); |
| 30 | + }); |
| 31 | + |
| 32 | + it("uses monospace font for the active badge (consistent with LEAD badge)", () => { |
| 33 | + // Active badge should use same styling pattern as the LEAD badge |
| 34 | + expect(specialistCardSrc).toMatch(/font-mono.*ACTIVE|ACTIVE.*font-mono/s); |
| 35 | + }); |
| 36 | + |
| 37 | + it("only shows ACTIVE badge on non-manager specialists", () => { |
| 38 | + // Should check isManager before rendering the ACTIVE badge |
| 39 | + // The ACTIVE badge should be in a conditional that excludes managers |
| 40 | + expect(specialistCardSrc).toMatch(/!isManager.*ACTIVE/s); |
| 41 | + }); |
| 42 | +}); |
| 43 | + |
| 44 | +// --------------------------------------------------------------------------- |
| 45 | +// Activity status — "Start your first conversation" for unused specialists |
| 46 | +// --------------------------------------------------------------------------- |
| 47 | +describe("SpecialistCard unused specialist prompt", () => { |
| 48 | + it("renders a prompt for unused specialists", () => { |
| 49 | + expect(specialistCardSrc).toMatch(/Start your first conversation/i); |
| 50 | + }); |
| 51 | + |
| 52 | + it("uses muted styling for the unused prompt", () => { |
| 53 | + // Should use muted-foreground or similar subdued styling |
| 54 | + expect(specialistCardSrc).toMatch(/text-muted-foreground/); |
| 55 | + }); |
| 56 | + |
| 57 | + it("uses monospace font for the unused prompt", () => { |
| 58 | + expect(specialistCardSrc).toMatch(/font-mono.*Start your first conversation|Start your first conversation.*font-mono/si); |
| 59 | + }); |
| 60 | + |
| 61 | + it("only shows unused prompt when there are no outputs (not on managers)", () => { |
| 62 | + // Should conditionally render based on hasOutputs being false |
| 63 | + expect(specialistCardSrc).toMatch(/!hasOutputs|hasOutputs.*false/s); |
| 64 | + }); |
| 65 | +}); |
0 commit comments