Skip to content

Commit 3801276

Browse files
committed
chore: PR updates
1 parent 1967f43 commit 3801276

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@ All notable changes to this project will be documented in this file. Dates are d
44

55
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
66

7+
#### [5.5.0-6](https://github.com/kinde-oss/kinde-auth-react/compare/5.4.1...5.5.0-6)
8+
9+
- feat: ProfileLink [`ccbf656`](https://github.com/kinde-oss/kinde-auth-react/commit/ccbf656a2a1acc17dbf216ba18851a66383be4a2)
10+
711
#### [5.4.1](https://github.com/kinde-oss/kinde-auth-react/compare/5.4.0...5.4.1)
812

13+
> 23 May 2025
14+
15+
- chore: release v5.4.1 [`b8e470c`](https://github.com/kinde-oss/kinde-auth-react/commit/b8e470c2ba2ae7c27b1a806c3a6af68ba77c715f)
916
- Merge pull request #141 from kinde-oss/fix/logoutlink-redirect [`f5dc561`](https://github.com/kinde-oss/kinde-auth-react/commit/f5dc5616f84d720cff18e562ff85bd8e37d88187)
1017
- fix: LogoutLink redirectUrl [`9697ce1`](https://github.com/kinde-oss/kinde-auth-react/commit/9697ce1d5c156a0b9c0b786225b62d0063fe12c3)
1118

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kinde-oss/kinde-auth-react",
3-
"version": "5.4.1",
3+
"version": "5.5.0-6",
44
"description": "Kinde React SDK for authentication",
55
"module": "./dist/kinde-auth-react.mjs",
66
"main": "./dist/kinde-auth-react.js",

src/components/PortalLink.test.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
render,
66
screen,
77
fireEvent,
8+
waitFor,
89
} from "@testing-library/react";
910
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
1011
import { PortalLink } from ".";
@@ -61,4 +62,22 @@ describe("ProfileLink Component", () => {
6162
expect(button).toHaveClass("test-class");
6263
expect(button).toBeDisabled();
6364
});
65+
66+
it("handles generatePortalUrl errors gracefully", async () => {
67+
const mockError = new Error("Failed to generate portal URL");
68+
mockGeneratePortalUrl.mockRejectedValueOnce(mockError);
69+
70+
const consoleSpy = vi.spyOn(console, "error").mockImplementation(() => {});
71+
72+
render(<PortalLink>Profile</PortalLink>);
73+
const button = screen.getByRole("button", { name: "Profile" });
74+
75+
fireEvent.click(button);
76+
77+
await waitFor(() => {
78+
expect(mockGeneratePortalUrl).toHaveBeenCalledTimes(1);
79+
});
80+
81+
consoleSpy.mockRestore();
82+
});
6483
});

src/components/PortalLink.tsx

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,23 @@ export function PortalLink({ children, ...props }: PortalLinkProps) {
66
const auth = useKindeAuth();
77

88
const viewProfile = useCallback(async () => {
9-
const generatedUrl = await auth.generatePortalUrl({
10-
subNav: props.subNav,
11-
returnUrl: props.returnUrl || window.location.href,
12-
});
13-
window.location.href = generatedUrl.url.toString();
9+
try {
10+
const generatedUrl = await auth.generatePortalUrl({
11+
subNav: props.subNav,
12+
returnUrl: props.returnUrl || window.location.href,
13+
});
14+
window.location.href = generatedUrl.url.toString();
15+
} catch (error) {
16+
console.error("Failed to generate portal URL:", error);
17+
}
1418
}, [auth, props.returnUrl, props.subNav]);
1519

1620
return (
1721
<button
1822
type="button"
1923
{...props}
20-
onClick={() => {
21-
viewProfile();
24+
onClick={async () => {
25+
await viewProfile();
2226
}}
2327
>
2428
{children}

0 commit comments

Comments
 (0)