diff --git a/cypress/e2e/organizations/add-privileged-donor-information-in-not-a-vendor-organization-record.cy.js b/cypress/e2e/organizations/add-privileged-donor-information-in-not-a-vendor-organization-record.cy.js new file mode 100644 index 0000000000..ed0ccc315a --- /dev/null +++ b/cypress/e2e/organizations/add-privileged-donor-information-in-not-a-vendor-organization-record.cy.js @@ -0,0 +1,76 @@ +import permissions from '../../support/dictionary/permissions'; +import Organizations from '../../support/fragments/organizations/organizations'; +import TopMenu from '../../support/fragments/topMenu'; +import Users from '../../support/fragments/users/users'; +import getRandomPostfix from '../../support/utils/stringTools'; +import NewOrganization from '../../support/fragments/organizations/newOrganization'; + +describe('Organizations', () => { + const organization = { + name: `1_autotest_name_${getRandomPostfix()}`, + status: 'Active', + code: `autotest_code_${getRandomPostfix()}`, + isVendor: false, + isDonor: true, + erpCode: `ERP-${getRandomPostfix()}`, + }; + const firstContact = { ...NewOrganization.defaultContact }; + const secondContact = { + firstName: `2AT_FN_${getRandomPostfix()}`, + lastName: `2AT_LN_${getRandomPostfix()}`, + }; + let user; + + before(() => { + cy.getAdminToken(); + Organizations.createOrganizationViaApi(organization).then((response) => { + organization.id = response; + }); + cy.loginAsAdmin({ path: TopMenu.organizationsPath, waiter: Organizations.waitLoading }); + Organizations.searchByParameters('Name', organization.name); + Organizations.selectOrganization(organization.name); + Organizations.editOrganization(); + Organizations.addNewDonorContact(firstContact); + Organizations.closeContact(); + Organizations.addDonorContactToOrganization(firstContact); + Organizations.checkDonorContactIsAdd(firstContact); + Organizations.saveOrganization(); + cy.createTempUser([ + permissions.uiOrganizationsViewEdit.gui, + permissions.uiOrganizationsViewEditCreateDeletePrivilegedDonorInformation.gui, + ]).then((userProperties) => { + user = userProperties; + cy.login(user.username, user.password, { + path: TopMenu.organizationsPath, + waiter: Organizations.waitLoading, + }); + }); + }); + + after(() => { + cy.getAdminToken(); + Users.deleteViaApi(user.userId); + Organizations.getOrganizationViaApi({ query: `name="${organization.name}"` }).then( + (returnedOrganization) => { + Organizations.deleteOrganizationViaApi(returnedOrganization.id); + }, + ); + }); + + it( + 'C423690 Add privileged donor information in Organization (NOT a vendor) record (thunderjet)', + { tags: ['criticalPath', 'thunderjet'] }, + () => { + Organizations.searchByParameters('Name', organization.name); + Organizations.selectOrganization(organization.name); + Organizations.editOrganization(); + Organizations.addNewDonorContact(secondContact); + Organizations.closeContact(); + Organizations.addDonorContactToOrganization(secondContact); + Organizations.checkDonorContactIsAdd(secondContact); + Organizations.cancelOrganization(); + Organizations.keepEditingOrganization(); + Organizations.saveOrganization(); + }, + ); +}); diff --git a/cypress/support/dictionary/permissions.js b/cypress/support/dictionary/permissions.js index 45b2c0b0f5..68127a2e6c 100644 --- a/cypress/support/dictionary/permissions.js +++ b/cypress/support/dictionary/permissions.js @@ -867,6 +867,10 @@ export default { internal: 'ui-organizations.create', gui: 'Organizations: View, edit, create', }, + uiOrganizationsViewEditCreateDeletePrivilegedDonorInformation: { + internal: 'ui-organizations.privileged-contacts.edit', + gui: 'Organizations: can view, create, edit, delete privileged donor information', + }, uiOrganizationsViewEditDelete: { internal: 'ui-organizations.delete', gui: 'Organizations: View, edit, delete', diff --git a/cypress/support/fragments/organizations/organizations.js b/cypress/support/fragments/organizations/organizations.js index bc99a13070..c28bae3cf6 100644 --- a/cypress/support/fragments/organizations/organizations.js +++ b/cypress/support/fragments/organizations/organizations.js @@ -520,6 +520,35 @@ export default { InteractorsTools.checkCalloutMessage('The contact was saved'); }, + addNewDonorContact: (contact) => { + cy.do([ + Button({ id: 'accordion-toggle-button-privilegedDonorInformation' }).click(), + Section({ id: 'privilegedDonorInformation' }).find(Button('Add donor')).click(), + addContacsModal.find(buttonNew).click(), + lastNameField.fillIn(contact.lastName), + firstNameField.fillIn(contact.firstName), + saveButtonInCotact.click(), + ]); + InteractorsTools.checkCalloutMessage('The contact was saved'); + }, + + addDonorContactToOrganization: (contact) => { + cy.do([ + Button({ id: 'accordion-toggle-button-privilegedDonorInformation' }).click(), + Section({ id: 'privilegedDonorInformation' }).find(Button('Add donor')).click(), + addContacsModal.find(TextField({ id: 'input-record-search' })).fillIn(contact.lastName), + addContacsModal.find(Button('Search')).click(), + ]); + cy.wait(4000); + cy.do([ + addContacsModal + .find(MultiColumnListCell({ row: 0, columnIndex: 0 })) + .find(Checkbox()) + .click(), + addContacsModal.find(saveButton).click(), + ]); + }, + deleteContact: () => { cy.do([actionsButton.click(), deleteButton.click(), confirmButton.click()]); }, @@ -608,15 +637,29 @@ export default { cy.do(Button('Cancel').click()); }, + keepEditingOrganization: () => { + cy.do( + Modal({ id: 'cancel-editing-confirmation' }) + .find(Button({ id: 'clickable-cancel-editing-confirmation-confirm' })) + .click(), + ); + }, + checkContactIsAdd: (contact) => { cy.expect( - contactPeopleSection + Section({ id: 'privilegedDonorInformation' }) .find(MultiColumnListRow({ index: 0 })) .find(MultiColumnListCell({ columnIndex: 0 })) .has({ content: `${contact.lastName}, ${contact.firstName}` }), ); }, + checkDonorContactIsAdd: (contact, index = 0) => { + cy.get('#privilegedDonorInformation [data-row-index="row-' + index + '"]').within(() => { + cy.get('div[class*=mclCell-]').eq(0).contains(`${contact.lastName}, ${contact.firstName}`); + }); + }, + checkInterfaceIsAdd: (defaultInterface) => { cy.do(openInterfaceSectionButton.click()); cy.expect(interfaceSection.find(KeyValue({ value: defaultInterface.name })).exists()); @@ -775,6 +818,7 @@ export default { saveOrganization: () => { cy.do(saveAndClose.click()); + cy.wait(6000); }, addBankingInformation: (bankingInformation) => {