Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions js/apps/admin-ui/cypress/e2e/clients_test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1278,6 +1278,25 @@ describe("Clients test", () => {
});
});

describe("Generated home URLs for built-in clients", () => {
beforeEach(() => {
loginPage.logIn();
keycloakBefore();
commonPage.sidebar().goToRealm(realmName);
commonPage.sidebar().goToClients();
});

it("Check account-console Home URL", () => {
cy.findByTestId("client-home-url-account-console").contains("/account/");
});

it("Check security-admin-console Home URL", () => {
cy.findByTestId("client-home-url-security-admin-console").contains(
"/console/",
);
});
});

describe("Accessibility tests for clients", () => {
const clientId = "a11y-client";

Expand Down
7 changes: 6 additions & 1 deletion js/apps/admin-ui/src/clients/ClientsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ const ClientHomeLink = (client: ClientRepresentation) => {
return "—";
}

return <FormattedLink href={href} />;
return (
<FormattedLink
href={href}
data-testid={`client-home-url-${client.clientId}`}
/>
);
};

const ToolbarItems = () => {
Expand Down
6 changes: 3 additions & 3 deletions js/apps/admin-ui/src/utils/client-url.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@ describe("convertClientToUrl", () => {
it("when root url constrains ${authAdminUrl}", () => {
//given
const rootUrl = "${authAdminUrl}";
const adminUrl = "/else";
const baseUrl = "/else";

//when
const result = convertClientToUrl(
{ rootUrl, adminUrl },
{ rootUrl, baseUrl },
//@ts-ignore
{ adminBaseUrl: "/admin" },
);

//then
expect(result).toBe("/admin");
expect(result).toBe("/admin/else");
});

it("when root url constrains ${authBaseUrl}", () => {
Expand Down
5 changes: 4 additions & 1 deletion js/apps/admin-ui/src/utils/client-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export const convertClientToUrl = (
}

if (rootUrl === "${authAdminUrl}") {
return rootUrl.replace(/\$\{(authAdminUrl)\}/, environment.adminBaseUrl);
return joinPath(
rootUrl.replace(/\$\{(authAdminUrl)\}/, environment.adminBaseUrl),
baseUrl || "",
);
}

if (rootUrl === "${authBaseUrl}") {
Expand Down