diff --git a/cypress/integration/realm_test.spec.ts b/cypress/integration/realm_test.spec.ts index 7fc645da10..8273211e18 100644 --- a/cypress/integration/realm_test.spec.ts +++ b/cypress/integration/realm_test.spec.ts @@ -20,7 +20,9 @@ describe("Realms test", () => { after(async () => { const client = new AdminClient(); - await client.deleteRealm(testRealmName); + [testRealmName, "one", "two"].map( + async (realm) => await client.deleteRealm(realm) + ); }); it("should fail creating Master realm", () => { @@ -39,6 +41,25 @@ describe("Realms test", () => { masthead.checkNotificationMessage("Realm created"); }); + it("should create realm from new a realm", () => { + sidebarPage.goToCreateRealm(); + createRealmPage.fillRealmName("one").createRealm(); + + const fetchUrl = "/auth/admin/realms"; + cy.intercept(fetchUrl).as("fetch"); + + masthead.checkNotificationMessage("Realm created"); + + cy.wait(["@fetch"]); + + sidebarPage.goToCreateRealm(); + createRealmPage.fillRealmName("two").createRealm(); + + masthead.checkNotificationMessage("Realm created"); + + cy.wait(["@fetch"]); + }); + it("should change to Test realm", () => { sidebarPage.getCurrentRealm().should("eq", "Master"); diff --git a/src/context/whoami/WhoAmI.tsx b/src/context/whoami/WhoAmI.tsx index 65a8fbb908..88fd66babf 100644 --- a/src/context/whoami/WhoAmI.tsx +++ b/src/context/whoami/WhoAmI.tsx @@ -1,6 +1,7 @@ import type WhoAmIRepresentation from "keycloak-admin/lib/defs/whoAmIRepresentation"; import type { AccessType } from "keycloak-admin/lib/defs/whoAmIRepresentation"; import React, { FunctionComponent, useState } from "react"; +import environment from "../../environment"; import i18n from "../../i18n"; import useRequiredContext from "../../utils/useRequiredContext"; import { useAdminClient, useFetch } from "../auth/AdminClient"; @@ -56,7 +57,7 @@ export const WhoAmIContextProvider: FunctionComponent = ({ children }) => { const [key, setKey] = useState(0); useFetch( - () => adminClient.whoAmI.find(), + () => adminClient.whoAmI.find({ realm: environment.loginRealm }), (me) => { const whoAmI = new WhoAmI(me); setWhoAmI(whoAmI);