From 0cf6256628e7b67e83fa88ec79932e30b427e23b Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Wed, 30 Oct 2024 12:19:26 -0700 Subject: [PATCH 1/3] fix: Pass sign out options to unstyled component --- packages/react/src/components/SignOutButton.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react/src/components/SignOutButton.tsx b/packages/react/src/components/SignOutButton.tsx index 19dd6f9bf7c..6676684eba4 100644 --- a/packages/react/src/components/SignOutButton.tsx +++ b/packages/react/src/components/SignOutButton.tsx @@ -18,7 +18,7 @@ export const SignOutButton = withClerk( children = normalizeWithDefaultValue(children, 'Sign out'); const child = assertSingleChild(children)('SignOutButton'); - const clickHandler = () => clerk.signOut({ redirectUrl }); + const clickHandler = () => clerk.signOut({ redirectUrl, ...signOutOptions }); const wrappedChildClickHandler: React.MouseEventHandler = async e => { await safeExecute((child as any).props.onClick)(e); return clickHandler(); From 6a68a3a5a77f1cd3c41732d8e53c63c3bb554feb Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Wed, 30 Oct 2024 12:34:13 -0700 Subject: [PATCH 2/3] test: add signOutOptions unit test --- .../__tests__/SignOutButton.test.tsx | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/packages/react/src/components/__tests__/SignOutButton.test.tsx b/packages/react/src/components/__tests__/SignOutButton.test.tsx index 686873c4806..88058dbd77e 100644 --- a/packages/react/src/components/__tests__/SignOutButton.test.tsx +++ b/packages/react/src/components/__tests__/SignOutButton.test.tsx @@ -24,6 +24,8 @@ jest.mock('../withClerk', () => { }; }); +const url = 'https://www.clerk.com'; + describe('', () => { beforeAll(() => { console.error = jest.fn(); @@ -46,6 +48,24 @@ describe('', () => { }); }); + it('handles redirectUrl prop', async () => { + render(); + const btn = screen.getByText('Sign out'); + userEvent.click(btn); + await waitFor(() => { + expect(mockSignOut).toHaveBeenCalledWith({ redirectUrl: url }); + }); + }); + + it('handles signOutOptions prop', async () => { + render(); + const btn = screen.getByText('Sign out'); + userEvent.click(btn); + await waitFor(() => { + expect(mockSignOut).toHaveBeenCalledWith({ redirectUrl: url, sessionId: 'sess_1yDceUR8SIKtQ0gIOO8fNsW7nhe' }); + }); + }); + it('uses text passed as children', async () => { render(text); screen.getByText('text'); From 4ff29ddf1d2e0246a1f1333fed813340b5d6e7a4 Mon Sep 17 00:00:00 2001 From: Robert Soriano Date: Wed, 30 Oct 2024 12:42:15 -0700 Subject: [PATCH 3/3] chore: add changeset --- .changeset/beige-bananas-look.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/beige-bananas-look.md diff --git a/.changeset/beige-bananas-look.md b/.changeset/beige-bananas-look.md new file mode 100644 index 00000000000..555726fa3b8 --- /dev/null +++ b/.changeset/beige-bananas-look.md @@ -0,0 +1,5 @@ +--- +"@clerk/clerk-react": patch +--- + +Fix `signOutOptions` prop usage in `` component