Skip to content

Commit 617839c

Browse files
authored
test(not-found): add 404 page tests (JhaSourav07#1201)
## Description Fixes JhaSourav07#1033 Added test coverage for the custom Not Found page. ### Test Coverage Added * Verifies the page renders successfully. * Verifies the stylized "𝒐𝒐𝒑𝒔" text is displayed. * Verifies the "git checkout main" link text is rendered. * Verifies the "Go back home" link points to `/`. * Verifies the GitHub link points to the CommitPulse repository. ## 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. * [x] 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. * [ ] I have updated `README.md` if required. * [x] I have starred the repo. * [x] I have made sure that I have only one commit to merge in this PR. * [x] The SVG output matches the CommitPulse "premium quality" aesthetic standard. * [x] (Recommended) I joined the CommitPulse Discord community.
2 parents 214003c + 8f26ac2 commit 617839c

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

app/not-found.test.tsx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { describe, expect, it, vi } from 'vitest';
2+
import { render, screen } from '@testing-library/react';
3+
import NotFound from './not-found';
4+
5+
vi.mock('next/link', () => ({
6+
default: ({ href, children, ...props }: { href: string; children: React.ReactNode }) => (
7+
<a href={href} {...props}>
8+
{children}
9+
</a>
10+
),
11+
}));
12+
13+
describe('NotFound', () => {
14+
it('renders without crashing', () => {
15+
render(<NotFound />);
16+
17+
expect(document.body).toBeTruthy();
18+
});
19+
20+
it('renders the oops text', () => {
21+
render(<NotFound />);
22+
23+
expect(screen.getAllByText('𝒐𝒐𝒑𝒔')).toHaveLength(2);
24+
});
25+
26+
it('renders git checkout main text', () => {
27+
render(<NotFound />);
28+
29+
expect(screen.getByText(/git checkout main/i)).toBeTruthy();
30+
});
31+
32+
it('renders go back home link with root href', () => {
33+
render(<NotFound />);
34+
35+
const homeLink = screen.getByRole('link', {
36+
name: /go back home/i,
37+
});
38+
39+
expect(homeLink.getAttribute('href')).toBe('/');
40+
});
41+
42+
it('renders github link pointing to commitpulse repository', () => {
43+
render(<NotFound />);
44+
45+
const githubLink = screen.getByRole('link', {
46+
name: /git checkout main/i,
47+
});
48+
49+
expect(githubLink.getAttribute('href')).toContain('github.com');
50+
expect(githubLink.getAttribute('href')).toContain('commitpulse');
51+
});
52+
});

0 commit comments

Comments
 (0)