1
import { v4 as uuid } from "uuid";
2
import LoginPage from "../support/pages/LoginPage";
3
import SidebarPage from "../support/pages/admin-ui/SidebarPage";
4
import CreateRealmPage from "../support/pages/admin-ui/CreateRealmPage";
5
import Masthead from "../support/pages/admin-ui/Masthead";
6
import adminClient from "../support/util/AdminClient";
7
import { keycloakBefore } from "../support/util/keycloak_hooks";
8
import RealmSettings from "../support/pages/admin-ui/configure/realm_settings/RealmSettings";
9
import ModalUtils from "../support/util/ModalUtils";
11
const masthead = new Masthead();
12
const loginPage = new LoginPage();
13
const sidebarPage = new SidebarPage();
14
const createRealmPage = new CreateRealmPage();
15
const realmSettings = new RealmSettings();
16
const modalUtils = new ModalUtils();
18
const testRealmName = "Test-realm-" + uuid();
19
const newRealmName = "New-Test-realm-" + uuid();
20
const editedRealmName = "Edited-Test-realm-" + uuid();
21
const testDisabledName = "Test-Disabled";
23
describe("Realm tests", () => {
31
[testRealmName, newRealmName, editedRealmName].map((realm) =>
32
adminClient.deleteRealm(realm),
37
it("should fail creating duplicated or empty name realm", () => {
38
sidebarPage.goToCreateRealm();
40
createRealmPage.createRealm().verifyRealmNameFieldInvalid();
42
createRealmPage.fillRealmName("master").createRealm();
44
masthead.checkNotificationMessage(
45
"Could not create realm Conflict detected. See logs for details",
48
createRealmPage.cancelRealmCreation();
51
it("should create Test realm", () => {
52
sidebarPage.goToCreateRealm();
54
// Test and clear resource field
55
createRealmPage.fillCodeEditor();
56
createRealmPage.clearTextField();
58
createRealmPage.fillRealmName(testRealmName).createRealm();
60
masthead.checkNotificationMessage("Realm created successfully");
63
it("CRUD test of Disabled realm", () => {
64
sidebarPage.goToCreateRealm();
65
sidebarPage.waitForPageLoad();
67
createRealmPage.fillRealmName(testDisabledName).createRealm();
69
masthead.checkNotificationMessage("Realm created successfully");
72
sidebarPage.goToRealm(testDisabledName).goToRealmSettings();
74
createRealmPage.disableRealm();
75
modalUtils.confirmModal();
77
masthead.checkNotificationMessage("Realm successfully updated");
79
sidebarPage.goToRealm(testDisabledName).goToRealmSettings();
80
realmSettings.clickActionMenu();
81
cy.findByText("Delete").click();
82
modalUtils.cancelModal();
85
sidebarPage.waitForPageLoad();
86
sidebarPage.goToRealm(testDisabledName).goToRealmSettings();
87
realmSettings.clickActionMenu();
88
cy.findByText("Delete").click();
89
modalUtils.confirmModal();
90
masthead.checkNotificationMessage("The realm has been deleted");
92
// Show current realms
93
sidebarPage.realmExists("Test-Disabled", false);
96
it("should create realm from new a realm", () => {
97
sidebarPage.goToCreateRealm();
98
createRealmPage.fillRealmName(newRealmName).createRealm();
100
masthead.checkNotificationMessage("Realm created successfully");
102
sidebarPage.goToCreateRealm();
103
createRealmPage.fillRealmName(editedRealmName).createRealm();
105
masthead.checkNotificationMessage("Realm created successfully");
107
// Show current realms
108
sidebarPage.showCurrentRealms(4);
111
it("should change to Test realm", () => {
112
sidebarPage.goToRealm(editedRealmName);
113
sidebarPage.getCurrentRealm().should("eq", editedRealmName);
116
.goToRealm(testRealmName)
118
.should("eq", testRealmName);