Skip to content

Commit aad6586

Browse files
committed
[React SDK] Fix: Hides custom_jwt profiles from UI (#5802)
## Problem solved Short description of the bug fixed or feature added <!-- start pr-codex --> --- ## PR-Codex overview This PR focuses on enhancing the filtering logic in the `LinkedProfilesScreen` component to exclude specific profile types, namely `guest`, `custom_jwt`, and `custom_auth_endpoint`, from being displayed. It also updates the test cases to reflect these changes. ### Detailed summary - Updated the filtering logic in `LinkedProfilesScreen.tsx` to exclude `guest`, `custom_jwt`, and `custom_auth_endpoint` profiles. - Added a test case to verify that `custom_jwt` profiles are not displayed. - Added a test case to ensure profiles that are not `guest` or `custom_jwt` are displayed correctly. > ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}` <!-- end pr-codex -->
1 parent 3683c11 commit aad6586

File tree

2 files changed

+34
-12
lines changed

2 files changed

+34
-12
lines changed

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/LinkedProfilesScreen.test.tsx

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,6 @@ describe("LinkedProfilesScreen", () => {
9999
expect(screen.getByText("cognito@example.com")).toBeInTheDocument();
100100
});
101101

102-
it("should display Custom Profile for custom_auth_endpoint", () => {
103-
vi.mocked(useProfiles).mockReturnValue({
104-
data: [{ type: "Custom_auth_endpoint", details: {} }],
105-
isLoading: false,
106-
// biome-ignore lint/suspicious/noExplicitAny: Mocking data
107-
} as any);
108-
109-
render(<LinkedProfilesScreen {...mockProps} />);
110-
expect(screen.getByText("Custom Profile")).toBeInTheDocument();
111-
});
112-
113102
it("should capitalize unknown profile types", () => {
114103
vi.mocked(useProfiles).mockReturnValue({
115104
data: [{ type: "unknown", details: {} }],
@@ -156,5 +145,33 @@ describe("LinkedProfilesScreen", () => {
156145
render(<LinkedProfilesScreen {...mockProps} />);
157146
expect(screen.queryByLabelText("Unlink")).not.toBeInTheDocument();
158147
});
148+
149+
it("should not display custom_jwt profiles", () => {
150+
vi.mocked(useProfiles).mockReturnValue({
151+
data: [{ type: "custom_jwt", details: {} }],
152+
isLoading: false,
153+
// biome-ignore lint/suspicious/noExplicitAny: Mocking data
154+
} as any);
155+
156+
render(<LinkedProfilesScreen {...mockProps} />);
157+
expect(screen.queryByText("Custom_jwt")).not.toBeInTheDocument();
158+
});
159+
160+
it("should display profiles that are not guest or custom_jwt", () => {
161+
vi.mocked(useProfiles).mockReturnValue({
162+
data: [
163+
{ type: "email", details: { email: "test@example.com" } },
164+
{ type: "custom_jwt", details: {} },
165+
{ type: "guest", details: {} },
166+
],
167+
isLoading: false,
168+
// biome-ignore lint/suspicious/noExplicitAny: Mocking data
169+
} as any);
170+
171+
render(<LinkedProfilesScreen {...mockProps} />);
172+
expect(screen.getByText("test@example.com")).toBeInTheDocument();
173+
expect(screen.queryByText("Custom_jwt")).not.toBeInTheDocument();
174+
expect(screen.queryByText("Guest")).not.toBeInTheDocument();
175+
});
159176
});
160177
});

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/LinkedProfilesScreen.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ export function LinkedProfilesScreen(props: {
9898
<Spacer y="xs" />
9999
{/* Exclude guest as a profile */}
100100
{connectedProfiles
101-
?.filter((profile) => profile.type !== "guest")
101+
?.filter(
102+
(profile) =>
103+
profile.type.toLowerCase() !== "guest" &&
104+
profile.type.toLowerCase() !== "custom_jwt" &&
105+
profile.type.toLowerCase() !== "custom_auth_endpoint",
106+
)
102107
.map((profile) => (
103108
<LinkedProfile
104109
key={`${JSON.stringify(profile)}`}

0 commit comments

Comments
 (0)