Skip to content

Commit 55b942c

Browse files
authored
Add Reddit share URL assertions to ShareSheet tests (JhaSourav07#967)
## Description Adds tests for the Reddit share action to verify: - Reddit submit URL is used - encoded profile URL is included - title parameter exists closes JhaSourav07#740 ## 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 update 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`). - [ ] 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. - [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 ecf41d5 + 6dafe73 commit 55b942c

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

components/dashboard/ShareSheet.test.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,30 @@ describe('ShareSheet', () => {
279279
});
280280
});
281281

282+
it('handles Reddit share URL correctly', async () => {
283+
render(<ShareSheet {...defaultProps} />);
284+
285+
const redditButton = screen.getByText('Reddit').closest('button');
286+
287+
fireEvent.click(redditButton!);
288+
289+
await waitFor(() => {
290+
expect(window.open).toHaveBeenCalled();
291+
});
292+
293+
expect(window.open).toHaveBeenCalledWith(
294+
expect.stringContaining('reddit.com/submit'),
295+
'_blank',
296+
'noopener,noreferrer'
297+
);
298+
299+
const calledUrl = vi.mocked(window.open).mock.calls[0][0] as string;
300+
301+
expect(calledUrl).toContain(encodeURIComponent(`/dashboard/${defaultProps.username}`));
302+
303+
expect(calledUrl).toContain('title=');
304+
});
305+
282306
it('handles Download SVG action', async () => {
283307
// Mock fetch
284308
global.fetch = vi.fn().mockResolvedValue({

story-spark-ai

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Subproject commit 8ee415e977aa4983793e53bd06ec01eb1b3b1524

0 commit comments

Comments
 (0)