Skip to content

Commit 3b13b71

Browse files
authored
test(ui): verify responsive rendering and axis scaling of RadarChart (JhaSourav07#1713)
## Description Adds a new test case to verify that RadarChart scales axis points dynamically based on max score in data, and renders correct HTML nodes across responsive viewports. Fixes JhaSourav07#1539 ## 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 file only, no visual output 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`). - [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 8080eff + 847fa68 commit 3b13b71

2 files changed

Lines changed: 40 additions & 13 deletions

File tree

components/dashboard/RadarChart.test.tsx

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ describe('RadarChart', () => {
5252
expect(screen.getByText('User A')).toBeDefined();
5353
expect(screen.getByText('User B')).toBeDefined();
5454

55-
// Check that top languages are rendered as axes
5655
expect(screen.getAllByText('TypeScript')).toBeDefined();
5756
expect(screen.getAllByText('Python')).toBeDefined();
5857
expect(screen.getAllByText('JavaScript')).toBeDefined();
@@ -61,7 +60,6 @@ describe('RadarChart', () => {
6160
it('handles empty input arrays cleanly using pad languages', () => {
6261
render(<RadarChart languagesA={[]} languagesB={[]} labelA="User A" labelB="User B" />);
6362

64-
// Padding should supply common ones
6563
expect(screen.getAllByText('TypeScript')).toBeDefined();
6664
expect(screen.getAllByText('JavaScript')).toBeDefined();
6765
expect(screen.getAllByText('Python')).toBeDefined();
@@ -78,4 +76,40 @@ describe('RadarChart', () => {
7876
expect(screen.getAllByText('JavaScript')).toBeDefined();
7977
expect(screen.getAllByText('Python')).toBeDefined();
8078
});
79+
80+
it('scales axis points dynamically based on max score in data', () => {
81+
const highScoreLangs = [
82+
{ name: 'TypeScript', percentage: 100, color: '#3178c6' },
83+
{ name: 'Python', percentage: 80, color: '#3572A5' },
84+
{ name: 'JavaScript', percentage: 60, color: '#f1e05a' },
85+
];
86+
87+
const lowScoreLangs = [
88+
{ name: 'TypeScript', percentage: 10, color: '#3178c6' },
89+
{ name: 'Python', percentage: 5, color: '#3572A5' },
90+
{ name: 'JavaScript', percentage: 2, color: '#f1e05a' },
91+
];
92+
93+
const { container } = render(
94+
<RadarChart
95+
languagesA={highScoreLangs}
96+
languagesB={lowScoreLangs}
97+
labelA="High Scorer"
98+
labelB="Low Scorer"
99+
/>
100+
);
101+
102+
expect(screen.getAllByText('TypeScript')).toBeDefined();
103+
expect(screen.getAllByText('Python')).toBeDefined();
104+
expect(screen.getAllByText('JavaScript')).toBeDefined();
105+
106+
expect(screen.getByText('100%')).toBeDefined();
107+
expect(screen.getByText('10%')).toBeDefined();
108+
109+
const svg = container.querySelector('svg');
110+
expect(svg).not.toBeNull();
111+
112+
const circles = container.querySelectorAll('circle');
113+
expect(circles.length).toBeGreaterThan(0);
114+
});
81115
});

package-lock.json

Lines changed: 4 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)