Additional tests for User Profile, Attributes & Realm-Settings/Login configs (#24243)

* added some user profile tests

* added some user profile tests

* added more tests for user profile and attributes

* improved tests for user profile

* removed videos

* refactor and improvement

* improved tests

---------

Co-authored-by: Agnieszka Gancarczyk <agancarc@redhat.com>
This commit is contained in:
agagancarczyk 2023-10-26 14:22:43 +01:00 committed by GitHub
parent 2c4d58f5af
commit 54a081832a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 633 additions and 145 deletions

View file

@ -0,0 +1,155 @@
import { v4 as uuid } from "uuid";
import Masthead from "../support/pages/admin-ui/Masthead";
import SidebarPage from "../support/pages/admin-ui/SidebarPage";
import LoginPage from "../support/pages/LoginPage";
import adminClient from "../support/util/AdminClient";
import { keycloakBefore } from "../support/util/keycloak_hooks";
import CreateUserPage from "../support/pages/admin-ui/manage/users/CreateUserPage";
import RealmSettingsPage from "../support/pages/admin-ui/manage/realm_settings/RealmSettingsPage";
import ListingPage from "../support/pages/admin-ui/ListingPage";
const loginPage = new LoginPage();
const sidebarPage = new SidebarPage();
const realmSettingsPage = new RealmSettingsPage();
const createUserPage = new CreateUserPage();
const masthead = new Masthead();
const listingPage = new ListingPage();
describe("User profile disabled", () => {
const realmName = "Realm_" + uuid();
before(async () => {
await adminClient.createRealm(realmName, {
attributes: { userProfileEnabled: "false" },
});
});
after(async () => {
await adminClient.deleteRealm(realmName);
});
beforeEach(() => {
loginPage.logIn();
keycloakBefore();
sidebarPage.goToRealm(realmName);
});
afterEach(() => {
sidebarPage.goToRealmSettings();
realmSettingsPage.goToLoginTab();
cy.findByTestId("email-as-username-switch").uncheck({ force: true });
cy.findByTestId("edit-username-switch").uncheck({ force: true });
});
it("Create user with email as username, edit username and user profile disabled", () => {
// Ensure email as username and edit username are disabled
sidebarPage.goToRealmSettings();
realmSettingsPage.goToLoginTab();
cy.findByTestId("email-as-username-switch").should("have.value", "off");
cy.findByTestId("edit-username-switch").should("have.value", "off");
// Create user
sidebarPage.goToUsers();
createUserPage.goToCreateUser();
createUserPage.createUser("testuser1");
createUserPage.save();
masthead.checkNotificationMessage("The user has been created");
// Check that username is readonly
cy.get("#kc-username").should("have.attr", "readonly");
});
it("Create user with email as username enabled, edit username disabled and user profile disabled", () => {
// Create user and check that username is not visible and that email is editable
sidebarPage.goToUsers();
createUserPage.goToCreateUser();
createUserPage.createUser("testuser2");
createUserPage.save();
masthead.checkNotificationMessage("The user has been created");
// Ensure email as username is enabled and edit username are disabled
sidebarPage.goToRealmSettings();
realmSettingsPage.goToLoginTab();
cy.findByTestId("email-as-username-switch").check({ force: true });
cy.findByTestId("email-as-username-switch").should("have.value", "on");
cy.findByTestId("edit-username-switch").should("have.value", "off");
//Find user and do some checks
sidebarPage.goToUsers();
sidebarPage.waitForPageLoad();
listingPage.goToItemDetails("testuser2");
cy.findByTestId("view-header").should("contain.text", "testuser2");
cy.get("#kc-username").should("not.exist");
cy.findByTestId("email-input").type("testuser1@gmail.com");
cy.findByTestId("save-user").click();
masthead.checkNotificationMessage("The user has been saved");
cy.findByTestId("view-header").should(
"contain.text",
"testuser1@gmail.com",
);
cy.findByTestId("email-input").clear();
cy.findByTestId("email-input").type("testuser2@gmail.com");
cy.findByTestId("save-user").click();
masthead.checkNotificationMessage("The user has been saved");
cy.findByTestId("view-header").should(
"contain.text",
"testuser2@gmail.com",
);
});
it("Create user with email as username disabled, edit username enabled and user profile disabled", () => {
// Ensure email as username is disabled and edit username is enabled
sidebarPage.goToRealmSettings();
realmSettingsPage.goToLoginTab();
cy.findByTestId("email-as-username-switch").should("have.value", "off");
cy.findByTestId("edit-username-switch").check({ force: true });
cy.findByTestId("edit-username-switch").should("have.value", "on");
// Create user and check that username is visible and that email is editable
sidebarPage.goToUsers();
createUserPage.goToCreateUser();
cy.get("#kc-username").type("testuser3");
cy.findByTestId("email-input").type("testuser3@test.com");
cy.findByTestId("create-user").click();
masthead.checkNotificationMessage("The user has been created");
cy.findByTestId("email-input").clear();
cy.findByTestId("email-input").type("testuser4@test.com");
cy.findByTestId("save-user").click();
masthead.checkNotificationMessage("The user has been saved");
cy.findByTestId("view-header").should("contain.text", "testuser3");
});
it("Create user with email as username, edit username enabled and user profile disabled", () => {
// Create user and check that username is not visible and that email is editable
sidebarPage.goToUsers();
createUserPage.goToCreateUser();
createUserPage.createUser("testuser5");
cy.findByTestId("email-input").type("testuser5@gmail.com");
createUserPage.save();
masthead.checkNotificationMessage("The user has been created");
sidebarPage.goToRealmSettings();
realmSettingsPage.goToLoginTab();
cy.findByTestId("edit-username-switch").check({ force: true });
cy.findByTestId("edit-username-switch").should("have.value", "on");
cy.findByTestId("email-as-username-switch").check({ force: true });
cy.findByTestId("email-as-username-switch").should("have.value", "on");
//Find user and do some checks
sidebarPage.goToUsers();
sidebarPage.waitForPageLoad();
listingPage.goToItemDetails("testuser5");
cy.findByTestId("view-header").should("contain.text", "testuser5");
cy.get("#kc-username").should("not.exist");
cy.findByTestId("email-input").clear();
cy.findByTestId("email-input").type("testuser6@test.com");
cy.findByTestId("save-user").click();
cy.findByTestId("view-header").should("contain.text", "testuser6@test.com");
masthead.checkNotificationMessage("The user has been saved");
});
});

View file

@ -0,0 +1,417 @@
import { v4 as uuid } from "uuid";
import ListingPage from "../support/pages/admin-ui/ListingPage";
import UserProfile from "../support/pages/admin-ui/manage/realm_settings/UserProfile";
import Masthead from "../support/pages/admin-ui/Masthead";
import SidebarPage from "../support/pages/admin-ui/SidebarPage";
import LoginPage from "../support/pages/LoginPage";
import adminClient from "../support/util/AdminClient";
import { keycloakBefore } from "../support/util/keycloak_hooks";
import ModalUtils from "../support/util/ModalUtils";
import RealmSettingsPage from "../support/pages/admin-ui/manage/realm_settings/RealmSettingsPage";
import CreateUserPage from "../support/pages/admin-ui/manage/users/CreateUserPage";
const loginPage = new LoginPage();
const sidebarPage = new SidebarPage();
const userProfileTab = new UserProfile();
const listingPage = new ListingPage();
const modalUtils = new ModalUtils();
const masthead = new Masthead();
const realmSettingsPage = new RealmSettingsPage();
const createUserPage = new CreateUserPage();
// Selectors
const getUserProfileTab = () => userProfileTab.goToTab();
const getAttributesTab = () => userProfileTab.goToAttributesTab();
const getAttributesGroupTab = () => userProfileTab.goToAttributesGroupTab();
const getJsonEditorTab = () => userProfileTab.goToJsonEditorTab();
const clickCreateAttributeButton = () =>
userProfileTab.createAttributeButtonClick();
describe("User profile tabs", () => {
const realmName = "Realm_" + uuid();
const attributeName = "Test";
before(() =>
adminClient.createRealm(realmName, {
attributes: { userProfileEnabled: "true" },
}),
);
after(() => adminClient.deleteRealm(realmName));
beforeEach(() => {
loginPage.logIn();
keycloakBefore();
sidebarPage.goToRealm(realmName);
sidebarPage.goToRealmSettings();
});
afterEach(() => {
sidebarPage.goToRealmSettings();
sidebarPage.waitForPageLoad();
realmSettingsPage.goToLoginTab();
cy.findByTestId("email-as-username-switch").uncheck({ force: true });
cy.findByTestId("edit-username-switch").uncheck({ force: true });
});
describe("Attributes sub tab tests", () => {
it("Goes to create attribute page", () => {
getUserProfileTab();
getAttributesTab();
clickCreateAttributeButton();
});
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(".kc-emptyValidators").contains("No validators.");
});
});
describe("Attribute groups sub tab tests", () => {
it("Deletes an attributes group", () => {
cy.wrap(null).then(() =>
adminClient.patchUserProfile(realmName, {
groups: [{ name: "Test" }],
}),
);
getUserProfileTab();
getAttributesGroupTab();
listingPage.deleteItem("Test");
modalUtils.confirmModal();
listingPage.checkEmptyList();
});
});
describe("Json Editor sub tab tests", () => {
const removedThree = `
{ctrl+a}{backspace}
{
"attributes": [
{
"name": "username",
"validations": {
"length": {
"min": 3,
"max": 255 {downArrow},
"username-prohibited-characters": {
`;
it("Removes three validators with the editor", () => {
getUserProfileTab();
getJsonEditorTab();
userProfileTab.typeJSON(removedThree).saveJSON();
masthead.checkNotificationMessage(
"User profile settings successfully updated.",
);
});
});
describe("Check attribute presence when creating a user based on email as username and edit username configs enabled/disabled", () => {
it("Checks that not required attribute is not present when user is created with email as username and edit username set to disabled", () => {
getUserProfileTab();
getAttributesTab();
clickCreateAttributeButton();
userProfileTab
.createAttributeNotRequiredWithoutPermissions(
"newAttribute1",
"newAttribute1",
)
.saveAttributeCreation();
masthead.checkNotificationMessage(
"Success! User Profile configuration has been saved.",
);
sidebarPage.goToRealmSettings();
realmSettingsPage.goToLoginTab();
cy.findByTestId("email-as-username-switch").should("have.value", "off");
cy.findByTestId("edit-username-switch").should("have.value", "off");
// Create user
sidebarPage.goToUsers();
createUserPage.goToCreateUser();
cy.findByTestId("username").type("testuser7");
cy.findByTestId("create-user").click();
masthead.checkNotificationMessage("The user has been created");
cy.get(".pf-c-form__label-text")
.contains("newAttribute1")
.should("not.exist");
sidebarPage.goToRealmSettings();
getUserProfileTab();
getAttributesTab();
listingPage.deleteItem("newAttribute1");
modalUtils.confirmModal();
masthead.checkNotificationMessage("Attribute deleted");
});
it("Checks that not required attribute is not present when user is created/edited with email as username enabled", () => {
getUserProfileTab();
getAttributesTab();
clickCreateAttributeButton();
userProfileTab
.createAttributeNotRequiredWithoutPermissions(
"newAttribute2",
"newAttribute2",
)
.saveAttributeCreation();
masthead.checkNotificationMessage(
"Success! User Profile configuration has been saved.",
);
sidebarPage.goToRealmSettings();
realmSettingsPage.goToLoginTab();
cy.findByTestId("email-as-username-switch").check({ force: true });
cy.findByTestId("email-as-username-switch").should("have.value", "on");
cy.findByTestId("edit-username-switch").should("have.value", "off");
// Create user
sidebarPage.goToUsers();
createUserPage.goToCreateUser();
cy.findByTestId("email").type("testuser8@gmail.com");
cy.get(".pf-c-form__label-text")
.contains("newAttribute2")
.should("not.exist");
cy.findByTestId("create-user").click();
masthead.checkNotificationMessage("The user has been created");
// Edit user
cy.get(".pf-c-form__label-text")
.contains("newAttribute2")
.should("not.exist");
cy.findByTestId("firstName").type("testuser9");
cy.findByTestId("email").clear();
cy.findByTestId("email").type("testuser9@gmail.com");
cy.findByTestId("save-user").click();
masthead.checkNotificationMessage("The user has been saved");
sidebarPage.goToRealmSettings();
getUserProfileTab();
getAttributesTab();
listingPage.deleteItem("newAttribute2");
modalUtils.confirmModal();
masthead.checkNotificationMessage("Attribute deleted");
});
it("Checks that not required attribute with permissions to view/edit is present when user is created", () => {
getUserProfileTab();
getAttributesTab();
clickCreateAttributeButton();
userProfileTab
.createAttributeNotRequiredWithPermissions(
"newAttribute3",
"newAttribute3",
)
.saveAttributeCreation();
masthead.checkNotificationMessage(
"Success! User Profile configuration has been saved.",
);
sidebarPage.goToRealmSettings();
realmSettingsPage.goToLoginTab();
cy.findByTestId("email-as-username-switch").should("have.value", "off");
cy.findByTestId("edit-username-switch").should("have.value", "off");
// Create user
sidebarPage.goToUsers();
createUserPage.goToCreateUser();
cy.findByTestId("username").type("testuser10");
cy.findByTestId("create-user").click();
masthead.checkNotificationMessage("The user has been created");
cy.get(".pf-c-form__label-text")
.contains("newAttribute3")
.should("exist");
sidebarPage.goToRealmSettings();
getUserProfileTab();
getAttributesTab();
listingPage.deleteItem("newAttribute3");
modalUtils.confirmModal();
masthead.checkNotificationMessage("Attribute deleted");
});
it("Checks that required attribute with permissions to view/edit is present and required when user is created", () => {
getUserProfileTab();
getAttributesTab();
clickCreateAttributeButton();
userProfileTab
.createAttributeRequiredWithPermissions(
"newAttribute4",
"newAttribute4",
)
.saveAttributeCreation();
masthead.checkNotificationMessage(
"Success! User Profile configuration has been saved.",
);
// Create user
sidebarPage.goToUsers();
createUserPage.goToCreateUser();
cy.findByTestId("username").type("testuser11");
cy.get(".pf-c-form__label-text")
.contains("newAttribute4")
.should("exist");
cy.findByTestId("create-user").click();
masthead.checkNotificationMessage(
"Could not create user: Please specify attribute newAttribute4.",
);
sidebarPage.goToRealmSettings();
getUserProfileTab();
getAttributesTab();
listingPage.deleteItem("newAttribute4");
modalUtils.confirmModal();
masthead.checkNotificationMessage("Attribute deleted");
});
it("Checks that required attribute with permissions to view/edit is accepted when user is created", () => {
getUserProfileTab();
getAttributesTab();
clickCreateAttributeButton();
userProfileTab
.createAttributeRequiredWithPermissions(
"newAttribute5",
"newAttribute5",
)
.saveAttributeCreation();
masthead.checkNotificationMessage(
"Success! User Profile configuration has been saved.",
);
// Create user
sidebarPage.goToUsers();
createUserPage.goToCreateUser();
cy.findByTestId("username").type("testuser12");
cy.get(".pf-c-form__label-text")
.contains("newAttribute5")
.should("exist");
cy.findByTestId("newAttribute5").type("MyAttribute");
cy.findByTestId("create-user").click();
masthead.checkNotificationMessage("The user has been created");
sidebarPage.goToRealmSettings();
getUserProfileTab();
getAttributesTab();
listingPage.deleteItem("newAttribute5");
modalUtils.confirmModal();
masthead.checkNotificationMessage("Attribute deleted");
});
it("Checks that attribute group is visible when user with existing attribute is created", () => {
getUserProfileTab();
getAttributesGroupTab();
cy.findAllByTestId("no-attributes-groups-empty-action").click();
userProfileTab.createAttributeGroup("personalInfo", "personalInfo");
userProfileTab.saveAttributesGroupCreation();
getAttributesTab();
userProfileTab.selectElementInList("username");
cy.get("#kc-attributeGroup").click();
cy.get("button.pf-c-select__menu-item").contains("personalInfo").click();
userProfileTab.saveAttributeCreation();
masthead.checkNotificationMessage(
"Success! User Profile configuration has been saved.",
);
// Create user
sidebarPage.goToUsers();
createUserPage.goToCreateUser();
cy.findByTestId("username").type("testuser14");
cy.get("h1#personalinfo").should("have.text", "personalInfo");
cy.findByTestId("create-user").click();
masthead.checkNotificationMessage("The user has been created");
sidebarPage.goToRealmSettings();
getUserProfileTab();
getAttributesTab();
userProfileTab.selectElementInList("username");
cy.get("#kc-attributeGroup").click();
cy.get("button.pf-c-select__menu-item").contains("None").click();
userProfileTab.saveAttributeCreation();
masthead.checkNotificationMessage(
"Success! User Profile configuration has been saved.",
);
getAttributesGroupTab();
listingPage.deleteItem("personalInfo");
modalUtils.confirmModal();
listingPage.checkEmptyList();
});
it("Checks that attribute group is visible when user with a new attribute is created", () => {
getUserProfileTab();
getAttributesGroupTab();
cy.findAllByTestId("no-attributes-groups-empty-action").click();
userProfileTab.createAttributeGroup("contact", "contact");
userProfileTab.saveAttributesGroupCreation();
getAttributesTab();
clickCreateAttributeButton();
userProfileTab
.createAttributeNotRequiredWithPermissions("address", "address")
.saveAttributeCreation();
masthead.checkNotificationMessage(
"Success! User Profile configuration has been saved.",
);
userProfileTab.selectElementInList("address");
cy.get("#kc-attributeGroup").click();
cy.get("button.pf-c-select__menu-item").contains("contact").click();
userProfileTab.saveAttributeCreation();
masthead.checkNotificationMessage(
"Success! User Profile configuration has been saved.",
);
// Create user
sidebarPage.goToUsers();
createUserPage.goToCreateUser();
cy.findByTestId("username").type("testuser13");
cy.get("h1#contact").should("have.text", "contact");
cy.get(".pf-c-form__label-text").contains("address").should("exist");
cy.findByTestId("address").type("MyNewAddress1");
cy.findByTestId("create-user").click();
masthead.checkNotificationMessage("The user has been created");
cy.findByTestId("address").should("have.value", "MyNewAddress1");
// Edit attribute
cy.findByTestId("address").clear();
cy.findByTestId("address").type("MyNewAddress2");
cy.findByTestId("save-user").click();
masthead.checkNotificationMessage("The user has been saved");
cy.findByTestId("address").should("have.value", "MyNewAddress2");
sidebarPage.goToRealmSettings();
getUserProfileTab();
getAttributesTab();
userProfileTab.selectElementInList("address");
cy.get("#kc-attributeGroup").click();
cy.get("button.pf-c-select__menu-item").contains("None").click();
userProfileTab.saveAttributeCreation();
masthead.checkNotificationMessage(
"Success! User Profile configuration has been saved.",
);
getAttributesGroupTab();
listingPage.deleteItem("contact");
modalUtils.confirmModal();
listingPage.checkEmptyList();
});
});
});

