|
| 1 | +import { describe, expect, it } from "vitest"; |
| 2 | +import { readFileSync } from "node:fs"; |
| 3 | +import { resolve } from "node:path"; |
| 4 | + |
| 5 | +const sidebarSrc = readFileSync( |
| 6 | + resolve(__dirname, "../../apps/desktop/src/app/shell/AppSidebar.tsx"), |
| 7 | + "utf-8", |
| 8 | +); |
| 9 | + |
| 10 | +// Extract the SessionItem function body for scoped assertions |
| 11 | +const sessionItemStart = sidebarSrc.indexOf("function SessionItem"); |
| 12 | +const sessionItemBody = sidebarSrc.slice(sessionItemStart); |
| 13 | + |
| 14 | +describe("Chat sidebar – active accent bar", () => { |
| 15 | + // AC1: Active chat entry shows a left emerald accent bar |
| 16 | + it("applies border-l-2 with primary color to active chat entry", () => { |
| 17 | + expect(sessionItemBody).toContain("border-l-2"); |
| 18 | + expect(sessionItemBody).toContain("border-primary"); |
| 19 | + }); |
| 20 | + |
| 21 | + // AC2: Inactive entries maintain consistent left alignment (transparent border) |
| 22 | + it("applies transparent left border to inactive entries for consistent alignment", () => { |
| 23 | + expect(sessionItemBody).toContain("border-transparent"); |
| 24 | + }); |
| 25 | + |
| 26 | + // AC3: All entries have a consistent 2px left border (no layout shift) |
| 27 | + it("all entries have border-l-2 regardless of active state", () => { |
| 28 | + // border-l-2 should be applied unconditionally (not inside isActive conditional) |
| 29 | + // Find the className area of the non-editing return path |
| 30 | + const normalReturn = sessionItemBody.indexOf("SidebarMenuButton"); |
| 31 | + const classNameArea = sessionItemBody.slice(normalReturn, normalReturn + 500); |
| 32 | + // border-l-2 should appear as a base class, not gated by isActive |
| 33 | + expect(classNameArea).toMatch(/["'`]border-l-2/); |
| 34 | + }); |
| 35 | + |
| 36 | + // AC4: Active entry uses primary border color and background tint |
| 37 | + it("active entry has background tint with emerald accent", () => { |
| 38 | + expect(sessionItemBody).toContain("bg-primary/[0.08]"); |
| 39 | + }); |
| 40 | + |
| 41 | + // AC5: Active entry has font-medium for text emphasis |
| 42 | + it("active entry has font-medium weight", () => { |
| 43 | + expect(sessionItemBody).toContain("font-medium"); |
| 44 | + }); |
| 45 | +}); |
0 commit comments