Skip to content

test(ComparisonStatsCard-responsive-breakpoints): verify Responsive M…#3946

Open
realtushartyagi wants to merge 2 commits into
JhaSourav07:mainfrom
realtushartyagi:test/comparison-stats-card-responsive
Open

test(ComparisonStatsCard-responsive-breakpoints): verify Responsive M…#3946
realtushartyagi wants to merge 2 commits into
JhaSourav07:mainfrom
realtushartyagi:test/comparison-stats-card-responsive

Conversation

@realtushartyagi
Copy link
Copy Markdown
Contributor

Description

This PR Adds responsive layout tests for the ComparisonStatsCard component.

Fixes #2519

Covered Scenarios

  • Mobile viewport rendering (375px).
  • Responsive column/layout behavior.
  • Prevention of horizontal overflow.
  • Username truncation handling.
    -Responsive visibility of mobile-specific elements.

Pillar

  • 🎨 Pillar 1 — New Theme Design
  • 📐 Pillar 2 — Geometric SVG Improvement
  • 🕐 Pillar 3 — Timezone Logic Optimization
  • 🛠️ Other (Testing, Responsive Viewport Layouts)

Visual Preview

N/A (Test-only changes, no UI modifications)

Checklist before requesting a review:

  • I have read the CONTRIBUTING.md file.
  • I have tested these changes locally (localhost:3000/api/streak?user=YOUR_USERNAME).
  • I have run npm run format and npm run lint locally and resolved all errors (CI will fail otherwise).
  • I have run npm run test and all tests pass locally.
  • I have run npm run test:coverage and branch coverage is at or above 70%.
  • 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.
  • I have starred the repo.
  • 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).
  • (Recommended) I joined the CommitPulse Discord server for faster collaboration, mentorship, and PR support.

…ulti-device Columns & Mobile Viewport Layouts (Variation 7)

Closes JhaSourav07#2519
Copilot AI review requested due to automatic review settings June 5, 2026 08:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a dedicated test suite to validate ComparisonStatsCard styling hooks intended to support responsive layouts across viewport sizes.

Changes:

  • Introduces a Vitest + Testing Library test file focused on responsive breakpoints and layout-related Tailwind classes
  • Adds a matchMedia mock and viewport width manipulation to simulate mobile/desktop environments
  • Adds assertions for grid/flex structure, progress bar sizing, truncation, and breakpoint-only elements

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +7 to +18
const mockMatchMedia = (width: number) => {
return vi.fn().mockImplementation((query) => ({
matches: width <= 768 ? query.includes('max-width') : query.includes('min-width'),
media: query,
onchange: null,
addListener: vi.fn(),
removeListener: vi.fn(),
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn(),
}));
};
Comment on lines +30 to +38
beforeEach(() => {
// Default to mobile viewport (iPhone SE width)
Object.defineProperty(window, 'innerWidth', { writable: true, configurable: true, value: 375 });
window.matchMedia = mockMatchMedia(375);
});

afterEach(() => {
vi.clearAllMocks();
});
Comment on lines +91 to +109
it('asserts mobile-specific visual elements (like center dividers) respond cleanly', () => {
const { container } = render(<ComparisonStatsCard {...defaultProps} />);

// The center divider uses hidden md:block so it disappears on mobile viewports
const divider = container.querySelector('.hidden.md\\:block');
expect(divider).not.toBeNull();
expect(divider?.className).toContain('absolute left-1/2');

// Simulate resizing to Desktop (1024px)
Object.defineProperty(window, 'innerWidth', {
writable: true,
configurable: true,
value: 1024,
});
window.matchMedia = mockMatchMedia(1024);

// Viewport should reflect desktop
expect(window.innerWidth).toBe(1024);
});
Comment on lines +46 to +49
// The component should render without crashing on mobile
expect(screen.getByText('Total Commits')).toBeDefined();
expect(screen.getByText('1500')).toBeDefined();
expect(screen.getByText('1200')).toBeDefined();
@github-actions github-actions Bot added the status:blocked This PR is blocked due to a failing CI check. label Jun 5, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 5, 2026

🚨 Hey @realtushartyagi, the CI Pipeline is failing on this PR and it has been marked as status:blocked.

Please fix the issues before this can be reviewed. Here's how:

1. Run checks locally before pushing:

npm run format:check   # Check Prettier formatting
npm run lint           # Run ESLint
npm run typecheck      # TypeScript type check
npm run test           # Run unit tests (Vitest)
npm run build          # Verify production build passes

2. Auto-fix common issues:

npm run format         # Auto-fix formatting with Prettier
npm run lint -- --fix  # Auto-fix lint errors where possible

3. Check the full failure log here:
👉 View CI Run

Once you push a fix and the CI passes, the status:blocked label will be removed automatically. 💪

@github-actions github-actions Bot added type:testing Adding, updating, or fixing tests and removed status:blocked This PR is blocked due to a failing CI check. labels Jun 5, 2026
@Aamod007 Aamod007 added GSSoC 2026 mentor:Aamod007 level:beginner Small changes Usually isolated fixes or simple UI/text updates. labels Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GSSoC 2026 level:beginner Small changes Usually isolated fixes or simple UI/text updates. mentor:Aamod007 type:testing Adding, updating, or fixing tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(ComparisonStatsCard-responsive-breakpoints): verify Responsive Multi-device Columns & Mobile Viewport Layouts (Variation 7)

3 participants