-
Notifications
You must be signed in to change notification settings - Fork 241
Expand file tree
/
Copy pathdashboard-page.test.tsx
More file actions
113 lines (93 loc) · 3.53 KB
/
Copy pathdashboard-page.test.tsx
File metadata and controls
113 lines (93 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import React from "react";
import { render, screen, fireEvent, waitFor } from "@testing-library/react";
import { vi, describe, it, expect, beforeEach } from "vitest";
vi.mock("next/dynamic", () => ({
default: () => {
const DynamicStub = () => (
<section data-testid="analytics-insights">Analytics insights</section>
);
return DynamicStub;
},
}));
vi.mock("next/link", () => ({
default: ({ href, children, className, "aria-label": ariaLabel }: {
href: string;
children: React.ReactNode;
className?: string;
"aria-label"?: string;
}) => (
<a href={href} className={className} aria-label={ariaLabel}>
{children}
</a>
),
}));
vi.mock("@/hooks/useTransactions", () => ({
useTransactions: vi.fn(),
}));
import Dashboard from "./dashboard-page";
vi.mock("@/components/dashboard/dashboard-navbar", () => ({
default: () => <nav data-testid="dashboard-navbar">Navbar</nav>,
}));
vi.mock("@/components/dashboard/account-overview", () => ({
default: () => <section data-testid="account-overview">Account Overview</section>,
}));
vi.mock("@/components/dashboard/quick-actions", () => ({
QuickActions: () => <section data-testid="quick-actions">Quick Actions</section>,
}));
vi.mock("@/components/dashboard/analytics-insights", () => ({
AnalyticsInsights: () => <section data-testid="analytics-insights">Analytics Insights</section>,
}));
vi.mock("@/components/analytics/client-analytics-view", () => ({
default: () => <section data-testid="client-analytics">Client Analytics</section>,
}));
vi.mock("@/components/dashboard/dashboard-tour", () => ({
DashboardTour: () => <div data-testid="dashboard-tour">Tour Overlay</div>,
}));
vi.mock("@/components/dashboard/watchlist-panel", () => ({
WatchlistPanel: () => (
<section data-testid="watchlist-panel">Watchlist Panel</section>
),
}));
describe("Dashboard", () => {
it("renders the dashboard navbar", () => {
render(<Dashboard />);
expect(screen.getByTestId("dashboard-navbar")).toBeInTheDocument();
});
it("renders the account overview widget", () => {
render(<Dashboard />);
expect(screen.getByTestId("account-overview")).toBeInTheDocument();
});
it("renders the quick actions widget", () => {
render(<Dashboard />);
expect(screen.getByTestId("quick-actions")).toBeInTheDocument();
});
it("renders the analytics insights widget", () => {
render(<Dashboard />);
expect(screen.getByTestId("analytics-insights")).toBeInTheDocument();
});
it("renders the client analytics view", () => {
render(<Dashboard />);
expect(screen.getByTestId("client-analytics")).toBeInTheDocument();
});
it("renders the dashboard tour overlay", () => {
render(<Dashboard />);
expect(screen.getByTestId("dashboard-tour")).toBeInTheDocument();
});
it("has the correct layout structure with space-y-10", () => {
const { container } = render(<Dashboard />);
const wrapper = container.querySelector(".space-y-10");
expect(wrapper).toBeInTheDocument();
});
it("renders all major sections in order", () => {
const { container } = render(<Dashboard />);
const sections = container.querySelectorAll(
"[data-testid='account-overview'], [data-testid='quick-actions'], [data-testid='analytics-insights'], [data-testid='client-analytics']",
);
expect(sections.length).toBe(4);
});
it("passes ref props to DashboardTour", () => {
const { container } = render(<Dashboard />);
const tour = container.querySelector('[data-testid="dashboard-tour"]');
expect(tour).toBeInTheDocument();
});
});