Skip to content

Commit

Permalink
FAT-18020: test added
Browse files Browse the repository at this point in the history
  • Loading branch information
zentestuken committed Jan 23, 2025
1 parent 4645f49 commit fae65fa
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import Users from '../../../support/fragments/users/users';
import UsersCard from '../../../support/fragments/users/usersCard';
import UserEdit from '../../../support/fragments/users/userEdit';
import getRandomPostfix from '../../../support/utils/stringTools';
import TopMenuNavigation from '../../../support/fragments/topMenuNavigation';
import { APPLICATION_NAMES } from '../../../support/constants';
import UsersSearchPane from '../../../support/fragments/users/usersSearchPane';

describe('Eureka', () => {
describe('Users', () => {
const testData = {
roleName: `Auto Role C627241 ${getRandomPostfix()}`,
};

const capabSetsToAssign = [
{ type: 'Data', resource: 'UI-Users Roles', action: 'View' },
{ type: 'Data', resource: 'UI-Users', action: 'Edit' },
];

before('Create users, role', () => {
cy.getAdminToken();
cy.createTempUser([]).then((createdTestUserProperties) => {
testData.tempUser = createdTestUserProperties;
cy.assignCapabilitiesToExistingUser(testData.tempUser.userId, [], capabSetsToAssign);
if (Cypress.env('runAsAdmin')) cy.updateRolesForUserApi(testData.tempUser.userId, []);
});
cy.createTempUser([]).then((createdUserProperties) => {
testData.userForRole = createdUserProperties;
});
cy.createAuthorizationRoleApi(testData.roleName).then((role) => {
testData.roleId = role.id;
cy.getCapabilitiesApi(2).then((capabs) => {
cy.getCapabilitySetsApi(2).then((capabSets) => {
cy.addCapabilitiesToNewRoleApi(
testData.roleId,
capabs.map((capab) => capab.id),
);
cy.addCapabilitySetsToNewRoleApi(
testData.roleId,
capabSets.map((capabSet) => capabSet.id),
);
});
});
});
});

before('Assign role, login', () => {
cy.getAdminToken();
if (Cypress.env('runAsAdmin')) {
cy.updateRolesForUserApi(testData.userForRole.userId, [testData.roleId]);
} else {
cy.addRolesToNewUserApi(testData.userForRole.userId, [testData.roleId]);
}
cy.login(testData.tempUser.username, testData.tempUser.password);
});

after('Delete role, users', () => {
cy.getAdminToken();
cy.deleteAuthorizationRoleApi(testData.roleId);
Users.deleteViaApi(testData.userForRole.userId);
Users.deleteViaApi(testData.tempUser.userId);
});

it(
"C627241 [UIU-3301] Verify that user with ui-users.roles. - View can't assign/unassign roles while editing user (eureka)",
{ tags: ['criticalPath', 'eureka', 'C627241'] },
() => {
TopMenuNavigation.navigateToApp(APPLICATION_NAMES.USERS);
Users.waitLoading();
UsersSearchPane.searchByUsername(testData.userForRole.username);
UsersSearchPane.selectUserFromList(testData.userForRole.username);
UsersCard.verifyUserRolesCounter('1');
UserEdit.openEdit();
UserEdit.checkUserEditPaneOpened();
UserEdit.verifyUserRolesCounter('1');
UserEdit.clickUserRolesAccordion(true, false);
UserEdit.verifyUserRoleNames([testData.roleName], false);
},
);
});
});
44 changes: 22 additions & 22 deletions cypress/support/fragments/users/userEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -787,13 +787,21 @@ export default {
cy.expect(userRolesAccordion.has({ counter: expectedCount }));
},

clickUserRolesAccordion(isExpanded = true) {
clickUserRolesAccordion(isExpanded = true, isEditable = true) {
cy.do(userRolesAccordion.clickHeader());
cy.expect([
userRolesAccordion.has({ open: isExpanded }),
addRolesButton.exists(),
unassignAllRolesButton.has({ disabled: or(true, false) }),
]);
cy.expect(userRolesAccordion.has({ open: isExpanded }));
if (isEditable) {
cy.expect([
addRolesButton.exists(),
unassignAllRolesButton.has({ disabled: or(true, false) }),
]);
} else {
cy.expect([
addRolesButton.absent(),
unassignAllRolesButton.absent(),
userRoleDeleteIcon.absent(),
]);
}
},

verifyUserRolesAccordionEmpty() {
Expand Down Expand Up @@ -834,27 +842,19 @@ export default {
cy.wait(1000);
},

verifyUserRoleNames(roleNames) {
verifyUserRoleNames(roleNames, isEditable = true) {
roleNames.forEach((roleName) => {
cy.expect(
userRolesAccordion
.find(
ListItem(including(roleName)).find(
Button({ id: including('clickable-remove-user-role') }),
),
)
.exists(),
);
const roleItem = userRolesAccordion.find(ListItem(including(roleName)));
if (isEditable) cy.expect(roleItem.find(userRoleDeleteIcon).exists());
else cy.expect(roleItem.exists());
});
},

verifyUserRoleNamesOrdered(roleNames) {
verifyUserRoleNamesOrdered(roleNames, isEditable = true) {
roleNames.forEach((roleName, index) => {
cy.expect(
userRolesAccordion
.find(ListItem(including(roleName), { index }).find(userRoleDeleteIcon))
.exists(),
);
const roleItem = userRolesAccordion.find(ListItem(including(roleName), { index }));
if (isEditable) cy.expect(roleItem.find(userRoleDeleteIcon).exists());
else cy.expect(roleItem.exists());
});
},

Expand Down

0 comments on commit fae65fa

Please sign in to comment.