Skip to content

Commit e85071d

Browse files
authored
test: add accessibility test for ShareSheet close button (JhaSourav07#778)
## Description Fixes # 741 ## Pillar - [ ] 🎨 Pillar 1 β€” New Theme Design - [ ] πŸ“ Pillar 2 β€” Geometric SVG Improvement - [ ] πŸ• Pillar 3 β€” Timezone Logic Optimization - [ ] πŸ› οΈ Other (Bug fix, refactoring, docs) ## Visual Preview ## 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). - [ ] 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 started 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 community for contributor discussions, mentorship, and faster PR support.
2 parents 0e0e348 + 89f8983 commit e85071d

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

β€Žapp/(root)/dashboard/[username]/page.test.tsxβ€Ž

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ vi.mock('@/components/dashboard/CommitClock', () => ({
4646
}));
4747

4848
vi.mock('@/components/dashboard/Heatmap', () => ({
49-
default: () => <div data-testid="heatmap">Heatmap</div>,
49+
default: ({ data }: { data: unknown[] }) => (
50+
<div data-testid="heatmap" data-prop={JSON.stringify(data)}>
51+
Heatmap
52+
</div>
53+
),
5054
}));
5155

5256
vi.mock('@/components/dashboard/AIInsights', () => ({
@@ -121,7 +125,9 @@ describe('DashboardPage', () => {
121125
bypassCache: false,
122126
});
123127

124-
expect(screen.getByText('Generate Your Own Dashboard')).toBeDefined();
128+
const generateLink = screen.getByText('Generate Your Own Dashboard').closest('a');
129+
expect(generateLink).toBeDefined();
130+
expect(generateLink?.getAttribute('href')).toBe('/');
125131
expect(screen.getByTestId('profile-card')).toBeDefined();
126132
expect(screen.getByTestId('activity-landscape')).toBeDefined();
127133
expect(screen.getByTestId('language-chart')).toBeDefined();
@@ -135,4 +141,15 @@ describe('DashboardPage', () => {
135141
expect(screen.getByText('Contributions: 500')).toBeDefined();
136142
});
137143
});
144+
it('passes the correct activity data to Heatmap', async () => {
145+
const PageContent = await DashboardPage({
146+
params: Promise.resolve({ username: 'octocat' }),
147+
searchParams: Promise.resolve({}),
148+
});
149+
150+
render(PageContent);
151+
152+
const heatmap = screen.getByTestId('heatmap');
153+
expect(JSON.parse(heatmap.getAttribute('data-prop') ?? '[]')).toEqual(mockData.activity);
154+
});
138155
});

β€Žcomponents/dashboard/ShareSheet.test.tsxβ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ describe('ShareSheet', () => {
8989
expect(screen.getByText('Share on X')).toBeDefined();
9090
expect(screen.getByText('Download JSON')).toBeDefined();
9191
});
92+
it('renders close button with correct aria-label and calls onClose', () => {
93+
render(<ShareSheet {...defaultProps} />);
94+
95+
const closeButton = screen.getByLabelText('Close share options panel');
96+
97+
expect(closeButton).toBeDefined();
98+
99+
fireEvent.click(closeButton);
100+
101+
expect(defaultProps.onClose).toHaveBeenCalled();
102+
});
92103

93104
it('calls onClose when close button is clicked', () => {
94105
render(<ShareSheet {...defaultProps} />);

0 commit comments

Comments
Β (0)