|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { readFileSync, existsSync } from "node:fs"; |
| 3 | +import { resolve } from "node:path"; |
| 4 | + |
| 5 | +const dashDir = resolve( |
| 6 | + __dirname, |
| 7 | + "../../apps/desktop/src/features/dashboard", |
| 8 | +); |
| 9 | +const readSrc = (path: string) => |
| 10 | + readFileSync(resolve(dashDir, path), "utf-8"); |
| 11 | + |
| 12 | +// ═══════════════════════════════════════════════════════ |
| 13 | +// 1. JobOrientedInput component |
| 14 | +// ═══════════════════════════════════════════════════════ |
| 15 | + |
| 16 | +describe("JobOrientedInput component", () => { |
| 17 | + const componentPath = resolve(dashDir, "components/JobOrientedInput.tsx"); |
| 18 | + |
| 19 | + it("component file exists", () => { |
| 20 | + expect(existsSync(componentPath)).toBe(true); |
| 21 | + }); |
| 22 | + |
| 23 | + it("exports JobOrientedInput", () => { |
| 24 | + const src = readSrc("components/JobOrientedInput.tsx"); |
| 25 | + expect(src).toContain("export function JobOrientedInput"); |
| 26 | + }); |
| 27 | + |
| 28 | + it("uses job-oriented placeholder framing", () => { |
| 29 | + const src = readSrc("components/JobOrientedInput.tsx"); |
| 30 | + // Must contain job-oriented language, not CMO branding |
| 31 | + expect(src).toMatch(/get.*done|want to produce|marketing job/i); |
| 32 | + }); |
| 33 | + |
| 34 | + it("does NOT use CMO branding", () => { |
| 35 | + const src = readSrc("components/JobOrientedInput.tsx"); |
| 36 | + expect(src).not.toContain("Ask CMO"); |
| 37 | + expect(src).not.toContain("BrainIcon"); |
| 38 | + expect(src).not.toContain('"CMO"'); |
| 39 | + }); |
| 40 | + |
| 41 | + it("has a textarea for multi-line input", () => { |
| 42 | + const src = readSrc("components/JobOrientedInput.tsx"); |
| 43 | + expect(src).toContain("<textarea"); |
| 44 | + }); |
| 45 | + |
| 46 | + it("handles Enter key for submission", () => { |
| 47 | + const src = readSrc("components/JobOrientedInput.tsx"); |
| 48 | + expect(src).toContain("Enter"); |
| 49 | + expect(src).toContain("handleSubmit"); |
| 50 | + }); |
| 51 | + |
| 52 | + it("has a submit button with ArrowRight icon", () => { |
| 53 | + const src = readSrc("components/JobOrientedInput.tsx"); |
| 54 | + expect(src).toContain("ArrowRightIcon"); |
| 55 | + expect(src).toContain("<button"); |
| 56 | + }); |
| 57 | + |
| 58 | + it("accepts onSubmit prop", () => { |
| 59 | + const src = readSrc("components/JobOrientedInput.tsx"); |
| 60 | + expect(src).toContain("onSubmit"); |
| 61 | + }); |
| 62 | + |
| 63 | + it("has a job-oriented section label", () => { |
| 64 | + const src = readSrc("components/JobOrientedInput.tsx"); |
| 65 | + // Should have a section label like "YOUR NEXT MOVE" or similar |
| 66 | + expect(src).toContain("section-label"); |
| 67 | + }); |
| 68 | +}); |
| 69 | + |
| 70 | +// ═══════════════════════════════════════════════════════ |
| 71 | +// 2. DashboardWorkspace integration |
| 72 | +// ═══════════════════════════════════════════════════════ |
| 73 | + |
| 74 | +describe("DashboardWorkspace integrates JobOrientedInput", () => { |
| 75 | + it("imports JobOrientedInput", () => { |
| 76 | + const src = readSrc("components/DashboardWorkspace.tsx"); |
| 77 | + expect(src).toContain("JobOrientedInput"); |
| 78 | + }); |
| 79 | + |
| 80 | + it("renders JobOrientedInput after RecommendedJobs", () => { |
| 81 | + const src = readSrc("components/DashboardWorkspace.tsx"); |
| 82 | + const jobsIdx = src.indexOf("RecommendedJobs"); |
| 83 | + const inputIdx = src.indexOf("JobOrientedInput", jobsIdx); |
| 84 | + const rosterIdx = src.indexOf("DashboardAgentRoster", inputIdx); |
| 85 | + // JobOrientedInput appears between RecommendedJobs and DashboardAgentRoster |
| 86 | + expect(inputIdx).toBeGreaterThan(jobsIdx); |
| 87 | + expect(rosterIdx).toBeGreaterThan(inputIdx); |
| 88 | + }); |
| 89 | + |
| 90 | + it("passes handleFreeTextSubmit to JobOrientedInput", () => { |
| 91 | + const src = readSrc("components/DashboardWorkspace.tsx"); |
| 92 | + expect(src).toMatch(/JobOrientedInput[\s\S]*?handleFreeTextSubmit/); |
| 93 | + }); |
| 94 | +}); |
0 commit comments