Skip to content

Commit 5f763d7

Browse files
committed
fix: disable hidden homepage tour controls
1 parent 35bef43 commit 5f763d7

2 files changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { JSDOM } from "jsdom";
2+
import { createElement } from "react";
3+
import { renderToStaticMarkup } from "react-dom/server";
4+
import { describe, expect, it } from "vitest";
5+
import { DesktopDemo } from "@/components/pages/HomeTwo/demo/DesktopDemo";
6+
7+
describe("homepage demo keyboard controls", () => {
8+
it("keeps hidden controls inert until the visitor starts the tour", () => {
9+
const dom = new JSDOM(renderToStaticMarkup(createElement(DesktopDemo)));
10+
try {
11+
const buttons = [...dom.window.document.querySelectorAll("button")];
12+
for (const label of [
13+
"Jump to Instant Mode",
14+
"Jump to Studio Mode",
15+
"Jump to The Editor",
16+
"Skip demo",
17+
"Restart demo",
18+
"Start recording",
19+
"Stop recording",
20+
"Export the recording",
21+
]) {
22+
const button = buttons.find(
23+
(candidate) =>
24+
(candidate.getAttribute("aria-label") ??
25+
candidate.textContent?.trim()) === label,
26+
);
27+
expect(button, label).toBeDefined();
28+
expect(button?.closest("[inert]"), label).not.toBeNull();
29+
}
30+
} finally {
31+
dom.window.close();
32+
}
33+
});
34+
});

apps/web/components/pages/HomeTwo/demo/DesktopDemo.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,6 +1417,7 @@ export const DesktopDemo = ({
14171417

14181418
{/* Controls: phase pills, tour progress, skip. Hidden until the tour starts. */}
14191419
<div
1420+
inert={idle}
14201421
className={classNames(
14211422
"relative z-10 mt-3 flex flex-wrap items-center justify-center gap-x-4 gap-y-2 transition-opacity duration-500",
14221423
idle ? "pointer-events-none opacity-0" : "opacity-100",

0 commit comments

Comments
 (0)