Commit 335dadd
authored
test(ShareSheet): verify navigator.share is called (JhaSourav07#760)
▶ Description
Fixes JhaSourav07#739
This PR adds test coverage for the native OS sharing flow inside the
`ShareSheet` component by mocking `navigator.share` and verifying it is
triggered correctly when the **"Share via OS Sheet"** button is clicked.
The native share sheet path is especially important for mobile devices,
and this test ensures the integration remains stable and
regression-safe.
▶ Changes Made
● Added a new unit test in:
"txt
components/dashboard/ShareSheet.test.tsx"
▶ Test coverage includes:
- Mocking "navigator.share" using "vi.fn()"
- Rendering the "ShareSheet" component
- Simulating user interaction with the native share button
- Verifying "navigator.share" is invoked
- Verifying the payload contains:
• title
• text
• url
▶ Pillar
Testing / Quality Assurance
▶ Validation
Successfully ran the complete Vitest test suite locally.
● Result:
"txt
Test Files 27 passed (27)
Tests 353 passed (353)"
No existing tests were broken.
▶ Why This Matters
The OS share sheet flow is a mobile-critical feature.
This test improves reliability by ensuring:
* native sharing continues working correctly
* payload structure remains consistent
* future regressions are caught automatically
✅ Checklist
[x] Added unit test for "navigator.share"
[x] Verified correct payload structure
[x] Followed existing test conventions
[x] All tests passing
[x] No unrelated files modified
<img width="1920" height="1080" alt="Screenshot 2026-05-27 221308"
src="https://github.com/user-attachments/assets/99d4e85c-644f-439d-8e4c-f6befa29a464"
/>
<img width="1920" height="1080" alt="Screenshot 2026-05-27 221344"
src="https://github.com/user-attachments/assets/f49ba90c-596f-4ee7-9044-0ffe7d19b15b"
/>1 file changed
Lines changed: 21 additions & 0 deletions
File tree
- components/dashboard
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
166 | 187 | | |
167 | 188 | | |
168 | 189 | | |
| |||
0 commit comments