Skip to content

Commit e4f90d8

Browse files
authored
test(historical-trend-view): add theme contrast coverage (JhaSourav07#3427)
## Description Fixes JhaSourav07#2675 Adds theme contrast test coverage for `HistoricalTrendView` to verify visual cohesion across light and dark color schemes. The test suite verifies: - Light mode styling classes are rendered correctly - Dark mode styling classes are present and applied - Text content remains accessible in both themes - Foreground content is rendered without clipping or overlay conflicts - Heatmap and statistical sections render correctly in theme-capable layouts ## Pillar - [ ] 🎨 Pillar 1 — New Theme Design - [ ] 📐 Pillar 2 — Geometric SVG Improvement - [ ] 🕐 Pillar 3 — Timezone Logic Optimization - [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview Not applicable — test-only change. ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [ ] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). - [x] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). - [x] My commits follow the Conventional Commits format (e.g., `feat(themes): ...`, `fix(calculate): ...`). - [ ] I have updated `README.md` if I added a new theme or URL parameter. - [x] I have started the repo. - [x] I have made sure that i have only one commit to merge in this PR. - [ ] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). - [x] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents 4bca90a + 47de3aa commit e4f90d8

1 file changed

Lines changed: 80 additions & 0 deletions

File tree

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { describe, it, expect, vi } from 'vitest';
2+
import { render, screen } from '@testing-library/react';
3+
import '@testing-library/jest-dom/vitest';
4+
5+
import HistoricalTrendView from './HistoricalTrendView';
6+
import type { ActivityData } from '@/types/dashboard';
7+
import type { DashboardPeriod } from '@/utils/dashboardPeriod';
8+
9+
vi.mock('next/navigation', () => ({
10+
useRouter: () => ({
11+
push: vi.fn(),
12+
}),
13+
}));
14+
15+
vi.mock('./Heatmap', () => ({
16+
default: () => <div data-testid="heatmap">Heatmap</div>,
17+
}));
18+
19+
const period: DashboardPeriod = {
20+
kind: 'month',
21+
month: '2025-05',
22+
label: 'May 2025',
23+
from: '2025-05-01T00:00:00.000Z',
24+
to: '2025-05-31T23:59:59.999Z',
25+
};
26+
27+
const activity: ActivityData[] = [
28+
{
29+
date: '2025-05-01',
30+
count: 5,
31+
intensity: 4,
32+
},
33+
{
34+
date: '2025-05-02',
35+
count: 2,
36+
intensity: 2,
37+
},
38+
];
39+
40+
describe('HistoricalTrendView theme contrast', () => {
41+
it('renders light mode background classes', () => {
42+
const { container } = render(
43+
<HistoricalTrendView username="tester" activity={activity} period={period} />
44+
);
45+
46+
expect(container.innerHTML).toContain('bg-white');
47+
expect(container.innerHTML).toContain('text-gray-900');
48+
});
49+
50+
it('includes dark mode styling classes', () => {
51+
const { container } = render(
52+
<HistoricalTrendView username="tester" activity={activity} period={period} />
53+
);
54+
55+
expect(container.innerHTML).toContain('dark:bg-[#0a0a0a]');
56+
expect(container.innerHTML).toContain('dark:text-white');
57+
});
58+
59+
it('renders text content with contrast-aware classes', () => {
60+
render(<HistoricalTrendView username="tester" activity={activity} period={period} />);
61+
62+
expect(screen.getByText(/Explore long-term activity patterns/i)).toBeInTheDocument();
63+
64+
expect(screen.getByText(/Contributions/i)).toBeInTheDocument();
65+
});
66+
67+
it('renders foreground content without clipping overlays', () => {
68+
render(<HistoricalTrendView username="tester" activity={activity} period={period} />);
69+
70+
expect(screen.getByText(/Monthly Summary/i)).toBeInTheDocument();
71+
expect(screen.getByText(/Yearly Summary/i)).toBeInTheDocument();
72+
});
73+
74+
it('renders heatmap and statistics in both theme-capable layouts', () => {
75+
render(<HistoricalTrendView username="tester" activity={activity} period={period} />);
76+
77+
expect(screen.getByTestId('heatmap')).toBeInTheDocument();
78+
expect(screen.getByText(/Current Streak/i)).toBeInTheDocument();
79+
});
80+
});

0 commit comments

Comments
 (0)