2022-01-07 12:56:27 +00:00
|
|
|
import ListingPage from "../support/pages/admin_console/ListingPage";
|
2022-02-16 11:39:08 +00:00
|
|
|
import UserProfile from "../support/pages/admin_console/manage/realm_settings/UserProfile";
|
2022-04-11 14:00:08 +00:00
|
|
|
import Masthead from "../support/pages/admin_console/Masthead";
|
2022-01-07 12:56:27 +00:00
|
|
|
import SidebarPage from "../support/pages/admin_console/SidebarPage";
|
|
|
|
import LoginPage from "../support/pages/LoginPage";
|
2022-02-24 10:31:46 +00:00
|
|
|
import adminClient from "../support/util/AdminClient";
|
2022-01-07 16:31:56 +00:00
|
|
|
import { keycloakBefore } from "../support/util/keycloak_hooks";
|
2022-01-07 12:56:27 +00:00
|
|
|
import ModalUtils from "../support/util/ModalUtils";
|
|
|
|
|
|
|
|
const loginPage = new LoginPage();
|
|
|
|
const sidebarPage = new SidebarPage();
|
2022-02-16 11:39:08 +00:00
|
|
|
const userProfileTab = new UserProfile();
|
2022-01-07 12:56:27 +00:00
|
|
|
const listingPage = new ListingPage();
|
|
|
|
const modalUtils = new ModalUtils();
|
2022-04-11 14:00:08 +00:00
|
|
|
const masthead = new Masthead();
|
2022-01-07 12:56:27 +00:00
|
|
|
|
|
|
|
// Selectors
|
2022-02-16 11:39:08 +00:00
|
|
|
const getUserProfileTab = () => userProfileTab.goToTab();
|
|
|
|
const getAttributesTab = () => userProfileTab.goToAttributesTab();
|
|
|
|
const getAttributesGroupTab = () => userProfileTab.goToAttributesGroupTab();
|
|
|
|
const getJsonEditorTab = () => userProfileTab.goToJsonEditorTab();
|
|
|
|
const clickCreateAttributeButton = () =>
|
|
|
|
userProfileTab.createAttributeButtonClick();
|
2022-01-07 12:56:27 +00:00
|
|
|
|
|
|
|
describe("User profile tabs", () => {
|
|
|
|
const realmName = "Realm_" + (Math.random() + 1).toString(36).substring(7);
|
2022-04-11 14:00:08 +00:00
|
|
|
const attributeName = "Test";
|
2022-01-07 12:56:27 +00:00
|
|
|
|
|
|
|
before(() =>
|
|
|
|
adminClient.createRealm(realmName, {
|
|
|
|
attributes: { userProfileEnabled: "true" },
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
|
|
|
after(() => adminClient.deleteRealm(realmName));
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
keycloakBefore();
|
|
|
|
loginPage.logIn();
|
|
|
|
sidebarPage.goToRealm(realmName);
|
|
|
|
sidebarPage.goToRealmSettings();
|
|
|
|
});
|
|
|
|
|
2022-02-16 11:39:08 +00:00
|
|
|
describe("Attributes sub tab tests", () => {
|
|
|
|
it("Goes to create attribute page", () => {
|
|
|
|
getUserProfileTab();
|
|
|
|
getAttributesTab();
|
|
|
|
clickCreateAttributeButton();
|
2022-03-24 09:11:35 +00:00
|
|
|
cy.get("p").should("have.text", "Create a new attribute");
|
2022-02-16 11:39:08 +00:00
|
|
|
});
|
2022-04-11 14:00:08 +00:00
|
|
|
|
|
|
|
it("Completes new attribute form and performs cancel", () => {
|
|
|
|
getUserProfileTab();
|
|
|
|
getAttributesTab();
|
|
|
|
clickCreateAttributeButton();
|
|
|
|
userProfileTab
|
|
|
|
.createAttribute(attributeName, "Test display name")
|
|
|
|
.cancelAttributeCreation()
|
|
|
|
.checkElementNotInList(attributeName);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Completes new attribute form and performs submit", () => {
|
|
|
|
getUserProfileTab();
|
|
|
|
getAttributesTab();
|
|
|
|
clickCreateAttributeButton();
|
|
|
|
userProfileTab
|
|
|
|
.createAttribute(attributeName, "Display name")
|
|
|
|
.saveAttributeCreation();
|
|
|
|
masthead.checkNotificationMessage(
|
|
|
|
"Success! User Profile configuration has been saved."
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Modifies existing attribute and performs save", () => {
|
|
|
|
getUserProfileTab();
|
|
|
|
getAttributesTab();
|
|
|
|
userProfileTab
|
|
|
|
.selectElementInList(attributeName)
|
|
|
|
.editAttribute("Edited display name")
|
|
|
|
.saveAttributeCreation();
|
|
|
|
masthead.checkNotificationMessage(
|
|
|
|
"Success! User Profile configuration has been saved."
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("Adds and removes validator to/from existing attribute and performs save", () => {
|
|
|
|
getUserProfileTab();
|
|
|
|
getAttributesTab();
|
|
|
|
userProfileTab.selectElementInList(attributeName).cancelAddingValidator();
|
|
|
|
userProfileTab.addValidator();
|
|
|
|
cy.get('tbody [data-label="Validator name"]').contains("email");
|
|
|
|
|
|
|
|
userProfileTab.cancelRemovingValidator();
|
|
|
|
userProfileTab.removeValidator();
|
|
|
|
cy.get('tbody [class="kc-emptyValidators"]').contains("No validators.");
|
|
|
|
});
|
2022-02-16 11:39:08 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe("Attribute groups sub tab tests", () => {
|
|
|
|
it("Deletes an attributes group", () => {
|
2022-01-07 12:56:27 +00:00
|
|
|
cy.wrap(null).then(() =>
|
|
|
|
adminClient.patchUserProfile(realmName, {
|
|
|
|
groups: [{ name: "Test" }],
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
2022-02-16 11:39:08 +00:00
|
|
|
getUserProfileTab();
|
|
|
|
getAttributesGroupTab();
|
2022-01-07 12:56:27 +00:00
|
|
|
listingPage.deleteItem("Test");
|
|
|
|
modalUtils.confirmModal();
|
|
|
|
listingPage.itemExist("Test", false);
|
|
|
|
});
|
|
|
|
});
|
2022-02-16 11:39:08 +00:00
|
|
|
|
|
|
|
describe("Json Editor sub tab tests", () => {
|
|
|
|
it("Goes to Json Editor tab", () => {
|
|
|
|
getUserProfileTab();
|
|
|
|
getJsonEditorTab();
|
|
|
|
});
|
|
|
|
});
|
2022-01-07 12:56:27 +00:00
|
|
|
});
|