Skip to content

Commit

Permalink
FAT-18024-C624254 (#4626)
Browse files Browse the repository at this point in the history
* FAT-18023: test added

* FAT-18024: test added

* C423957 commented steps due to bug
  • Loading branch information
zentestuken authored Jan 14, 2025
1 parent c2c1900 commit 1e8d08c
Show file tree
Hide file tree
Showing 3 changed files with 235 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
import Users from '../../../support/fragments/users/users';
import TopMenu from '../../../support/fragments/topMenu';
import getRandomPostfix from '../../../support/utils/stringTools';
import AuthorizationRoles from '../../../support/fragments/settings/authorization-roles/authorizationRoles';
import { CAPABILITY_TYPES, CAPABILITY_ACTIONS } from '../../../support/constants';

describe('Eureka', () => {
describe('Settings', () => {
describe('Authorization roles', () => {
const testData = {
roleName: `Auto Role C624254 ${getRandomPostfix()}`,
originalCapabilitySet: {
table: CAPABILITY_TYPES.SETTINGS,
resource: 'Serials-Management Settings',
action: CAPABILITY_ACTIONS.VIEW,
},
originalCapabilitiesInSet: [
{
table: CAPABILITY_TYPES.SETTINGS,
resource: 'Serials-Management Settings',
action: CAPABILITY_ACTIONS.VIEW,
},
],
originalCapabilities: [
{
table: CAPABILITY_TYPES.PROCEDURAL,
resource: 'Auth Token',
action: CAPABILITY_ACTIONS.EXECUTE,
},
],
capabilitySetsColumnToSelect: {
type: CAPABILITY_TYPES.SETTINGS,
action: CAPABILITY_ACTIONS.CREATE,
},
capabilityColumnToSelect: {
type: CAPABILITY_TYPES.PROCEDURAL,
action: CAPABILITY_ACTIONS.EXECUTE,
},
notSelectedCapabilitySetColumn: {
type: CAPABILITY_TYPES.SETTINGS,
action: CAPABILITY_ACTIONS.EDIT,
},
notSelectedCapabilityColumn: {
type: CAPABILITY_TYPES.DATA,
action: CAPABILITY_ACTIONS.MANAGE,
},
absentCapabilitySetTables: [CAPABILITY_TYPES.DATA, CAPABILITY_TYPES.PROCEDURAL],
capabSetIds: [],
capabIds: [],
};

const capabSetsForTestUser = [
{
type: CAPABILITY_TYPES.SETTINGS,
resource: 'UI-Authorization-Roles Settings Admin',
action: CAPABILITY_ACTIONS.VIEW,
},
{
type: CAPABILITY_TYPES.DATA,
resource: 'Capabilities',
action: CAPABILITY_ACTIONS.MANAGE,
},
{
type: CAPABILITY_TYPES.DATA,
resource: 'Role-Capability-Sets',
action: CAPABILITY_ACTIONS.MANAGE,
},
];

const capabsForTestUser = [
{
type: CAPABILITY_TYPES.SETTINGS,
resource: 'Settings Enabled',
action: CAPABILITY_ACTIONS.VIEW,
},
];

before('Create role, user', () => {
cy.createTempUser([]).then((createdUserProperties) => {
testData.user = createdUserProperties;
cy.assignCapabilitiesToExistingUser(
testData.user.userId,
capabsForTestUser,
capabSetsForTestUser,
);
if (Cypress.env('runAsAdmin')) cy.updateRolesForUserApi(testData.user.userId, []);
cy.createAuthorizationRoleApi(testData.roleName, testData.roleDescription).then(
(role) => {
testData.roleId = role.id;
testData.originalCapabilities.forEach((capability) => {
capability.type = capability.table;
cy.getCapabilityIdViaApi(capability).then((capabId) => {
testData.capabIds.push(capabId);
});
});
testData.originalCapabilitySet.type = testData.originalCapabilitySet.table;
cy.getCapabilitySetIdViaApi(testData.originalCapabilitySet).then((capabSetId) => {
testData.capabSetIds.push(capabSetId);
});
},
);
});
});

before('Assign capabilities and login', () => {
cy.addCapabilitiesToNewRoleApi(testData.roleId, testData.capabIds);
cy.addCapabilitySetsToNewRoleApi(testData.roleId, testData.capabSetIds);
cy.login(testData.user.username, testData.user.password, {
path: TopMenu.settingsAuthorizationRoles,
waiter: AuthorizationRoles.waitContentLoading,
});
});

afterEach(() => {
cy.getAdminToken();
Users.deleteViaApi(testData.user.userId);
cy.deleteAuthorizationRoleApi(testData.roleId);
});

it(
'C624254 Selecting all checkboxes in columns when editing authorization role (eureka)',
{ tags: ['criticalPath', 'eureka', 'C624254'] },
() => {
AuthorizationRoles.searchRole(testData.roleName);
AuthorizationRoles.clickOnRoleName(testData.roleName);
AuthorizationRoles.openForEdit();
AuthorizationRoles.verifyCapabilitySetCheckboxChecked(testData.originalCapabilitySet);
testData.originalCapabilitiesInSet.forEach((capability) => {
AuthorizationRoles.verifyCapabilityCheckboxCheckedAndDisabled(capability);
});
testData.originalCapabilities.forEach((capability) => {
AuthorizationRoles.verifyCapabilityCheckboxChecked(capability);
});
AuthorizationRoles.selectCapabilityColumn(
testData.capabilityColumnToSelect.type,
testData.capabilityColumnToSelect.action,
);
AuthorizationRoles.getCapabilityCheckboxCountInColumn(
testData.capabilityColumnToSelect.type,
testData.capabilityColumnToSelect.action,
).then((capabCount) => {
AuthorizationRoles.selectCapabilitySetColumn(
testData.capabilitySetsColumnToSelect.type,
testData.capabilitySetsColumnToSelect.action,
);
AuthorizationRoles.getCapabilitySetCheckboxCountInColumn(
testData.capabilitySetsColumnToSelect.type,
testData.capabilitySetsColumnToSelect.action,
).then((setCount) => {
AuthorizationRoles.clickSaveButton();
AuthorizationRoles.checkAfterSaveEdit(testData.roleName);
AuthorizationRoles.clickOnCapabilitySetsAccordion();
AuthorizationRoles.getCapabilitySetCheckboxCountInColumn(
testData.capabilitySetsColumnToSelect.type,
testData.capabilitySetsColumnToSelect.action,
).then((setCountInView) => {
cy.expect(setCount).to.eq(setCountInView);
});
AuthorizationRoles.verifyNoCheckboxesInCapabilitySetColumn(
testData.notSelectedCapabilitySetColumn.type,
testData.notSelectedCapabilitySetColumn.action,
);
testData.absentCapabilitySetTables.forEach((table) => {
AuthorizationRoles.verifyCapabilitySetTableAbsent(table);
});
AuthorizationRoles.clickOnCapabilitiesAccordion();
AuthorizationRoles.getCapabilityCheckboxCountInColumn(
testData.capabilityColumnToSelect.type,
testData.capabilityColumnToSelect.action,
).then((capabCountInView) => {
cy.expect(capabCount).to.eq(capabCountInView);
});
AuthorizationRoles.verifyNoCheckboxesInCapabilityColumn(
testData.notSelectedCapabilityColumn.type,
testData.notSelectedCapabilityColumn.action,
);
AuthorizationRoles.verifyCapabilitySetCheckboxChecked(testData.originalCapabilitySet);
testData.originalCapabilitiesInSet.forEach((capability) => {
AuthorizationRoles.verifyCapabilityCheckboxCheckedAndDisabled(capability);
});
testData.originalCapabilities.forEach((capability) => {
AuthorizationRoles.verifyCapabilityCheckboxChecked(capability);
});

cy.reload();
cy.wait('@/authn/refresh', { timeout: 20000 });
AuthorizationRoles.verifyRoleViewPane(testData.roleName);
AuthorizationRoles.openForEdit();
AuthorizationRoles.selectCapabilityColumn(
testData.capabilityColumnToSelect.type,
testData.capabilityColumnToSelect.action,
false,
);
AuthorizationRoles.selectCapabilitySetColumn(
testData.capabilitySetsColumnToSelect.type,
testData.capabilitySetsColumnToSelect.action,
false,
);
AuthorizationRoles.clickSaveButton();
AuthorizationRoles.checkAfterSaveEdit(testData.roleName);
AuthorizationRoles.checkCapabilitySetsAccordionCounter('1');
AuthorizationRoles.clickOnCapabilitySetsAccordion();
AuthorizationRoles.verifyCapabilitySetCheckboxChecked(testData.originalCapabilitySet);
AuthorizationRoles.checkCapabilitiesAccordionCounter(
`${testData.originalCapabilitiesInSet.length}`,
);
AuthorizationRoles.clickOnCapabilitiesAccordion();
testData.originalCapabilitiesInSet.forEach((capability) => {
AuthorizationRoles.verifyCapabilityCheckboxCheckedAndDisabled(capability);
});
});
});
},
);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ describe('Eureka', () => {
).to.eq(1);
});
cy.expect(Heading(including('Welcome')).exists());
cy.get('@samlCall.all').then((calls) => {
expect(calls).to.have.length(0);
});
// TO DO: uncomment the following step when EUREKA-629 is done
// cy.get('@samlCall.all').then((calls) => {
// expect(calls).to.have.length(0);
// });
},
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -712,38 +712,44 @@ export default {
else cy.expect(actionsButton.absent());
},

selectCapabilityColumn: (table, action) => {
selectCapabilityColumn: (table, action, isSelected = true) => {
const targetCheckbox = capabilitiesAccordion
.find(capabilityTables[table])
.find(MultiColumnListHeader(including(action)))
.find(Checkbox());
cy.do(targetCheckbox.click());
cy.expect(targetCheckbox.has({ checked: true }));
cy.expect(targetCheckbox.has({ checked: isSelected }));
},

getCapabilityCheckboxCountInColumn: (table, action) => {
cy.wait(2000);
return cy
.get(`div[data-testid="capabilities-${table.toLowerCase()}-type"]`)
.eq(1)
.xpath(
'//section[starts-with(@class, "accordion--")][.//div[starts-with(@class, "labelArea")][text()="Capabilities"]]',
)
.find(`div[data-testid="capabilities-${table.toLowerCase()}-type"]`)
.find(`input[type="checkbox"][aria-label^="${action} "]`)
.then((checkboxes) => {
return checkboxes.length;
});
},

selectCapabilitySetColumn: (table, action) => {
selectCapabilitySetColumn: (table, action, isSelected = true) => {
const targetCheckbox = capabilitySetsAccordion
.find(capabilityTables[table])
.find(MultiColumnListHeader(including(action)))
.find(Checkbox());
cy.do(targetCheckbox.click());
cy.expect(targetCheckbox.has({ checked: true }));
cy.expect(targetCheckbox.has({ checked: isSelected }));
},

getCapabilitySetCheckboxCountInColumn: (table, action) => {
cy.wait(2000);
return cy
.get(`div[data-testid="capabilities-${table.toLowerCase()}-type"]`)
.eq(0)
.xpath(
'//section[starts-with(@class, "accordion--")][.//div[starts-with(@class, "labelArea")][text()="Capability sets"]]',
)
.find(`div[data-testid="capabilities-${table.toLowerCase()}-type"]`)
.find(`input[type="checkbox"][aria-label^="${action} "]`)
.then((checkboxes) => {
return checkboxes.length;
Expand Down

0 comments on commit 1e8d08c

Please sign in to comment.