Skip to content

Commit e6752cd

Browse files
authored
test(RadarChart): verify language axis labels deduplicate for shared languages (JhaSourav07#2159)
## Description Fixes JhaSourav07#1072 Adds a deduplication test to `RadarChart.test.tsx` that verifies when both users share the same language (TypeScript), it appears as a single axis label — not two separate axes. - `languagesA` and `languagesB` both set to `[{ name: 'TypeScript', ... }]` - Asserts `getAllByText('TypeScript')` returns exactly 2 nodes (1 SVG axis label + 1 stats table entry), confirming no duplicate axis is rendered ## 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 change, no SVG output modified. ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [ ] 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): ...`). - [x] I have updated `README.md` if I added a new theme or URL parameter. (N/A) - [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 (no raw elements, smooth animations, correct fonts). (N/A — test only) - [x] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents 558ce7d + b222d81 commit e6752cd

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

components/dashboard/RadarChart.test.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,17 @@ describe('RadarChart', () => {
7777
expect(screen.getAllByText('Python')).toBeDefined();
7878
});
7979

80+
it('deduplicates shared languages so TypeScript appears as a single axis label', () => {
81+
const langsA = [{ name: 'TypeScript', percentage: 70, color: '#3178c6' }];
82+
const langsB = [{ name: 'TypeScript', percentage: 50, color: '#3178c6' }];
83+
84+
render(<RadarChart languagesA={langsA} languagesB={langsB} labelA="User A" labelB="User B" />);
85+
86+
// TypeScript should appear exactly once as an axis label (SVG <text>) and once
87+
// in the bottom stats table — 2 total, not 4 (which would indicate two separate axes)
88+
expect(screen.getAllByText('TypeScript')).toHaveLength(2);
89+
});
90+
8091
it('scales axis points dynamically based on max score in data', () => {
8192
const highScoreLangs = [
8293
{ name: 'TypeScript', percentage: 100, color: '#3178c6' },

0 commit comments

Comments
 (0)