-
-
Notifications
You must be signed in to change notification settings - Fork 213
Expand file tree
/
Copy pathPlaygroundSidebar.test.tsx
More file actions
73 lines (62 loc) · 2.52 KB
/
PlaygroundSidebar.test.tsx
File metadata and controls
73 lines (62 loc) · 2.52 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
import { render, screen } from "@testing-library/react";
import "@testing-library/jest-dom";
import PlaygroundSidebar from "../../components/PlaygroundSidebar";
import { vi } from "vitest";
// Mock the store
vi.mock("../../store/store", () => ({
default: () => ({
isEditorsVisible: true,
isPreviewVisible: true,
isProblemPanelVisible: false,
isAIChatOpen: false,
setEditorsVisible: vi.fn(),
setPreviewVisible: vi.fn(),
setProblemPanelVisible: vi.fn(),
setAIChatOpen: vi.fn(),
setSettingsOpen: vi.fn(),
generateShareableLink: vi.fn(() => "https://example.com"),
exportTemplate: vi.fn(),
importTemplate: vi.fn(),
}),
}));
// Mock the Tour
vi.mock("../../components/Tour", () => ({
default: { start: vi.fn() },
}));
// Mock FullScreenModal
vi.mock("../../components/FullScreenModal", () => ({
default: () => <div data-testid="fullscreen-modal">FullScreen</div>,
}));
// Mock SettingsModal
vi.mock("../../components/SettingsModal", () => ({
default: () => <div data-testid="settings-modal">Settings</div>,
}));
const renderSidebar = () => {
render(<PlaygroundSidebar />);
};
describe("PlaygroundSidebar", () => {
it("renders all top navigation items", () => {
renderSidebar();
expect(screen.getByRole("button", { name: /Editor/i })).toBeInTheDocument();
expect(screen.getByRole("button", { name: /Preview/i })).toBeInTheDocument();
expect(screen.getByRole("button", { name: /Problems/i })).toBeInTheDocument();
expect(screen.getByRole("button", { name: /AI Assistant/i })).toBeInTheDocument();
});
it("renders all bottom navigation items", () => {
renderSidebar();
expect(screen.getByRole("button", { name: /Export/i })).toBeInTheDocument();
expect(screen.getByRole("button", { name: /Import/i })).toBeInTheDocument();
expect(screen.getByRole("button", { name: /Share/i })).toBeInTheDocument();
expect(screen.getByRole("button", { name: /Start Tour/i })).toBeInTheDocument();
expect(screen.getByRole("button", { name: /Settings/i })).toBeInTheDocument();
});
it("wraps navigation items with Tooltip component", () => {
renderSidebar();
const editorButton = screen.getByRole("button", { name: /Editor/i });
expect(editorButton).toBeInTheDocument();
});
it("renders FullScreen modal component", () => {
renderSidebar();
expect(screen.getByTestId("fullscreen-modal")).toBeInTheDocument();
});
});