From 1e8d08c3f15d355b149f134e65995d605f801e39 Mon Sep 17 00:00:00 2001 From: Yauhen Viazau Date: Tue, 14 Jan 2025 10:09:28 +0300 Subject: [PATCH] FAT-18024-C624254 (#4626) * FAT-18023: test added * FAT-18024: test added * C423957 commented steps due to bug --- .../selecting-capabilities-columns-edit.cy.js | 217 ++++++++++++++++++ .../access-token-not-shown-on-login.cy.js | 7 +- .../authorization-roles/authorizationRoles.js | 22 +- 3 files changed, 235 insertions(+), 11 deletions(-) create mode 100644 cypress/e2e/eureka/authorization-roles/selecting-capabilities-columns-edit.cy.js diff --git a/cypress/e2e/eureka/authorization-roles/selecting-capabilities-columns-edit.cy.js b/cypress/e2e/eureka/authorization-roles/selecting-capabilities-columns-edit.cy.js new file mode 100644 index 0000000000..4d2248bb1a --- /dev/null +++ b/cypress/e2e/eureka/authorization-roles/selecting-capabilities-columns-edit.cy.js @@ -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); + }); + }); + }); + }, + ); + }); + }); +}); diff --git a/cypress/e2e/eureka/login/access-token-not-shown-on-login.cy.js b/cypress/e2e/eureka/login/access-token-not-shown-on-login.cy.js index 787da99d50..d1ab4e8e87 100644 --- a/cypress/e2e/eureka/login/access-token-not-shown-on-login.cy.js +++ b/cypress/e2e/eureka/login/access-token-not-shown-on-login.cy.js @@ -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); + // }); }, ); }); diff --git a/cypress/support/fragments/settings/authorization-roles/authorizationRoles.js b/cypress/support/fragments/settings/authorization-roles/authorizationRoles.js index f5c21ae2da..9b86e65130 100644 --- a/cypress/support/fragments/settings/authorization-roles/authorizationRoles.js +++ b/cypress/support/fragments/settings/authorization-roles/authorizationRoles.js @@ -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;