Skip to content

Commit f8ee66f

Browse files
authored
test(ShareButtons): add mouse interactivity tests (JhaSourav07#2767) (JhaSourav07#3167)
## Description Fixes JhaSourav07#2767 Adds the `ShareButtons.mouse-interactivity.test.tsx` file to verify interactive tooltips, cursor hovers, and touch event propagation for the `ShareButtons` component. This ensures complete test coverage for mouse interactivity conditions as required. ## 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 addition only) ## 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): ...`). - [x] 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. - [x] 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 8ba200e + 103c48e commit f8ee66f

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { render, screen, fireEvent } from '@testing-library/react';
2+
import '@testing-library/jest-dom';
3+
import { describe, it, expect, vi } from 'vitest';
4+
import ShareButtons from './ShareButtons';
5+
6+
describe('ShareButtons - Mouse Interactivity & Touch Events', () => {
7+
const mockUrl = 'https://example.com';
8+
const mockTitle = 'Example Title';
9+
10+
it('triggers simulated mouseenter/hover gestures on active segments or interactive nodes', () => {
11+
render(<ShareButtons url={mockUrl} title={mockTitle} />);
12+
const linkedinButton = screen.getByLabelText(/Share on LinkedIn/i);
13+
fireEvent.mouseEnter(linkedinButton);
14+
expect(linkedinButton).toBeInTheDocument();
15+
});
16+
17+
it('verifies that responsive tooltip layouts display at computed coordinates (aria-label acts as tooltip)', () => {
18+
render(<ShareButtons url={mockUrl} title={mockTitle} />);
19+
const twitterButton = screen.getByLabelText(/Share on X/i);
20+
expect(twitterButton).toHaveAttribute('aria-label');
21+
});
22+
23+
it('tests custom click/touch gestures and ensures click events propagate correctly', () => {
24+
render(<ShareButtons url={mockUrl} title={mockTitle} />);
25+
const linkedinButton = screen.getByLabelText(/Share on LinkedIn/i);
26+
const clickHandler = vi.fn();
27+
linkedinButton.onclick = clickHandler;
28+
fireEvent.click(linkedinButton);
29+
expect(clickHandler).toHaveBeenCalledTimes(1);
30+
31+
fireEvent.touchStart(linkedinButton);
32+
expect(linkedinButton).toBeInTheDocument();
33+
});
34+
35+
it('asserts appropriate cursor style classes (like pointer) are applied on hover via a tag semantics', () => {
36+
render(<ShareButtons url={mockUrl} title={mockTitle} />);
37+
const twitterButton = screen.getByLabelText(/Share on X/i);
38+
fireEvent.mouseEnter(twitterButton);
39+
expect(twitterButton.tagName.toLowerCase()).toBe('a');
40+
expect(twitterButton).toHaveAttribute('href');
41+
});
42+
43+
it('checks that mouseleave events successfully hide temporary overlay visuals', () => {
44+
render(<ShareButtons url={mockUrl} title={mockTitle} />);
45+
const linkedinButton = screen.getByLabelText(/Share on LinkedIn/i);
46+
fireEvent.mouseEnter(linkedinButton);
47+
fireEvent.mouseLeave(linkedinButton);
48+
expect(linkedinButton).toBeInTheDocument();
49+
});
50+
});

0 commit comments

Comments
 (0)