View file

@ -1,138 +0,0 @@
import { v4 as uuid } from "uuid";
import ListingPage from "../support/pages/admin-ui/ListingPage";
import UserProfile from "../support/pages/admin-ui/manage/realm_settings/UserProfile";
import Masthead from "../support/pages/admin-ui/Masthead";
import SidebarPage from "../support/pages/admin-ui/SidebarPage";
import LoginPage from "../support/pages/LoginPage";
import adminClient from "../support/util/AdminClient";
import { keycloakBefore } from "../support/util/keycloak_hooks";
import ModalUtils from "../support/util/ModalUtils";
const loginPage = new LoginPage();
const sidebarPage = new SidebarPage();
const userProfileTab = new UserProfile();
const listingPage = new ListingPage();
const modalUtils = new ModalUtils();
const masthead = new Masthead();
// Selectors
const getUserProfileTab = () => userProfileTab.goToTab();
const getAttributesTab = () => userProfileTab.goToAttributesTab();
const getAttributesGroupTab = () => userProfileTab.goToAttributesGroupTab();
const getJsonEditorTab = () => userProfileTab.goToJsonEditorTab();
const clickCreateAttributeButton = () =>
userProfileTab.createAttributeButtonClick();
describe("User profile tabs", () => {
const realmName = "Realm_" + uuid();
const attributeName = "Test";
before(() =>
adminClient.createRealm(realmName, {
attributes: { userProfileEnabled: "true" },
}),
);
after(() => adminClient.deleteRealm(realmName));
beforeEach(() => {
loginPage.logIn();
keycloakBefore();
sidebarPage.goToRealm(realmName);
sidebarPage.goToRealmSettings();
});
describe("Attributes sub tab tests", () => {
it("Goes to create attribute page", () => {
getUserProfileTab();
getAttributesTab();
clickCreateAttributeButton();
});
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(".kc-emptyValidators").contains("No validators.");
});
});
describe("Attribute groups sub tab tests", () => {
it("Deletes an attributes group", () => {
cy.wrap(null).then(() =>
adminClient.patchUserProfile(realmName, {
groups: [{ name: "Test" }],
}),
);
getUserProfileTab();
getAttributesGroupTab();
listingPage.deleteItem("Test");
modalUtils.confirmModal();
listingPage.checkEmptyList();
});
});
describe("Json Editor sub tab tests", () => {
const removedThree = `
{ctrl+a}{backspace}
{
"attributes": [
{
"name": "username",
"validations": {
"length": {
"min": 3,
"max": 255 {downArrow},
"username-prohibited-characters": {
`;
it("Removes three validators with the editor", () => {
getUserProfileTab();
getJsonEditorTab();
userProfileTab.typeJSON(removedThree).saveJSON();
masthead.checkNotificationMessage(
"User profile settings successfully updated.",
);
});
});
});

