|
| 1 | +// @vitest-environment node |
| 2 | +import { readFileSync } from "node:fs"; |
| 3 | +import { describe, expect, it } from "vitest"; |
| 4 | + |
| 5 | +const stylesheet = readFileSync(`${process.cwd()}/src/styles/components.css`, "utf8"); |
| 6 | + |
| 7 | +function getRuleBlocks(selector: string) { |
| 8 | + const blocks: string[] = []; |
| 9 | + const matcher = /([^{}]+)\{([^}]*)\}/g; |
| 10 | + const normalizedSelector = selector.replace(/\s+/g, " ").trim(); |
| 11 | + let match: RegExpExecArray | null = null; |
| 12 | + |
| 13 | + while ((match = matcher.exec(stylesheet)) !== null) { |
| 14 | + const selectors = match[1] |
| 15 | + .replace(/\/\*[\s\S]*?\*\//g, "") |
| 16 | + .split(",") |
| 17 | + .map((entry) => entry.replace(/\s+/g, " ").trim()); |
| 18 | + |
| 19 | + if (selectors.includes(normalizedSelector)) { |
| 20 | + blocks.push(match[2]); |
| 21 | + } |
| 22 | + } |
| 23 | + |
| 24 | + if (blocks.length === 0) { |
| 25 | + throw new Error(`expected CSS rule for ${selector}`); |
| 26 | + } |
| 27 | + |
| 28 | + return blocks; |
| 29 | +} |
| 30 | + |
| 31 | +describe("pane-layout vertical divider styles", () => { |
| 32 | + it("keeps stacked pane dividers visible on shared workspace surfaces", () => { |
| 33 | + const divider = getRuleBlocks(".pane-layout-vertical-divider").join("\n"); |
| 34 | + const dividerLine = getRuleBlocks(".pane-layout-vertical-divider::after").join("\n"); |
| 35 | + |
| 36 | + expect(divider).toContain("width: 100%"); |
| 37 | + expect(divider).toContain("height: 10px"); |
| 38 | + expect(divider).toContain("margin-top: -5px"); |
| 39 | + expect(divider).toContain("margin-bottom: -5px"); |
| 40 | + expect(divider).toContain("background: linear-gradient("); |
| 41 | + expect(divider).toContain("var(--component-mix-status-info-fg-24pct-transparent)"); |
| 42 | + expect(dividerLine).toContain("var(--component-mix-border-default-78pct-status-info-fg-22pct)"); |
| 43 | + }); |
| 44 | +}); |
0 commit comments