Skip to content

Commit 7bf34d7

Browse files
test: retain behavioral presentation coverage
1 parent 0b8dc7f commit 7bf34d7

4 files changed

Lines changed: 137 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { renderToStaticMarkup } from "react-dom/server";
2+
import { describe, expect, it } from "vite-plus/test";
3+
4+
import { PanelLayoutControls } from "./PanelLayoutControls";
5+
6+
describe("PanelLayoutControls", () => {
7+
it("keeps unavailable panel tooltip triggers interactive", () => {
8+
const markup = renderToStaticMarkup(
9+
<PanelLayoutControls
10+
showTerminalControl
11+
terminalAvailable={false}
12+
terminalOpen={false}
13+
terminalShortcutLabel={null}
14+
rightPanelAvailable={false}
15+
rightPanelOpen={false}
16+
rightPanelShortcutLabel={null}
17+
liveAgentCount={0}
18+
onToggleTerminal={() => {}}
19+
onToggleRightPanel={() => {}}
20+
/>,
21+
);
22+
23+
expect(markup.match(/data-slot="tooltip-trigger"/g)).toHaveLength(2);
24+
expect(markup.match(/data-slot="tooltip-trigger"[^>]*><button[^>]*disabled=""/g)).toHaveLength(
25+
2,
26+
);
27+
});
28+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { renderToStaticMarkup } from "react-dom/server";
2+
import { describe, expect, it, vi } from "vite-plus/test";
3+
4+
import { PreviewChromeRow } from "./PreviewChromeRow";
5+
6+
describe("PreviewChromeRow", () => {
7+
it("shows the complete URL while the address bar is not focused", () => {
8+
const markup = renderToStaticMarkup(
9+
<PreviewChromeRow
10+
url="https://example.com/dashboard?mode=edit&tab=1#notes"
11+
loading={false}
12+
canGoBack={false}
13+
canGoForward={false}
14+
refreshDisabled={false}
15+
onBack={vi.fn()}
16+
onForward={vi.fn()}
17+
onRefresh={vi.fn()}
18+
onSubmit={vi.fn()}
19+
/>,
20+
);
21+
22+
expect(markup).toContain('value="https://example.com/dashboard?mode=edit&amp;tab=1#notes"');
23+
});
24+
});
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { renderToStaticMarkup } from "react-dom/server";
2+
import { describe, expect, it } from "vite-plus/test";
3+
import { FlaskConicalIcon } from "lucide-react";
4+
5+
import { Button } from "./button";
6+
7+
describe("button geometry tokens", () => {
8+
it("uses the shared control radius and an opaque semantic icon color", () => {
9+
const html = renderToStaticMarkup(
10+
<Button size="icon-xs" variant="outline" aria-label="Run tests">
11+
<FlaskConicalIcon />
12+
</Button>,
13+
);
14+
15+
expect(html).toContain("rounded-[var(--control-radius)]");
16+
expect(html).toContain("[--control-icon-color:var(--contrast-muted-foreground)]");
17+
expect(html).toContain("text-[var(--control-icon-color)]");
18+
expect(html).not.toContain("opacity-80");
19+
});
20+
21+
it("keeps compact icon buttons square at every breakpoint", () => {
22+
const html = renderToStaticMarkup(
23+
<Button size="icon-xs" aria-label="Add action">
24+
<span>+</span>
25+
</Button>,
26+
);
27+
28+
expect(html).toContain("size-7");
29+
expect(html).toContain("sm:size-6");
30+
});
31+
32+
it("owns shared compact and micro control geometry", () => {
33+
const compact = renderToStaticMarkup(<Button size="compact">Condition</Button>);
34+
const microLabel = renderToStaticMarkup(
35+
<Button size="micro">
36+
<FlaskConicalIcon /> Run
37+
</Button>,
38+
);
39+
const micro = renderToStaticMarkup(
40+
<Button size="icon-micro" variant="ghost-muted" aria-label="Add action">
41+
<span>+</span>
42+
</Button>,
43+
);
44+
45+
expect(compact).toContain("h-7");
46+
expect(compact).toContain("rounded-md");
47+
expect(microLabel).toContain("text-[11px]");
48+
expect(microLabel).toContain("sm:text-[11px]");
49+
expect(microLabel).toContain("sm:[&amp;_svg:not([class*=&#x27;size-&#x27;])]:size-3");
50+
expect(micro).toContain("size-5");
51+
expect(micro).toContain("rounded-sm");
52+
expect(micro).toContain("text-muted-foreground");
53+
});
54+
});
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { renderToStaticMarkup } from "react-dom/server";
2+
import { describe, expect, it } from "vite-plus/test";
3+
4+
import { Command, CommandFooter, CommandInput } from "./command";
5+
6+
describe("command compact geometry", () => {
7+
it("keeps shell selectors on the wrapper and direct-input padding on AutocompleteInput", () => {
8+
const html = renderToStaticMarkup(
9+
<Command>
10+
<CommandInput placeholder="Search commands" />
11+
</Command>,
12+
);
13+
const shellClass = html.match(/class="([^"]*px-\[var\(--command-shell-inset\)[^"]*)"/)?.[1];
14+
const inputClass = html.match(/class="([^"]*has-focus-visible:ring-0[^"]*)"/)?.[1];
15+
16+
expect(shellClass).toContain(
17+
"[&amp;_[data-slot=autocomplete-start-addon]]:ps-[calc(var(--command-shell-inset)+0.0625rem)]",
18+
);
19+
expect(shellClass).not.toContain("sm:*:data-[slot=autocomplete-input]");
20+
expect(inputClass).toContain(
21+
"sm:*:data-[slot=autocomplete-input]:ps-[calc(var(--command-shell-inset)+1.5rem)]!",
22+
);
23+
});
24+
25+
it("uses the semantic footer inset without changing compact vertical padding", () => {
26+
const html = renderToStaticMarkup(<CommandFooter>Shortcuts</CommandFooter>);
27+
28+
expect(html).toContain("px-[var(--command-content-inset)]");
29+
expect(html).toContain("py-2.5");
30+
});
31+
});

0 commit comments

Comments
 (0)