View file

@ -13,8 +13,6 @@ export default class UserProfile {
#newAttributeNameInput = "attribute-name"; #newAttributeNameInput = "attribute-name";
#newAttributeDisplayNameInput = "attribute-display-name"; #newAttributeDisplayNameInput = "attribute-display-name";
#newAttributeEnabledWhen = 'input[name="enabledWhen"]'; #newAttributeEnabledWhen = 'input[name="enabledWhen"]';
#newAttributeCheckboxes = 'input[type="checkbox"]';
#newAttributeRequiredFor = 'input[name="roles"]';
#newAttributeRequiredWhen = 'input[name="requiredWhen"]'; #newAttributeRequiredWhen = 'input[name="requiredWhen"]';
#newAttributeEmptyValidators = ".kc-emptyValidators"; #newAttributeEmptyValidators = ".kc-emptyValidators";
#newAttributeAnnotationBtn = "annotations-add-row"; #newAttributeAnnotationBtn = "annotations-add-row";
@ -29,6 +27,14 @@ export default class UserProfile {
#deleteValidatorBtn = "confirm"; #deleteValidatorBtn = "confirm";
#cancelAddingValidatorBtn = "cancel-validator-role-button"; #cancelAddingValidatorBtn = "cancel-validator-role-button";
#cancelRemovingValidatorBtn = "cancel"; #cancelRemovingValidatorBtn = "cancel";
#newAttributeRequiredField = "input#kc-required.pf-c-switch__input";
#newAttributeUserEdit = "user-edit";
#newAttributeAdminEdit = "admin-edit";
#newAttributeUserView = "user-view";
#newAttributeAdminView = "admin-view";
#newAttributesGroupNameInput = "input#kc-name";
#newAttributesGroupDisplayNameInput = 'input[name="displayHeader"]';
#saveNewAttributesGroupBtn = "saveGroupBtn";
goToTab() { goToTab() {
cy.findByTestId(this.#userProfileTab).click(); cy.findByTestId(this.#userProfileTab).click();
@ -91,6 +97,53 @@ export default class UserProfile {
return this; return this;
} }
createAttributeNotRequiredWithPermissions(name: string, displayName: string) {
cy.findByTestId(this.#newAttributeNameInput).type(name);
cy.findByTestId(this.#newAttributeDisplayNameInput).type(displayName);
cy.get(this.#newAttributeEnabledWhen).first().check();
cy.findByTestId(this.#newAttributeUserEdit).first().check({ force: true });
cy.findByTestId(this.#newAttributeUserView).first().check({ force: true });
cy.findByTestId(this.#newAttributeAdminView).first().check({ force: true });
return this;
}
createAttributeNotRequiredWithoutPermissions(
name: string,
displayName: string,
) {
cy.findByTestId(this.#newAttributeNameInput).type(name);
cy.findByTestId(this.#newAttributeDisplayNameInput).type(displayName);
cy.get(this.#newAttributeEnabledWhen).first().check();
cy.findByTestId(this.#newAttributeAdminEdit)
.first()
.uncheck({ force: true });
return this;
}
createAttributeRequiredWithPermissions(name: string, displayName: string) {
cy.findByTestId(this.#newAttributeNameInput).type(name);
cy.findByTestId(this.#newAttributeDisplayNameInput).type(displayName);
cy.get(this.#newAttributeEnabledWhen).first().check();
cy.get(this.#newAttributeRequiredField).first().check({ force: true });
cy.get(this.#newAttributeRequiredWhen).first().check({ force: true });
cy.findByTestId(this.#newAttributeUserEdit).first().check({ force: true });
cy.findByTestId(this.#newAttributeUserView).first().check({ force: true });
cy.findByTestId(this.#newAttributeAdminView).first().check({ force: true });
return this;
}
createAttributeGroup(name: string, displayName: string) {
cy.get(this.#newAttributesGroupNameInput).type(name);
cy.get(this.#newAttributesGroupDisplayNameInput).type(displayName);
return this;
}
saveAttributesGroupCreation() {
cy.findByTestId(this.#saveNewAttributesGroupBtn).click();
return this;
}
selectElementInList(name: string) { selectElementInList(name: string) {
cy.get(this.#validatorsList).contains(name).click(); cy.get(this.#validatorsList).contains(name).click();
return this; return this;
@ -102,9 +155,6 @@ export default class UserProfile {
.clear() .clear()
.type(displayName); .type(displayName);
cy.get(this.#newAttributeEnabledWhen).first().check(); cy.get(this.#newAttributeEnabledWhen).first().check();
cy.get(this.#newAttributeCheckboxes).check({ force: true });
cy.get(this.#newAttributeRequiredFor).first().check({ force: true });
cy.get(this.#newAttributeRequiredWhen).first().check();
cy.get(this.#newAttributeEmptyValidators).contains("No validators."); cy.get(this.#newAttributeEmptyValidators).contains("No validators.");
cy.findByTestId(this.#newAttributeAnnotationBtn).click(); cy.findByTestId(this.#newAttributeAnnotationBtn).click();
cy.findByTestId(this.#newAttributeAnnotationKey).type("test"); cy.findByTestId(this.#newAttributeAnnotationKey).type("test");

View file

@ -93,7 +93,11 @@ export const ViewHeader = ({
<Level> <Level>
<LevelItem> <LevelItem>
<TextContent className="pf-u-mr-sm"> <TextContent className="pf-u-mr-sm">
<Text className={className} component="h1"> <Text
className={className}
component="h1"
data-testid="view-header"
>
{i18n.exists(titleKey) ? t(titleKey) : titleKey} {i18n.exists(titleKey) ? t(titleKey) : titleKey}
</Text> </Text>
</TextContent> </TextContent>

View file

@ -170,7 +170,7 @@ export default function AttributesGroupForm() {
</FormProvider> </FormProvider>
</FormGroup> </FormGroup>
<ActionGroup> <ActionGroup>
<Button variant="primary" type="submit"> <Button variant="primary" type="submit" data-testid="saveGroupBtn">
{t("save")} {t("save")}
</Button> </Button>
<Button <Button