diff --git a/cypress/integration/realm_test.spec.ts b/cypress/integration/realm_test.spec.ts
index b549f96733..fc3d0f57fb 100644
--- a/cypress/integration/realm_test.spec.ts
+++ b/cypress/integration/realm_test.spec.ts
@@ -3,7 +3,10 @@ import SidebarPage from "../support/pages/admin_console/SidebarPage";
import CreateRealmPage from "../support/pages/admin_console/CreateRealmPage";
import Masthead from "../support/pages/admin_console/Masthead";
import AdminClient from "../support/util/AdminClient";
-import { keycloakBefore } from "../support/util/keycloak_hooks";
+import {
+ keycloakBefore,
+ keycloakBeforeEach,
+} from "../support/util/keycloak_hooks";
const masthead = new Masthead();
const loginPage = new LoginPage();
@@ -13,11 +16,15 @@ const createRealmPage = new CreateRealmPage();
describe("Realms test", () => {
const testRealmName = "Test realm";
describe("Realm creation", () => {
- beforeEach(() => {
+ before(() => {
keycloakBefore();
loginPage.logIn();
});
+ beforeEach(() => {
+ keycloakBeforeEach();
+ });
+
after(async () => {
const client = new AdminClient();
[testRealmName, "one", "two"].map(
@@ -45,7 +52,7 @@ describe("Realms test", () => {
sidebarPage.goToCreateRealm();
createRealmPage.fillRealmName("one").createRealm();
- const fetchUrl = "/auth/admin/realms";
+ const fetchUrl = "/auth/admin/realms?briefRepresentation=true";
cy.intercept(fetchUrl).as("fetch");
masthead.checkNotificationMessage("Realm created");
@@ -61,7 +68,7 @@ describe("Realms test", () => {
});
it("should change to Test realm", () => {
- sidebarPage.getCurrentRealm().should("eq", "Master");
+ sidebarPage.getCurrentRealm().should("eq", "Two");
sidebarPage
.goToRealm(testRealmName)
diff --git a/cypress/support/pages/admin_console/CreateRealmPage.ts b/cypress/support/pages/admin_console/CreateRealmPage.ts
index 1329fdf12c..c109de5e52 100644
--- a/cypress/support/pages/admin_console/CreateRealmPage.ts
+++ b/cypress/support/pages/admin_console/CreateRealmPage.ts
@@ -20,7 +20,7 @@ export default class CreateRealmPage {
}
fillRealmName(realmName: string) {
- cy.get(this.realmNameInput).type(realmName);
+ cy.get(this.realmNameInput).clear().type(realmName);
return this;
}
diff --git a/src/components/realm-selector/RealmSelector.tsx b/src/components/realm-selector/RealmSelector.tsx
index 5b947722cd..b73026df9d 100644
--- a/src/components/realm-selector/RealmSelector.tsx
+++ b/src/components/realm-selector/RealmSelector.tsx
@@ -41,7 +41,7 @@ export const RealmSelector = () => {
})
.concat(
realms
- .filter((r) => !recentUsed.used.includes(r.realm!))
+ .filter((r) => !recentUsed.used.includes(r.realm!) || r.realm === realm)
.map((r) => {
return { name: r.realm!, used: false };
})
@@ -132,9 +132,11 @@ export const RealmSelector = () => {
onSearchInputChange={(value) => setSearch(value)}
className="keycloak__realm_selector__context_selector"
footer={
-
-
-
+ whoAmI.canCreateRealm() && (
+
+
+
+ )
}
>
{(filteredItems || all).map((item) => (
diff --git a/src/context/RealmsContext.tsx b/src/context/RealmsContext.tsx
index dcf0777e47..8005af7824 100644
--- a/src/context/RealmsContext.tsx
+++ b/src/context/RealmsContext.tsx
@@ -33,7 +33,7 @@ export const RealmsProvider: FunctionComponent = ({ children }) => {
}
useFetch(
- () => adminClient.realms.find(),
+ () => adminClient.realms.find({ briefRepresentation: true }),
(realms) => updateRealms(realms),
[]
);
@@ -42,7 +42,7 @@ export const RealmsProvider: FunctionComponent = ({ children }) => {
//this is needed otherwise the realm find function will not return
//new or renamed realms because of the cached realms in the token (perhaps?)
await adminClient.keycloak?.updateToken(Number.MAX_VALUE);
- updateRealms(await adminClient.realms.find());
+ updateRealms(await adminClient.realms.find({ briefRepresentation: true }));
}, []);
const value = useMemo(