Skip to content

Commit 99b9e46

Browse files
authored
test(ContributorsLoading-responsive-breakpoints): verify Responsive Multi-device Columns & Mobile Viewport Layouts (JhaSourav07#3178)
## Description Fixes JhaSourav07#2849 Added responsive breakpoint test coverage for the contributors loading component. ## Pillar - [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview N/A (Test-only change) ## Checklist - [x] I have read the CONTRIBUTING.md file. - [x] I have run npm run format. - [x] I have run npm run lint. - [x] I have run npm run typecheck. - [x] I have run npm run test. - [x] I have run npm run test:coverage. - [x] I have only one commit in this PR. ## Changes Made - Created `app/contributors/loading.responsive-breakpoints.test.tsx` - Added 5 responsive breakpoint test cases - Verified loading component renders correctly on mobile-width viewports - Verified vertical flex layout for mobile-friendly presentation - Verified centered viewport positioning remains intact - Verified no fixed-width container styles introduce horizontal scrolling - Verified loading spinner remains visible on smaller screens ## Result - Improves responsive layout test coverage for the contributors loading page - Documents expected mobile viewport behavior through automated tests - Helps prevent regressions affecting small-screen users - Existing tests continue to pass
2 parents 897e228 + 331e3f0 commit 99b9e46

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { describe, it, expect, beforeEach } from 'vitest';
2+
import { render, screen } from '@testing-library/react';
3+
import Loading from './loading';
4+
5+
describe('Loading - Responsive Multi-device Columns & Mobile Viewport Layouts', () => {
6+
beforeEach(() => {
7+
Object.defineProperty(window, 'innerWidth', {
8+
writable: true,
9+
configurable: true,
10+
value: 375,
11+
});
12+
});
13+
14+
it('renders correctly on a mobile-width viewport', () => {
15+
const { container } = render(<Loading />);
16+
17+
expect(container.firstChild).toBeTruthy();
18+
});
19+
20+
it('uses a vertical flex layout suitable for mobile screens', () => {
21+
const { container } = render(<Loading />);
22+
23+
const contentWrapper = container.querySelector('.flex-col');
24+
25+
expect(contentWrapper).toBeTruthy();
26+
});
27+
28+
it('keeps content centered within the viewport', () => {
29+
const { container } = render(<Loading />);
30+
31+
const wrapper = container.querySelector('.min-h-screen');
32+
33+
expect(wrapper?.className).toContain('items-center');
34+
expect(wrapper?.className).toContain('justify-center');
35+
});
36+
37+
it('does not use fixed-width container classes that could cause horizontal scrolling', () => {
38+
const { container } = render(<Loading />);
39+
40+
const root = container.firstElementChild;
41+
42+
expect(root?.className).not.toContain('w-screen');
43+
expect(root?.className).not.toContain('max-w');
44+
});
45+
46+
it('renders the loading spinner on mobile layouts', () => {
47+
const { container } = render(<Loading />);
48+
49+
const spinner = container.querySelector('.animate-spin');
50+
51+
expect(spinner).toBeTruthy();
52+
});
53+
});

0 commit comments

Comments
 (0)