|
| 1 | +import assert from "node:assert/strict"; |
| 2 | +import test from "node:test"; |
| 3 | + |
| 4 | +import { |
| 5 | + isThreadRailVisible, |
| 6 | + projectThreadRailLayout, |
| 7 | + threadRailEntryClassName, |
| 8 | + threadRailHeaderClassName, |
| 9 | + threadRailShellClassName, |
| 10 | +} from "./threadRailLayout.ts"; |
| 11 | + |
| 12 | +test("isThreadRailVisible hides the rail at and below the desktop breakpoint", () => { |
| 13 | + assert.equal(isThreadRailVisible(600, 1), false); |
| 14 | + assert.equal(isThreadRailVisible(599, 1), false); |
| 15 | + assert.equal(isThreadRailVisible(601, 1), true); |
| 16 | + assert.equal(isThreadRailVisible(601, 0), false); |
| 17 | +}); |
| 18 | + |
| 19 | +test("Thread Rail uses one native rounded surface at the content bounds", () => { |
| 20 | + for (const collapsed of [false, true]) { |
| 21 | + const className = threadRailShellClassName(collapsed); |
| 22 | + |
| 23 | + assert.match(className, /mt-px/); |
| 24 | + assert.match(className, /mb-2/); |
| 25 | + assert.match(className, /h-\[calc\(100%-0\.5625rem\)\]/); |
| 26 | + assert.match(className, /self-start/); |
| 27 | + assert.match(className, /rounded-2xl/); |
| 28 | + assert.match(className, /overflow-hidden/); |
| 29 | + assert.match(className, /bg-background(?!\/)/); |
| 30 | + assert.match(className, /shadow-content-edge/); |
| 31 | + assert.match(className, /ring-border\/30/); |
| 32 | + assert.match(className, /ring-inset/); |
| 33 | + assert.doesNotMatch(className, /clip-path/); |
| 34 | + assert.doesNotMatch(className, /self-stretch/); |
| 35 | + assert.doesNotMatch(className, /\bmy-2\b/); |
| 36 | + } |
| 37 | +}); |
| 38 | + |
| 39 | +test("Thread Rail header and rows use native panel density and one full-width selection surface", () => { |
| 40 | + const headerClassName = threadRailHeaderClassName(); |
| 41 | + assert.match(headerClassName, /min-h-13/); |
| 42 | + assert.doesNotMatch(headerClassName, /border-b/); |
| 43 | + |
| 44 | + const idleEntryClassName = threadRailEntryClassName(false); |
| 45 | + const activeEntryClassName = threadRailEntryClassName(true); |
| 46 | + assert.match(idleEntryClassName, /rounded-lg/); |
| 47 | + assert.match(idleEntryClassName, /hover:bg-muted/); |
| 48 | + assert.match(activeEntryClassName, /bg-muted/); |
| 49 | +}); |
| 50 | + |
| 51 | +test("projectThreadRailLayout keeps pin count and exposes collapse state", () => { |
| 52 | + const pins = [ |
| 53 | + { channelId: "channel-a", rootId: "root-a", pinnedAt: 100 }, |
| 54 | + { channelId: "channel-b", rootId: "root-b", pinnedAt: 200 }, |
| 55 | + ]; |
| 56 | + |
| 57 | + assert.deepEqual(projectThreadRailLayout({ collapsed: false, pins }, 800), { |
| 58 | + visible: true, |
| 59 | + pinCount: 2, |
| 60 | + collapsed: false, |
| 61 | + collapseControl: { expanded: true, label: "Collapse pinned threads" }, |
| 62 | + }); |
| 63 | + assert.deepEqual(projectThreadRailLayout({ collapsed: true, pins }, 800), { |
| 64 | + visible: true, |
| 65 | + pinCount: 2, |
| 66 | + collapsed: true, |
| 67 | + collapseControl: { expanded: false, label: "Expand 2 pinned threads" }, |
| 68 | + }); |
| 69 | +}); |
0 commit comments