-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.shell.test.tsx
More file actions
83 lines (66 loc) · 3.53 KB
/
Copy pathapp.shell.test.tsx
File metadata and controls
83 lines (66 loc) · 3.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import { screen, within } from "@testing-library/react";
import { beforeEach, expect, it } from "vitest";
import { DEFAULT_DRAW_COUNT, DEFAULT_TIMER_SECONDS } from "./test/gameConstants";
import {
DRAW_SUMMARY_PATTERN,
openCustomizeDeck,
openTimerPopover,
READY_SUMMARY_PATTERN,
renderApp,
resetAppTestState,
SELECTED_CATEGORIES,
SOURCE_SUMMARY_PATTERN,
} from "./test/renderApp";
beforeEach(resetAppTestState);
it("renders the core app shell and primary controls", async () => {
await renderApp();
expect(screen.getByRole("heading", { level: 1 })).toHaveTextContent("Scattergories");
expect(screen.getByRole("button", { name: "Start round" })).toBeInTheDocument();
expect(screen.getByRole("button", { name: "How to play" })).toBeInTheDocument();
});
it("keeps the main surface lean and categories outside the playmat", async () => {
await renderApp();
expect(screen.queryByTestId("onboarding-banner")).not.toBeInTheDocument();
const playmat = screen.getByRole("region", { name: "Game board" });
const categoriesPanel = screen.getByRole("region", { name: "Categories" });
expect(
within(playmat).queryByRole("list", { name: SELECTED_CATEGORIES }),
).not.toBeInTheDocument();
expect(
within(categoriesPanel).getByRole("list", { name: SELECTED_CATEGORIES }),
).toBeInTheDocument();
expect(within(categoriesPanel).queryByRole("button", { pressed: true })).not.toBeInTheDocument();
expect(within(categoriesPanel).queryByText(SOURCE_SUMMARY_PATTERN)).not.toBeInTheDocument();
expect(within(categoriesPanel).queryByText(DRAW_SUMMARY_PATTERN)).not.toBeInTheDocument();
expect(within(categoriesPanel).queryByText(READY_SUMMARY_PATTERN)).not.toBeInTheDocument();
});
it("keeps the playmat lean: mute lives in the top bar, round controls always rendered", async () => {
await renderApp();
const playmat = screen.getByRole("region", { name: "Game board" });
// Secondary round controls are always present (disabled when unavailable) so the
// layout never shifts as the phase changes.
const roundControls = within(playmat).getByRole("group", { name: "Round controls" });
expect(within(roundControls).getByRole("button", { name: "New letter" })).toBeInTheDocument();
expect(within(roundControls).getByRole("button", { name: "Next round" })).toBeInTheDocument();
// Mute is a borderless toggle in the top settings cluster, not on the playmat.
expect(screen.getByRole("button", { name: "Mute" })).toBeInTheDocument();
expect(within(playmat).queryByRole("button", { name: "Mute" })).not.toBeInTheDocument();
});
it("shows default editable settings in their owning dialogs", async () => {
const { user } = await renderApp();
const timerPopover = await openTimerPopover(user);
expect(within(timerPopover).getByLabelText("Round")).toHaveValue(DEFAULT_TIMER_SECONDS);
expect(within(timerPopover).queryByLabelText("Rounds")).not.toBeInTheDocument();
await user.keyboard("{Escape}");
const customizeDialog = await openCustomizeDeck(user);
expect(within(customizeDialog).getByLabelText("Draw")).toHaveValue(DEFAULT_DRAW_COUNT);
});
it("opens and dismisses the How To Play dialog", async () => {
const { user } = await renderApp();
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
await user.click(screen.getByRole("button", { name: "How to play" }));
expect(await screen.findByRole("dialog")).toBeInTheDocument();
expect(await screen.findByRole("heading", { name: "How to play" })).toBeInTheDocument();
await user.keyboard("{Escape}");
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
});