Skip to content

Commit

Permalink
Implement FAT-12696 (#3657)
Browse files Browse the repository at this point in the history
* Fix extended tests Thunderjet

* Rewrite big UI methods into one API

* Implement FAT-12695

* Implement FAT-12696

* Fix

---------

Co-authored-by: bohdanihor <bohdvn@gmail.com>
  • Loading branch information
IhorBohdan and bohdanihor committed May 27, 2024
1 parent 14fa99c commit 8b00530
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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();
},
);
});
23 changes: 19 additions & 4 deletions cypress/support/fragments/finance/funds/funds.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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());
},
Expand Down Expand Up @@ -212,7 +227,7 @@ export default {
addGroupToFund: (group) => {
cy.do([
actionsButton.click(),
Button('Edit').click(),
editButton.click(),
MultiSelect({ label: 'Group' }).select([group]),
saveAndCloseButton.click(),
]);
Expand All @@ -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(),
]);
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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([
Expand Down

0 comments on commit 8b00530

Please sign in to comment.