Fix realm_settings_user_profile_enabled test instability

The instability is caused by pending alert which sometimes leaks
into user creation and causes the user to be created but its creation
not detected by the test due to another message. This causes test
being repeated and fail because the user already exists.

Fixes: #27653
Signed-off-by: Hynek Mlnarik <hmlnarik@redhat.com>
This commit is contained in:
Hynek Mlnarik 2024-03-19 11:31:45 +01:00 committed by Hynek Mlnařík
parent 04fc9d27fd
commit 5c59722176
4 changed files with 24 additions and 13 deletions

Binary file not shown.

View file

@ -156,10 +156,10 @@ describe("User profile tabs", () => {
it("Removes three validators with the editor", () => {
getUserProfileTab();
getJsonEditorTab();
userProfileTab.typeJSON(removedThree).saveJSON();
masthead.checkNotificationMessage(
"User profile settings successfully updated.",
);
userProfileTab
.typeJSON(removedThree)
.saveJSON()
.assertNotificationUpdated();
});
});
@ -185,7 +185,7 @@ describe("User profile tabs", () => {
createUserPage
.goToCreateUser()
.assertAttributeFieldExists(attrName, false)
.setUsername("testuser7")
.setUsername(`testuser7-${uuid()}`)
.create()
.assertNotificationCreated()
.assertAttributeFieldExists(attrName, false);
@ -251,7 +251,7 @@ describe("User profile tabs", () => {
createUserPage
.goToCreateUser()
.assertAttributeFieldExists(attrName, true)
.setUsername("testuser10")
.setUsername(`testuser10-${uuid()}`)
.create()
.assertNotificationCreated()
.assertAttributeFieldExists(attrName, true);
@ -270,7 +270,7 @@ describe("User profile tabs", () => {
createUserPage
.goToCreateUser()
.assertAttributeLabel(attrName, attrName)
.setUsername("testuser11")
.setUsername(`testuser11-${uuid()}`)
.create()
.assertValidationErrorRequired(attrName);
@ -293,7 +293,7 @@ describe("User profile tabs", () => {
createUserPage
.goToCreateUser()
.assertAttributeLabel(attrName, attrName)
.setUsername("testuser12")
.setUsername(`testuser12-${uuid()}`)
.setAttributeValue(attrName, "MyAttribute")
.create()
.assertNotificationCreated();
@ -306,7 +306,8 @@ describe("User profile tabs", () => {
getAttributesGroupTab()
.clickOnCreatesAttributesGroupButton()
.createAttributeGroup(group, group)
.saveAttributesGroupCreation();
.saveAttributesGroupCreation()
.assertNotificationUpdated();
getAttributesTab();
userProfileTab
@ -320,7 +321,7 @@ describe("User profile tabs", () => {
createUserPage
.goToCreateUser()
.assertGroupDisplayName(group, group)
.setUsername("testuser14")
.setUsername(`testuser14-${uuid()}`)
.create()
.assertNotificationCreated();
@ -342,7 +343,8 @@ describe("User profile tabs", () => {
getAttributesGroupTab()
.clickOnCreatesAttributesGroupButton()
.createAttributeGroup(group, group)
.saveAttributesGroupCreation();
.saveAttributesGroupCreation()
.assertNotificationUpdated();
createAttributeDefinition(attrName, (attrConfigurer) =>
attrConfigurer.setAllAttributePermissions(),
@ -361,7 +363,7 @@ describe("User profile tabs", () => {
.goToCreateUser()
.assertGroupDisplayName(group, group)
.assertAttributeLabel(attrName, attrName)
.setUsername("testuser13")
.setUsername(`testuser13-${uuid()}`)
.setAttributeValue(attrName, initialAttrValue)
.create()
.assertNotificationCreated()

View file

@ -216,6 +216,14 @@ export default class UserProfile {
return this;
}
assertNotificationUpdated() {
this.masthead.checkNotificationMessage(
"User profile settings successfully updated.",
);
return this;
}
shouldHaveText(text: string) {
this.#getText().should("have.text", text);
return this;

View file

@ -186,7 +186,8 @@ export default class CreateUserPage {
}
setAttributeValue(attrName: string, value: string) {
cy.findByTestId(attrName).clear().type(value);
cy.findByTestId(attrName).as("attr").clear();
cy.get("@attr").type(value);
return this;
}