|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { readFileSync } from "node:fs"; |
| 3 | +import { resolve } from "node:path"; |
| 4 | + |
| 5 | +const desktopSrc = resolve(__dirname, "../../apps/desktop/src"); |
| 6 | +const readFile = (relPath: string) => |
| 7 | + readFileSync(resolve(desktopSrc, relPath), "utf-8"); |
| 8 | + |
| 9 | +// ═══════════════════════════════════════════════════════ |
| 10 | +// 1. Complete section order — all 7 sections |
| 11 | +// ═══════════════════════════════════════════════════════ |
| 12 | + |
| 13 | +describe("Dashboard section order — all 7 sections", () => { |
| 14 | + const dashSrc = () => readFile("features/dashboard/components/DashboardWorkspace.tsx"); |
| 15 | + |
| 16 | + it("renders all 7 sections in correct order: Hero, Jobs, Input, Roster, Outputs, Continue, Board", () => { |
| 17 | + const src = dashSrc(); |
| 18 | + const heroIdx = src.indexOf("<CompanyUnderstandingHero"); |
| 19 | + const jobsIdx = src.indexOf("<RecommendedJobs"); |
| 20 | + const inputIdx = src.indexOf("<JobOrientedInput"); |
| 21 | + const rosterIdx = src.indexOf("<DashboardAgentRoster"); |
| 22 | + const outputsIdx = src.indexOf("<RecentOutputs"); |
| 23 | + const continueIdx = src.indexOf("<ContinueWhereYouLeftOff"); |
| 24 | + const boardIdx = src.indexOf("<BoardSummary"); |
| 25 | + |
| 26 | + // All 7 must exist |
| 27 | + expect(heroIdx).toBeGreaterThan(-1); |
| 28 | + expect(jobsIdx).toBeGreaterThan(-1); |
| 29 | + expect(inputIdx).toBeGreaterThan(-1); |
| 30 | + expect(rosterIdx).toBeGreaterThan(-1); |
| 31 | + expect(outputsIdx).toBeGreaterThan(-1); |
| 32 | + expect(continueIdx).toBeGreaterThan(-1); |
| 33 | + expect(boardIdx).toBeGreaterThan(-1); |
| 34 | + |
| 35 | + // Correct order: 1 < 2 < 3 < 4 < 5 < 6 < 7 |
| 36 | + expect(heroIdx).toBeLessThan(jobsIdx); |
| 37 | + expect(jobsIdx).toBeLessThan(inputIdx); |
| 38 | + expect(inputIdx).toBeLessThan(rosterIdx); |
| 39 | + expect(rosterIdx).toBeLessThan(outputsIdx); |
| 40 | + expect(outputsIdx).toBeLessThan(continueIdx); |
| 41 | + expect(continueIdx).toBeLessThan(boardIdx); |
| 42 | + }); |
| 43 | + |
| 44 | + it("JobOrientedInput appears between RecommendedJobs and DashboardAgentRoster", () => { |
| 45 | + const src = dashSrc(); |
| 46 | + const jobsIdx = src.indexOf("<RecommendedJobs"); |
| 47 | + const inputIdx = src.indexOf("<JobOrientedInput"); |
| 48 | + const rosterIdx = src.indexOf("<DashboardAgentRoster"); |
| 49 | + |
| 50 | + expect(inputIdx).toBeGreaterThan(jobsIdx); |
| 51 | + expect(inputIdx).toBeLessThan(rosterIdx); |
| 52 | + }); |
| 53 | +}); |
| 54 | + |
| 55 | +// ═══════════════════════════════════════════════════════ |
| 56 | +// 2. ContinueWhereYouLeftOff receives maturity prop |
| 57 | +// ═══════════════════════════════════════════════════════ |
| 58 | + |
| 59 | +describe("ContinueWhereYouLeftOff maturity-aware demotion", () => { |
| 60 | + const dashSrc = () => readFile("features/dashboard/components/DashboardWorkspace.tsx"); |
| 61 | + const continueSrc = () => readFile("features/dashboard/components/ContinueWhereYouLeftOff.tsx"); |
| 62 | + |
| 63 | + it("DashboardWorkspace passes maturity prop to ContinueWhereYouLeftOff", () => { |
| 64 | + const src = dashSrc(); |
| 65 | + // The JSX should pass maturity={maturity} or maturity= |
| 66 | + expect(src).toMatch(/<ContinueWhereYouLeftOff[\s\S]*?maturity[=]/); |
| 67 | + }); |
| 68 | + |
| 69 | + it("ContinueWhereYouLeftOff accepts a maturity prop", () => { |
| 70 | + const src = continueSrc(); |
| 71 | + expect(src).toContain("maturity"); |
| 72 | + }); |
| 73 | + |
| 74 | + it("ContinueWhereYouLeftOff hides empty state for non-active maturity", () => { |
| 75 | + const src = continueSrc(); |
| 76 | + // Should return null when items are empty and maturity is not active |
| 77 | + expect(src).toMatch(/items\.length\s*===\s*0/); |
| 78 | + expect(src).toMatch(/return\s+null/); |
| 79 | + }); |
| 80 | + |
| 81 | + it("ContinueWhereYouLeftOff uses neutral (non-primary) border styling", () => { |
| 82 | + const src = continueSrc(); |
| 83 | + // Populated state should NOT use primary-color border — should be neutral |
| 84 | + expect(src).not.toMatch(/border-primary\/10/); |
| 85 | + }); |
| 86 | + |
| 87 | + it("ContinueWhereYouLeftOff hover uses neutral colors, not primary", () => { |
| 88 | + const src = continueSrc(); |
| 89 | + // Hover on items should be neutral, not primary-tinted |
| 90 | + expect(src).not.toMatch(/hover:bg-primary/); |
| 91 | + }); |
| 92 | +}); |
| 93 | + |
| 94 | +// ═══════════════════════════════════════════════════════ |
| 95 | +// 3. BoardSummary demotion verification |
| 96 | +// ═══════════════════════════════════════════════════════ |
| 97 | + |
| 98 | +describe("BoardSummary demotion", () => { |
| 99 | + const dashSrc = () => readFile("features/dashboard/components/DashboardWorkspace.tsx"); |
| 100 | + const boardSrc = () => readFile("features/dashboard/components/BoardSummary.tsx"); |
| 101 | + |
| 102 | + it("BoardSummary is gated by maturity !== 'new'", () => { |
| 103 | + const src = dashSrc(); |
| 104 | + expect(src).toMatch(/maturity\s*!==\s*['"]new['"]/); |
| 105 | + }); |
| 106 | + |
| 107 | + it("BoardSummary uses neutral border, not accent/primary", () => { |
| 108 | + const src = boardSrc(); |
| 109 | + // Should use neutral border colors |
| 110 | + expect(src).toMatch(/border-border|border-white/); |
| 111 | + // Should NOT use primary-colored borders on the outer container |
| 112 | + expect(src).not.toMatch(/border-primary/); |
| 113 | + }); |
| 114 | + |
| 115 | + it("BoardSummary returns null when empty", () => { |
| 116 | + const src = boardSrc(); |
| 117 | + expect(src).toMatch(/isEmpty[\s\S]*?return\s+null/); |
| 118 | + }); |
| 119 | +}); |
| 120 | + |
| 121 | +// ═══════════════════════════════════════════════════════ |
| 122 | +// 4. Action-first layout: jobs/outputs visually heavier than continue/board |
| 123 | +// ═══════════════════════════════════════════════════════ |
| 124 | + |
| 125 | +describe("Action-first layout hierarchy", () => { |
| 126 | + const dashSrc = () => readFile("features/dashboard/components/DashboardWorkspace.tsx"); |
| 127 | + |
| 128 | + it("RecommendedJobs is wrapped in dashboard-section", () => { |
| 129 | + const src = dashSrc(); |
| 130 | + expect(src).toMatch(/dashboard-section[\s\S]*?<RecommendedJobs/); |
| 131 | + }); |
| 132 | + |
| 133 | + it("JobOrientedInput is wrapped in dashboard-section", () => { |
| 134 | + const src = dashSrc(); |
| 135 | + expect(src).toMatch(/dashboard-section[\s\S]*?<JobOrientedInput/); |
| 136 | + }); |
| 137 | + |
| 138 | + it("DashboardAgentRoster is wrapped in dashboard-section", () => { |
| 139 | + const src = dashSrc(); |
| 140 | + expect(src).toMatch(/dashboard-section[\s\S]*?<DashboardAgentRoster/); |
| 141 | + }); |
| 142 | + |
| 143 | + it("BoardSummary is wrapped in dashboard-section", () => { |
| 144 | + const src = dashSrc(); |
| 145 | + expect(src).toMatch(/dashboard-section[\s\S]*?<BoardSummary/); |
| 146 | + }); |
| 147 | +}); |
0 commit comments