Skip to content

Commit

Permalink
[React SDK] Fix: Hides custom_jwt profiles from UI (#5802)
Browse files Browse the repository at this point in the history
## 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 -->
  • Loading branch information
gregfromstl committed Dec 19, 2024
1 parent 3683c11 commit aad6586
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,6 @@ describe("LinkedProfilesScreen", () => {
expect(screen.getByText("cognito@example.com")).toBeInTheDocument();
});

it("should display Custom Profile for custom_auth_endpoint", () => {
vi.mocked(useProfiles).mockReturnValue({
data: [{ type: "Custom_auth_endpoint", details: {} }],
isLoading: false,
// biome-ignore lint/suspicious/noExplicitAny: Mocking data
} as any);

render(<LinkedProfilesScreen {...mockProps} />);
expect(screen.getByText("Custom Profile")).toBeInTheDocument();
});

it("should capitalize unknown profile types", () => {
vi.mocked(useProfiles).mockReturnValue({
data: [{ type: "unknown", details: {} }],
Expand Down Expand Up @@ -156,5 +145,33 @@ describe("LinkedProfilesScreen", () => {
render(<LinkedProfilesScreen {...mockProps} />);
expect(screen.queryByLabelText("Unlink")).not.toBeInTheDocument();
});

it("should not display custom_jwt profiles", () => {
vi.mocked(useProfiles).mockReturnValue({
data: [{ type: "custom_jwt", details: {} }],
isLoading: false,
// biome-ignore lint/suspicious/noExplicitAny: Mocking data
} as any);

render(<LinkedProfilesScreen {...mockProps} />);
expect(screen.queryByText("Custom_jwt")).not.toBeInTheDocument();
});

it("should display profiles that are not guest or custom_jwt", () => {
vi.mocked(useProfiles).mockReturnValue({
data: [
{ type: "email", details: { email: "test@example.com" } },
{ type: "custom_jwt", details: {} },
{ type: "guest", details: {} },
],
isLoading: false,
// biome-ignore lint/suspicious/noExplicitAny: Mocking data
} as any);

render(<LinkedProfilesScreen {...mockProps} />);
expect(screen.getByText("test@example.com")).toBeInTheDocument();
expect(screen.queryByText("Custom_jwt")).not.toBeInTheDocument();
expect(screen.queryByText("Guest")).not.toBeInTheDocument();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@ export function LinkedProfilesScreen(props: {
<Spacer y="xs" />
{/* Exclude guest as a profile */}
{connectedProfiles
?.filter((profile) => profile.type !== "guest")
?.filter(
(profile) =>
profile.type.toLowerCase() !== "guest" &&
profile.type.toLowerCase() !== "custom_jwt" &&
profile.type.toLowerCase() !== "custom_auth_endpoint",
)
.map((profile) => (
<LinkedProfile
key={`${JSON.stringify(profile)}`}
Expand Down

0 comments on commit aad6586

Please sign in to comment.