diff --git a/cypress/e2e/finance/funds/making-an-existing-fund-restricted-by-location.cy.js b/cypress/e2e/finance/funds/making-an-existing-fund-restricted-by-location.cy.js new file mode 100644 index 0000000000..ab0239a7f6 --- /dev/null +++ b/cypress/e2e/finance/funds/making-an-existing-fund-restricted-by-location.cy.js @@ -0,0 +1,76 @@ +import permissions from '../../../support/dictionary/permissions'; +import FinanceHelp from '../../../support/fragments/finance/financeHelper'; +import FiscalYears from '../../../support/fragments/finance/fiscalYears/fiscalYears'; +import Funds from '../../../support/fragments/finance/funds/funds'; +import Ledgers from '../../../support/fragments/finance/ledgers/ledgers'; +import TopMenu from '../../../support/fragments/topMenu'; +import Users from '../../../support/fragments/users/users'; +import NewLocation from '../../../support/fragments/settings/tenant/locations/newLocation'; +import ServicePoints from '../../../support/fragments/settings/tenant/servicePoints/servicePoints'; + +describe('ui-finance: Funds', () => { + const defaultFund = { ...Funds.defaultUiFund }; + const defaultFiscalYear = { ...FiscalYears.defaultUiFiscalYear }; + const defaultLedger = { ...Ledgers.defaultUiLedger }; + let user; + let servicePointId; + let location; + + before(() => { + cy.getAdminToken(); + + FiscalYears.createViaApi(defaultFiscalYear).then((response) => { + defaultFiscalYear.id = response.id; + defaultLedger.fiscalYearOneId = defaultFiscalYear.id; + + Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { + defaultLedger.id = ledgerResponse.id; + defaultFund.ledgerId = defaultLedger.id; + Funds.createViaApi(defaultFund).then((fundResponse) => { + defaultFund.id = fundResponse.fund.id; + }); + }); + }); + + ServicePoints.getViaApi().then((servicePoint) => { + servicePointId = servicePoint[0].id; + NewLocation.createViaApi(NewLocation.getDefaultLocation(servicePointId)).then((res) => { + location = res; + }); + }); + + cy.createTempUser([permissions.uiFinanceViewEditCreateFundAndBudget.gui]).then( + (userProperties) => { + user = userProperties; + cy.login(userProperties.username, userProperties.password, { + path: TopMenu.fundPath, + waiter: Funds.waitLoading, + }); + }, + ); + }); + + after(() => { + cy.getAdminToken(); + Funds.deleteFundViaApi(defaultFund.id); + Ledgers.deleteledgerViaApi(defaultLedger.id); + FiscalYears.deleteFiscalYearViaApi(defaultFiscalYear.id); + Users.deleteViaApi(user.userId); + }); + + it( + 'C423530 Marking Fund as restricted by location when create a fund (thunderjet)', + { tags: ['criticalPath', 'thunderjet'] }, + () => { + FinanceHelp.searchByName(defaultFund.name); + Funds.selectFund(defaultFund.name); + Funds.editBudget(); + Funds.clickRestrictByLocationsCheckbox(); + Funds.varifyLocationSectionExist(); + Funds.addLocationToFund(location.name); + Funds.save(); + Funds.varifyFundIsSaved(); + Funds.waitForFundDetailsLoading(); + }, + ); +}); diff --git a/cypress/support/fragments/finance/funds/funds.js b/cypress/support/fragments/finance/funds/funds.js index d312fe65f7..074d6561da 100644 --- a/cypress/support/fragments/finance/funds/funds.js +++ b/cypress/support/fragments/finance/funds/funds.js @@ -69,6 +69,8 @@ const addExpenseClassButton = Button({ id: 'budget-status-expense-classes-add-bu const saveAndClose = Button('Save & close'); const fundFormSection = Section({ id: 'pane-fund-form' }); const locationSection = Section({ id: 'locations' }); +const editButton = Button('Edit'); +const selectLocationsModal = Modal('Select locations'); export default { defaultUiFund: { @@ -166,6 +168,19 @@ export default { cy.wait(4000); }, + addLocationToFund(locationName) { + cy.do([ + locationSection.find(Button({ id: 'fund-locations' })).click(), + selectLocationsModal.find(SearchField({ id: 'input-record-search' })).fillIn(locationName), + Button('Search').click(), + ]); + cy.wait(2000); + cy.do([ + selectLocationsModal.find(Checkbox({ ariaLabel: 'Select all' })).click(), + selectLocationsModal.find(Button('Save')).click(), + ]); + }, + varifyLocationSectionExist() { cy.expect(fundFormSection.find(locationSection).exists()); }, @@ -212,7 +227,7 @@ export default { addGroupToFund: (group) => { cy.do([ actionsButton.click(), - Button('Edit').click(), + editButton.click(), MultiSelect({ label: 'Group' }).select([group]), saveAndCloseButton.click(), ]); @@ -222,7 +237,7 @@ export default { addTransferTo: (fund) => { cy.do([ actionsButton.click(), - Button('Edit').click(), + editButton.click(), MultiSelect({ label: 'Transfer to' }).select([fund]), saveAndCloseButton.click(), ]); @@ -856,7 +871,7 @@ export default { editBudget: () => { cy.wait(4000); - cy.do([actionsButton.click(), Button('Edit').click()]); + cy.do([actionsButton.click(), editButton.click()]); }, changeStatusOfBudget: (statusName, fund, fiscalYear) => { @@ -1051,7 +1066,7 @@ export default { }, addAUToFund: (AUName) => { - cy.do([actionsButton.click(), Button('Edit').click()]); + cy.do([actionsButton.click(), editButton.click()]); // eslint-disable-next-line cypress/no-unnecessary-waiting cy.wait(4000); cy.do([