Skip to content

Commit dd640d5

Browse files
authored
test(copyrepobutton): add massive scaling test coverage (JhaSourav07#2973)
## Description Fixes JhaSourav07#2804 Added massive scaling test coverage for `CopyRepoButton`. ### Tests Added * Verifies rendering of large numbers of CopyRepoButton components without crashing. * Ensures button text remains consistent under heavy render loads. * Confirms icons render correctly across many component instances. * Validates repeated mounting does not throw errors. * Checks large-scale button rendering behavior remains stable. ## Pillar * [ ] 🎨 Pillar 1 — New Theme Design * [ ] 📐 Pillar 2 — Geometric SVG Improvement * [ ] 🕐 Pillar 3 — Timezone Logic Optimization * [x] 🛠️ Other (Bug fix, refactoring, docs) ## Visual Preview N/A (Test-only changes) ## 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`). * [ ] 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 I added a new theme or URL parameter. (Not applicable) * [x] I have starred 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. (Not applicable) * [ ] (Recommended) I joined the CommitPulse Discord community.
2 parents 9e2b68c + 779c3ac commit dd640d5

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { render, screen } from '@testing-library/react';
2+
import { describe, it, expect, vi } from 'vitest';
3+
import CopyRepoButton from './CopyRepoButton';
4+
5+
vi.mock('lucide-react', () => ({
6+
Copy: () => <svg data-testid="copy-icon" />,
7+
}));
8+
9+
describe('CopyRepoButton Massive Scaling', () => {
10+
it('renders 100 buttons without crashing', () => {
11+
render(
12+
<>
13+
{Array.from({ length: 100 }).map((_, i) => (
14+
<CopyRepoButton key={i} />
15+
))}
16+
</>
17+
);
18+
19+
expect(screen.getAllByText('Copy URL')).toHaveLength(100);
20+
});
21+
22+
it('renders 500 buttons without layout break', () => {
23+
render(
24+
<>
25+
{Array.from({ length: 500 }).map((_, i) => (
26+
<CopyRepoButton key={i} />
27+
))}
28+
</>
29+
);
30+
31+
expect(screen.getAllByRole('button')).toHaveLength(500);
32+
});
33+
34+
it('renders icon for every button under heavy load', () => {
35+
render(
36+
<>
37+
{Array.from({ length: 200 }).map((_, i) => (
38+
<CopyRepoButton key={i} />
39+
))}
40+
</>
41+
);
42+
43+
expect(screen.getAllByTestId('copy-icon')).toHaveLength(200);
44+
});
45+
46+
it('maintains button text consistency across many renders', () => {
47+
render(
48+
<>
49+
{Array.from({ length: 300 }).map((_, i) => (
50+
<CopyRepoButton key={i} />
51+
))}
52+
</>
53+
);
54+
55+
const buttons = screen.getAllByText('Copy URL');
56+
expect(buttons.length).toBe(300);
57+
});
58+
59+
it('handles repeated mounting without throwing errors', () => {
60+
expect(() => {
61+
for (let i = 0; i < 50; i++) {
62+
render(<CopyRepoButton />);
63+
}
64+
}).not.toThrow();
65+
});
66+
});

0 commit comments

Comments
 (0)