From 3ecae0bb3df764bcaa79b3260badd1c29192a58b Mon Sep 17 00:00:00 2001 From: Tetiana_Paranich Date: Sun, 22 Feb 2026 11:59:08 +0200 Subject: [PATCH 1/3] fixed tests --- ...dings-with-linked-central-and-member.cy.js | 338 ++++++++++++++++++ ...er-settings-applying-to-encumbrances.cy.js | 2 +- ...kers-when-leader-05-value-is-changed.cy.js | 2 +- ...or-linked-to-instance-subject-source.cy.js | 93 +++++ ...-for-linked-to-instance-subject-type.cy.js | 92 +++++ ...dy-existed-folio-subject-source-name.cy.js | 48 +++ ...dy-existed-local-subject-source-name.cy.js | 61 ++++ ...-already-existed-subject-source-name.cy.js | 84 +++++ ...eady-existed-folio-subject-type-name.cy.js | 48 +++ ...eady-existed-local-subject-type-name.cy.js | 61 ++++ ...th-already-existed-subject-type-name.cy.js | 81 +++++ .../import-by-oclc-source-folio.cy.js | 1 - ...add-template-folio-by-import-from-lc.cy.js | 132 +++++++ ...d-template-folio-by-import-from-oclc.cy.js | 122 +++++++ ...nvoice-with-multiple-expense-classes.cy.js | 272 +++++++++----- ...order-format-from-pe-mix-to-physical.cy.js | 71 ++-- .../create-new-routing-list-from-poline.cy.js | 206 +++++------ ...ew-routing-list-from-receiving-title.cy.js | 195 ++++------ ...or-po-line-with-quantity-more-then-1.cy.js | 230 +++++------- .../delete-routing-list-from-orders.cy.js | 215 +++++------ ...edit-existing-routing-list-in-orders.cy.js | 288 ++++++++------- cypress/e2e/orders/pol-search-am-filter.cy.js | 6 +- .../copy-number-not-shown-in-receiving.cy.js | 2 +- ...ist-collapsed-for-physical-and-pemix.cy.js | 255 +++++++------ ...yed-for-electronic-and-other-formats.cy.js | 220 ++++++------ ...with-users-added-via-receiving-title.cy.js | 307 ++++++++-------- ...r-receiving-title-with-quantitymore1.cy.js | 240 +++++-------- ...lete-routing-list-from-receiving-app.cy.js | 228 +++++------- .../fragments/inventory/instanceRecordView.js | 10 +- .../fragments/inventory/inventoryInstance.js | 4 +- .../fragments/inventory/inventoryInstances.js | 10 +- cypress/support/fragments/invoices/index.js | 2 + .../fragments/invoices/invoiceLineDetails.js | 34 +- .../fragments/invoices/invoiceLineEditForm.js | 29 +- .../fragments/invoices/invoiceNewForm.js | 114 ++++++ .../support/fragments/invoices/invoices.js | 6 + .../fragments/orders/orderLineDetails.js | 114 +++++- .../fragments/orders/orderLineEditForm.js | 1 + .../support/fragments/orders/orderLines.js | 152 +------- .../orders/routingLists/newRoutingList.js | 83 +++++ .../orders/routingLists/routingListDetails.js | 52 +++ .../routingLists/routingListEditForm.js | 89 +++++ .../support/fragments/receiving/receiving.js | 92 ++++- .../settings/finance/settingsFinance.js | 2 +- .../inventory/instances/subjectSources.js | 93 ++++- .../inventory/instances/subjectTypes.js | 84 +++++ 46 files changed, 3222 insertions(+), 1649 deletions(-) create mode 100644 cypress/e2e/consortia/inventory/holdings/receiving-history-accordion-for-shared-holdings-with-linked-central-and-member.cy.js create mode 100644 cypress/e2e/inventory/settings/subjects/delete-action-in-settings-inventory-create-edit-delete-subject-sources-permission-for-linked-to-instance-subject-source.cy.js create mode 100644 cypress/e2e/inventory/settings/subjects/delete-action-in-settings-inventory-create-edit-delete-subject-types-permission-for-linked-to-instance-subject-type.cy.js create mode 100644 cypress/e2e/inventory/settings/subjects/subject-source-can-not-be-created-with-already-existed-folio-subject-source-name.cy.js create mode 100644 cypress/e2e/inventory/settings/subjects/subject-source-can-not-be-created-with-already-existed-local-subject-source-name.cy.js create mode 100644 cypress/e2e/inventory/settings/subjects/subject-source-can-not-be-edited-with-already-existed-subject-source-name.cy.js create mode 100644 cypress/e2e/inventory/settings/subjects/subject-type-can-not-be-created-with-already-existed-folio-subject-type-name.cy.js create mode 100644 cypress/e2e/inventory/settings/subjects/subject-type-can-not-be-created-with-already-existed-local-subject-type-name.cy.js create mode 100644 cypress/e2e/inventory/settings/subjects/subject-type-can-not-be-edited-with-already-existed-subject-type-name.cy.js create mode 100644 cypress/e2e/inventory/single-record-import/overlay-record-created-by-using-fast-add-template-folio-by-import-from-lc.cy.js create mode 100644 cypress/e2e/inventory/single-record-import/overlay-record-created-by-using-fast-add-template-folio-by-import-from-oclc.cy.js create mode 100644 cypress/support/fragments/invoices/invoiceNewForm.js create mode 100644 cypress/support/fragments/orders/routingLists/newRoutingList.js create mode 100644 cypress/support/fragments/orders/routingLists/routingListDetails.js create mode 100644 cypress/support/fragments/orders/routingLists/routingListEditForm.js diff --git a/cypress/e2e/consortia/inventory/holdings/receiving-history-accordion-for-shared-holdings-with-linked-central-and-member.cy.js b/cypress/e2e/consortia/inventory/holdings/receiving-history-accordion-for-shared-holdings-with-linked-central-and-member.cy.js new file mode 100644 index 0000000000..5abfe8d1f7 --- /dev/null +++ b/cypress/e2e/consortia/inventory/holdings/receiving-history-accordion-for-shared-holdings-with-linked-central-and-member.cy.js @@ -0,0 +1,338 @@ +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + APPLICATION_NAMES, + LOCATION_NAMES, + ORDER_STATUSES, + VENDOR_NAMES, +} from '../../../../support/constants'; +import Affiliations, { tenantNames } from '../../../../support/dictionary/affiliations'; +import Permissions from '../../../../support/dictionary/permissions'; +import InventoryHoldings from '../../../../support/fragments/inventory/holdings/inventoryHoldings'; +import HoldingsRecordView from '../../../../support/fragments/inventory/holdingsRecordView'; +import InstanceRecordView from '../../../../support/fragments/inventory/instanceRecordView'; +import InventoryInstance from '../../../../support/fragments/inventory/inventoryInstance'; +import InventoryInstances from '../../../../support/fragments/inventory/inventoryInstances'; +import InventorySearchAndFilter from '../../../../support/fragments/inventory/inventorySearchAndFilter'; +import BasicOrderLine from '../../../../support/fragments/orders/basicOrderLine'; +import NewOrder from '../../../../support/fragments/orders/newOrder'; +import OrderLines from '../../../../support/fragments/orders/orderLines'; +import Orders from '../../../../support/fragments/orders/orders'; +import Organizations from '../../../../support/fragments/organizations/organizations'; +import Receiving from '../../../../support/fragments/receiving/receiving'; +import ConsortiumManager from '../../../../support/fragments/settings/consortium-manager/consortium-manager'; +import TopMenuNavigation from '../../../../support/fragments/topMenuNavigation'; +import Users from '../../../../support/fragments/users/users'; +import DateTools from '../../../../support/utils/dateTools'; + +describe('Inventory', () => { + describe('Holdings', () => { + describe('Consortia', () => { + const testData = { + holdings: {}, + instance: {}, + user: {}, + }; + const userPermissions = [ + Permissions.inventoryAll.gui, + Permissions.uiOrdersView.gui, + Permissions.uiReceivingViewEditCreate.gui, + ]; + const centralData = { + order: {}, + orderLine: {}, + piece: {}, + }; + const memberData = { + order: {}, + orderLine: {}, + piece: {}, + }; + // create order for central tenant + const createOrderLineOnCentral = (purchaseOrderId, vendorId, acquisitionMethodId) => { + return { + ...BasicOrderLine.defaultOrderLine, + purchaseOrderId, + source: 'User', + claimingActive: false, + claimingInterval: 45, + cost: { + currency: 'USD', + discountType: 'percentage', + discount: 10, + listUnitPrice: 10, + quantityPhysical: 1, + }, + physical: { + createInventory: 'Instance, Holding', + materialSupplier: vendorId, + }, + locations: [ + { + tenantId: 'college', + holdingId: testData.holdings.holdingId, + quantityPhysical: 1, + }, + ], + isPackage: false, + checkinItems: false, + suppressInstanceFromDiscovery: false, + instanceId: testData.instance.instanceId, + titleOrPackage: testData.instance.instanceTitle, + acquisitionMethod: acquisitionMethodId, + orderFormat: 'Physical Resource', + }; + }; + const createOrderWithLineOnCentral = (vendorId, acquisitionMethodId) => { + const order = { + ...NewOrder.getDefaultOrder({ vendorId }), + orderType: 'One-Time', + reEncumber: true, + approved: true, + }; + + return Orders.createOrderViaApi(order).then((orderResponse) => { + centralData.order.id = orderResponse.id; + const orderLine = createOrderLineOnCentral( + orderResponse.id, + orderResponse.vendorId, + acquisitionMethodId, + ); + + return OrderLines.createOrderLineViaApi(orderLine).then((orderLineResponse) => { + centralData.orderLine = orderLineResponse; + + return Orders.updateOrderViaApi({ + ...orderResponse, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); + }); + }; + + // create order for member tenant + const createOrderLineOnMember = (purchaseOrderId, vendorId, acquisitionMethodId) => { + return { + ...BasicOrderLine.defaultOrderLine, + purchaseOrderId, + source: 'User', + claimingActive: false, + claimingInterval: 45, + cost: { + currency: 'USD', + discountType: 'percentage', + discount: 10, + listUnitPrice: 10, + quantityPhysical: 1, + }, + physical: { + createInventory: 'Instance, Holding', + materialSupplier: vendorId, + }, + locations: [ + { + holdingId: testData.holdings.holdingId, + quantityPhysical: 1, + }, + ], + isPackage: false, + checkinItems: false, + suppressInstanceFromDiscovery: false, + instanceId: testData.instance.instanceId, + titleOrPackage: testData.instance.instanceTitle, + acquisitionMethod: acquisitionMethodId, + orderFormat: 'Physical Resource', + }; + }; + const createOrderWithLineOnMember = (vendorId, acquisitionMethodId) => { + const order = { + ...NewOrder.getDefaultOrder({ vendorId }), + orderType: 'One-Time', + reEncumber: true, + approved: true, + }; + + return Orders.createOrderViaApi(order).then((orderResponse) => { + memberData.order.id = orderResponse.id; + const orderLine = createOrderLineOnMember( + orderResponse.id, + orderResponse.vendorId, + acquisitionMethodId, + testData.holdings.location.id, + ); + + return OrderLines.createOrderLineViaApi(orderLine).then((orderLineResponse) => { + memberData.orderLine = orderLineResponse; + + return Orders.updateOrderViaApi({ + ...orderResponse, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); + }); + }; + + before('Create test data', () => { + cy.getAdminToken(); + ConsortiumManager.enableCentralOrderingViaApi(); + // create instance on central tenant + InventoryInstance.createInstanceViaApi() + .then(({ instanceData }) => { + testData.instance = instanceData; + }) + .then(() => { + cy.setTenant(Affiliations.College); + cy.getLocations({ query: `name="${LOCATION_NAMES.DCB_UI}"` }).then((res) => { + testData.holdings.location = res; + }); + InventoryHoldings.getHoldingsFolioSource().then((folioSource) => { + testData.holdings.sourceId = folioSource.id; + }); + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((params) => { + memberData.acquisitionMethodId = params.body.acquisitionMethods[0].id; + }); + Organizations.getOrganizationViaApi({ query: `name="${VENDOR_NAMES.MOSAIC}"` }).then( + (organization) => { + memberData.vendorId = organization.id; + }, + ); + }) + .then(() => { + // create holding on member tenant + InventoryHoldings.createHoldingRecordViaApi({ + instanceId: testData.instance.instanceId, + permanentLocationId: testData.holdings.location.id, + sourceId: testData.holdings.sourceId, + }).then((resp) => { + testData.holdings.holdingId = resp.id; + + // create order with order line on member tenant + createOrderWithLineOnMember(memberData.vendorId, memberData.acquisitionMethodId).then( + () => { + // receive piece for the order line on member tenant + return cy.wait(3000).then(() => { + return Receiving.getPiecesViaApi(memberData.orderLine.id).then((pieces) => { + return Receiving.receivePieceViaApi({ + poLineId: memberData.orderLine.id, + tenantId: Affiliations.College, + pieces: [ + { + id: pieces[0].id, + displayOnHolding: true, + }, + ], + }); + }); + }); + }, + ); + }); + }); + + cy.resetTenant(); + cy.getAdminToken() + .then(() => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((params) => { + centralData.acquisitionMethodId = params.body.acquisitionMethods[0].id; + }); + Organizations.getOrganizationViaApi({ query: `name="${VENDOR_NAMES.MOSAIC}"` }).then( + (organization) => { + centralData.vendorId = organization.id; + }, + ); + }) + .then(() => { + // create order with order line on central tenant + createOrderWithLineOnCentral( + centralData.vendorId, + centralData.acquisitionMethodId, + ).then(() => { + // receive piece for the order line on central tenant + return cy.wait(3000).then(() => { + return Receiving.getPiecesViaApi(centralData.orderLine.id).then((pieces) => { + return Receiving.receivePieceViaApi({ + poLineId: centralData.orderLine.id, + tenantId: Affiliations.College, + pieces: [ + { + id: pieces[0].id, + displayOnHolding: true, + }, + ], + }); + }); + }); + }); + }); + + cy.resetTenant(); + cy.getAdminToken(); + cy.createTempUser(userPermissions).then((userProperties) => { + testData.user = userProperties; + + [Affiliations.College, Affiliations.University].forEach((affiliation) => { + cy.affiliateUserToTenant({ + tenantId: affiliation, + userId: testData.user.userId, + permissions: userPermissions, + }); + }); + + cy.login(testData.user.username, testData.user.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.INVENTORY); + InventoryInstances.waitContentLoading(); + ConsortiumManager.switchActiveAffiliation(tenantNames.central, tenantNames.college); + ConsortiumManager.checkCurrentTenantInTopMenu(tenantNames.college); + }); + }); + + after('Delete test data', () => { + cy.getAdminToken(); + cy.setTenant(Affiliations.College); + cy.deleteHoldingRecordViaApi(testData.holdings.holdingId); + Orders.deleteOrderViaApi(memberData.order.id); + cy.withinTenant(Affiliations.Consortia, () => { + cy.getAdminToken(); + InventoryInstance.deleteInstanceViaApi(testData.instance.instanceId); + Orders.deleteOrderViaApi(centralData.order.id); + Users.deleteViaApi(testData.user.userId); + }); + }); + + it( + 'C491283 Check Receiving history accordion for shared Holdings with linked central and member tenants (consortia) (folijet)', + { tags: ['extendedPathECS', 'folijet', 'C491283'] }, + () => { + const todayDate = DateTools.getFormattedDate({ date: new Date() }, 'MM/DD/YYYY'); + + InventorySearchAndFilter.clearDefaultFilter('Held by'); + InventorySearchAndFilter.searchInstanceByTitle(testData.instance.instanceTitle); + InventoryInstances.selectInstance(); + InstanceRecordView.waitLoading(); + InstanceRecordView.openHoldingView(); + HoldingsRecordView.checkHoldingRecordViewOpened(); + HoldingsRecordView.openAccordion('Receiving history'); + HoldingsRecordView.checkReceivingHistoryAccordionForMemberTenant(todayDate, 'Receiving'); + HoldingsRecordView.checkReceivingHistoryAccordionForCentralTenant(todayDate, 'Receiving'); + + ConsortiumManager.switchActiveAffiliation(tenantNames.college, tenantNames.university); + ConsortiumManager.checkCurrentTenantInTopMenu(tenantNames.university); + InventorySearchAndFilter.clearDefaultFilter('Held by'); + InventorySearchAndFilter.searchInstanceByTitle(testData.instance.instanceTitle); + InventoryInstances.selectInstance(); + InstanceRecordView.waitLoading(); + InstanceRecordView.expandConsortiaHoldings(); + InstanceRecordView.expandMemberSubHoldings(tenantNames.college); + InstanceRecordView.openHoldingView(); + HoldingsRecordView.checkHoldingRecordViewOpened(); + HoldingsRecordView.openAccordion('Receiving history'); + HoldingsRecordView.checkReceivingHistoryAccordionForMemberTenant(todayDate, 'Receiving'); + HoldingsRecordView.checkReceivingHistoryAccordionForCentralTenant(todayDate, 'Receiving'); + }, + ); + }); + }); +}); diff --git a/cypress/e2e/finance/fiscalYears/fiscalYearRollover/rollover-settings-applying-to-encumbrances.cy.js b/cypress/e2e/finance/fiscalYears/fiscalYearRollover/rollover-settings-applying-to-encumbrances.cy.js index 1117cb0c4f..b26198320d 100644 --- a/cypress/e2e/finance/fiscalYears/fiscalYearRollover/rollover-settings-applying-to-encumbrances.cy.js +++ b/cypress/e2e/finance/fiscalYears/fiscalYearRollover/rollover-settings-applying-to-encumbrances.cy.js @@ -188,7 +188,7 @@ describe('Finance', () => { Ledgers.selectLedger(ledger.name); LedgerDetails.checkLedgerDetails({ - information: [{ key: 'Fiscal year', value: fiscalYears.first.code }], + information: [{ key: 'Current fiscal year', value: fiscalYears.first.code }], financialSummary: { information: [{ key: 'Encumbered', value: '$50.00' }], }, diff --git a/cypress/e2e/inventory/set-record-for-deletion/update-deleted-markers-when-leader-05-value-is-changed.cy.js b/cypress/e2e/inventory/set-record-for-deletion/update-deleted-markers-when-leader-05-value-is-changed.cy.js index 19d6b8e2f9..2e5c2af55b 100644 --- a/cypress/e2e/inventory/set-record-for-deletion/update-deleted-markers-when-leader-05-value-is-changed.cy.js +++ b/cypress/e2e/inventory/set-record-for-deletion/update-deleted-markers-when-leader-05-value-is-changed.cy.js @@ -77,7 +77,7 @@ describe('Inventory', () => { AUTHORITY_LDR_FIELD_DROPDOWNS_NAMES.STATUS, AUTHORITY_LDR_FIELD_STATUS_DROPDOWN.C, ); - QuickMarcEditor.saveAndCloseWithValidationWarnings(); + QuickMarcEditor.pressSaveAndCloseButton(); InstanceRecordView.waitLoading(); InstanceRecordView.verifyMarkAsSuppressedFromDiscoveryAndStaffSuppressedWarning(); InstanceRecordView.verifyInstanceIsMarkedAsSuppressedFromDiscovery(); diff --git a/cypress/e2e/inventory/settings/subjects/delete-action-in-settings-inventory-create-edit-delete-subject-sources-permission-for-linked-to-instance-subject-source.cy.js b/cypress/e2e/inventory/settings/subjects/delete-action-in-settings-inventory-create-edit-delete-subject-sources-permission-for-linked-to-instance-subject-source.cy.js new file mode 100644 index 0000000000..a8344f1f70 --- /dev/null +++ b/cypress/e2e/inventory/settings/subjects/delete-action-in-settings-inventory-create-edit-delete-subject-sources-permission-for-linked-to-instance-subject-source.cy.js @@ -0,0 +1,93 @@ +import { APPLICATION_NAMES } from '../../../../support/constants'; +import { Permissions } from '../../../../support/dictionary'; +import InventoryInstance from '../../../../support/fragments/inventory/inventoryInstance'; +import SubjectSources, { + ACTION_BUTTONS, +} from '../../../../support/fragments/settings/inventory/instances/subjectSources'; +import SettingsInventory, { + INVENTORY_SETTINGS_TABS, +} from '../../../../support/fragments/settings/inventory/settingsInventory'; +import TopMenuNavigation from '../../../../support/fragments/topMenuNavigation'; +import Users from '../../../../support/fragments/users/users'; +import getRandomPostfix from '../../../../support/utils/stringTools'; + +describe('Inventory', () => { + describe('Settings', () => { + describe('Subjects', () => { + const testData = { + source: 'local', + name: `AT_C543780_SubjectSource${getRandomPostfix()}`, + heading: `AT_C543780_SubjectHeading${getRandomPostfix()}`, + }; + + before('Create test data', () => { + cy.getAdminToken(); + InventoryInstance.createInstanceViaApi().then(({ instanceData }) => { + testData.instance = instanceData; + + SubjectSources.createViaApi({ + source: testData.source, + name: testData.name, + }).then((response) => { + testData.subjectSourceId = response.body.id; + + cy.getInstanceById(testData.instance.instanceId).then((body) => { + body.subjects = [ + { + authorityId: null, + value: testData.heading, + sourceId: response.body.id, + typeId: null, + }, + ]; + cy.updateInstance(body); + }); + }); + }); + cy.getAdminUserDetails().then((user) => { + testData.adminLastName = user.personal.lastName; + }); + cy.createTempUser([Permissions.uiSettingsSubjectSourceCreateEditDelete.gui]).then( + (userProperties) => { + testData.user = userProperties; + + cy.login(testData.user.username, testData.user.password); + }, + ); + }); + + after('Delete user', () => { + cy.getAdminToken(); + InventoryInstance.deleteInstanceViaApi(testData.instance.instanceId); + SubjectSources.deleteViaApi(testData.subjectSourceId); + Users.deleteViaApi(testData.user.userId); + }); + + it( + 'C543780 Check the "Delete" action in "Settings (Inventory): Create, edit, delete subject sources" permission for linked to Instance subject source (folijet)', + { tags: ['extendedPath', 'folijet', 'C543780'] }, + () => { + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.SETTINGS); + SettingsInventory.goToSettingsInventory(); + SettingsInventory.selectSettingsTab(INVENTORY_SETTINGS_TABS.SUBJECT_SOURCES); + SubjectSources.waitLoading(); + SubjectSources.verifySubjectSourceExists( + testData.name, + testData.source, + testData.adminLastName, + { actions: [ACTION_BUTTONS.EDIT, ACTION_BUTTONS.TRASH] }, + ); + SubjectSources.deleteSubjectSource(testData.name); + SubjectSources.confirmDeletionOfSubjectSource(testData.name); + SubjectSources.verifySubjectSourceCannotBeDeleted(); + SubjectSources.verifySubjectSourceExists( + testData.name, + testData.source, + testData.adminLastName, + { actions: [ACTION_BUTTONS.EDIT, ACTION_BUTTONS.TRASH] }, + ); + }, + ); + }); + }); +}); diff --git a/cypress/e2e/inventory/settings/subjects/delete-action-in-settings-inventory-create-edit-delete-subject-types-permission-for-linked-to-instance-subject-type.cy.js b/cypress/e2e/inventory/settings/subjects/delete-action-in-settings-inventory-create-edit-delete-subject-types-permission-for-linked-to-instance-subject-type.cy.js new file mode 100644 index 0000000000..2f115a2d72 --- /dev/null +++ b/cypress/e2e/inventory/settings/subjects/delete-action-in-settings-inventory-create-edit-delete-subject-types-permission-for-linked-to-instance-subject-type.cy.js @@ -0,0 +1,92 @@ +import { Permissions } from '../../../../support/dictionary'; +import Users from '../../../../support/fragments/users/users'; +import getRandomPostfix from '../../../../support/utils/stringTools'; +import InventoryInstance from '../../../../support/fragments/inventory/inventoryInstance'; +import { APPLICATION_NAMES } from '../../../../support/constants'; +import TopMenuNavigation from '../../../../support/fragments/topMenuNavigation'; +import SettingsInventory, { + INVENTORY_SETTINGS_TABS, +} from '../../../../support/fragments/settings/inventory/settingsInventory'; +import SubjectTypes, { + ACTION_BUTTONS, +} from '../../../../support/fragments/settings/inventory/instances/subjectTypes'; + +describe('Inventory', () => { + describe('Settings', () => { + describe('Subjects', () => { + const testData = { + source: 'local', + name: `AT_C543781_SubjectType${getRandomPostfix()}`, + heading: `AT_C543781_SubjectHeading${getRandomPostfix()}`, + }; + + before('Create test data', () => { + cy.getAdminToken(); + InventoryInstance.createInstanceViaApi().then(({ instanceData }) => { + testData.instance = instanceData; + + SubjectTypes.createViaApi({ + source: testData.source, + name: testData.name, + }).then((response) => { + testData.subjectTypeId = response.body.id; + + cy.getInstanceById(testData.instance.instanceId).then((body) => { + body.subjects = [ + { + value: testData.heading, + typeId: response.body.id, + }, + ]; + cy.updateInstance(body); + }); + }); + }); + cy.getAdminUserDetails().then((user) => { + testData.adminLastName = user.personal.lastName; + }); + cy.createTempUser([Permissions.uiSettingsCreateEditDeleteSubjectTypes.gui]).then( + (userProperties) => { + testData.user = userProperties; + + cy.login(testData.user.username, testData.user.password); + }, + ); + }); + + after('Delete user', () => { + cy.getAdminToken(); + InventoryInstance.deleteInstanceViaApi(testData.instance.instanceId); + SubjectTypes.deleteViaApi(testData.subjectTypeId); + Users.deleteViaApi(testData.user.userId); + }); + + it( + 'C543781 Check the "Delete" action in "Settings (Inventory): Create, edit, delete subject types" permission for linked to Instance subject type (folijet)', + { tags: ['extendedPath', 'folijet', 'C543781'] }, + () => { + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.SETTINGS); + SettingsInventory.goToSettingsInventory(); + SettingsInventory.selectSettingsTab(INVENTORY_SETTINGS_TABS.SUBJECT_TYPES); + SubjectTypes.waitLoading(); + SubjectTypes.verifySubjectTypeExists({ + name: testData.name, + source: testData.source, + user: testData.adminLastName, + actions: [ACTION_BUTTONS.EDIT, ACTION_BUTTONS.TRASH], + }); + SubjectTypes.deleteSubjectType(testData.name); + SubjectTypes.confirmDeletionOfSubjectType(testData.name); + SubjectTypes.verifySubjectTypeCannotBeDeleted(); + SubjectTypes.waitLoading(); + SubjectTypes.verifySubjectTypeExists({ + name: testData.name, + source: testData.source, + user: testData.adminLastName, + actions: [ACTION_BUTTONS.EDIT, ACTION_BUTTONS.TRASH], + }); + }, + ); + }); + }); +}); diff --git a/cypress/e2e/inventory/settings/subjects/subject-source-can-not-be-created-with-already-existed-folio-subject-source-name.cy.js b/cypress/e2e/inventory/settings/subjects/subject-source-can-not-be-created-with-already-existed-folio-subject-source-name.cy.js new file mode 100644 index 0000000000..6ec0d94445 --- /dev/null +++ b/cypress/e2e/inventory/settings/subjects/subject-source-can-not-be-created-with-already-existed-folio-subject-source-name.cy.js @@ -0,0 +1,48 @@ +import { APPLICATION_NAMES } from '../../../../support/constants'; +import { Permissions } from '../../../../support/dictionary'; +import SubjectSources from '../../../../support/fragments/settings/inventory/instances/subjectSources'; +import SettingsInventory, { + INVENTORY_SETTINGS_TABS, +} from '../../../../support/fragments/settings/inventory/settingsInventory'; +import TopMenuNavigation from '../../../../support/fragments/topMenuNavigation'; +import Users from '../../../../support/fragments/users/users'; + +describe('Inventory', () => { + describe('Settings', () => { + describe('Subjects', () => { + const testData = { + user: {}, + subjectSourceName: 'Canadian Subject Headings', + errorMessage: 'Error saving data. Name must be unique.', + }; + + before('Create test data and login', () => { + cy.createTempUser([Permissions.uiSettingsSubjectSourceCreateEditDelete.gui]).then( + (userProperties) => { + testData.user = userProperties; + + cy.login(testData.user.username, testData.user.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.SETTINGS); + SettingsInventory.goToSettingsInventory(); + SettingsInventory.selectSettingsTab(INVENTORY_SETTINGS_TABS.SUBJECT_SOURCES); + SubjectSources.waitLoading(); + }, + ); + }); + + after('Delete test data', () => { + cy.getAdminToken(); + Users.deleteViaApi(testData.user.userId); + }); + + it( + "C543860 Check that Subject source can't be created with already existed folio subject source name (folijet)", + { tags: ['extendedPath', 'folijet', 'C543860'] }, + () => { + SubjectSources.create(testData.subjectSourceName); + SubjectSources.validateNameFieldWithError(testData.errorMessage); + }, + ); + }); + }); +}); diff --git a/cypress/e2e/inventory/settings/subjects/subject-source-can-not-be-created-with-already-existed-local-subject-source-name.cy.js b/cypress/e2e/inventory/settings/subjects/subject-source-can-not-be-created-with-already-existed-local-subject-source-name.cy.js new file mode 100644 index 0000000000..79a671f7af --- /dev/null +++ b/cypress/e2e/inventory/settings/subjects/subject-source-can-not-be-created-with-already-existed-local-subject-source-name.cy.js @@ -0,0 +1,61 @@ +import { APPLICATION_NAMES } from '../../../../support/constants'; +import { Permissions } from '../../../../support/dictionary'; +import SubjectSources from '../../../../support/fragments/settings/inventory/instances/subjectSources'; +import SettingsInventory, { + INVENTORY_SETTINGS_TABS, +} from '../../../../support/fragments/settings/inventory/settingsInventory'; +import TopMenuNavigation from '../../../../support/fragments/topMenuNavigation'; +import Users from '../../../../support/fragments/users/users'; +import getRandomPostfix from '../../../../support/utils/stringTools'; + +describe('Inventory', () => { + describe('Settings', () => { + describe('Subjects', () => { + const testData = { + user: {}, + errorMessage: 'Error saving data. Name must be unique.', + }; + const localSubjectSource = { + name: `C543861 autotestSubjectSourceName${getRandomPostfix()}`, + source: 'local', + }; + + before('Create test data and login', () => { + cy.getAdminToken(); + SubjectSources.createViaApi({ + source: localSubjectSource.source, + name: localSubjectSource.name, + }).then((response) => { + localSubjectSource.id = response.body.id; + }); + + cy.createTempUser([Permissions.uiSettingsSubjectSourceCreateEditDelete.gui]).then( + (userProperties) => { + testData.user = userProperties; + + cy.login(testData.user.username, testData.user.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.SETTINGS); + SettingsInventory.goToSettingsInventory(); + SettingsInventory.selectSettingsTab(INVENTORY_SETTINGS_TABS.SUBJECT_SOURCES); + SubjectSources.waitLoading(); + }, + ); + }); + + after('Delete test data', () => { + cy.getAdminToken(); + Users.deleteViaApi(testData.user.userId); + SubjectSources.deleteViaApi(localSubjectSource.id); + }); + + it( + "C543861 Check that Subject source can't be created with already existed local subject source name (folijet)", + { tags: ['extendedPath', 'folijet', 'C543861'] }, + () => { + SubjectSources.create(localSubjectSource.name); + SubjectSources.validateNameFieldWithError(testData.errorMessage); + }, + ); + }); + }); +}); diff --git a/cypress/e2e/inventory/settings/subjects/subject-source-can-not-be-edited-with-already-existed-subject-source-name.cy.js b/cypress/e2e/inventory/settings/subjects/subject-source-can-not-be-edited-with-already-existed-subject-source-name.cy.js new file mode 100644 index 0000000000..ff8e001838 --- /dev/null +++ b/cypress/e2e/inventory/settings/subjects/subject-source-can-not-be-edited-with-already-existed-subject-source-name.cy.js @@ -0,0 +1,84 @@ +import { APPLICATION_NAMES } from '../../../../support/constants'; +import { Permissions } from '../../../../support/dictionary'; +import SubjectSources from '../../../../support/fragments/settings/inventory/instances/subjectSources'; +import SettingsInventory, { + INVENTORY_SETTINGS_TABS, +} from '../../../../support/fragments/settings/inventory/settingsInventory'; +import TopMenuNavigation from '../../../../support/fragments/topMenuNavigation'; +import Users from '../../../../support/fragments/users/users'; +import getRandomPostfix from '../../../../support/utils/stringTools'; + +describe('Inventory', () => { + describe('Settings', () => { + describe('Subjects', () => { + const testData = { + user: {}, + errorMessage: 'Error saving data. Name must be unique.', + }; + const firstLocalSubjectSource = { + name: `C543864 autotestSubjectSourceName${getRandomPostfix()}`, + source: 'local', + }; + const secondLocalSubjectSource = { + name: `C543864 autotestSubjectSourceName${getRandomPostfix()}`, + source: 'local', + }; + + before('Create test data and login', () => { + cy.getAdminToken(); + cy.getAdminUserDetails().then((admin) => { + testData.adminUser = admin; + }); + SubjectSources.createViaApi({ + source: firstLocalSubjectSource.source, + name: firstLocalSubjectSource.name, + }).then((response) => { + firstLocalSubjectSource.id = response.body.id; + }); + SubjectSources.createViaApi({ + source: secondLocalSubjectSource.source, + name: secondLocalSubjectSource.name, + }).then((response) => { + secondLocalSubjectSource.id = response.body.id; + }); + + cy.createTempUser([Permissions.uiSettingsSubjectSourceCreateEditDelete.gui]).then( + (userProperties) => { + testData.user = userProperties; + + cy.login(testData.user.username, testData.user.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.SETTINGS); + SettingsInventory.goToSettingsInventory(); + SettingsInventory.selectSettingsTab(INVENTORY_SETTINGS_TABS.SUBJECT_SOURCES); + SubjectSources.waitLoading(); + }, + ); + }); + + after('Delete test data', () => { + cy.getAdminToken(); + Users.deleteViaApi(testData.user.userId); + SubjectSources.deleteViaApi(firstLocalSubjectSource.id); + SubjectSources.deleteViaApi(secondLocalSubjectSource.id); + }); + + it( + "C543864 Check that Subject source can't be edited with already existed subject source name (folijet)", + { tags: ['extendedPath', 'folijet', 'C543864'] }, + () => { + SubjectSources.verifySubjectSourceExists( + firstLocalSubjectSource.name, + firstLocalSubjectSource.source, + `${testData.adminUser.personal.lastName}, ${testData.adminUser.personal.firstName}`, + { actions: ['edit', 'trash'] }, + ); + SubjectSources.editSubjectSourceName( + firstLocalSubjectSource.name, + secondLocalSubjectSource.name, + ); + SubjectSources.validateNameFieldWithError(testData.errorMessage); + }, + ); + }); + }); +}); diff --git a/cypress/e2e/inventory/settings/subjects/subject-type-can-not-be-created-with-already-existed-folio-subject-type-name.cy.js b/cypress/e2e/inventory/settings/subjects/subject-type-can-not-be-created-with-already-existed-folio-subject-type-name.cy.js new file mode 100644 index 0000000000..f818dd4356 --- /dev/null +++ b/cypress/e2e/inventory/settings/subjects/subject-type-can-not-be-created-with-already-existed-folio-subject-type-name.cy.js @@ -0,0 +1,48 @@ +import { APPLICATION_NAMES } from '../../../../support/constants'; +import { Permissions } from '../../../../support/dictionary'; +import SubjectTypes from '../../../../support/fragments/settings/inventory/instances/subjectTypes'; +import SettingsInventory, { + INVENTORY_SETTINGS_TABS, +} from '../../../../support/fragments/settings/inventory/settingsInventory'; +import TopMenuNavigation from '../../../../support/fragments/topMenuNavigation'; +import Users from '../../../../support/fragments/users/users'; + +describe('Inventory', () => { + describe('Settings', () => { + describe('Subjects', () => { + const testData = { + user: {}, + subjectTypeName: 'Chronological term', + errorMessage: 'Error saving data. Name must be unique.', + }; + + before('Create test data and login', () => { + cy.createTempUser([Permissions.uiSettingsCreateEditDeleteSubjectTypes.gui]).then( + (userProperties) => { + testData.user = userProperties; + + cy.login(testData.user.username, testData.user.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.SETTINGS); + SettingsInventory.goToSettingsInventory(); + SettingsInventory.selectSettingsTab(INVENTORY_SETTINGS_TABS.SUBJECT_TYPES); + SubjectTypes.waitLoading(); + }, + ); + }); + + after('Delete test data', () => { + cy.getAdminToken(); + Users.deleteViaApi(testData.user.userId); + }); + + it( + "C543862 Check that Subject type can't be created with already existed folio subject type name name (folijet)", + { tags: ['extendedPath', 'folijet', 'C543862'] }, + () => { + SubjectTypes.createSubjectType(testData.subjectTypeName); + SubjectTypes.validateNameFieldWithError(testData.errorMessage); + }, + ); + }); + }); +}); diff --git a/cypress/e2e/inventory/settings/subjects/subject-type-can-not-be-created-with-already-existed-local-subject-type-name.cy.js b/cypress/e2e/inventory/settings/subjects/subject-type-can-not-be-created-with-already-existed-local-subject-type-name.cy.js new file mode 100644 index 0000000000..9884c43d25 --- /dev/null +++ b/cypress/e2e/inventory/settings/subjects/subject-type-can-not-be-created-with-already-existed-local-subject-type-name.cy.js @@ -0,0 +1,61 @@ +import { APPLICATION_NAMES } from '../../../../support/constants'; +import { Permissions } from '../../../../support/dictionary'; +import SubjectTypes from '../../../../support/fragments/settings/inventory/instances/subjectTypes'; +import SettingsInventory, { + INVENTORY_SETTINGS_TABS, +} from '../../../../support/fragments/settings/inventory/settingsInventory'; +import TopMenuNavigation from '../../../../support/fragments/topMenuNavigation'; +import Users from '../../../../support/fragments/users/users'; +import getRandomPostfix from '../../../../support/utils/stringTools'; + +describe('Inventory', () => { + describe('Settings', () => { + describe('Subjects', () => { + const testData = { + user: {}, + errorMessage: 'Error saving data. Name must be unique.', + }; + const localSubjectType = { + name: `C543863 autotestSubjectTypeName${getRandomPostfix()}`, + source: 'local', + }; + + before('Create test data and login', () => { + cy.getAdminToken(); + SubjectTypes.createViaApi({ + source: localSubjectType.source, + name: localSubjectType.name, + }).then((response) => { + localSubjectType.id = response.body.id; + }); + + cy.createTempUser([Permissions.uiSettingsCreateEditDeleteSubjectTypes.gui]).then( + (userProperties) => { + testData.user = userProperties; + + cy.login(testData.user.username, testData.user.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.SETTINGS); + SettingsInventory.goToSettingsInventory(); + SettingsInventory.selectSettingsTab(INVENTORY_SETTINGS_TABS.SUBJECT_TYPES); + SubjectTypes.waitLoading(); + }, + ); + }); + + after('Delete test data', () => { + cy.getAdminToken(); + Users.deleteViaApi(testData.user.userId); + SubjectTypes.deleteViaApi(localSubjectType.id); + }); + + it( + "C543863 Check that Subject type can't be created with already existed local subject type name (folijet)", + { tags: ['extendedPath', 'folijet', 'C543863'] }, + () => { + SubjectTypes.createSubjectType(localSubjectType.name); + SubjectTypes.validateNameFieldWithError(testData.errorMessage); + }, + ); + }); + }); +}); diff --git a/cypress/e2e/inventory/settings/subjects/subject-type-can-not-be-edited-with-already-existed-subject-type-name.cy.js b/cypress/e2e/inventory/settings/subjects/subject-type-can-not-be-edited-with-already-existed-subject-type-name.cy.js new file mode 100644 index 0000000000..f7e41b3974 --- /dev/null +++ b/cypress/e2e/inventory/settings/subjects/subject-type-can-not-be-edited-with-already-existed-subject-type-name.cy.js @@ -0,0 +1,81 @@ +import { APPLICATION_NAMES } from '../../../../support/constants'; +import { Permissions } from '../../../../support/dictionary'; +import SubjectTypes from '../../../../support/fragments/settings/inventory/instances/subjectTypes'; +import SettingsInventory, { + INVENTORY_SETTINGS_TABS, +} from '../../../../support/fragments/settings/inventory/settingsInventory'; +import TopMenuNavigation from '../../../../support/fragments/topMenuNavigation'; +import Users from '../../../../support/fragments/users/users'; +import getRandomPostfix from '../../../../support/utils/stringTools'; + +describe('Inventory', () => { + describe('Settings', () => { + describe('Subjects', () => { + const testData = { + user: {}, + errorMessage: 'Error saving data. Name must be unique.', + }; + const firstLocalSubjectType = { + name: `C543865 autotestSubjectTypeName${getRandomPostfix()}`, + source: 'local', + }; + const secondLocalSubjectType = { + name: `C543865 autotestSubjectTypeName${getRandomPostfix()}`, + source: 'local', + }; + + before('Create test data and login', () => { + cy.getAdminToken(); + cy.getAdminUserDetails().then((admin) => { + testData.adminUser = admin; + }); + SubjectTypes.createViaApi({ + source: firstLocalSubjectType.source, + name: firstLocalSubjectType.name, + }).then((response) => { + firstLocalSubjectType.id = response.body.id; + }); + SubjectTypes.createViaApi({ + source: secondLocalSubjectType.source, + name: secondLocalSubjectType.name, + }).then((response) => { + secondLocalSubjectType.id = response.body.id; + }); + + cy.createTempUser([Permissions.uiSettingsCreateEditDeleteSubjectTypes.gui]).then( + (userProperties) => { + testData.user = userProperties; + + cy.login(testData.user.username, testData.user.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.SETTINGS); + SettingsInventory.goToSettingsInventory(); + SettingsInventory.selectSettingsTab(INVENTORY_SETTINGS_TABS.SUBJECT_TYPES); + SubjectTypes.waitLoading(); + }, + ); + }); + + after('Delete test data', () => { + cy.getAdminToken(); + Users.deleteViaApi(testData.user.userId); + SubjectTypes.deleteViaApi(firstLocalSubjectType.id); + SubjectTypes.deleteViaApi(secondLocalSubjectType.id); + }); + + it( + "C543865 Check that Subject type can't be edited with already existed subject type name (folijet)", + { tags: ['extendedPath', 'folijet', 'C543865'] }, + () => { + SubjectTypes.verifySubjectTypeExists({ + name: firstLocalSubjectType.name, + source: firstLocalSubjectType.source, + user: `${testData.adminUser.personal.lastName}, ${testData.adminUser.personal.firstName}`, + actions: ['edit', 'trash'], + }); + SubjectTypes.editSubjectTypeName(firstLocalSubjectType.name, secondLocalSubjectType.name); + SubjectTypes.validateNameFieldWithError(testData.errorMessage); + }, + ); + }); + }); +}); diff --git a/cypress/e2e/inventory/single-record-import/import-by-oclc-source-folio.cy.js b/cypress/e2e/inventory/single-record-import/import-by-oclc-source-folio.cy.js index bfa4fef929..c8f548126b 100644 --- a/cypress/e2e/inventory/single-record-import/import-by-oclc-source-folio.cy.js +++ b/cypress/e2e/inventory/single-record-import/import-by-oclc-source-folio.cy.js @@ -45,7 +45,6 @@ describe('Inventory', () => { Permissions.uiInventorySingleRecordImport.gui, Permissions.uiInventorySettingsConfigureSingleRecordImport.gui, Permissions.uiQuickMarcQuickMarcBibliographicEditorAll.gui, - Permissions.remoteStorageView.gui, Permissions.settingsDataImportEnabled.gui, ]).then((userProperties) => { user = userProperties; diff --git a/cypress/e2e/inventory/single-record-import/overlay-record-created-by-using-fast-add-template-folio-by-import-from-lc.cy.js b/cypress/e2e/inventory/single-record-import/overlay-record-created-by-using-fast-add-template-folio-by-import-from-lc.cy.js new file mode 100644 index 0000000000..0898e366ba --- /dev/null +++ b/cypress/e2e/inventory/single-record-import/overlay-record-created-by-using-fast-add-template-folio-by-import-from-lc.cy.js @@ -0,0 +1,132 @@ +import uuid from 'uuid'; +import { APPLICATION_NAMES, LOCATION_NAMES } from '../../../support/constants'; +import { Permissions } from '../../../support/dictionary'; +import FastAddNewRecord from '../../../support/fragments/inventory/fastAddNewRecord'; +import instanceRecordEdit from '../../../support/fragments/inventory/instanceRecordEdit'; +import InstanceRecordView from '../../../support/fragments/inventory/instanceRecordView'; +import InventoryActions from '../../../support/fragments/inventory/inventoryActions'; +import InventoryInstance from '../../../support/fragments/inventory/inventoryInstance'; +import InventoryInstances from '../../../support/fragments/inventory/inventoryInstances'; +import InventoryViewSource from '../../../support/fragments/inventory/inventoryViewSource'; +import TopMenuNavigation from '../../../support/fragments/topMenuNavigation'; +import Users from '../../../support/fragments/users/users'; + +const testData = { + user: {}, + identifierType: 'LCCN', + lccnIdentifier: '08020755', + instanceSource: 'FOLIO', +}; +const fastAddRecord = { + resourceTitle: 'Wayeeses, the white wolf, from "Northern trails,"', + resourceType: 'text', + permanentLocationOption: `${LOCATION_NAMES.MAIN_LIBRARY} `, + permanentLocationValue: LOCATION_NAMES.MAIN_LIBRARY_UI, + materialType: 'book', + permanentLoanType: 'Can circulate', + itemBarcode: uuid(), + note: 'AT_C196838 Fast Add Note', +}; +const updatedInstanceValues = { + instanceTitle: 'Wayeeses, the white wolf, from "Northern trails,"', + instanceSource: 'MARC', + indexTitle: 'Wayeeses, the white wolf, from "Northern trails,"', + contributorName: 'Long, William J. (William Joseph), 1867-1952', + publisher: 'Ginn & company', + publisherRole: '-', + placeOfPublication: 'Boston ; New York [etc.]', + publicationDate: '[c1908]', + date1: '1908', + date2: 'No value set-', + dateType: 'Single known date/probable date', + + urlRelationship: 'Version of resource', + uri: 'http://hdl.loc.gov/loc.gdc/scd0001.00055061130', + subjectHeadings: 'Wolves', + subjectSource: 'Library of Congress Subject Headings', + subjectType: 'Topical term', +}; + +describe('Inventory', () => { + describe('Single record import', () => { + before('Create test user and login', () => { + cy.createTempUser([ + Permissions.uiInventoryViewCreateEditInstances.gui, + Permissions.uiInventorySingleRecordImport.gui, + Permissions.inventoryFastAddCreate.gui, + Permissions.uiQuickMarcQuickMarcBibliographicEditorAll.gui, + ]).then((userProperties) => { + testData.user = userProperties; + + cy.login(testData.user.username, testData.user.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.INVENTORY); + InventoryInstances.waitContentLoading(); + }); + }); + + after('Delete test data', () => { + cy.getAdminToken(); + InventoryInstances.deleteInstanceAndHoldingRecordAndAllItemsViaApi(fastAddRecord.itemBarcode); + Users.deleteViaApi(testData.user.userId); + }); + + it( + 'C196838 Overlay record created by using Fast add template (instance source = FOLIO) by import of single MARC record from LC (folijet)', + { tags: ['extendedPath', 'folijet', 'C196838'] }, + () => { + InventoryActions.openNewFastAddRecordForm(); + FastAddNewRecord.waitLoading(); + FastAddNewRecord.fillFastAddNewRecordForm(fastAddRecord); + FastAddNewRecord.saveAndClose(); + InstanceRecordView.waitLoading(); + + InstanceRecordView.edit(); + instanceRecordEdit.addIdentifier(testData.identifierType, testData.lccnIdentifier); + InstanceRecordView.waitLoading(); + + InstanceRecordView.verifyInstanceSource(testData.instanceSource); + InstanceRecordView.openAccordion('Identifiers'); + InstanceRecordView.verifyResourceIdentifier( + testData.identifierType, + testData.lccnIdentifier, + 0, + ); + + InventoryInstance.startOverlaySourceBibRecord(); + InventoryInstance.overlayWithOclc(testData.lccnIdentifier, 'Library of Congress'); + InventoryInstance.waitLoading(); + InstanceRecordView.verifyInstanceSource(updatedInstanceValues.instanceSource); + InstanceRecordView.verifyResourceTitle(updatedInstanceValues.instanceTitle); + InstanceRecordView.verifyIndexTitle(updatedInstanceValues.indexTitle, 0); + InstanceRecordView.openAccordion('Contributor'); + InventoryInstance.verifyContributor(0, 1, updatedInstanceValues.contributorName); + InstanceRecordView.verifyPublisher({ + publisher: updatedInstanceValues.publisher, + role: updatedInstanceValues.publisherRole, + place: updatedInstanceValues.placeOfPublication, + date: updatedInstanceValues.publicationDate, + }); + InstanceRecordView.verifyDates( + updatedInstanceValues.date1, + updatedInstanceValues.date2, + updatedInstanceValues.dateType, + ); + InventoryInstance.checkElectronicAccessValues( + updatedInstanceValues.urlRelationship, + updatedInstanceValues.uri, + 'No value set-', + ); + InstanceRecordView.openAccordion('Subject'); + InstanceRecordView.verifyInstanceSubject({ + indexRow: 0, + subjectHeadings: updatedInstanceValues.subjectHeadings, + subjectSource: updatedInstanceValues.subjectSource, + subjectType: updatedInstanceValues.subjectType, + }); + + InventoryInstance.viewSource(); + InventoryViewSource.contains('Wayeeses, $b the white wolf, from "Northern trails,"'); + }, + ); + }); +}); diff --git a/cypress/e2e/inventory/single-record-import/overlay-record-created-by-using-fast-add-template-folio-by-import-from-oclc.cy.js b/cypress/e2e/inventory/single-record-import/overlay-record-created-by-using-fast-add-template-folio-by-import-from-oclc.cy.js new file mode 100644 index 0000000000..39a5159b74 --- /dev/null +++ b/cypress/e2e/inventory/single-record-import/overlay-record-created-by-using-fast-add-template-folio-by-import-from-oclc.cy.js @@ -0,0 +1,122 @@ +import uuid from 'uuid'; +import { APPLICATION_NAMES, LOCATION_NAMES } from '../../../support/constants'; +import { Permissions } from '../../../support/dictionary'; +import FastAddNewRecord from '../../../support/fragments/inventory/fastAddNewRecord'; +import instanceRecordEdit from '../../../support/fragments/inventory/instanceRecordEdit'; +import InstanceRecordView from '../../../support/fragments/inventory/instanceRecordView'; +import InventoryActions from '../../../support/fragments/inventory/inventoryActions'; +import InventoryInstance from '../../../support/fragments/inventory/inventoryInstance'; +import InventoryInstances from '../../../support/fragments/inventory/inventoryInstances'; +import InventoryViewSource from '../../../support/fragments/inventory/inventoryViewSource'; +import Z3950TargetProfiles from '../../../support/fragments/settings/inventory/integrations/z39.50TargetProfiles'; +import TopMenuNavigation from '../../../support/fragments/topMenuNavigation'; +import Users from '../../../support/fragments/users/users'; + +const testData = { + user: {}, + identifierType: 'OCLC', + oclcIdentifier: '949639961', + OCLCAuthentication: '100481406/PAOLF', + instanceSource: 'FOLIO', +}; +const fastAddRecord = { + resourceTitle: 'The wolves / Alex Berenson.', + resourceType: 'text', + permanentLocationOption: `${LOCATION_NAMES.MAIN_LIBRARY} `, + permanentLocationValue: LOCATION_NAMES.MAIN_LIBRARY_UI, + materialType: 'book', + permanentLoanType: 'Can circulate', + itemBarcode: uuid(), + note: 'AT_C196837 Fast Add Note', +}; +const updatedInstanceValues = { + instanceTitle: 'The wolves / Alex Berenson.', + instanceSource: 'MARC', + indexTitle: 'Wolves /', + seriesStatement: 'Berenson, Alex. John Wells novel ; bk. 10.', + contributorName: 'Berenson, Alex', + publisher: "G.P. Putnam's Sons", + publisherRole: 'Publication', + placeOfPublication: 'New York', + publicationDate: '2017', + edition: "First G.P. Putnam's Sons premium edition.", + date1: '2017', + date2: '2016', + dateType: 'Publication date and copyright date', +}; + +describe('Inventory', () => { + describe('Single record import', () => { + before('Create test user and login', () => { + cy.createTempUser([ + Permissions.uiInventoryViewCreateEditInstances.gui, + Permissions.uiInventorySingleRecordImport.gui, + Permissions.inventoryFastAddCreate.gui, + Permissions.uiQuickMarcQuickMarcBibliographicEditorAll.gui, + ]).then((userProperties) => { + testData.user = userProperties; + + Z3950TargetProfiles.changeOclcWorldCatValueViaApi(testData.OCLCAuthentication); + + cy.login(testData.user.username, testData.user.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.INVENTORY); + InventoryInstances.waitContentLoading(); + }); + }); + + after('Delete test data', () => { + cy.getAdminToken(); + InventoryInstances.deleteInstanceAndHoldingRecordAndAllItemsViaApi(fastAddRecord.itemBarcode); + Users.deleteViaApi(testData.user.userId); + }); + + it( + 'C196837 Overlay record created by using Fast add template (instance source = FOLIO) by import of single MARC record from OCLC (folijet)', + { tags: ['extendedPath', 'folijet', 'C196837'] }, + () => { + InventoryActions.openNewFastAddRecordForm(); + FastAddNewRecord.waitLoading(); + FastAddNewRecord.fillFastAddNewRecordForm(fastAddRecord); + FastAddNewRecord.saveAndClose(); + InstanceRecordView.waitLoading(); + + InstanceRecordView.edit(); + instanceRecordEdit.addIdentifier(testData.identifierType, testData.oclcIdentifier); + InstanceRecordView.waitLoading(); + + InstanceRecordView.verifyInstanceSource(testData.instanceSource); + InstanceRecordView.openAccordion('Identifiers'); + InstanceRecordView.verifyResourceIdentifier( + testData.identifierType, + testData.oclcIdentifier, + 0, + ); + + InventoryInstance.startOverlaySourceBibRecord(); + InventoryInstance.overlayWithOclc(testData.oclcIdentifier); + InventoryInstance.waitLoading(); + InstanceRecordView.verifyInstanceSource(updatedInstanceValues.instanceSource); + InstanceRecordView.verifyResourceTitle(updatedInstanceValues.instanceTitle); + InstanceRecordView.verifyIndexTitle(updatedInstanceValues.indexTitle, 0); + InventoryInstance.verifySeriesStatement(0, updatedInstanceValues.seriesStatement); + InstanceRecordView.openAccordion('Contributor'); + InventoryInstance.verifyContributor(0, 1, updatedInstanceValues.contributorName); + InstanceRecordView.verifyPublisher({ + publisher: updatedInstanceValues.publisher, + role: updatedInstanceValues.publisherRole, + place: updatedInstanceValues.placeOfPublication, + date: updatedInstanceValues.publicationDate, + }); + InstanceRecordView.verifyEdition(updatedInstanceValues.edition, 0); + InstanceRecordView.verifyDates( + updatedInstanceValues.date1, + updatedInstanceValues.date2, + updatedInstanceValues.dateType, + ); + + InventoryInstance.viewSource(); + InventoryViewSource.contains('$a The wolves / $c Alex Berenson.'); + }, + ); + }); +}); diff --git a/cypress/e2e/invoices/pay-invoice-with-multiple-expense-classes.cy.js b/cypress/e2e/invoices/pay-invoice-with-multiple-expense-classes.cy.js index de3439ce86..1abbc5e5ea 100644 --- a/cypress/e2e/invoices/pay-invoice-with-multiple-expense-classes.cy.js +++ b/cypress/e2e/invoices/pay-invoice-with-multiple-expense-classes.cy.js @@ -1,122 +1,210 @@ -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 Invoices from '../../support/fragments/invoices/invoices'; -import NewInvoice from '../../support/fragments/invoices/newInvoice'; -import NewOrder from '../../support/fragments/orders/newOrder'; -import OrderLines from '../../support/fragments/orders/orderLines'; -import Orders from '../../support/fragments/orders/orders'; -import NewOrganization from '../../support/fragments/organizations/newOrganization'; -import Organizations from '../../support/fragments/organizations/organizations'; -import NewExpenseClass from '../../support/fragments/settings/finance/newExpenseClass'; -import SettingsFinance from '../../support/fragments/settings/finance/settingsFinance'; -import NewLocation from '../../support/fragments/settings/tenant/locations/newLocation'; -import ServicePoints from '../../support/fragments/settings/tenant/servicePoints/servicePoints'; -import SettingsMenu from '../../support/fragments/settingsMenu'; -import TopMenu from '../../support/fragments/topMenu'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + APPLICATION_NAMES, + INVOICE_STATUSES, + LOCATION_NAMES, + ORDER_STATUSES, +} from '../../support/constants'; +import Permissions from '../../support/dictionary/permissions'; +import { BudgetDetails, Budgets, Funds } from '../../support/fragments/finance'; +import { + InvoiceLineEditForm, + InvoiceNewForm, + Invoices, + InvoiceView, + NewInvoice, +} from '../../support/fragments/invoices'; +import InvoiceLineDetails from '../../support/fragments/invoices/invoiceLineDetails'; +import { BasicOrderLine, NewOrder, OrderLines, Orders } from '../../support/fragments/orders'; +import { NewOrganization, Organizations } from '../../support/fragments/organizations'; +import ExpenseClasses from '../../support/fragments/settings/finance/expenseClasses'; +import TopMenuNavigation from '../../support/fragments/topMenuNavigation'; import Users from '../../support/fragments/users/users'; +import getRandomPostfix from '../../support/utils/stringTools'; describe('Invoices', () => { - const firstFiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const defaultFund = { ...Funds.defaultUiFund }; - const firstOrder = { ...NewOrder.defaultOneTimeOrder, approved: true, reEncumber: true }; - const firstExpenseClass = { ...NewExpenseClass.defaultUiBatchGroup }; - const organization = { ...NewOrganization.defaultUiOrganizations }; + const organization = NewOrganization.getDefaultOrganization(); + const testData = { + organization, + user: {}, + }; const invoice = { ...NewInvoice.defaultUiInvoice }; - const allocatedQuantity = '100'; - let user; - let firstOrderNumber; - let servicePointId; - let location; + const expenseClass1 = { ...ExpenseClasses.getDefaultExpenseClass() }; + const expenseClass2 = { + ...ExpenseClasses.getDefaultExpenseClass(), + name: `autotest_class_2_name_${getRandomPostfix()}`, + }; - before(() => { + before('Setup test data', () => { cy.getAdminToken(); - cy.loginAsAdmin({ - path: SettingsMenu.expenseClassesPath, - waiter: SettingsFinance.waitExpenseClassesLoading, - }); - SettingsFinance.createNewExpenseClass(firstExpenseClass); - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - defaultFund.ledgerId = defaultLedger.id; + ExpenseClasses.createExpenseClassViaApi(expenseClass1).then((ec1) => { + testData.expenseClass1 = ec1; - Funds.createViaApi(defaultFund).then((fundResponse) => { - defaultFund.id = fundResponse.fund.id; + ExpenseClasses.createExpenseClassViaApi(expenseClass2).then((ec2) => { + testData.expenseClass2 = ec2; - cy.loginAsAdmin({ path: TopMenu.fundPath, waiter: Funds.waitLoading }); - FinanceHelp.searchByName(defaultFund.name); - Funds.selectFund(defaultFund.name); - Funds.addBudget(allocatedQuantity); - Funds.editBudget(); - Funds.addExpensesClass(firstExpenseClass.name); + const { fiscalYear, fund } = Budgets.createBudgetWithFundLedgerAndFYViaApi({ + budget: { + allocated: 100, + statusExpenseClasses: [ + { + status: 'Active', + expenseClassId: testData.expenseClass1.id, + }, + { + status: 'Active', + expenseClassId: testData.expenseClass2.id, + }, + ], + }, }); + testData.fiscalYear = fiscalYear; + testData.fund = fund; }); }); - ServicePoints.getViaApi().then((servicePoint) => { - servicePointId = servicePoint[0].id; - NewLocation.createViaApi(NewLocation.getDefaultLocation(servicePointId)).then((res) => { - location = res; - }); - }); - - Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { - organization.id = responseOrganizations; + Organizations.createOrganizationViaApi(testData.organization).then((orgResp) => { + testData.organization.id = orgResp; invoice.accountingCode = organization.erpCode; - firstOrder.orderType = 'One-time'; - firstOrder.vendor = organization.name; - cy.visit(TopMenu.ordersPath); - Orders.createApprovedOrderForRollover(firstOrder, true).then((secondOrderResponse) => { - firstOrder.id = secondOrderResponse.id; - firstOrderNumber = secondOrderResponse.poNumber; - OrderLines.addPOLine(); - OrderLines.selectRandomInstanceInTitleLookUP('*', 15); - OrderLines.rolloverPOLineInfoforPhysicalMaterialWithFund( - defaultFund, - '40', - '1', - '40', - location.name, - ); - OrderLines.backToEditingOrder(); - Orders.openOrder(); + + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((amResp) => { + cy.getBookMaterialType().then((mtypeResp) => { + testData.order = { + ...NewOrder.getDefaultOrder({ vendorId: testData.organization.id }), + reEncumber: true, + approved: true, + }; + const orderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + listUnitPrice: 20.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 20.0, + }, + fundDistribution: [ + { + code: testData.fund.code, + fundId: testData.fund.id, + value: 100, + }, + ], + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: amResp.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypeResp.id, + materialSupplier: orgResp.id, + volumes: [], + }, + }; + + Orders.createOrderViaApi(testData.order).then((orderResp) => { + testData.order.id = orderResp.id; + testData.orderNumber = orderResp.poNumber; + orderLine.purchaseOrderId = orderResp.id; + + OrderLines.createOrderLineViaApi(orderLine); + Orders.updateOrderViaApi({ + ...orderResp, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); + }); + }); }); }); + cy.getBatchGroups().then((bgResp) => { + invoice.batchGroup = bgResp.name; + }); cy.createTempUser([ - permissions.uiInvoicesApproveInvoices.gui, - permissions.viewEditCreateInvoiceInvoiceLine.gui, - permissions.uiFinanceViewFundAndBudget.gui, - permissions.uiInvoicesPayInvoices.gui, + Permissions.uiInvoicesApproveInvoices.gui, + Permissions.viewEditCreateInvoiceInvoiceLine.gui, + Permissions.uiFinanceViewFundAndBudget.gui, + Permissions.uiInvoicesPayInvoices.gui, ]).then((userProperties) => { - user = userProperties; - cy.login(userProperties.username, userProperties.password, { - path: TopMenu.invoicesPath, - waiter: Invoices.waitLoading, - authRefresh: true, - }); + testData.user = userProperties; + + cy.login(userProperties.username, userProperties.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.INVOICES); + Invoices.waitLoading(); }); }); - after(() => { + after('Clean up test data', () => { cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); + Organizations.deleteOrganizationViaApi(testData.organization.id); }); it( 'C15859 Pay an invoice with multiple "Expense classes" assigned to it (thunderjet)', - { tags: ['criticalPathBroken', 'thunderjet', 'C15859'] }, + { tags: ['criticalPath', 'thunderjet', 'C15859'] }, () => { - Invoices.createRolloverInvoice(invoice, organization.name); - Invoices.createInvoiceLineFromPol(firstOrderNumber); - Invoices.approveInvoice(); - Invoices.payInvoice(); + Invoices.openNewInvoiceForm(); + InvoiceNewForm.createInvoice({ + status: invoice.status, + invoiceDate: invoice.invoiceDate, + invoiceNumber: invoice.invoiceNumber, + vendorName: organization.name, + accountingCode: invoice.accountingCode, + batchGroup: invoice.batchGroup, + paymentMethod: 'Cash', + }); + Invoices.createInvoiceLineFromPol(testData.orderNumber); + Invoices.selectInvoiceLine(); + InvoiceLineDetails.waitLoading(); + InvoiceLineDetails.openInvoiceLineEditForm(); + InvoiceLineEditForm.configureFundDistribution(0, { + expenseClass: expenseClass1.name, + value: '50', + }); + InvoiceLineEditForm.clickAddFundDistributionButton(); + InvoiceLineEditForm.configureFundDistribution(1, { + fund: `${testData.fund.name} (${testData.fund.code})`, + expenseClass: expenseClass2.name, + value: '50', + }); + InvoiceLineEditForm.clickSaveButton(); + InvoiceView.approveInvoice(); + InvoiceView.checkInvoiceDetails({ + invoiceInformation: [ + { key: 'Fiscal year', value: testData.fiscalYear.code }, + { key: 'Status', value: INVOICE_STATUSES.APPROVED }, + ], + }); + InvoiceView.selectInvoiceLine(); + InvoiceLineDetails.waitLoading(); + InvoiceLineDetails.openFundDetailsPane(testData.fund.name); + Funds.selectBudgetDetails(); + BudgetDetails.checkBudgetDetails({ + summary: [{ key: 'Awaiting payment', value: '$20.00' }], + }); + Funds.viewTransactions(); + Funds.checkTransactionCount('Pending payment', 2); + + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.INVOICES); + Invoices.waitLoading(); + Invoices.searchByNumber(invoice.invoiceNumber); + Invoices.selectInvoice(invoice.invoiceNumber); + InvoiceView.payInvoice(); + InvoiceView.checkInvoiceDetails({ + invoiceInformation: [{ key: 'Status', value: INVOICE_STATUSES.PAID }], + }); + InvoiceView.selectInvoiceLine(); + InvoiceLineDetails.waitLoading(); + InvoiceLineDetails.openFundDetailsPane(testData.fund.name, 0); + Funds.selectBudgetDetails(); + BudgetDetails.checkBudgetDetails({ + summary: [{ key: 'Expended', value: '$20.00' }], + }); + Funds.viewTransactions(); + Funds.checkTransactionCount('Payment', 2); }, ); }); diff --git a/cypress/e2e/orders/changing-order-format-from-pe-mix-to-physical.cy.js b/cypress/e2e/orders/changing-order-format-from-pe-mix-to-physical.cy.js index 547bed4724..d3438577c3 100644 --- a/cypress/e2e/orders/changing-order-format-from-pe-mix-to-physical.cy.js +++ b/cypress/e2e/orders/changing-order-format-from-pe-mix-to-physical.cy.js @@ -11,51 +11,48 @@ describe('Orders', () => { organization, order: {}, user: {}, + location: LOCATION_NAMES.ANNEX_UI, }; before('Create test data', () => { cy.getAdminToken(); Organizations.createOrganizationViaApi(testData.organization); - cy.getLocations({ query: `name="${LOCATION_NAMES.MAIN_LIBRARY_UI}"` }).then( - (locationResponse) => { - cy.getDefaultMaterialType().then(({ id: materialTypeId }) => { - testData.order = NewOrder.getDefaultOrder({ vendorId: testData.organization.id }); - testData.orderLine = { - ...BasicOrderLine.getDefaultOrderLine(), - cost: { - currency: 'USD', - discountType: 'percentage', + cy.getLocations({ query: `name="${testData.location}"` }).then((locationResponse) => { + cy.getDefaultMaterialType().then(({ id: materialTypeId }) => { + testData.order = NewOrder.getDefaultOrder({ vendorId: testData.organization.id }); + testData.orderLine = { + ...BasicOrderLine.getDefaultOrderLine(), + cost: { + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + quantityElectronic: 1, + listUnitPriceElectronic: 10, + listUnitPrice: 10, + }, + orderFormat: 'P/E Mix', + eresource: { + createInventory: 'Instance, Holding', + accessProvider: testData.organization.id, + }, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: materialTypeId, + }, + locations: [ + { + locationId: locationResponse.id, quantityPhysical: 1, quantityElectronic: 1, - listUnitPriceElectronic: 10, - listUnitPrice: 10, }, - orderFormat: 'P/E Mix', - eresource: { - createInventory: 'Instance, Holding', - accessProvider: testData.organization.id, - }, - physical: { - createInventory: 'Instance, Holding, Item', - materialType: materialTypeId, - }, - locations: [ - { - locationId: locationResponse.id, - quantityPhysical: 1, - quantityElectronic: 1, - }, - ], - }; - - Orders.createOrderWithOrderLineViaApi(testData.order, testData.orderLine).then( - (order) => { - testData.order = order; - }, - ); + ], + }; + + Orders.createOrderWithOrderLineViaApi(testData.order, testData.orderLine).then((order) => { + testData.order = order; }); - }, - ); + }); + }); cy.createTempUser([Permissions.uiOrdersEdit.gui, Permissions.uiOrdersView.gui]).then( (userProperties) => { @@ -149,7 +146,7 @@ describe('Orders', () => { ], locationDetails: [ [ - { key: 'Holding', value: testData.location.name }, + { key: 'Holding', value: testData.location }, { key: 'Quantity physical', value: 1 }, { key: 'Quantity electronic', value: 1 }, ], diff --git a/cypress/e2e/orders/create-new-routing-list-from-poline.cy.js b/cypress/e2e/orders/create-new-routing-list-from-poline.cy.js index 345177c4f6..db96252539 100644 --- a/cypress/e2e/orders/create-new-routing-list-from-poline.cy.js +++ b/cypress/e2e/orders/create-new-routing-list-from-poline.cy.js @@ -1,35 +1,28 @@ -import permissions from '../../support/dictionary/permissions'; -import getRandomPostfix from '../../support/utils/stringTools'; -import FiscalYears from '../../support/fragments/finance/fiscalYears/fiscalYears'; -import Ledgers from '../../support/fragments/finance/ledgers/ledgers'; -import Users from '../../support/fragments/users/users'; -import Funds from '../../support/fragments/finance/funds/funds'; -import NewOrder from '../../support/fragments/orders/newOrder'; -import Orders from '../../support/fragments/orders/orders'; -import OrderLines from '../../support/fragments/orders/orderLines'; -import Organizations from '../../support/fragments/organizations/organizations'; -import NewOrganization from '../../support/fragments/organizations/newOrganization'; -import ServicePoints from '../../support/fragments/settings/tenant/servicePoints/servicePoints'; -import NewLocation from '../../support/fragments/settings/tenant/locations/newLocation'; -import Budgets from '../../support/fragments/finance/budgets/budgets'; -import { ACQUISITION_METHOD_NAMES_IN_PROFILE, ORDER_STATUSES } from '../../support/constants'; -import BasicOrderLine from '../../support/fragments/orders/basicOrderLine'; -import MaterialTypes from '../../support/fragments/settings/inventory/materialTypes'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + APPLICATION_NAMES, + LOCATION_NAMES, + ORDER_STATUSES, +} from '../../support/constants'; +import Permissions from '../../support/dictionary/permissions'; +import { + BasicOrderLine, + NewOrder, + OrderDetails, + OrderLineDetails, + OrderLines, + Orders, +} from '../../support/fragments/orders'; +import NewRoutingList from '../../support/fragments/orders/routingLists/newRoutingList'; +import { NewOrganization, Organizations } from '../../support/fragments/organizations'; import Receiving from '../../support/fragments/receiving/receiving'; import TopMenuNavigation from '../../support/fragments/topMenuNavigation'; +import Users from '../../support/fragments/users/users'; +import getRandomPostfix from '../../support/utils/stringTools'; -describe('Receiving', () => { - const firstFiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const firstFund = { ...Funds.defaultUiFund }; - const secondFund = { - name: `autotest_fund2_${getRandomPostfix()}`, - code: getRandomPostfix(), - externalAccountNo: getRandomPostfix(), - fundStatus: 'Active', - description: `This is fund created by E2E test automation script_${getRandomPostfix()}`, - }; - const firstOrder = { +describe('Orders', () => { + const testData = {}; + const order = { ...NewOrder.getDefaultOngoingOrder, orderType: 'Ongoing', ongoing: { isSubscription: false, manualRenewal: false }, @@ -37,85 +30,46 @@ describe('Receiving', () => { reEncumber: true, }; const organization = { ...NewOrganization.defaultUiOrganizations }; - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - const firstBudget = { - ...Budgets.getDefaultBudget(), - allocated: 1000, - }; - const routingList1 = `routingList_1${getRandomPostfix()}`; - let user; - let firstOrderNumber; - let servicePointId; - let location; + const routingList = `routingList_1${getRandomPostfix()}`; - before(() => { + before('Setup test data', () => { cy.getAdminToken(); - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - firstBudget.fiscalYearId = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - firstFund.ledgerId = defaultLedger.id; - secondFund.ledgerId = defaultLedger.id; - - Funds.createViaApi(firstFund).then((fundResponse) => { - firstFund.id = fundResponse.fund.id; - firstBudget.fundId = fundResponse.fund.id; - Budgets.createViaApi(firstBudget); - - ServicePoints.getViaApi().then((servicePoint) => { - servicePointId = servicePoint[0].id; - NewLocation.createViaApi(NewLocation.getDefaultLocation(servicePointId)).then((res) => { - location = res; + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getBookMaterialType().then((mtypes) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((params) => { + Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { + organization.id = responseOrganizations; + order.vendor = organization.id; + const orderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + listUnitPrice: 100.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 100.0, + }, + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: params.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypes.id, + materialSupplier: responseOrganizations, + volumes: [], + }, + }; + Orders.createOrderViaApi(order).then((orderResponse) => { + order.id = orderResponse.id; + testData.orderNumber = orderResponse.poNumber; + orderLine.purchaseOrderId = orderResponse.id; - MaterialTypes.createMaterialTypeViaApi(MaterialTypes.getDefaultMaterialType()).then( - (mtypes) => { - cy.getAcquisitionMethodsApi({ - query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, - }).then((params) => { - Organizations.createOrganizationViaApi(organization).then( - (responseOrganizations) => { - organization.id = responseOrganizations; - firstOrder.vendor = organization.id; - const firstOrderLine = { - ...BasicOrderLine.defaultOrderLine, - cost: { - listUnitPrice: 100.0, - currency: 'USD', - discountType: 'percentage', - quantityPhysical: 1, - poLineEstimatedPrice: 100.0, - }, - fundDistribution: [ - { code: firstFund.code, fundId: firstFund.id, value: 100 }, - ], - locations: [ - { locationId: location.id, quantity: 1, quantityPhysical: 1 }, - ], - acquisitionMethod: params.body.acquisitionMethods[0].id, - physical: { - createInventory: 'Instance, Holding, Item', - materialType: mtypes.body.id, - materialSupplier: responseOrganizations, - volumes: [], - }, - }; - Orders.createOrderViaApi(firstOrder).then((firstOrderResponse) => { - firstOrder.id = firstOrderResponse.id; - firstOrderNumber = firstOrderResponse.poNumber; - firstOrderLine.purchaseOrderId = firstOrderResponse.id; - OrderLines.createOrderLineViaApi(firstOrderLine); - Orders.updateOrderViaApi({ - ...firstOrderResponse, - workflowStatus: ORDER_STATUSES.OPEN, - }); - }); - }, - ); - }); - }, - ); + OrderLines.createOrderLineViaApi(orderLine); + Orders.updateOrderViaApi({ + ...orderResponse, + workflowStatus: ORDER_STATUSES.OPEN, + }); }); }); }); @@ -123,37 +77,45 @@ describe('Receiving', () => { }); cy.createTempUser([ - permissions.uiOrdersEdit.gui, - permissions.uiReceivingViewEditCreate.gui, + Permissions.uiOrdersEdit.gui, + Permissions.uiReceivingViewEditCreate.gui, ]).then((userProperties) => { - user = userProperties; + testData.user = userProperties; cy.login(userProperties.username, userProperties.password); }); }); - after(() => { + after('Clean up test data', () => { cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); + Orders.deleteOrderViaApi(order.id); + Organizations.deleteOrganizationViaApi(organization.id); }); it( 'C466265 Create new routing list from PO line (thunderjet)', { tags: ['criticalPath', 'thunderjet', 'C466265'] }, () => { - TopMenuNavigation.navigateToApp('Orders'); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.ORDERS); + OrderLines.searchByParameter('Keyword', `${testData.orderNumber}-1`); + OrderLines.selectOrderline(`${testData.orderNumber}-1`); + OrderLineDetails.openRoutingListsAccordion(); + OrderLineDetails.addRoutingListButtonExist(); + OrderLineDetails.addRoutingList(); + NewRoutingList.fillInRoutingListAndCancel(routingList); + OrderLineDetails.expandRoutingListSection(); + OrderLineDetails.checkNoRoutingListsText(); + OrderLineDetails.addRoutingList(); + NewRoutingList.fillInRoutingListInfoAndSave(routingList); + OrderLineDetails.verifyAddingRoutingList(routingList); Orders.selectOrdersPane(); - Orders.searchByParameter('PO number', firstOrderNumber); - Orders.selectFromResultsList(firstOrderNumber); - OrderLines.selectPOLInOrder(); - OrderLines.openRoutingLists(); - OrderLines.addRoutingListExist(); - OrderLines.addRoutingList(); - OrderLines.fillInRoutingListInfoAndSave(routingList1); - OrderLines.varifyAddingRoutingList(routingList1); - OrderLines.backToEditingOrder(); - Orders.receiveOrderViaActions(); + Orders.searchByParameter('PO number', testData.orderNumber); + Orders.selectFromResultsList(testData.orderNumber); + OrderDetails.openReceivingsPage(); Receiving.selectLinkFromResultsList(); - Receiving.varifyAddingRoutingList(routingList1); + Receiving.waitLoading(); + Receiving.verifyRoutingListWarning(); + Receiving.verifyAddingRoutingList(routingList); }, ); }); diff --git a/cypress/e2e/orders/create-new-routing-list-from-receiving-title.cy.js b/cypress/e2e/orders/create-new-routing-list-from-receiving-title.cy.js index 04db809370..4c8a4f224e 100644 --- a/cypress/e2e/orders/create-new-routing-list-from-receiving-title.cy.js +++ b/cypress/e2e/orders/create-new-routing-list-from-receiving-title.cy.js @@ -1,35 +1,21 @@ -import permissions from '../../support/dictionary/permissions'; -import getRandomPostfix from '../../support/utils/stringTools'; -import FiscalYears from '../../support/fragments/finance/fiscalYears/fiscalYears'; -import TopMenu from '../../support/fragments/topMenu'; -import Ledgers from '../../support/fragments/finance/ledgers/ledgers'; -import Users from '../../support/fragments/users/users'; -import Funds from '../../support/fragments/finance/funds/funds'; -import NewOrder from '../../support/fragments/orders/newOrder'; -import Orders from '../../support/fragments/orders/orders'; -import OrderLines from '../../support/fragments/orders/orderLines'; -import Organizations from '../../support/fragments/organizations/organizations'; -import NewOrganization from '../../support/fragments/organizations/newOrganization'; -import ServicePoints from '../../support/fragments/settings/tenant/servicePoints/servicePoints'; -import NewLocation from '../../support/fragments/settings/tenant/locations/newLocation'; -import Budgets from '../../support/fragments/finance/budgets/budgets'; -import { ACQUISITION_METHOD_NAMES_IN_PROFILE, ORDER_STATUSES } from '../../support/constants'; -import BasicOrderLine from '../../support/fragments/orders/basicOrderLine'; -import MaterialTypes from '../../support/fragments/settings/inventory/materialTypes'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + APPLICATION_NAMES, + LOCATION_NAMES, + ORDER_STATUSES, +} from '../../support/constants'; +import Permissions from '../../support/dictionary/permissions'; +import { BasicOrderLine, NewOrder, OrderLines, Orders } from '../../support/fragments/orders'; +import NewRoutingList from '../../support/fragments/orders/routingLists/newRoutingList'; +import { NewOrganization, Organizations } from '../../support/fragments/organizations'; import Receiving from '../../support/fragments/receiving/receiving'; +import TopMenuNavigation from '../../support/fragments/topMenuNavigation'; +import Users from '../../support/fragments/users/users'; +import getRandomPostfix from '../../support/utils/stringTools'; describe('Receiving', () => { - const firstFiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const firstFund = { ...Funds.defaultUiFund }; - const secondFund = { - name: `autotest_fund2_${getRandomPostfix()}`, - code: getRandomPostfix(), - externalAccountNo: getRandomPostfix(), - fundStatus: 'Active', - description: `This is fund created by E2E test automation script_${getRandomPostfix()}`, - }; - const firstOrder = { + const testData = {}; + const order = { ...NewOrder.getDefaultOngoingOrder, orderType: 'Ongoing', ongoing: { isSubscription: false, manualRenewal: false }, @@ -37,85 +23,46 @@ describe('Receiving', () => { reEncumber: true, }; const organization = { ...NewOrganization.defaultUiOrganizations }; - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - const firstBudget = { - ...Budgets.getDefaultBudget(), - allocated: 1000, - }; - const routingList1 = `routingList_1${getRandomPostfix()}`; - let user; - let firstOrderNumber; - let servicePointId; - let location; + const routingList = `routingList_1${getRandomPostfix()}`; - before(() => { + before('Setup test data', () => { cy.getAdminToken(); - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - firstBudget.fiscalYearId = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - firstFund.ledgerId = defaultLedger.id; - secondFund.ledgerId = defaultLedger.id; - - Funds.createViaApi(firstFund).then((fundResponse) => { - firstFund.id = fundResponse.fund.id; - firstBudget.fundId = fundResponse.fund.id; - Budgets.createViaApi(firstBudget); - - ServicePoints.getViaApi().then((servicePoint) => { - servicePointId = servicePoint[0].id; - NewLocation.createViaApi(NewLocation.getDefaultLocation(servicePointId)).then((res) => { - location = res; + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getBookMaterialType().then((mtypes) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((params) => { + Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { + organization.id = responseOrganizations; + order.vendor = organization.id; + const orderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + listUnitPrice: 100.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 100.0, + }, + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: params.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypes.id, + materialSupplier: responseOrganizations, + volumes: [], + }, + }; + Orders.createOrderViaApi(order).then((orderResponse) => { + order.id = orderResponse.id; + testData.orderNumber = orderResponse.poNumber; + orderLine.purchaseOrderId = orderResponse.id; - MaterialTypes.createMaterialTypeViaApi(MaterialTypes.getDefaultMaterialType()).then( - (mtypes) => { - cy.getAcquisitionMethodsApi({ - query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, - }).then((params) => { - Organizations.createOrganizationViaApi(organization).then( - (responseOrganizations) => { - organization.id = responseOrganizations; - firstOrder.vendor = organization.id; - const firstOrderLine = { - ...BasicOrderLine.defaultOrderLine, - cost: { - listUnitPrice: 100.0, - currency: 'USD', - discountType: 'percentage', - quantityPhysical: 1, - poLineEstimatedPrice: 100.0, - }, - fundDistribution: [ - { code: firstFund.code, fundId: firstFund.id, value: 100 }, - ], - locations: [ - { locationId: location.id, quantity: 1, quantityPhysical: 1 }, - ], - acquisitionMethod: params.body.acquisitionMethods[0].id, - physical: { - createInventory: 'Instance, Holding, Item', - materialType: mtypes.body.id, - materialSupplier: responseOrganizations, - volumes: [], - }, - }; - Orders.createOrderViaApi(firstOrder).then((firstOrderResponse) => { - firstOrder.id = firstOrderResponse.id; - firstOrderNumber = firstOrderResponse.poNumber; - firstOrderLine.purchaseOrderId = firstOrderResponse.id; - OrderLines.createOrderLineViaApi(firstOrderLine); - Orders.updateOrderViaApi({ - ...firstOrderResponse, - workflowStatus: ORDER_STATUSES.OPEN, - }); - }); - }, - ); - }); - }, - ); + OrderLines.createOrderLineViaApi(orderLine); + Orders.updateOrderViaApi({ + ...orderResponse, + workflowStatus: ORDER_STATUSES.OPEN, + }); }); }); }); @@ -123,35 +70,41 @@ describe('Receiving', () => { }); cy.createTempUser([ - permissions.uiOrdersEdit.gui, - permissions.uiReceivingViewEditCreate.gui, + Permissions.uiOrdersEdit.gui, + Permissions.uiReceivingViewEditCreate.gui, ]).then((userProperties) => { - user = userProperties; - cy.login(userProperties.username, userProperties.password, { - path: TopMenu.ordersPath, - waiter: Orders.waitLoading, - }); + testData.user = userProperties; + + cy.login(userProperties.username, userProperties.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.ORDERS); + Orders.selectOrdersPane(); + Orders.waitLoading(); }); }); - after(() => { + after('Clean up test data', () => { cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); + Orders.deleteOrderViaApi(order.id); + Organizations.deleteOrganizationViaApi(organization.id); }); it( 'C468205 Create new routing list from Receiving title (thunderjet)', { tags: ['criticalPath', 'thunderjet', 'C468205'] }, () => { - Orders.searchByParameter('PO number', firstOrderNumber); - Orders.selectFromResultsList(firstOrderNumber); + Orders.searchByParameter('PO number', testData.orderNumber); + Orders.selectFromResultsList(testData.orderNumber); Orders.receiveOrderViaActions(); Receiving.selectLinkFromResultsList(); - OrderLines.openRoutingLists(); - OrderLines.addRoutingListExist(); - OrderLines.addRoutingList(); - OrderLines.fillInRoutingListInfoAndSave(routingList1); - Receiving.varifyAddingRoutingList(routingList1); + Receiving.openRoutingListsAccordionSection(); + Receiving.clickAddRoutingListButton(); + NewRoutingList.fillInRoutingListAndCancel(routingList); + Receiving.verifyRoutingListAbsent(routingList); + Receiving.openRoutingListsAccordionSection(); + Receiving.clickAddRoutingListButton(); + NewRoutingList.fillInRoutingListInfoAndSave(routingList); + Receiving.verifyRoutingListExists(routingList); }, ); }); diff --git a/cypress/e2e/orders/create-second-routing-list-for-po-line-with-quantity-more-then-1.cy.js b/cypress/e2e/orders/create-second-routing-list-for-po-line-with-quantity-more-then-1.cy.js index 99cb43de4a..42a328c794 100644 --- a/cypress/e2e/orders/create-second-routing-list-for-po-line-with-quantity-more-then-1.cy.js +++ b/cypress/e2e/orders/create-second-routing-list-for-po-line-with-quantity-more-then-1.cy.js @@ -1,34 +1,27 @@ -import permissions from '../../support/dictionary/permissions'; -import getRandomPostfix from '../../support/utils/stringTools'; -import FiscalYears from '../../support/fragments/finance/fiscalYears/fiscalYears'; -import TopMenu from '../../support/fragments/topMenu'; -import Ledgers from '../../support/fragments/finance/ledgers/ledgers'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + APPLICATION_NAMES, + LOCATION_NAMES, + ORDER_STATUSES, +} from '../../support/constants'; +import Permissions from '../../support/dictionary/permissions'; +import { + BasicOrderLine, + NewOrder, + OrderLineDetails, + OrderLines, + Orders, +} from '../../support/fragments/orders'; +import NewRoutingList from '../../support/fragments/orders/routingLists/newRoutingList'; +import RoutingListDetails from '../../support/fragments/orders/routingLists/routingListDetails'; +import { NewOrganization, Organizations } from '../../support/fragments/organizations'; +import TopMenuNavigation from '../../support/fragments/topMenuNavigation'; import Users from '../../support/fragments/users/users'; -import Funds from '../../support/fragments/finance/funds/funds'; -import NewOrder from '../../support/fragments/orders/newOrder'; -import Orders from '../../support/fragments/orders/orders'; -import OrderLines from '../../support/fragments/orders/orderLines'; -import Organizations from '../../support/fragments/organizations/organizations'; -import NewOrganization from '../../support/fragments/organizations/newOrganization'; -import ServicePoints from '../../support/fragments/settings/tenant/servicePoints/servicePoints'; -import NewLocation from '../../support/fragments/settings/tenant/locations/newLocation'; -import Budgets from '../../support/fragments/finance/budgets/budgets'; -import { ACQUISITION_METHOD_NAMES_IN_PROFILE, ORDER_STATUSES } from '../../support/constants'; -import BasicOrderLine from '../../support/fragments/orders/basicOrderLine'; -import MaterialTypes from '../../support/fragments/settings/inventory/materialTypes'; +import getRandomPostfix from '../../support/utils/stringTools'; -describe('Receiving', () => { - const firstFiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const firstFund = { ...Funds.defaultUiFund }; - const secondFund = { - name: `autotest_fund2_${getRandomPostfix()}`, - code: getRandomPostfix(), - externalAccountNo: getRandomPostfix(), - fundStatus: 'Active', - description: `This is fund created by E2E test automation script_${getRandomPostfix()}`, - }; - const firstOrder = { +describe('Orders', () => { + const testData = {}; + const order = { ...NewOrder.getDefaultOngoingOrder, orderType: 'Ongoing', ongoing: { isSubscription: false, manualRenewal: false }, @@ -36,98 +29,51 @@ describe('Receiving', () => { reEncumber: true, }; const organization = { ...NewOrganization.defaultUiOrganizations }; - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - const firstBudget = { - ...Budgets.getDefaultBudget(), - allocated: 1000, - }; const routingList1 = `routingList_1${getRandomPostfix()}`; const routingList2 = `routingList_2${getRandomPostfix()}`; const notes = `notes${getRandomPostfix()}`; - let user; - let firstOrderNumber; - let servicePointId; - let location; - before(() => { + before('Set up test data', () => { cy.getAdminToken(); - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - firstBudget.fiscalYearId = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - firstFund.ledgerId = defaultLedger.id; - secondFund.ledgerId = defaultLedger.id; + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getBookMaterialType().then((mtypes) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((params) => { + Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { + organization.id = responseOrganizations; + order.vendor = organization.id; + const orderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + listUnitPrice: 10.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 2, + poLineEstimatedPrice: 10.0, + }, + locations: [{ locationId: locationResp.id, quantity: 2, quantityPhysical: 2 }], + acquisitionMethod: params.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypes.id, + materialSupplier: responseOrganizations, + volumes: [], + }, + }; + Orders.createOrderViaApi(order).then((orderResponse) => { + order.id = orderResponse.id; + testData.orderNumber = orderResponse.poNumber; + orderLine.purchaseOrderId = orderResponse.id; - Funds.createViaApi(firstFund).then((fundResponse) => { - firstFund.id = fundResponse.fund.id; - firstBudget.fundId = fundResponse.fund.id; - Budgets.createViaApi(firstBudget); + OrderLines.createOrderLineViaApi(orderLine).then((orderLineResponse) => { + testData.orderLineId = orderLineResponse.id; - ServicePoints.getViaApi().then((servicePoint) => { - servicePointId = servicePoint[0].id; - NewLocation.createViaApi(NewLocation.getDefaultLocation(servicePointId)).then((res) => { - location = res; - - MaterialTypes.createMaterialTypeViaApi(MaterialTypes.getDefaultMaterialType()).then( - (mtypes) => { - cy.getAcquisitionMethodsApi({ - query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, - }).then((params) => { - Organizations.createOrganizationViaApi(organization).then( - (responseOrganizations) => { - organization.id = responseOrganizations; - firstOrder.vendor = organization.id; - const firstOrderLine = { - ...BasicOrderLine.defaultOrderLine, - cost: { - listUnitPrice: 100.0, - currency: 'USD', - discountType: 'percentage', - quantityPhysical: 2, - poLineEstimatedPrice: 100.0, - }, - fundDistribution: [ - { code: firstFund.code, fundId: firstFund.id, value: 100 }, - ], - locations: [ - { locationId: location.id, quantity: 2, quantityPhysical: 2 }, - ], - acquisitionMethod: params.body.acquisitionMethods[0].id, - physical: { - createInventory: 'Instance, Holding, Item', - materialType: mtypes.body.id, - materialSupplier: responseOrganizations, - volumes: [], - }, - }; - Orders.createOrderViaApi(firstOrder).then((firstOrderResponse) => { - firstOrder.id = firstOrderResponse.id; - firstOrderNumber = firstOrderResponse.poNumber; - firstOrderLine.purchaseOrderId = firstOrderResponse.id; - OrderLines.createOrderLineViaApi(firstOrderLine); - Orders.updateOrderViaApi({ - ...firstOrderResponse, - workflowStatus: ORDER_STATUSES.OPEN, - }); - cy.loginAsAdmin({ - path: TopMenu.ordersPath, - waiter: Orders.waitLoading, - }); - Orders.searchByParameter('PO number', firstOrderNumber); - Orders.selectFromResultsList(firstOrderNumber); - OrderLines.selectPOLInOrder(); - OrderLines.openRoutingLists(); - OrderLines.addRoutingList(); - OrderLines.fillInRoutingListInfoAndSave(routingList1); - OrderLines.varifyAddingRoutingList(routingList1); - }); - }, - ); - }); - }, - ); + Orders.updateOrderViaApi({ + ...orderResponse, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); }); }); }); @@ -135,39 +81,55 @@ describe('Receiving', () => { }); cy.createTempUser([ - permissions.uiOrdersEdit.gui, - permissions.uiReceivingViewEditCreate.gui, + Permissions.uiOrdersEdit.gui, + Permissions.uiReceivingViewEditCreate.gui, ]).then((userProperties) => { - user = userProperties; - cy.login(userProperties.username, userProperties.password, { - path: TopMenu.ordersPath, - waiter: Orders.waitLoading, + testData.user = userProperties; + + cy.getAdminToken(); + OrderLineDetails.createRoutingListViaApi( + [userProperties.userId], + routingList1, + testData.orderLineId, + ).then((routingListResponse) => { + testData.routingListId1 = routingListResponse; }); + + cy.login(userProperties.username, userProperties.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.ORDERS); + Orders.selectOrdersPane(); + Orders.waitLoading(); }); }); - after(() => { + after('Clean up test data', () => { cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); + RoutingListDetails.deleteRoutingListViaApi(testData.routingListId1); + Orders.deleteOrderViaApi(order.id); + Organizations.deleteOrganizationViaApi(organization.id); }); it( 'C468148 Create second routing list for a PO line with quantity > 1 (thunderjet)', { tags: ['criticalPath', 'thunderjet', 'C468148'] }, () => { - Orders.searchByParameter('PO number', firstOrderNumber); - Orders.selectFromResultsList(firstOrderNumber); + Orders.searchByParameter('PO number', testData.orderNumber); + Orders.selectFromResultsList(testData.orderNumber); OrderLines.selectPOLInOrder(); - OrderLines.addRoutingListByActions(); - OrderLines.fillInRoutingListInfoWithNotesAndSave(routingList2, notes); - OrderLines.varifyAddingRoutingList(routingList1); - OrderLines.varifyAddingRoutingList(routingList2); - OrderLines.openRoutingList(routingList2); - OrderLines.checkRoutingListNameDetails(routingList2); - OrderLines.checkRoutingListNotesDetails(notes); - OrderLines.closeRoutingListDetails(); - OrderLines.varifyAddingRoutingList(routingList1); - OrderLines.varifyAddingRoutingList(routingList2); + OrderLineDetails.verifyAddingRoutingList(routingList1); + OrderLineDetails.addRoutingListByActions(); + NewRoutingList.fillInRoutingListInfoWithNotesAndSave(routingList2, notes); + OrderLineDetails.verifyAddingRoutingList(routingList1); + OrderLineDetails.verifyAddingRoutingList(routingList2); + OrderLineDetails.openRoutingList(routingList2); + RoutingListDetails.checkRoutingListNameDetails(routingList2); + RoutingListDetails.closeRoutingListDetails(); + OrderLineDetails.verifyRoutingListAccordionRecordCount(2); + OrderLineDetails.verifyAddingRoutingList(routingList1); + OrderLineDetails.verifyAddingRoutingList(routingList2); + OrderLineDetails.verifyRoutingListTableColumns(); + OrderLineDetails.verifyAddRoutingListInactive(); }, ); }); diff --git a/cypress/e2e/orders/delete-routing-list-from-orders.cy.js b/cypress/e2e/orders/delete-routing-list-from-orders.cy.js index dad7d6de14..a2ae5e3c0b 100644 --- a/cypress/e2e/orders/delete-routing-list-from-orders.cy.js +++ b/cypress/e2e/orders/delete-routing-list-from-orders.cy.js @@ -1,35 +1,27 @@ -import permissions from '../../support/dictionary/permissions'; -import getRandomPostfix from '../../support/utils/stringTools'; -import FiscalYears from '../../support/fragments/finance/fiscalYears/fiscalYears'; -import Ledgers from '../../support/fragments/finance/ledgers/ledgers'; -import Users from '../../support/fragments/users/users'; -import Funds from '../../support/fragments/finance/funds/funds'; -import NewOrder from '../../support/fragments/orders/newOrder'; -import Orders from '../../support/fragments/orders/orders'; -import OrderLines from '../../support/fragments/orders/orderLines'; -import Organizations from '../../support/fragments/organizations/organizations'; -import NewOrganization from '../../support/fragments/organizations/newOrganization'; -import ServicePoints from '../../support/fragments/settings/tenant/servicePoints/servicePoints'; -import NewLocation from '../../support/fragments/settings/tenant/locations/newLocation'; -import Budgets from '../../support/fragments/finance/budgets/budgets'; -import { ACQUISITION_METHOD_NAMES_IN_PROFILE, ORDER_STATUSES } from '../../support/constants'; -import BasicOrderLine from '../../support/fragments/orders/basicOrderLine'; -import MaterialTypes from '../../support/fragments/settings/inventory/materialTypes'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + APPLICATION_NAMES, + LOCATION_NAMES, + ORDER_STATUSES, +} from '../../support/constants'; +import Permissions from '../../support/dictionary/permissions'; +import { + BasicOrderLine, + NewOrder, + OrderLineDetails, + OrderLines, + Orders, +} from '../../support/fragments/orders'; +import RoutingListDetails from '../../support/fragments/orders/routingLists/routingListDetails'; +import { NewOrganization, Organizations } from '../../support/fragments/organizations'; import Receiving from '../../support/fragments/receiving/receiving'; import TopMenuNavigation from '../../support/fragments/topMenuNavigation'; +import Users from '../../support/fragments/users/users'; +import getRandomPostfix from '../../support/utils/stringTools'; -describe('Receiving', () => { - const firstFiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const firstFund = { ...Funds.defaultUiFund }; - const secondFund = { - name: `autotest_fund2_${getRandomPostfix()}`, - code: getRandomPostfix(), - externalAccountNo: getRandomPostfix(), - fundStatus: 'Active', - description: `This is fund created by E2E test automation script_${getRandomPostfix()}`, - }; - const firstOrder = { +describe('Orders', () => { + const testData = {}; + const order = { ...NewOrder.getDefaultOngoingOrder, orderType: 'Ongoing', ongoing: { isSubscription: false, manualRenewal: false }, @@ -37,131 +29,96 @@ describe('Receiving', () => { reEncumber: true, }; const organization = { ...NewOrganization.defaultUiOrganizations }; - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - const firstBudget = { - ...Budgets.getDefaultBudget(), - allocated: 1000, - }; - const routingList1 = `routingList_1${getRandomPostfix()}`; - let user; - let firstOrderNumber; - let servicePointId; - let location; + const routingList = `routingList_1${getRandomPostfix()}`; - before(() => { + before('Set up test data', () => { cy.getAdminToken(); - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - firstBudget.fiscalYearId = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - firstFund.ledgerId = defaultLedger.id; - secondFund.ledgerId = defaultLedger.id; + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getBookMaterialType().then((mtypes) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((params) => { + Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { + organization.id = responseOrganizations; + order.vendor = organization.id; + const orderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + listUnitPrice: 100.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 100.0, + }, + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: params.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypes.id, + materialSupplier: responseOrganizations, + volumes: [], + }, + }; + Orders.createOrderViaApi(order).then((orderResponse) => { + order.id = orderResponse.id; + testData.orderNumber = orderResponse.poNumber; + orderLine.purchaseOrderId = orderResponse.id; - Funds.createViaApi(firstFund).then((fundResponse) => { - firstFund.id = fundResponse.fund.id; - firstBudget.fundId = fundResponse.fund.id; - Budgets.createViaApi(firstBudget); - - ServicePoints.getViaApi().then((servicePoint) => { - servicePointId = servicePoint[0].id; - NewLocation.createViaApi(NewLocation.getDefaultLocation(servicePointId)).then((res) => { - location = res; - - MaterialTypes.createMaterialTypeViaApi(MaterialTypes.getDefaultMaterialType()).then( - (mtypes) => { - cy.getAcquisitionMethodsApi({ - query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, - }).then((params) => { - Organizations.createOrganizationViaApi(organization).then( - (responseOrganizations) => { - organization.id = responseOrganizations; - firstOrder.vendor = organization.id; - const firstOrderLine = { - ...BasicOrderLine.defaultOrderLine, - cost: { - listUnitPrice: 100.0, - currency: 'USD', - discountType: 'percentage', - quantityPhysical: 1, - poLineEstimatedPrice: 100.0, - }, - fundDistribution: [ - { code: firstFund.code, fundId: firstFund.id, value: 100 }, - ], - locations: [ - { locationId: location.id, quantity: 1, quantityPhysical: 1 }, - ], - acquisitionMethod: params.body.acquisitionMethods[0].id, - physical: { - createInventory: 'Instance, Holding, Item', - materialType: mtypes.body.id, - materialSupplier: responseOrganizations, - volumes: [], - }, - }; - Orders.createOrderViaApi(firstOrder).then((firstOrderResponse) => { - firstOrder.id = firstOrderResponse.id; - firstOrderNumber = firstOrderResponse.poNumber; - firstOrderLine.purchaseOrderId = firstOrderResponse.id; - OrderLines.createOrderLineViaApi(firstOrderLine); - Orders.updateOrderViaApi({ - ...firstOrderResponse, - workflowStatus: ORDER_STATUSES.OPEN, - }); - cy.loginAsAdmin(); - TopMenuNavigation.openAppFromDropdown('Orders'); - Orders.selectOrdersPane(); - Orders.searchByParameter('PO number', firstOrderNumber); - Orders.selectFromResultsList(firstOrderNumber); - OrderLines.selectPOLInOrder(); - OrderLines.openRoutingLists(); - OrderLines.addRoutingList(); - OrderLines.fillInRoutingListInfoAndSave(routingList1); - OrderLines.varifyAddingRoutingList(routingList1); - }); - }, - ); - }); - }, - ); + OrderLines.createOrderLineViaApi(orderLine).then((orderLineResponse) => { + testData.orderLineId = orderLineResponse.id; + Orders.updateOrderViaApi({ + ...orderResponse, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); }); }); }); }); }); - cy.logout(); + cy.createTempUser([ - permissions.uiOrdersEdit.gui, - permissions.uiReceivingViewEditCreate.gui, + Permissions.uiOrdersEdit.gui, + Permissions.uiReceivingViewEditCreate.gui, ]).then((userProperties) => { - user = userProperties; + testData.user = userProperties; + + cy.getAdminToken(); + OrderLineDetails.createRoutingListViaApi( + [userProperties.userId], + routingList, + testData.orderLineId, + ); + cy.login(userProperties.username, userProperties.password); }); }); - after(() => { + after('Clean up test data', () => { cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); + Orders.deleteOrderViaApi(order.id); + Organizations.deleteOrganizationViaApi(organization.id); }); it( 'C468172 Delete routing list from "Orders" app (thunderjet)', { tags: ['criticalPath', 'thunderjet', 'C468172'] }, () => { - TopMenuNavigation.navigateToApp('Orders'); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.ORDERS); Orders.selectOrdersPane(); - Orders.searchByParameter('PO number', firstOrderNumber); - Orders.selectFromResultsList(firstOrderNumber); + Orders.searchByParameter('PO number', testData.orderNumber); + Orders.selectFromResultsList(testData.orderNumber); OrderLines.selectPOLInOrder(); - OrderLines.openRoutingList(routingList1); - OrderLines.deleteRoutingList(); - OrderLines.backToEditingOrder(); + OrderLineDetails.openRoutingList(routingList); + RoutingListDetails.deleteRoutingList(); + OrderLineDetails.verifyRoutingListAccordionRecordCount(0); + OrderLineDetails.backToOrderDetails(); Orders.receiveOrderViaActions(); Receiving.selectLinkFromResultsList(); - Receiving.openRoutingListsSection(); - Receiving.addRoutingListExist(); + Receiving.openRoutingListsAccordionSection(); + Receiving.addRoutingListButtonExist(); + Receiving.checkNoRoutingListsText(); }, ); }); diff --git a/cypress/e2e/orders/edit-existing-routing-list-in-orders.cy.js b/cypress/e2e/orders/edit-existing-routing-list-in-orders.cy.js index 1582392391..84caee5e94 100644 --- a/cypress/e2e/orders/edit-existing-routing-list-in-orders.cy.js +++ b/cypress/e2e/orders/edit-existing-routing-list-in-orders.cy.js @@ -1,34 +1,33 @@ -import permissions from '../../support/dictionary/permissions'; -import getRandomPostfix from '../../support/utils/stringTools'; -import FiscalYears from '../../support/fragments/finance/fiscalYears/fiscalYears'; -import TopMenu from '../../support/fragments/topMenu'; -import Ledgers from '../../support/fragments/finance/ledgers/ledgers'; +import uuid from 'uuid'; +import { calloutTypes } from '../../../interactors'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + APPLICATION_NAMES, + LOCATION_NAMES, + ORDER_STATUSES, +} from '../../support/constants'; +import Permissions from '../../support/dictionary/permissions'; +import { + BasicOrderLine, + NewOrder, + OrderDetails, + OrderLineDetails, + OrderLines, + Orders, +} from '../../support/fragments/orders'; +import RoutingListDetails from '../../support/fragments/orders/routingLists/routingListDetails'; +import RoutingListEditForm from '../../support/fragments/orders/routingLists/routingListEditForm'; +import { NewOrganization, Organizations } from '../../support/fragments/organizations'; +import Receiving from '../../support/fragments/receiving/receiving'; +import OrderLinesLimit from '../../support/fragments/settings/orders/orderLinesLimit'; +import TopMenuNavigation from '../../support/fragments/topMenuNavigation'; import Users from '../../support/fragments/users/users'; -import Funds from '../../support/fragments/finance/funds/funds'; -import NewOrder from '../../support/fragments/orders/newOrder'; -import Orders from '../../support/fragments/orders/orders'; -import OrderLines from '../../support/fragments/orders/orderLines'; -import Organizations from '../../support/fragments/organizations/organizations'; -import NewOrganization from '../../support/fragments/organizations/newOrganization'; -import ServicePoints from '../../support/fragments/settings/tenant/servicePoints/servicePoints'; -import NewLocation from '../../support/fragments/settings/tenant/locations/newLocation'; -import Budgets from '../../support/fragments/finance/budgets/budgets'; -import { ACQUISITION_METHOD_NAMES_IN_PROFILE, ORDER_STATUSES } from '../../support/constants'; -import BasicOrderLine from '../../support/fragments/orders/basicOrderLine'; -import MaterialTypes from '../../support/fragments/settings/inventory/materialTypes'; +import InteractorsTools from '../../support/utils/interactorsTools'; +import getRandomPostfix from '../../support/utils/stringTools'; -describe('Receiving', () => { - const firstFiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const firstFund = { ...Funds.defaultUiFund }; - const secondFund = { - name: `autotest_fund2_${getRandomPostfix()}`, - code: getRandomPostfix(), - externalAccountNo: getRandomPostfix(), - fundStatus: 'Active', - description: `This is fund created by E2E test automation script_${getRandomPostfix()}`, - }; - const firstOrder = { +describe('Orders', () => { + const testData = {}; + const order = { ...NewOrder.getDefaultOngoingOrder, orderType: 'Ongoing', ongoing: { isSubscription: false, manualRenewal: false }, @@ -36,98 +35,85 @@ describe('Receiving', () => { reEncumber: true, }; const organization = { ...NewOrganization.defaultUiOrganizations }; - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - const firstBudget = { - ...Budgets.getDefaultBudget(), - allocated: 1000, - }; const routingList1 = `routingList_1${getRandomPostfix()}`; const routingList2 = `routingList_2${getRandomPostfix()}`; - const notes = `notes${getRandomPostfix()}`; - let user; - let firstOrderNumber; - let servicePointId; - let location; + const routingList3 = `routingList_3${getRandomPostfix()}`; - before(() => { + before('Setup test data', () => { cy.getAdminToken(); - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - firstBudget.fiscalYearId = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - firstFund.ledgerId = defaultLedger.id; - secondFund.ledgerId = defaultLedger.id; - - Funds.createViaApi(firstFund).then((fundResponse) => { - firstFund.id = fundResponse.fund.id; - firstBudget.fundId = fundResponse.fund.id; - Budgets.createViaApi(firstBudget); + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getBookMaterialType().then((mtypes) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((params) => { + Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { + organization.id = responseOrganizations; + order.vendor = organization.id; + const firstOrderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + quantityElectronic: 1, + listUnitPriceElectronic: 5, + listUnitPrice: 5, + }, + orderFormat: 'P/E Mix', + eresource: { + createInventory: 'Instance, Holding', + accessProvider: organization.id, + }, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypes.id, + }, + locations: [ + { + locationId: locationResp.id, + quantityPhysical: 1, + quantityElectronic: 1, + }, + ], + acquisitionMethod: params.body.acquisitionMethods[0].id, + }; + const secondOrderLine = { + ...BasicOrderLine.defaultOrderLine, + id: uuid(), + cost: { + listUnitPrice: 5.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 5.0, + }, + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: params.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypes.id, + materialSupplier: responseOrganizations, + volumes: [], + }, + }; + Orders.createOrderViaApi(order).then((orderResponse) => { + order.id = orderResponse.id; + testData.orderNumber = orderResponse.poNumber; + firstOrderLine.purchaseOrderId = orderResponse.id; + secondOrderLine.purchaseOrderId = orderResponse.id; - ServicePoints.getViaApi().then((servicePoint) => { - servicePointId = servicePoint[0].id; - NewLocation.createViaApi(NewLocation.getDefaultLocation(servicePointId)).then((res) => { - location = res; + OrderLinesLimit.setPOLLimit(2); + OrderLines.createOrderLineViaApi(firstOrderLine).then((firstOrderLineResponse) => { + testData.firstOrderLineId = firstOrderLineResponse.id; + }); + OrderLines.createOrderLineViaApi(secondOrderLine).then((secondOrderLineResponse) => { + testData.secondOrderLineId = secondOrderLineResponse.id; + }); - MaterialTypes.createMaterialTypeViaApi(MaterialTypes.getDefaultMaterialType()).then( - (mtypes) => { - cy.getAcquisitionMethodsApi({ - query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, - }).then((params) => { - Organizations.createOrganizationViaApi(organization).then( - (responseOrganizations) => { - organization.id = responseOrganizations; - firstOrder.vendor = organization.id; - const firstOrderLine = { - ...BasicOrderLine.defaultOrderLine, - cost: { - listUnitPrice: 100.0, - currency: 'USD', - discountType: 'percentage', - quantityPhysical: 2, - poLineEstimatedPrice: 100.0, - }, - fundDistribution: [ - { code: firstFund.code, fundId: firstFund.id, value: 100 }, - ], - locations: [ - { locationId: location.id, quantity: 2, quantityPhysical: 2 }, - ], - acquisitionMethod: params.body.acquisitionMethods[0].id, - physical: { - createInventory: 'Instance, Holding, Item', - materialType: mtypes.body.id, - materialSupplier: responseOrganizations, - volumes: [], - }, - }; - Orders.createOrderViaApi(firstOrder).then((firstOrderResponse) => { - firstOrder.id = firstOrderResponse.id; - firstOrderNumber = firstOrderResponse.poNumber; - firstOrderLine.purchaseOrderId = firstOrderResponse.id; - OrderLines.createOrderLineViaApi(firstOrderLine); - Orders.updateOrderViaApi({ - ...firstOrderResponse, - workflowStatus: ORDER_STATUSES.OPEN, - }); - cy.loginAsAdmin({ - path: TopMenu.ordersPath, - waiter: Orders.waitLoading, - }); - Orders.searchByParameter('PO number', firstOrderNumber); - Orders.selectFromResultsList(firstOrderNumber); - OrderLines.selectPOLInOrder(); - OrderLines.openRoutingLists(); - OrderLines.addRoutingList(); - OrderLines.fillInRoutingListInfoAndSave(routingList1); - OrderLines.varifyAddingRoutingList(routingList1); - }); - }, - ); - }); - }, - ); + Orders.updateOrderViaApi({ + ...orderResponse, + workflowStatus: ORDER_STATUSES.OPEN, + }); }); }); }); @@ -135,39 +121,71 @@ describe('Receiving', () => { }); cy.createTempUser([ - permissions.uiOrdersEdit.gui, - permissions.uiReceivingViewEditCreate.gui, + Permissions.uiOrdersEdit.gui, + Permissions.uiReceivingViewEditCreate.gui, ]).then((userProperties) => { - user = userProperties; - cy.login(userProperties.username, userProperties.password, { - path: TopMenu.ordersPath, - waiter: Orders.waitLoading, + testData.user = userProperties; + + cy.getAdminToken(); + OrderLineDetails.createRoutingListViaApi( + [userProperties.userId], + routingList1, + testData.firstOrderLineId, + ).then((routingListResponse) => { + testData.routingListId1 = routingListResponse; }); + OrderLineDetails.createRoutingListViaApi( + [userProperties.userId], + routingList2, + testData.secondOrderLineId, + ).then((routingListResponse) => { + testData.routingListId2 = routingListResponse; + }); + + cy.login(userProperties.username, userProperties.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.ORDERS); + Orders.selectOrdersPane(); + Orders.waitLoading(); }); }); - after(() => { + after('Cleanup test data', () => { cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); + RoutingListDetails.deleteRoutingListViaApi(testData.routingListId1); + RoutingListDetails.deleteRoutingListViaApi(testData.routingListId2); + Orders.deleteOrderViaApi(order.id); + Organizations.deleteOrganizationViaApi(organization.id); }); it( 'C468149 Edit existing routing list in "Orders" app (thunderjet)', { tags: ['criticalPath', 'thunderjet', 'C468149'] }, () => { - Orders.searchByParameter('PO number', firstOrderNumber); - Orders.selectFromResultsList(firstOrderNumber); + Orders.searchByParameter('PO number', testData.orderNumber); + Orders.selectFromResultsList(testData.orderNumber); OrderLines.selectPOLInOrder(); - OrderLines.addRoutingListByActions(); - OrderLines.fillInRoutingListInfoWithNotesAndSave(routingList2, notes); - OrderLines.varifyAddingRoutingList(routingList1); - OrderLines.varifyAddingRoutingList(routingList2); - OrderLines.openRoutingList(routingList2); - OrderLines.checkRoutingListNameDetails(routingList2); - OrderLines.checkRoutingListNotesDetails(notes); - OrderLines.closeRoutingListDetails(); - OrderLines.varifyAddingRoutingList(routingList1); - OrderLines.varifyAddingRoutingList(routingList2); + OrderLineDetails.addRoutingListIsDisabled(); + OrderLineDetails.openRoutingList(routingList1); + RoutingListDetails.checkRoutingListNameDetails(routingList1); + RoutingListDetails.editRoutingList(); + RoutingListEditForm.fillInRoutingListInfoAndSave(''); + RoutingListEditForm.verifyNameFieldWithError('Required!'); + RoutingListEditForm.fillInRoutingListInfoAndSave(routingList2); + InteractorsTools.checkCalloutMessage('Name must be unique', calloutTypes.error); + InteractorsTools.closeCalloutMessage(); + RoutingListEditForm.fillInRoutingListInfoAndSave(routingList3); + InteractorsTools.checkCalloutMessage('The Routing list was successfully updated.'); + RoutingListDetails.closeRoutingListDetails(); + OrderLineDetails.waitLoading(); + OrderLineDetails.verifyAddingRoutingList(routingList3); + OrderLineDetails.addRoutingListIsDisabled(); + OrderLineDetails.backToOrderDetails(); + OrderDetails.openReceivingsPage(); + Receiving.selectFromResultsListByPolNumber(`${testData.orderNumber}-1`); + Receiving.waitLoading(); + Receiving.verifyRoutingListWarning(); + Receiving.verifyRoutingListExists(routingList3); }, ); }); diff --git a/cypress/e2e/orders/pol-search-am-filter.cy.js b/cypress/e2e/orders/pol-search-am-filter.cy.js index 030bf3e599..2b89ee71b3 100644 --- a/cypress/e2e/orders/pol-search-am-filter.cy.js +++ b/cypress/e2e/orders/pol-search-am-filter.cy.js @@ -6,10 +6,9 @@ import { VENDOR_NAMES, } from '../../support/constants'; import Permissions from '../../support/dictionary/permissions'; -import BasicOrderLine from '../../support/fragments/orders/basicOrderLine'; -import OrderLines from '../../support/fragments/orders/orderLines'; -import Orders from '../../support/fragments/orders/orders'; +import { BasicOrderLine, OrderLines, Orders } from '../../support/fragments/orders'; import Organizations from '../../support/fragments/organizations/organizations'; +import OrderLinesLimit from '../../support/fragments/settings/orders/orderLinesLimit'; import TopMenuNavigation from '../../support/fragments/topMenuNavigation'; import Users from '../../support/fragments/users/users'; @@ -73,6 +72,7 @@ describe('Export Manager', () => { poLines[index].purchaseOrderId = purchaseOrderId; poLines[index].physical.materialSupplier = order.vendor; + OrderLinesLimit.setPOLLimit(3); OrderLines.createOrderLineViaApi(poLines[index]); }); }); diff --git a/cypress/e2e/orders/receiving-and-check-in/copy-number-not-shown-in-receiving.cy.js b/cypress/e2e/orders/receiving-and-check-in/copy-number-not-shown-in-receiving.cy.js index 3890950528..21a272dcdb 100644 --- a/cypress/e2e/orders/receiving-and-check-in/copy-number-not-shown-in-receiving.cy.js +++ b/cypress/e2e/orders/receiving-and-check-in/copy-number-not-shown-in-receiving.cy.js @@ -1,7 +1,7 @@ import uuid from 'uuid'; import { APPLICATION_NAMES, LOCATION_NAMES } from '../../../support/constants'; import { Permissions } from '../../../support/dictionary'; -import InventoryInstances from '../../../support/fragments/inventory'; +import InventoryInstances from '../../../support/fragments/inventory/inventoryInstances'; import InventoryInstance from '../../../support/fragments/inventory/inventoryInstance'; import { BasicOrderLine, NewOrder, Orders } from '../../../support/fragments/orders'; import { NewOrganization, Organizations } from '../../../support/fragments/organizations'; diff --git a/cypress/e2e/orders/routing-list-collapsed-for-physical-and-pemix.cy.js b/cypress/e2e/orders/routing-list-collapsed-for-physical-and-pemix.cy.js index c67112b184..d41984c433 100644 --- a/cypress/e2e/orders/routing-list-collapsed-for-physical-and-pemix.cy.js +++ b/cypress/e2e/orders/routing-list-collapsed-for-physical-and-pemix.cy.js @@ -1,168 +1,155 @@ -import permissions from '../../support/dictionary/permissions'; -import BasicOrderLine from '../../support/fragments/orders/basicOrderLine'; -import NewOrder from '../../support/fragments/orders/newOrder'; -import OrderLineDetails from '../../support/fragments/orders/orderLineDetails'; -import OrderLines from '../../support/fragments/orders/orderLines'; -import Orders from '../../support/fragments/orders/orders'; -import NewOrganization from '../../support/fragments/organizations/newOrganization'; -import Organizations from '../../support/fragments/organizations/organizations'; -import TopMenu from '../../support/fragments/topMenu'; +import uuid from 'uuid'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + APPLICATION_NAMES, + LOCATION_NAMES, + ORDER_STATUSES, +} from '../../support/constants'; +import Permissions from '../../support/dictionary/permissions'; +import { + BasicOrderLine, + NewOrder, + OrderLineDetails, + OrderLines, + Orders, +} from '../../support/fragments/orders'; +import { NewOrganization, Organizations } from '../../support/fragments/organizations'; +import TopMenuNavigation from '../../support/fragments/topMenuNavigation'; import Users from '../../support/fragments/users/users'; -import MaterialTypes from '../../support/fragments/settings/inventory/materialTypes'; -import { ACQUISITION_METHOD_NAMES_IN_PROFILE } from '../../support/constants'; -import ServicePoints from '../../support/fragments/settings/tenant/servicePoints/servicePoints'; -import NewLocation from '../../support/fragments/settings/tenant/locations/newLocation'; -describe('ui-orders: Orders and Order lines', () => { - const organization = { ...NewOrganization.defaultUiOrganizations }; +describe('Orders', () => { + const testData = {}; const firstOrder = { - ...NewOrder.getDefaultOngoingOrder({ orderType: 'One-Time' }), + ...NewOrder.getDefaultOngoingOrder, + orderType: 'Ongoing', + ongoing: { isSubscription: false, manualRenewal: false }, approved: true, + reEncumber: true, }; const secondOrder = { - ...NewOrder.getDefaultOngoingOrder({ orderType: 'One-Time' }), + ...NewOrder.getDefaultOngoingOrder, + id: uuid(), + orderType: 'Ongoing', + ongoing: { isSubscription: false, manualRenewal: false }, approved: true, + reEncumber: true, }; - let user; - let firstOrderNumber; - let secondOrderNumber; - let location; - let servicePointId; - let materialType; + const organization = { ...NewOrganization.defaultUiOrganizations }; - before('Create user, data', () => { + before('Setup test data', () => { cy.getAdminToken(); - - ServicePoints.getViaApi().then((servicePoint) => { - servicePointId = servicePoint[0].id; - NewLocation.createViaApi(NewLocation.getDefaultLocation(servicePointId)).then( - (locationRes) => { - location = locationRes; - + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getBookMaterialType().then((mtypes) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((params) => { Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { organization.id = responseOrganizations; firstOrder.vendor = organization.id; secondOrder.vendor = organization.id; - MaterialTypes.createMaterialTypeViaApi(MaterialTypes.getDefaultMaterialType()).then( - (mtypes) => { - materialType = mtypes.body; - cy.getAcquisitionMethodsApi({ - query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, - }).then((params) => { - const firstOrderLine = { - ...BasicOrderLine.getDefaultOrderLine(), - orderFormat: 'Physical Resource', - cost: { - listUnitPrice: 10.0, - currency: 'USD', - discountType: 'percentage', - quantityPhysical: 1, - poLineEstimatedPrice: 10.0, - }, - locations: [ - { - locationId: location.id, - quantity: 1, - quantityPhysical: 1, - }, - ], - acquisitionMethod: params.body.acquisitionMethods[0].id, - physical: { - createInventory: 'Instance, Holding', - materialType: mtypes.body.id, - materialSupplier: responseOrganizations, - volumes: [], - }, - }; - - Orders.createOrderViaApi(firstOrder).then((firstOrderResponse) => { - firstOrder.id = firstOrderResponse.id; - firstOrderLine.purchaseOrderId = firstOrderResponse.id; - firstOrderNumber = firstOrderResponse.poNumber; + const firstOrderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + listUnitPrice: 5.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 5.0, + }, + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: params.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypes.id, + materialSupplier: responseOrganizations, + volumes: [], + }, + }; + const secondOrderLine = { + ...BasicOrderLine.defaultOrderLine, + id: uuid(), + cost: { + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + quantityElectronic: 1, + listUnitPriceElectronic: 5, + listUnitPrice: 5, + }, + orderFormat: 'P/E Mix', + eresource: { + createInventory: 'Instance, Holding', + accessProvider: organization.id, + }, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypes.id, + }, + locations: [ + { + locationId: locationResp.id, + quantityPhysical: 1, + quantityElectronic: 1, + }, + ], + acquisitionMethod: params.body.acquisitionMethods[0].id, + }; + Orders.createOrderViaApi(firstOrder).then((orderResponse) => { + firstOrder.id = orderResponse.id; + testData.firstOrderNumber = orderResponse.poNumber; + firstOrderLine.purchaseOrderId = orderResponse.id; - OrderLines.createOrderLineViaApi(firstOrderLine).then(() => { - const secondOrderLine = { - ...BasicOrderLine.getDefaultOrderLine(), - orderFormat: 'P/E Mix', - cost: { - listUnitPrice: 10.0, - listUnitPriceElectronic: 10.0, - currency: 'USD', - discountType: 'percentage', - quantityPhysical: 1, - quantityElectronic: 1, - }, - locations: [ - { - locationId: location.id, - quantityPhysical: 1, - quantityElectronic: 0, - }, - { - locationId: location.id, - quantityPhysical: 0, - quantityElectronic: 1, - }, - ], - acquisitionMethod: params.body.acquisitionMethods[0].id, - physical: { - createInventory: 'Instance, Holding', - materialType: mtypes.body.id, - }, - eresource: { - createInventory: 'Instance', - accessProvider: responseOrganizations, - }, - }; + OrderLines.createOrderLineViaApi(firstOrderLine); + Orders.updateOrderViaApi({ + ...orderResponse, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); + Orders.createOrderViaApi(secondOrder).then((orderResponse) => { + secondOrder.id = orderResponse.id; + testData.secondOrderNumber = orderResponse.poNumber; + secondOrderLine.purchaseOrderId = orderResponse.id; - Orders.createOrderViaApi(secondOrder).then((secondOrderResponse) => { - secondOrder.id = secondOrderResponse.id; - secondOrderLine.purchaseOrderId = secondOrderResponse.id; - secondOrderNumber = secondOrderResponse.poNumber; + OrderLines.createOrderLineViaApi(secondOrderLine); + Orders.updateOrderViaApi({ + ...orderResponse, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); + }); + }); + }); + }); - OrderLines.createOrderLineViaApi(secondOrderLine).then(() => { - cy.createTempUser([ - permissions.uiOrdersView.gui, - permissions.uiNotesItemView.gui, - permissions.uiSettingsOrdersCanViewAllSettings.gui, - ]).then((userProperties) => { - user = userProperties; + cy.createTempUser([ + Permissions.uiOrdersView.gui, + Permissions.uiNotesItemView.gui, + Permissions.uiSettingsOrdersCanViewAllSettings.gui, + ]).then((userProperties) => { + testData.user = userProperties; - cy.login(userProperties.username, userProperties.password, { - path: TopMenu.ordersPath, - waiter: Orders.waitLoading, - }); - }); - }); - }); - }); - }); - }); - }, - ); - }); - }, - ); + cy.login(userProperties.username, userProperties.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.ORDERS); + Orders.selectOrdersPane(); + Orders.waitLoading(); }); }); after('Delete user, data', () => { cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); Orders.deleteOrderViaApi(firstOrder.id); Orders.deleteOrderViaApi(secondOrder.id); Organizations.deleteOrganizationViaApi(organization.id); - NewLocation.deleteViaApi(location.id); - MaterialTypes.deleteViaApi(materialType.id); }); it( 'C466242 "Routing lists" accordion is collapsed when PO line does not have related Routing lists and Order format = "Physical Resource" or "P/E Mix" (thunderjet)', { tags: ['criticalPath', 'thunderjet', 'C466242'] }, () => { - Orders.searchByParameter('PO number', firstOrderNumber); - Orders.selectFromResultsList(firstOrderNumber); + Orders.searchByParameter('PO number', testData.firstOrderNumber); + Orders.selectFromResultsList(testData.firstOrderNumber); cy.wait(4000); OrderLines.selectPOLInOrder(); OrderLineDetails.waitLoading(); @@ -175,8 +162,8 @@ describe('ui-orders: Orders and Order lines', () => { OrderLineDetails.checkNoRoutingListsText(); Orders.resetFilters(); - Orders.searchByParameter('PO number', secondOrderNumber); - Orders.selectFromResultsList(secondOrderNumber); + Orders.searchByParameter('PO number', testData.secondOrderNumber); + Orders.selectFromResultsList(testData.secondOrderNumber); cy.wait(2000); OrderLines.selectPOLInOrder(); OrderLineDetails.waitLoading(); diff --git a/cypress/e2e/orders/routing-list-not-displayed-for-electronic-and-other-formats.cy.js b/cypress/e2e/orders/routing-list-not-displayed-for-electronic-and-other-formats.cy.js index 6e2c54a7bb..0d84b1cd7c 100644 --- a/cypress/e2e/orders/routing-list-not-displayed-for-electronic-and-other-formats.cy.js +++ b/cypress/e2e/orders/routing-list-not-displayed-for-electronic-and-other-formats.cy.js @@ -1,19 +1,22 @@ -import permissions from '../../support/dictionary/permissions'; -import BasicOrderLine from '../../support/fragments/orders/basicOrderLine'; -import NewOrder from '../../support/fragments/orders/newOrder'; -import OrderLineDetails from '../../support/fragments/orders/orderLineDetails'; -import OrderLines from '../../support/fragments/orders/orderLines'; -import Orders from '../../support/fragments/orders/orders'; -import NewOrganization from '../../support/fragments/organizations/newOrganization'; -import Organizations from '../../support/fragments/organizations/organizations'; -import TopMenu from '../../support/fragments/topMenu'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + APPLICATION_NAMES, + LOCATION_NAMES, +} from '../../support/constants'; +import Permissions from '../../support/dictionary/permissions'; +import { + BasicOrderLine, + NewOrder, + OrderLineDetails, + OrderLines, + Orders, +} from '../../support/fragments/orders'; +import { NewOrganization, Organizations } from '../../support/fragments/organizations'; +import TopMenuNavigation from '../../support/fragments/topMenuNavigation'; import Users from '../../support/fragments/users/users'; -import MaterialTypes from '../../support/fragments/settings/inventory/materialTypes'; -import { ACQUISITION_METHOD_NAMES_IN_PROFILE } from '../../support/constants'; -import ServicePoints from '../../support/fragments/settings/tenant/servicePoints/servicePoints'; -import NewLocation from '../../support/fragments/settings/tenant/locations/newLocation'; -describe('ui-orders: Orders and Order lines', () => { +describe('Orders', () => { + const testData = {}; const organization = { ...NewOrganization.defaultUiOrganizations }; const firstOrder = { ...NewOrder.getDefaultOngoingOrder({ orderType: 'One-Time' }), @@ -23,143 +26,122 @@ describe('ui-orders: Orders and Order lines', () => { ...NewOrder.getDefaultOngoingOrder({ orderType: 'One-Time' }), approved: true, }; - let user; - let firstOrderNumber; - let secondOrderNumber; - let location; - let servicePointId; - let materialType; before('Create user, data', () => { cy.getAdminToken(); - ServicePoints.getViaApi().then((servicePoint) => { - servicePointId = servicePoint[0].id; - NewLocation.createViaApi(NewLocation.getDefaultLocation(servicePointId)).then( - (locationRes) => { - location = locationRes; - + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getBookMaterialType().then((mtypes) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((params) => { Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { organization.id = responseOrganizations; firstOrder.vendor = organization.id; secondOrder.vendor = organization.id; - MaterialTypes.createMaterialTypeViaApi(MaterialTypes.getDefaultMaterialType()).then( - (mtypes) => { - materialType = mtypes.body; - cy.getAcquisitionMethodsApi({ - query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, - }).then((params) => { - // eslint-disable-next-line no-unused-vars - const { physical, ...orderLineWithoutPhysical } = - BasicOrderLine.getDefaultOrderLine(); - - const firstOrderLine = { - ...orderLineWithoutPhysical, - acquisitionMethod: params.body.acquisitionMethods[0].id, - orderFormat: 'Electronic Resource', - cost: { - listUnitPriceElectronic: 10.0, - currency: 'USD', - discountType: 'percentage', - quantityElectronic: 1, - }, - locations: [ - { - locationId: location.id, - quantity: 1, - quantityElectronic: 1, - }, - ], - eresource: { - createInventory: 'Instance, Holding', - materialType: mtypes.body.id, - }, - }; + // eslint-disable-next-line no-unused-vars + const { physical, ...orderLineWithoutPhysical } = BasicOrderLine.getDefaultOrderLine(); - Orders.createOrderViaApi(firstOrder).then((firstOrderResponse) => { - firstOrder.id = firstOrderResponse.id; - firstOrderLine.purchaseOrderId = firstOrderResponse.id; - firstOrderNumber = firstOrderResponse.poNumber; + const firstOrderLine = { + ...orderLineWithoutPhysical, + acquisitionMethod: params.body.acquisitionMethods[0].id, + orderFormat: 'Electronic Resource', + cost: { + listUnitPriceElectronic: 10.0, + currency: 'USD', + discountType: 'percentage', + quantityElectronic: 1, + }, + locations: [ + { + locationId: locationResp.id, + quantity: 1, + quantityElectronic: 1, + }, + ], + eresource: { + createInventory: 'Instance, Holding', + materialType: mtypes.id, + }, + }; + const secondOrderLine = { + ...BasicOrderLine.getDefaultOrderLine(), + orderFormat: 'Other', + cost: { + listUnitPrice: 10.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 10.0, + }, + locations: [ + { + locationId: locationResp.id, + quantity: 1, + quantityPhysical: 1, + }, + ], + acquisitionMethod: params.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding', + materialType: mtypes.id, + materialSupplier: responseOrganizations, + volumes: [], + }, + }; - OrderLines.createOrderLineViaApi(firstOrderLine).then(() => { - const secondOrderLine = { - ...BasicOrderLine.getDefaultOrderLine(), - orderFormat: 'Other', - cost: { - listUnitPrice: 10.0, - currency: 'USD', - discountType: 'percentage', - quantityPhysical: 1, - poLineEstimatedPrice: 10.0, - }, - locations: [ - { - locationId: location.id, - quantity: 1, - quantityPhysical: 1, - }, - ], - acquisitionMethod: params.body.acquisitionMethods[0].id, - physical: { - createInventory: 'Instance, Holding', - materialType: mtypes.body.id, - materialSupplier: responseOrganizations, - volumes: [], - }, - }; + Orders.createOrderViaApi(firstOrder).then((firstOrderResponse) => { + firstOrder.id = firstOrderResponse.id; + firstOrderLine.purchaseOrderId = firstOrderResponse.id; + testData.firstOrderNumber = firstOrderResponse.poNumber; - Orders.createOrderViaApi(secondOrder).then((secondOrderResponse) => { - secondOrder.id = secondOrderResponse.id; - secondOrderLine.purchaseOrderId = secondOrderResponse.id; - secondOrderNumber = secondOrderResponse.poNumber; + OrderLines.createOrderLineViaApi(firstOrderLine); + }); - OrderLines.createOrderLineViaApi(secondOrderLine).then(() => { - cy.createTempUser([ - permissions.uiOrdersView.gui, - permissions.uiOrdersEdit.gui, - ]).then((userProperties) => { - user = userProperties; + Orders.createOrderViaApi(secondOrder).then((secondOrderResponse) => { + secondOrder.id = secondOrderResponse.id; + secondOrderLine.purchaseOrderId = secondOrderResponse.id; + testData.secondOrderNumber = secondOrderResponse.poNumber; - cy.login(userProperties.username, userProperties.password, { - path: TopMenu.ordersPath, - waiter: Orders.waitLoading, - }); - }); - }); - }); - }); - }); - }); - }, - ); + OrderLines.createOrderLineViaApi(secondOrderLine); + }); }); - }, - ); + }); + }); }); + + cy.createTempUser([Permissions.uiOrdersView.gui, Permissions.uiOrdersEdit.gui]).then( + (userProperties) => { + testData.user = userProperties; + + cy.login(userProperties.username, userProperties.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.ORDERS); + Orders.selectOrdersPane(); + Orders.waitLoading(); + }, + ); }); after('Delete user, data', () => { cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); Orders.deleteOrderViaApi(firstOrder.id); Orders.deleteOrderViaApi(secondOrder.id); Organizations.deleteOrganizationViaApi(organization.id); - NewLocation.deleteViaApi(location.id); - MaterialTypes.deleteViaApi(materialType.id); }); it( 'C466239 "Routing lists" accordion is not displayed when Order format = "Electronic Resource" or "Other" (thunderjet)', { tags: ['criticalPath', 'thunderjet', 'C466239'] }, () => { - Orders.searchByParameter('PO number', firstOrderNumber); - Orders.selectFromResultsList(firstOrderNumber); + Orders.searchByParameter('PO number', testData.firstOrderNumber); + Orders.selectFromResultsList(testData.firstOrderNumber); OrderLines.selectPOLInOrder(); OrderLineDetails.checkRoutingListSectionPresence(false); Orders.resetFilters(); - Orders.searchByParameter('PO number', secondOrderNumber); - Orders.selectFromResultsList(secondOrderNumber); + Orders.searchByParameter('PO number', testData.secondOrderNumber); + Orders.selectFromResultsList(testData.secondOrderNumber); OrderLines.selectPOLInOrder(); OrderLineDetails.checkRoutingListSectionPresence(false); }, diff --git a/cypress/e2e/orders/users-added-to-routing-list-from-pol-are-synchronized-with-users-added-via-receiving-title.cy.js b/cypress/e2e/orders/users-added-to-routing-list-from-pol-are-synchronized-with-users-added-via-receiving-title.cy.js index b9c9f7896d..2c78299fc9 100644 --- a/cypress/e2e/orders/users-added-to-routing-list-from-pol-are-synchronized-with-users-added-via-receiving-title.cy.js +++ b/cypress/e2e/orders/users-added-to-routing-list-from-pol-are-synchronized-with-users-added-via-receiving-title.cy.js @@ -1,194 +1,179 @@ -import permissions from '../../support/dictionary/permissions'; -import getRandomPostfix from '../../support/utils/stringTools'; -import FiscalYears from '../../support/fragments/finance/fiscalYears/fiscalYears'; -import TopMenu from '../../support/fragments/topMenu'; -import Ledgers from '../../support/fragments/finance/ledgers/ledgers'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + APPLICATION_NAMES, + LOCATION_NAMES, + ORDER_STATUSES, +} from '../../support/constants'; +import Permissions from '../../support/dictionary/permissions'; +import { + BasicOrderLine, + NewOrder, + OrderLineDetails, + OrderLines, + Orders, +} from '../../support/fragments/orders'; +import RoutingListDetails from '../../support/fragments/orders/routingLists/routingListDetails'; +import RoutingListEditForm from '../../support/fragments/orders/routingLists/routingListEditForm'; +import { NewOrganization, Organizations } from '../../support/fragments/organizations'; +import Receiving from '../../support/fragments/receiving/receiving'; +import TopMenuNavigation from '../../support/fragments/topMenuNavigation'; import Users from '../../support/fragments/users/users'; -import Funds from '../../support/fragments/finance/funds/funds'; -import NewOrder from '../../support/fragments/orders/newOrder'; -import Orders from '../../support/fragments/orders/orders'; -import Organizations from '../../support/fragments/organizations/organizations'; -import NewOrganization from '../../support/fragments/organizations/newOrganization'; -import ServicePoints from '../../support/fragments/settings/tenant/servicePoints/servicePoints'; -import NewLocation from '../../support/fragments/settings/tenant/locations/newLocation'; -import Budgets from '../../support/fragments/finance/budgets/budgets'; -import { ACQUISITION_METHOD_NAMES_IN_PROFILE, ORDER_STATUSES } from '../../support/constants'; -import BasicOrderLine from '../../support/fragments/orders/basicOrderLine'; -import MaterialTypes from '../../support/fragments/settings/inventory/materialTypes'; -import OrderLines from '../../support/fragments/orders/orderLines'; +import getRandomPostfix from '../../support/utils/stringTools'; -describe('Receiving', () => { - const firstFiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const firstFund = { ...Funds.defaultUiFund }; - const secondFund = { - name: `autotest_fund2_${getRandomPostfix()}`, - code: getRandomPostfix(), - externalAccountNo: getRandomPostfix(), - fundStatus: 'Active', - description: `This is fund created by E2E test automation script_${getRandomPostfix()}`, - }; - const firstOrder = { - ...NewOrder.getDefaultOngoingOrder, - orderType: 'Ongoing', - ongoing: { isSubscription: false, manualRenewal: false }, - approved: true, - reEncumber: true, - }; +describe('Orders', () => { + const testData = {}; const organization = { ...NewOrganization.defaultUiOrganizations }; - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - const firstBudget = { - ...Budgets.getDefaultBudget(), - allocated: 1000, + const order = { + ...NewOrder.getDefaultOngoingOrder({ orderType: 'One-Time' }), + approved: true, }; - const routingList1 = `routingList_1${getRandomPostfix()}`; - let user; - let firstOrderNumber; - let servicePointId; - let location; - let secondUser; - let thirdUser; - let fourthUser; + const routingList = `routingList_1${getRandomPostfix()}`; before(() => { cy.getAdminToken(); - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - firstBudget.fiscalYearId = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - firstFund.ledgerId = defaultLedger.id; - secondFund.ledgerId = defaultLedger.id; + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getBookMaterialType().then((mtypes) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((params) => { + Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { + organization.id = responseOrganizations; + order.vendor = organization.id; + const orderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + listUnitPrice: 10.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 10.0, + }, + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: params.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypes.id, + materialSupplier: responseOrganizations, + volumes: [], + }, + }; + Orders.createOrderViaApi(order).then((orderResponse) => { + order.id = orderResponse.id; + testData.orderNumber = orderResponse.poNumber; + orderLine.purchaseOrderId = orderResponse.id; - Funds.createViaApi(firstFund).then((fundResponse) => { - firstFund.id = fundResponse.fund.id; - firstBudget.fundId = fundResponse.fund.id; - Budgets.createViaApi(firstBudget); + OrderLines.createOrderLineViaApi(orderLine).then((orderLineResponse) => { + testData.orderLineId = orderLineResponse.id; - ServicePoints.getViaApi().then((servicePoint) => { - servicePointId = servicePoint[0].id; - NewLocation.createViaApi(NewLocation.getDefaultLocation(servicePointId)).then((res) => { - location = res; + Orders.updateOrderViaApi({ + ...orderResponse, + workflowStatus: ORDER_STATUSES.OPEN, + }); - MaterialTypes.createMaterialTypeViaApi(MaterialTypes.getDefaultMaterialType()).then( - (mtypes) => { - cy.getAcquisitionMethodsApi({ - query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, - }).then((params) => { - Organizations.createOrganizationViaApi(organization).then( - (responseOrganizations) => { - organization.id = responseOrganizations; - firstOrder.vendor = organization.id; - const firstOrderLine = { - ...BasicOrderLine.defaultOrderLine, - cost: { - listUnitPrice: 100.0, - currency: 'USD', - discountType: 'percentage', - quantityPhysical: 2, - poLineEstimatedPrice: 100.0, - }, - fundDistribution: [ - { code: firstFund.code, fundId: firstFund.id, value: 100 }, - ], - locations: [ - { locationId: location.id, quantity: 2, quantityPhysical: 2 }, - ], - acquisitionMethod: params.body.acquisitionMethods[0].id, - physical: { - createInventory: 'Instance, Holding, Item', - materialType: mtypes.body.id, - materialSupplier: responseOrganizations, - volumes: [], - }, - }; - Orders.createOrderViaApi(firstOrder).then((firstOrderResponse) => { - firstOrder.id = firstOrderResponse.id; - firstOrderNumber = firstOrderResponse.poNumber; - firstOrderLine.purchaseOrderId = firstOrderResponse.id; - OrderLines.createOrderLineViaApi(firstOrderLine); - Orders.updateOrderViaApi({ - ...firstOrderResponse, - workflowStatus: ORDER_STATUSES.OPEN, - }); - cy.loginAsAdmin({ - path: TopMenu.ordersPath, - waiter: Orders.waitLoading, - }); - Orders.searchByParameter('PO number', firstOrderNumber); - Orders.selectFromResultsList(firstOrderNumber); - OrderLines.selectPOLInOrder(); - OrderLines.openRoutingLists(); - OrderLines.addRoutingList(); - OrderLines.fillInRoutingListInfoAndSave(routingList1); - OrderLines.varifyAddingRoutingList(routingList1); - }); - }, - ); - }); - }, - ); + OrderLineDetails.createRoutingListViaApi( + [], + routingList, + testData.orderLineId, + ).then((routingListResponse) => { + testData.routingListId = routingListResponse; + }); + }); }); }); }); }); }); - cy.createTempUser([permissions.uiOrdersEdit.gui]).then((secondUserProperties) => { - secondUser = secondUserProperties; + + cy.createTempUser([]).then((secondUserProperties) => { + testData.secondUser = secondUserProperties; }); - cy.createTempUser([permissions.uiOrdersEdit.gui]).then((thirdUserProperties) => { - thirdUser = thirdUserProperties; + cy.createTempUser([]).then((thirdUserProperties) => { + testData.thirdUser = thirdUserProperties; }); - cy.createTempUser([permissions.uiOrdersEdit.gui]).then((fourthUserProperties) => { - fourthUser = fourthUserProperties; + cy.createTempUser([]).then((fourthUserProperties) => { + testData.fourthUser = fourthUserProperties; }); - cy.createTempUser([permissions.uiOrdersEdit.gui]).then((userProperties) => { - user = userProperties; - cy.login(userProperties.username, userProperties.password, { - path: TopMenu.ordersPath, - waiter: Orders.waitLoading, - }); + cy.createTempUser([ + Permissions.uiOrdersEdit.gui, + Permissions.uiReceivingViewEditCreate.gui, + ]).then((userProperties) => { + testData.firstUser = userProperties; + + cy.login(userProperties.username, userProperties.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.ORDERS); + Orders.selectOrdersPane(); + Orders.waitLoading(); }); }); after(() => { cy.getAdminToken(); - Users.deleteViaApi(user.userId); - Users.deleteViaApi(secondUser.userId); - Users.deleteViaApi(thirdUser.userId); - Users.deleteViaApi(fourthUser.userId); + Users.deleteViaApi(testData.firstUser.userId); + Users.deleteViaApi(testData.secondUser.userId); + Users.deleteViaApi(testData.thirdUser.userId); + Users.deleteViaApi(testData.fourthUser.userId); + RoutingListDetails.deleteRoutingListViaApi(testData.routingListId); + Orders.deleteOrderViaApi(order.id); + Organizations.deleteOrganizationViaApi(organization.id); }); it( 'C471488 Users added to Routing list from POL are synchronized with users added via Receiving title (thunderjet)', { tags: ['criticalPath', 'thunderjet', 'C471488'] }, () => { - Orders.searchByParameter('PO number', firstOrderNumber); - Orders.selectFromResultsList(firstOrderNumber); + Orders.searchByParameter('PO number', testData.orderNumber); + Orders.selectFromResultsList(testData.orderNumber); OrderLines.selectPOLInOrder(); - OrderLines.openRoutingLists(); - OrderLines.openRoutingList(routingList1); - OrderLines.editRoutingList(); - OrderLines.addUserToRoutingList(); - OrderLines.assignUser(user.username); - OrderLines.checkUserIsAdded(user.username); - OrderLines.addUserToRoutingList(); - OrderLines.assignUser(secondUser.username); - OrderLines.checkUserIsAdded(secondUser.username); - OrderLines.saveOrderLine(); - OrderLines.editRoutingList(); - OrderLines.checkUserIsAdded(user.username); - OrderLines.checkUserIsAdded(secondUser.username); - OrderLines.deleteUserFromRoutingList(secondUser.userId); - OrderLines.addUserToRoutingList(); - OrderLines.assignUser(thirdUser.username); - OrderLines.checkUserIsAdded(thirdUser.username); - OrderLines.addUserToRoutingList(); - OrderLines.assignUser(fourthUser.username); - OrderLines.checkUserIsAdded(fourthUser.username); - OrderLines.saveOrderLine(); - OrderLines.checkUserIsAbsent(secondUser.username); + OrderLineDetails.openRoutingListsAccordion(); + OrderLineDetails.openRoutingList(routingList); + RoutingListDetails.editRoutingList(); + RoutingListEditForm.addUserToRoutingList(); + RoutingListEditForm.assignUser(testData.firstUser.username); + RoutingListEditForm.checkUserIsAdded(testData.firstUser.username); + RoutingListEditForm.addUserToRoutingList(); + RoutingListEditForm.assignUser(testData.secondUser.username); + RoutingListEditForm.checkUserIsAdded(testData.secondUser.username); + RoutingListEditForm.save(); + RoutingListDetails.closeRoutingListDetails(); + OrderLineDetails.checkAssignedUsersInRoutingList([ + testData.firstUser.username, + testData.secondUser.username, + ]); + OrderLineDetails.backToOrderDetails(); + Orders.receiveOrderViaActions(); + Receiving.selectLinkFromResultsList(); + Receiving.openRoutingListsAccordionSection(); + Receiving.verifyRoutingListExists(); + Receiving.openRoutingList(routingList); + RoutingListDetails.editRoutingList(); + RoutingListEditForm.checkUserIsAdded(testData.firstUser.username); + RoutingListEditForm.checkUserIsAdded(testData.secondUser.username); + RoutingListEditForm.unAssignUserFromRoutingList(testData.secondUser.userId); + RoutingListEditForm.checkUserIsAbsent(testData.secondUser.username); + RoutingListEditForm.addUserToRoutingList(); + RoutingListEditForm.assignUser(testData.thirdUser.username); + RoutingListEditForm.checkUserIsAdded(testData.thirdUser.username); + RoutingListEditForm.addUserToRoutingList(); + RoutingListEditForm.assignUser(testData.fourthUser.username); + RoutingListEditForm.checkUserIsAdded(testData.fourthUser.username); + RoutingListEditForm.save(); + RoutingListDetails.closeRoutingListDetails(); + Receiving.verifyRoutingListExists(routingList); + Receiving.verifyRoutingListWarning(); + Receiving.checkAssignedUsersInRoutingList([ + testData.firstUser.username, + testData.thirdUser.username, + testData.fourthUser.username, + ]); + Receiving.selectPOLineInReceive(); + OrderLineDetails.waitLoading(); + OrderLineDetails.openRoutingListsAccordion(); + OrderLineDetails.verifyAddingRoutingList(routingList); + OrderLineDetails.checkAssignedUsersInRoutingList([ + testData.firstUser.username, + testData.thirdUser.username, + testData.fourthUser.username, + ]); }, ); }); diff --git a/cypress/e2e/receiving/create-second-routing-list-for-receiving-title-with-quantitymore1.cy.js b/cypress/e2e/receiving/create-second-routing-list-for-receiving-title-with-quantitymore1.cy.js index 0c6632b96d..28801a1229 100644 --- a/cypress/e2e/receiving/create-second-routing-list-for-receiving-title-with-quantitymore1.cy.js +++ b/cypress/e2e/receiving/create-second-routing-list-for-receiving-title-with-quantitymore1.cy.js @@ -1,135 +1,86 @@ -import permissions from '../../support/dictionary/permissions'; -import getRandomPostfix from '../../support/utils/stringTools'; -import FiscalYears from '../../support/fragments/finance/fiscalYears/fiscalYears'; -import TopMenu from '../../support/fragments/topMenu'; -import Ledgers from '../../support/fragments/finance/ledgers/ledgers'; -import Users from '../../support/fragments/users/users'; -import Funds from '../../support/fragments/finance/funds/funds'; -import NewOrder from '../../support/fragments/orders/newOrder'; -import Orders from '../../support/fragments/orders/orders'; -import OrderLines from '../../support/fragments/orders/orderLines'; -import Organizations from '../../support/fragments/organizations/organizations'; -import NewOrganization from '../../support/fragments/organizations/newOrganization'; -import ServicePoints from '../../support/fragments/settings/tenant/servicePoints/servicePoints'; -import NewLocation from '../../support/fragments/settings/tenant/locations/newLocation'; -import Budgets from '../../support/fragments/finance/budgets/budgets'; -import { ACQUISITION_METHOD_NAMES_IN_PROFILE, ORDER_STATUSES } from '../../support/constants'; -import BasicOrderLine from '../../support/fragments/orders/basicOrderLine'; -import MaterialTypes from '../../support/fragments/settings/inventory/materialTypes'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + APPLICATION_NAMES, + LOCATION_NAMES, + ORDER_STATUSES, +} from '../../support/constants'; +import Permissions from '../../support/dictionary/permissions'; +import { + BasicOrderLine, + NewOrder, + OrderLineDetails, + OrderLines, + Orders, +} from '../../support/fragments/orders'; +import NewRoutingList from '../../support/fragments/orders/routingLists/newRoutingList'; +import { NewOrganization, Organizations } from '../../support/fragments/organizations'; import Receiving from '../../support/fragments/receiving/receiving'; +import TopMenuNavigation from '../../support/fragments/topMenuNavigation'; +import Users from '../../support/fragments/users/users'; +import getRandomPostfix from '../../support/utils/stringTools'; describe('Receiving', () => { - const firstFiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const firstFund = { ...Funds.defaultUiFund }; - const secondFund = { - name: `autotest_fund2_${getRandomPostfix()}`, - code: getRandomPostfix(), - externalAccountNo: getRandomPostfix(), - fundStatus: 'Active', - description: `This is fund created by E2E test automation script_${getRandomPostfix()}`, - }; - const firstOrder = { - ...NewOrder.getDefaultOngoingOrder, - orderType: 'Ongoing', - ongoing: { isSubscription: false, manualRenewal: false }, - approved: true, - reEncumber: true, - }; + const testData = {}; const organization = { ...NewOrganization.defaultUiOrganizations }; - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - const firstBudget = { - ...Budgets.getDefaultBudget(), - allocated: 1000, + const order = { + ...NewOrder.getDefaultOngoingOrder({ orderType: 'One-Time' }), + approved: true, }; - const routingList1 = `routingList_1${getRandomPostfix()}`; - const routingList2 = `routingList_2${getRandomPostfix()}`; - const notes = `notes${getRandomPostfix()}`; - let user; - let firstOrderNumber; - let servicePointId; - let location; + const routingList1 = `routingList_1_${getRandomPostfix()}`; + const notes1 = `notes${getRandomPostfix()}`; + const routingList2 = `routingList_2_${getRandomPostfix()}`; + const notes2 = `notes${getRandomPostfix()}`; before(() => { cy.getAdminToken(); - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - firstBudget.fiscalYearId = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - firstFund.ledgerId = defaultLedger.id; - secondFund.ledgerId = defaultLedger.id; - - Funds.createViaApi(firstFund).then((fundResponse) => { - firstFund.id = fundResponse.fund.id; - firstBudget.fundId = fundResponse.fund.id; - Budgets.createViaApi(firstBudget); + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getBookMaterialType().then((mtypes) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((params) => { + Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { + organization.id = responseOrganizations; + order.vendor = organization.id; + const orderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + listUnitPrice: 10.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 2, + poLineEstimatedPrice: 10.0, + }, + locations: [{ locationId: locationResp.id, quantity: 2, quantityPhysical: 2 }], + acquisitionMethod: params.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypes.id, + materialSupplier: responseOrganizations, + volumes: [], + }, + }; + Orders.createOrderViaApi(order).then((orderResponse) => { + order.id = orderResponse.id; + testData.orderNumber = orderResponse.poNumber; + orderLine.purchaseOrderId = orderResponse.id; - ServicePoints.getViaApi().then((servicePoint) => { - servicePointId = servicePoint[0].id; - NewLocation.createViaApi(NewLocation.getDefaultLocation(servicePointId)).then((res) => { - location = res; - - MaterialTypes.createMaterialTypeViaApi(MaterialTypes.getDefaultMaterialType()).then( - (mtypes) => { - cy.getAcquisitionMethodsApi({ - query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, - }).then((params) => { - Organizations.createOrganizationViaApi(organization).then( - (responseOrganizations) => { - organization.id = responseOrganizations; - firstOrder.vendor = organization.id; - const firstOrderLine = { - ...BasicOrderLine.defaultOrderLine, - cost: { - listUnitPrice: 100.0, - currency: 'USD', - discountType: 'percentage', - quantityPhysical: 2, - poLineEstimatedPrice: 100.0, - }, - fundDistribution: [ - { code: firstFund.code, fundId: firstFund.id, value: 100 }, - ], - locations: [ - { locationId: location.id, quantity: 2, quantityPhysical: 2 }, - ], - acquisitionMethod: params.body.acquisitionMethods[0].id, - physical: { - createInventory: 'Instance, Holding, Item', - materialType: mtypes.body.id, - materialSupplier: responseOrganizations, - volumes: [], - }, - }; - Orders.createOrderViaApi(firstOrder).then((firstOrderResponse) => { - firstOrder.id = firstOrderResponse.id; - firstOrderNumber = firstOrderResponse.poNumber; - firstOrderLine.purchaseOrderId = firstOrderResponse.id; - OrderLines.createOrderLineViaApi(firstOrderLine); - Orders.updateOrderViaApi({ - ...firstOrderResponse, - workflowStatus: ORDER_STATUSES.OPEN, - }); - cy.loginAsAdmin({ - path: TopMenu.ordersPath, - waiter: Orders.waitLoading, - }); - Orders.searchByParameter('PO number', firstOrderNumber); - Orders.selectFromResultsList(firstOrderNumber); - Orders.receiveOrderViaActions(); - Receiving.selectLinkFromResultsList(); - OrderLines.openRoutingLists(); - OrderLines.addRoutingList(); - OrderLines.fillInRoutingListInfoAndSave(routingList1); - OrderLines.varifyAddingRoutingList(routingList1); - }); - }, - ); - }); - }, - ); + OrderLines.createOrderLineViaApi(orderLine); + Orders.updateOrderViaApi({ + ...orderResponse, + workflowStatus: ORDER_STATUSES.OPEN, + }); + cy.loginAsAdmin(); + TopMenuNavigation.openAppFromDropdown(APPLICATION_NAMES.ORDERS); + Orders.selectOrdersPane(); + Orders.waitLoading(); + Orders.searchByParameter('PO number', testData.orderNumber); + Orders.selectFromResultsList(testData.orderNumber); + Orders.receiveOrderViaActions(); + Receiving.selectLinkFromResultsList(); + Receiving.openRoutingListsAccordionSection(); + Receiving.clickAddRoutingListButton(); + NewRoutingList.fillInRoutingListInfoWithNotesAndSave(routingList1, notes1); + cy.wait(2000); }); }); }); @@ -137,40 +88,43 @@ describe('Receiving', () => { }); cy.createTempUser([ - permissions.uiOrdersEdit.gui, - permissions.uiReceivingViewEditCreate.gui, + Permissions.uiOrdersEdit.gui, + Permissions.uiReceivingViewEditCreate.gui, ]).then((userProperties) => { - user = userProperties; - cy.login(userProperties.username, userProperties.password, { - path: TopMenu.ordersPath, - waiter: Orders.waitLoading, - }); + testData.user = userProperties; + + cy.login(userProperties.username, userProperties.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.ORDERS); + Orders.selectOrdersPane(); + Orders.waitLoading(); }); }); after(() => { cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); + Orders.deleteOrderViaApi(order.id); + Organizations.deleteOrganizationViaApi(organization.id); }); it( 'C468206 Create second routing list for a Receiving title with quantity > 1 (thunderjet)', { tags: ['criticalPath', 'thunderjet', 'C468206'] }, () => { - Orders.searchByParameter('PO number', firstOrderNumber); - Orders.selectFromResultsList(firstOrderNumber); + Orders.searchByParameter('PO number', testData.orderNumber); + Orders.selectFromResultsList(testData.orderNumber); Orders.receiveOrderViaActions(); Receiving.selectLinkFromResultsList(); - OrderLines.addRoutingListByActions(); - OrderLines.fillInRoutingListInfoWithNotesAndSave(routingList2, notes); - OrderLines.varifyAddingRoutingList(routingList1); - OrderLines.varifyAddingRoutingList(routingList2); - OrderLines.openRoutingList(routingList2); - OrderLines.checkRoutingListNameDetails(routingList2); - OrderLines.checkRoutingListNotesDetails(notes); - OrderLines.closeRoutingListDetails(); - OrderLines.varifyAddingRoutingList(routingList1); - OrderLines.varifyAddingRoutingList(routingList2); + Receiving.addRoutingListByActions(); + NewRoutingList.fillInRoutingListInfoWithNotesAndSave(routingList2, notes2); + Receiving.verifyRoutingListExists(routingList1); + Receiving.verifyRoutingListExists(routingList2); + Receiving.addRoutingListIsDisabled(); + Receiving.selectPOLineInReceive(); + OrderLineDetails.waitLoading(); + OrderLineDetails.verifyAddingRoutingList(routingList1); + OrderLineDetails.verifyAddingRoutingList(routingList2); + OrderLineDetails.addRoutingListIsDisabled(); }, ); }); diff --git a/cypress/e2e/receiving/delete-routing-list-from-receiving-app.cy.js b/cypress/e2e/receiving/delete-routing-list-from-receiving-app.cy.js index a8976fed0c..d6023fa3a4 100644 --- a/cypress/e2e/receiving/delete-routing-list-from-receiving-app.cy.js +++ b/cypress/e2e/receiving/delete-routing-list-from-receiving-app.cy.js @@ -1,167 +1,127 @@ -import permissions from '../../support/dictionary/permissions'; -import getRandomPostfix from '../../support/utils/stringTools'; -import FiscalYears from '../../support/fragments/finance/fiscalYears/fiscalYears'; -import Ledgers from '../../support/fragments/finance/ledgers/ledgers'; -import Users from '../../support/fragments/users/users'; -import Funds from '../../support/fragments/finance/funds/funds'; -import NewOrder from '../../support/fragments/orders/newOrder'; -import Orders from '../../support/fragments/orders/orders'; -import OrderLines from '../../support/fragments/orders/orderLines'; -import Organizations from '../../support/fragments/organizations/organizations'; -import NewOrganization from '../../support/fragments/organizations/newOrganization'; -import ServicePoints from '../../support/fragments/settings/tenant/servicePoints/servicePoints'; -import NewLocation from '../../support/fragments/settings/tenant/locations/newLocation'; -import Budgets from '../../support/fragments/finance/budgets/budgets'; -import { ACQUISITION_METHOD_NAMES_IN_PROFILE, ORDER_STATUSES } from '../../support/constants'; -import BasicOrderLine from '../../support/fragments/orders/basicOrderLine'; -import MaterialTypes from '../../support/fragments/settings/inventory/materialTypes'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + APPLICATION_NAMES, + LOCATION_NAMES, + ORDER_STATUSES, +} from '../../support/constants'; +import Permissions from '../../support/dictionary/permissions'; +import { + BasicOrderLine, + NewOrder, + OrderLineDetails, + OrderLines, + Orders, +} from '../../support/fragments/orders'; +import NewRoutingList from '../../support/fragments/orders/routingLists/newRoutingList'; +import RoutingListDetails from '../../support/fragments/orders/routingLists/routingListDetails'; +import { NewOrganization, Organizations } from '../../support/fragments/organizations'; import Receiving from '../../support/fragments/receiving/receiving'; import TopMenuNavigation from '../../support/fragments/topMenuNavigation'; +import Users from '../../support/fragments/users/users'; +import getRandomPostfix from '../../support/utils/stringTools'; describe('Receiving', () => { - const firstFiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const firstFund = { ...Funds.defaultUiFund }; - const secondFund = { - name: `autotest_fund2_${getRandomPostfix()}`, - code: getRandomPostfix(), - externalAccountNo: getRandomPostfix(), - fundStatus: 'Active', - description: `This is fund created by E2E test automation script_${getRandomPostfix()}`, - }; - const firstOrder = { - ...NewOrder.getDefaultOngoingOrder, - orderType: 'Ongoing', - ongoing: { isSubscription: false, manualRenewal: false }, + const testData = {}; + const order = { + ...NewOrder.getDefaultOngoingOrder({ orderType: 'One-Time' }), approved: true, - reEncumber: true, }; const organization = { ...NewOrganization.defaultUiOrganizations }; - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - const firstBudget = { - ...Budgets.getDefaultBudget(), - allocated: 1000, - }; - const routingList1 = `routingList_1${getRandomPostfix()}`; - let user; - let firstOrderNumber; - let servicePointId; - let location; + const routingList = `routingList_1_${getRandomPostfix()}`; + const notes = `notes_${getRandomPostfix()}`; - before(() => { + before('Setup test data', () => { cy.getAdminToken(); - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - firstBudget.fiscalYearId = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - firstFund.ledgerId = defaultLedger.id; - secondFund.ledgerId = defaultLedger.id; - - Funds.createViaApi(firstFund).then((fundResponse) => { - firstFund.id = fundResponse.fund.id; - firstBudget.fundId = fundResponse.fund.id; - Budgets.createViaApi(firstBudget); + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getBookMaterialType().then((mtypes) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((params) => { + Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { + organization.id = responseOrganizations; + order.vendor = organization.id; + const orderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + listUnitPrice: 10.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 10.0, + }, + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: params.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypes.id, + materialSupplier: responseOrganizations, + volumes: [], + }, + }; + Orders.createOrderViaApi(order).then((orderResponse) => { + order.id = orderResponse.id; + testData.orderNumber = orderResponse.poNumber; + orderLine.purchaseOrderId = orderResponse.id; - ServicePoints.getViaApi().then((servicePoint) => { - servicePointId = servicePoint[0].id; - NewLocation.createViaApi(NewLocation.getDefaultLocation(servicePointId)).then((res) => { - location = res; - - MaterialTypes.createMaterialTypeViaApi(MaterialTypes.getDefaultMaterialType()).then( - (mtypes) => { - cy.getAcquisitionMethodsApi({ - query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, - }).then((params) => { - Organizations.createOrganizationViaApi(organization).then( - (responseOrganizations) => { - organization.id = responseOrganizations; - firstOrder.vendor = organization.id; - const firstOrderLine = { - ...BasicOrderLine.defaultOrderLine, - cost: { - listUnitPrice: 100.0, - currency: 'USD', - discountType: 'percentage', - quantityPhysical: 1, - poLineEstimatedPrice: 100.0, - }, - fundDistribution: [ - { code: firstFund.code, fundId: firstFund.id, value: 100 }, - ], - locations: [ - { locationId: location.id, quantity: 1, quantityPhysical: 1 }, - ], - acquisitionMethod: params.body.acquisitionMethods[0].id, - physical: { - createInventory: 'Instance, Holding, Item', - materialType: mtypes.body.id, - materialSupplier: responseOrganizations, - volumes: [], - }, - }; - Orders.createOrderViaApi(firstOrder).then((firstOrderResponse) => { - firstOrder.id = firstOrderResponse.id; - firstOrderNumber = firstOrderResponse.poNumber; - firstOrderLine.purchaseOrderId = firstOrderResponse.id; - OrderLines.createOrderLineViaApi(firstOrderLine); - Orders.updateOrderViaApi({ - ...firstOrderResponse, - workflowStatus: ORDER_STATUSES.OPEN, - }); - cy.loginAsAdmin(); - TopMenuNavigation.openAppFromDropdown('Orders'); - Orders.selectOrdersPane(); - - Orders.searchByParameter('PO number', firstOrderNumber); - Orders.selectFromResultsList(firstOrderNumber); - Orders.receiveOrderViaActions(); - Receiving.selectLinkFromResultsList(); - OrderLines.openRoutingLists(); - OrderLines.addRoutingList(); - OrderLines.fillInRoutingListInfoAndSave(routingList1); - OrderLines.varifyAddingRoutingList(routingList1); - }); - }, - ); - }); - }, - ); + OrderLines.createOrderLineViaApi(orderLine); + Orders.updateOrderViaApi({ + ...orderResponse, + workflowStatus: ORDER_STATUSES.OPEN, + }); + cy.loginAsAdmin(); + TopMenuNavigation.openAppFromDropdown(APPLICATION_NAMES.ORDERS); + Orders.selectOrdersPane(); + Orders.waitLoading(); + Orders.searchByParameter('PO number', testData.orderNumber); + Orders.selectFromResultsList(testData.orderNumber); + Orders.receiveOrderViaActions(); + Receiving.selectLinkFromResultsList(); + Receiving.openRoutingListsAccordionSection(); + Receiving.clickAddRoutingListButton(); + NewRoutingList.fillInRoutingListInfoWithNotesAndSave(routingList, notes); + cy.wait(2000); }); }); }); }); }); - cy.logout(); + cy.createTempUser([ - permissions.uiOrdersEdit.gui, - permissions.uiReceivingViewEditCreate.gui, + Permissions.uiOrdersEdit.gui, + Permissions.uiReceivingViewEditCreate.gui, ]).then((userProperties) => { - user = userProperties; + testData.user = userProperties; + cy.login(userProperties.username, userProperties.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.ORDERS); + Orders.selectOrdersPane(); }); }); - after(() => { + after('Clean up test data', () => { cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); + Orders.deleteOrderViaApi(order.id); + Organizations.deleteOrganizationViaApi(organization.id); }); it( 'C468209 Delete routing list from "Receiving" app (thunderjet)', { tags: ['criticalPath', 'thunderjet', 'C468209'] }, () => { - TopMenuNavigation.navigateToApp('Orders'); - Orders.selectOrdersPane(); - Orders.searchByParameter('PO number', firstOrderNumber); - Orders.selectFromResultsList(firstOrderNumber); + Orders.searchByParameter('PO number', testData.orderNumber); + Orders.selectFromResultsList(testData.orderNumber); Orders.receiveOrderViaActions(); Receiving.selectLinkFromResultsList(); - OrderLines.openRoutingList(routingList1); - OrderLines.deleteRoutingList(); - Receiving.openRoutingListsSection(); - Receiving.addRoutingListExist(); + Receiving.openRoutingList(routingList); + RoutingListDetails.deleteRoutingList(); + Receiving.openRoutingListsAccordionSection(); + Receiving.addRoutingListButtonExist(); + Receiving.selectPOLineInReceive(); + OrderLineDetails.waitLoading(); + OrderLineDetails.checkRoutingListSectionCounter('0'); + OrderLineDetails.expandRoutingListSection(); + OrderLineDetails.checkNoRoutingListsText(); }, ); }); diff --git a/cypress/support/fragments/inventory/instanceRecordView.js b/cypress/support/fragments/inventory/instanceRecordView.js index 2ddd957ad7..1e631c74b6 100644 --- a/cypress/support/fragments/inventory/instanceRecordView.js +++ b/cypress/support/fragments/inventory/instanceRecordView.js @@ -924,7 +924,7 @@ export default { } cy.expect( - Accordion('Administrative data') + adminDataAccordion .find( HTML( or(...timePoints.map((timePoint) => including(`Record last updated: ${timePoint}`))), @@ -936,9 +936,7 @@ export default { verifyLastUpdatedDateAndTime(updatedDate) { cy.expect( - Accordion('Administrative data') - .find(HTML(including(`Record last updated: ${updatedDate}`))) - .exists(), + adminDataAccordion.find(HTML(including(`Record last updated: ${updatedDate}`))).exists(), ); }, @@ -1139,4 +1137,8 @@ export default { ); } }, + + openAccordion: (name) => { + cy.do(Accordion(name).clickHeader()); + }, }; diff --git a/cypress/support/fragments/inventory/inventoryInstance.js b/cypress/support/fragments/inventory/inventoryInstance.js index 4d5198edeb..f0fec354fb 100644 --- a/cypress/support/fragments/inventory/inventoryInstance.js +++ b/cypress/support/fragments/inventory/inventoryInstance.js @@ -1519,11 +1519,11 @@ export default { singleOverlaySourceBibRecordModalIsPresented: () => cy.expect(singleRecordImportModal.exists()), - overlayWithOclc: (oclc) => { + overlayWithOclc: (oclc, externalTarget = 'OCLC WorldCat') => { cy.getSingleImportProfilesViaAPI().then((importProfiles) => { if (importProfiles.filter((importProfile) => importProfile.enabled === true).length > 1) { cy.wait(3000); - cy.do(singleRecordImportModal.find(importTypeSelect).choose('OCLC WorldCat')); + cy.do(singleRecordImportModal.find(importTypeSelect).choose(externalTarget)); cy.wait(1500); } cy.do( diff --git a/cypress/support/fragments/inventory/inventoryInstances.js b/cypress/support/fragments/inventory/inventoryInstances.js index 56994f2096..149de7128e 100644 --- a/cypress/support/fragments/inventory/inventoryInstances.js +++ b/cypress/support/fragments/inventory/inventoryInstances.js @@ -1,10 +1,9 @@ /* eslint-disable cypress/no-unnecessary-waiting */ -import { HTML, including, matching } from '@interactors/html'; +import { and, HTML, including, matching, or } from '@interactors/html'; import { recurse } from 'cypress-recurse'; import uuid from 'uuid'; import { AdvancedSearch, - MultiSelectMenu, AdvancedSearchRow, Button, Callout, @@ -15,6 +14,7 @@ import { MultiColumnListHeader, MultiColumnListRow, MultiSelect, + MultiSelectMenu, MultiSelectOption, Pane, PaneContent, @@ -24,21 +24,19 @@ import { TextArea, TextField, TextInput, - or, - and, } from '../../../../interactors'; import { ITEM_STATUS_NAMES, LOCATION_NAMES, REQUEST_METHOD } from '../../constants'; import Arrays from '../../utils/arrays'; +import DateTools from '../../utils/dateTools'; import FileManager from '../../utils/fileManager'; import parseMrkFile from '../../utils/parseMrkFile'; import getRandomPostfix from '../../utils/stringTools'; import CheckinActions from '../check-in-actions/checkInActions'; +import QuickMarcEditor from '../quickMarcEditor'; import InventoryHoldings from './holdings/inventoryHoldings'; import InventoryInstance from './inventoryInstance'; import InventoryNewInstance from './inventoryNewInstance'; import InventoryItems from './item/inventoryItems'; -import QuickMarcEditor from '../quickMarcEditor'; -import DateTools from '../../utils/dateTools'; const rootSection = Section({ id: 'pane-results' }); const resultsPaneHeader = PaneHeader({ id: 'paneHeaderpane-results' }); diff --git a/cypress/support/fragments/invoices/index.js b/cypress/support/fragments/invoices/index.js index 24ce2b2ae3..aaf469b75f 100644 --- a/cypress/support/fragments/invoices/index.js +++ b/cypress/support/fragments/invoices/index.js @@ -1,5 +1,7 @@ export { default as InvoiceLineDetails } from './invoiceLineDetails'; export { default as InvoiceEditForm } from './invoiceEditForm'; +export { default as InvoiceNewForm } from './invoiceNewForm'; +export { default as InvoiceLineEditForm } from './invoiceLineEditForm'; export { default as Invoices } from './invoices'; export { default as InvoiceView } from './invoiceView'; export { default as NewInvoice } from './newInvoice'; diff --git a/cypress/support/fragments/invoices/invoiceLineDetails.js b/cypress/support/fragments/invoices/invoiceLineDetails.js index 308c8b4df8..92ee2817cc 100644 --- a/cypress/support/fragments/invoices/invoiceLineDetails.js +++ b/cypress/support/fragments/invoices/invoiceLineDetails.js @@ -122,28 +122,40 @@ export default { cy.expect(fundDistributionsSection.has({ text: including('The list contains no items') })); } }, - openFundDetailsPane(fundName) { - this.clickTheLinkInFundDetailsSection({ fundName }); + openFundDetailsPane(fundName, rowIndex = 0) { + this.clickTheLinkInFundDetailsSection({ fundName, columnIndex: 0, rowIndex }); FundDetails.waitLoading(); return FundDetails; }, - openEncumbrancePane(fundName) { - this.clickTheLinkInFundDetailsSection({ fundName, columnIndex: 5 }); + openEncumbrancePane(fundName, rowIndex = 0) { + this.clickTheLinkInFundDetailsSection({ fundName, columnIndex: 5, rowIndex }); TransactionDetails.waitLoading(); return TransactionDetails; }, - clickTheLinkInFundDetailsSection({ fundName, columnIndex = 0 } = {}) { - const tableRow = fundName - ? fundDistributionsSection.find( - MultiColumnListRow({ content: including(fundName), isContainer: true }), - ) - : fundDistributionsSection.find(MultiColumnListRow({ rowIndexInParent: 'row-0' })); - const link = tableRow.find(MultiColumnListCell({ columnIndex })).find(Link()); + clickTheLinkInFundDetailsSection({ fundName, columnIndex = 0, rowIndex } = {}) { + let tableRow; + + if (fundName && rowIndex !== undefined) { + // When both fundName and rowIndex are provided, find the specific row by index + // and verify it contains the expected fund name + tableRow = fundDistributionsSection.find( + MultiColumnListRow({ rowIndexInParent: `row-${rowIndex}` }), + ); + } else if (fundName) { + // Find by fund name in the Fund column specifically to avoid ambiguity + tableRow = fundDistributionsSection + .find(MultiColumnListCell({ column: 'Fund', content: including(fundName) })) + .find(MultiColumnListRow({ isContainer: true })); + } else { + // Default to first row + tableRow = fundDistributionsSection.find(MultiColumnListRow({ rowIndexInParent: 'row-0' })); + } + const link = tableRow.find(MultiColumnListCell({ columnIndex })).find(Link()); cy.do([link.perform((el) => el.removeAttribute('target')), link.click()]); }, getInvoiceLinesViaApi(searchParams) { diff --git a/cypress/support/fragments/invoices/invoiceLineEditForm.js b/cypress/support/fragments/invoices/invoiceLineEditForm.js index 8a9f18fa21..90c8569bf5 100644 --- a/cypress/support/fragments/invoices/invoiceLineEditForm.js +++ b/cypress/support/fragments/invoices/invoiceLineEditForm.js @@ -99,6 +99,7 @@ export default { }, clickAddFundDistributionButton() { cy.do(Button('Add fund distribution').click()); + cy.wait(1000); }, fillInvoiceLineFields(invoiceLine) { if (invoiceLine.description) { @@ -142,7 +143,7 @@ export default { InteractorsTools.checkCalloutMessage(InvoiceStates.invoiceLineCreatedMessage); } // wait for changes to be applied - cy.wait(1000); + cy.wait(1500); }, checkSelectionOptions(selectionName, expectedOptions) { @@ -153,4 +154,30 @@ export default { selectSelectionOption(optionName) { cy.do([SelectionList().select(optionName)]); }, + + configureFundDistribution(index, config) { + const { fund, expenseClass, value } = config; + + if (fund) { + cy.do([ + Button({ id: `fundDistributions[${index}].fundId` }).click(), + SelectionList().filter(fund), + SelectionList().select(including(fund)), + ]); + cy.wait(1000); + } + + if (expenseClass) { + cy.do([ + Button({ id: `fundDistributions[${index}].expenseClassId` }).click(), + SelectionList().filter(expenseClass), + SelectionList().select(including(expenseClass)), + ]); + cy.wait(1000); + } + + if (value) { + cy.do(TextField({ name: `fundDistributions[${index}].value` }).fillIn(value)); + } + }, }; diff --git a/cypress/support/fragments/invoices/invoiceNewForm.js b/cypress/support/fragments/invoices/invoiceNewForm.js new file mode 100644 index 0000000000..f4e22fb75a --- /dev/null +++ b/cypress/support/fragments/invoices/invoiceNewForm.js @@ -0,0 +1,114 @@ +import { + Button, + Checkbox, + Select, + Selection, + SelectionList, + SelectionOption, + TextField, + SearchField, +} from '../../../../interactors'; +import InteractorsTools from '../../utils/interactorsTools'; +import FinanceHelper from '../finance/financeHelper'; +import InvoiceStates from './invoiceStates'; + +const saveAndClose = Button('Save & close'); +const invoiceDateField = TextField('Invoice date*'); +const vendorInvoiceNumberField = TextField('Vendor invoice number*'); +const batchGroupSelection = Selection('Batch group*'); +const invoicePaymentMethodSelect = Select({ id: 'invoice-payment-method' }); + +const searchOrganization = (vendorName) => { + cy.do(Button('Organization look-up').click()); + cy.wait(2000); + cy.expect(SearchField({ id: 'input-record-search' }).exists()); + cy.expect(SearchField({ id: 'input-record-search' }).has({ visible: true })); + cy.do([SearchField({ id: 'input-record-search' }).fillIn(vendorName), Button('Search').click()]); + FinanceHelper.selectFromResultsList(); +}; + +export default { + searchOrganization, + createInvoice(invoiceData) { + const { + status, + invoiceDate, + invoiceNumber, + vendorName, + accountingCode, + batchGroup, + paymentMethod = 'Cash', + exportToAccounting = false, + adjustment, + saveAndContinue = false, + } = invoiceData; + + cy.do([Selection('Status*').open(), SelectionList().select(status)]); + if (invoiceDate) { + cy.do(invoiceDateField.fillIn(invoiceDate)); + } + if (invoiceNumber) { + cy.do(vendorInvoiceNumberField.fillIn(invoiceNumber)); + } + searchOrganization(vendorName); + if (accountingCode) { + cy.do([ + Selection('Accounting code').open(), + SelectionList().select(`Default (${accountingCode})`), + ]); + } + cy.do([ + batchGroupSelection.open(), + SelectionList().select(batchGroup), + invoicePaymentMethodSelect.choose(paymentMethod), + ]); + if (exportToAccounting) { + cy.do(Checkbox('Export to accounting').click()); + } + if (adjustment) { + const { + description, + value, + type = '%', // '%' or '$' + prorate, + relationToTotal, + exportToAccounting: adjustmentExportToAccounting = false, + fund, + } = adjustment; + cy.do(Button({ id: 'adjustments-add-button' }).click()); + if (description) { + cy.do(TextField({ name: 'adjustments[0].description' }).fillIn(description)); + } + if (value) { + cy.do(TextField({ name: 'adjustments[0].value' }).fillIn(value)); + } + if (type) { + cy.do(Button(type).click()); + } + if (prorate) { + cy.do(Select({ name: 'adjustments[0].prorate' }).choose(prorate)); + } + if (relationToTotal) { + cy.do(Select({ name: 'adjustments[0].relationToTotal' }).choose(relationToTotal)); + } + if (adjustmentExportToAccounting) { + cy.do(Checkbox({ name: 'adjustments[0].exportToAccounting' }).click()); + } + if (fund) { + cy.do([ + Button({ id: 'adjustments[0].fundDistributions-add-button' }).click(), + Button({ id: 'adjustments[0].fundDistributions[0].fundId' }).click(), + SelectionOption(`${fund.name} (${fund.code})`).click(), + ]); + cy.wait(3000); + } + } + if (saveAndContinue) { + cy.do(Button('Save & keep editing').click()); + cy.wait(4000); + } else { + cy.do(saveAndClose.click()); + } + InteractorsTools.checkCalloutMessage(InvoiceStates.invoiceCreatedMessage); + }, +}; diff --git a/cypress/support/fragments/invoices/invoices.js b/cypress/support/fragments/invoices/invoices.js index f231184c6a..f1363d4d6e 100644 --- a/cypress/support/fragments/invoices/invoices.js +++ b/cypress/support/fragments/invoices/invoices.js @@ -138,6 +138,12 @@ export default { }) .then(({ body }) => body); }, + openNewInvoiceForm() { + cy.wait(4000); + cy.do(actionsButton.click()); + cy.expect(buttonNew.exists()); + cy.do(buttonNew.click()); + }, createInvoiceViaApi({ vendorId, accountingCode, diff --git a/cypress/support/fragments/orders/orderLineDetails.js b/cypress/support/fragments/orders/orderLineDetails.js index 6d606deca0..4f35755242 100644 --- a/cypress/support/fragments/orders/orderLineDetails.js +++ b/cypress/support/fragments/orders/orderLineDetails.js @@ -1,3 +1,4 @@ +import { including } from '@interactors/html'; import { Button, Checkbox, @@ -9,7 +10,7 @@ import { PaneHeader, Section, Warning, - including, + MultiColumnListHeader, } from '../../../../interactors'; import { DEFAULT_WAIT_TIME } from '../../constants'; import InteractorsTools from '../../utils/interactorsTools'; @@ -46,6 +47,7 @@ const routingListSection = orderLineDetailsSection.find(Section({ id: 'routing-l const routingListAccordionButton = '#accordion-toggle-button-routing-list'; const routingListBadgeSelector = '[class*="badge"]'; const routingListContainer = '#routing-list'; +const addRoutingListButton = Button('Add routing list'); export default { waitLoading(ms = DEFAULT_WAIT_TIME) { @@ -399,4 +401,114 @@ export default { checkNoRoutingListsText() { cy.get(routingListContainer).should('contain.text', 'No routing lists'); }, + openRoutingListsAccordion: () => { + cy.do(Button({ id: 'accordion-toggle-button-routing-list' }).click()); + }, + + addRoutingListButtonExist: () => { + cy.expect(routingListSection.find(addRoutingListButton).exists()); + }, + + addRoutingList: () => { + cy.do(routingListSection.find(addRoutingListButton).click()); + }, + + addRoutingListByActions: () => { + cy.do([routingListSection.find(actionsButton).click(), addRoutingListButton.click()]); + }, + + verifyAddingRoutingList: (name) => { + cy.expect(routingListSection.find(MultiColumnListCell(name)).exists()); + }, + + openRoutingList: (name) => { + cy.do(routingListSection.find(MultiColumnListCell(name)).find(Link()).click()); + }, + + addRoutingListIsDisabled() { + this.clickActionsButtonInRoutingList(); + cy.get('[class^=overlay-]') + .find('[data-test-routing-list-button="true"]') + .should('have.attr', 'disabled'); + }, + + clickActionsButtonInRoutingList() { + cy.do(routingListSection.find(actionsButton).click()); + }, + + verifyRoutingListAccordionRecordCount(expectedCount) { + cy.get(routingListContainer).find('[class*="mclRow-"]').should('have.length', expectedCount); + }, + + verifyRoutingListTableColumns() { + cy.expect(routingListSection.find(MultiColumnListHeader('Name')).exists()); + cy.expect(routingListSection.find(MultiColumnListHeader('Notes')).exists()); + cy.expect(routingListSection.find(MultiColumnListHeader('Users')).exists()); + }, + + verifyRoutingListNamesClickable() { + // Verify each routing list name is clickable (has link) + cy.get(routingListContainer) + .find('[class*="mclRow-"]') + .each(($row) => { + cy.wrap($row).find('a').should('exist'); + }); + }, + + verifyAddRoutingListInactive() { + // Open actions menu and verify "Add routing list" is inactive/disabled + this.clickActionsButtonInRoutingList(); + + cy.get('[class^=overlay-]') + .find('[data-test-routing-list-button="true"]') + .should('have.attr', 'disabled'); + }, + + checkAssignedUsersInRoutingList(usernames = [], options = {}) { + const { rowIndex = 0 } = options; + + // Always use index-based selection to avoid multiple element matching + const targetRow = routingListSection.find(MultiColumnListRow({ index: rowIndex })); + + if (usernames.length === 0) { + // Check for empty users column + cy.expect(targetRow.find(MultiColumnListCell({ column: 'Users' })).has({ content: '' })); + return; + } + + // For single user, check directly + if (usernames.length === 1) { + cy.expect( + targetRow + .find(MultiColumnListCell({ column: 'Users' })) + .has({ content: including(usernames[0]) }), + ); + return; + } + + // For multiple users, verify each username is present in the content + usernames.forEach((username) => { + cy.expect( + targetRow + .find(MultiColumnListCell({ column: 'Users' })) + .has({ content: including(username) }), + ); + }); + }, + + createRoutingListViaApi(userIds, routingListName, polId) { + return cy + .okapiRequest({ + method: 'POST', + path: 'orders/routing-lists', + body: { + userIds, + name: routingListName, + poLineId: polId, + }, + }) + .then((response) => { + return response.body.id; + }); + }, }; diff --git a/cypress/support/fragments/orders/orderLineEditForm.js b/cypress/support/fragments/orders/orderLineEditForm.js index ded36f80ad..ef99945502 100644 --- a/cypress/support/fragments/orders/orderLineEditForm.js +++ b/cypress/support/fragments/orders/orderLineEditForm.js @@ -216,6 +216,7 @@ export default { fillLocationDetails(locationDetails) { locationDetails.forEach((location, index) => { Object.entries(location).forEach(([key, value]) => { + cy.wait(1500); cy.do( locationSection.find(TextField({ name: `locations[${index}].${key}` })).fillIn(value), ); diff --git a/cypress/support/fragments/orders/orderLines.js b/cypress/support/fragments/orders/orderLines.js index cab4788b0a..676b52680e 100644 --- a/cypress/support/fragments/orders/orderLines.js +++ b/cypress/support/fragments/orders/orderLines.js @@ -38,10 +38,6 @@ import SelectInstanceModal from './modals/selectInstanceModal'; import SelectLocationModal from './modals/selectLocationModal'; import OrderLineDetails from './orderLineDetails'; -const addRoutingListButton = Section({ id: 'routing-list-menu-actions' }).find( - Button('Add routing list'), -); -const routingListSection = Section({ id: 'routing-list' }); const filtersPane = PaneContent({ id: 'order-lines-filters-pane-content' }); const receivedtitleDetails = PaneContent({ id: 'receiving-results-pane-content' }); const resetButton = Button('Reset all'); @@ -119,11 +115,6 @@ const poLineDetails = { receiptStatus: lineDetails.find(Select('Receipt status')), }; const selectLocationsModal = Modal('Select locations'); -const findUserButton = Button({ id: 'clickable-plugin-find-user' }); -const userSearchModal = Modal('Select User'); -const searchTextField = TextField({ type: 'search' }); -const firstSearchResult = MultiColumnListCell({ row: 0, columnIndex: 0 }); -const checkboxAll = Checkbox(); const submitOrderLine = () => { cy.wait(4000); const submitButton = Button('Submit'); @@ -288,14 +279,6 @@ export default { ); }, - closeRoutingListDetails: () => { - cy.do( - PaneHeader({ id: 'paneHeaderrouting-list-pane' }) - .find(Button({ icon: 'times' })) - .click(), - ); - }, - closePOLEditForm: () => { cy.do(Button({ icon: 'clickable-close-new-line-dialog' }).click()); }, @@ -2074,12 +2057,11 @@ export default { ]); }, setPhysicalQuantity(quantity) { - cy.do([quantityPhysicalLocationField.clear(), quantityPhysicalLocationField.fillIn(quantity)]); + cy.do(quantityPhysicalLocationField.fillIn(quantity)); cy.expect(quantityPhysicalLocationField.has({ value: quantity })); }, setElectronicQuantity(quantity) { - cy.wait(1500); - cy.do([quantityElectronicField.clear(), quantityElectronicField.fillIn(quantity)]); + cy.do(quantityElectronicField.fillIn(quantity)); cy.expect(quantityElectronicField.has({ value: quantity })); }, openCreateHoldingForLocation() { @@ -2765,112 +2747,6 @@ export default { cy.do(Section({ id: 'order-lines-filters-pane' }).find(Button('Orders')).click()); }, - openRoutingLists: () => { - cy.do(Button({ id: 'accordion-toggle-button-routing-list' }).click()); - }, - - addRoutingListExist: () => { - cy.expect(routingListSection.find(addRoutingListButton).exists()); - }, - - addRoutingList: () => { - cy.do(routingListSection.find(addRoutingListButton).click()); - }, - - addRoutingListByActions: () => { - cy.do([routingListSection.find(actionsButton).click(), addRoutingListButton.click()]); - }, - - addRoutingListAbsent: () => { - cy.expect(routingListSection.find(addRoutingListButton).absent()); - }, - - fillInRoutingListInfoAndSave: (name) => { - cy.do([TextField({ id: 'input-routing-list-name' }).fillIn(name), saveAndCloseButton.click()]); - }, - - fillInRoutingListInfoWithNotesAndSave: (name, notes) => { - cy.do([ - TextField({ id: 'input-routing-list-name' }).fillIn(name), - TextArea({ name: 'notes' }).fillIn(notes), - saveAndCloseButton.click(), - ]); - }, - - varifyAddingRoutingList: (name) => { - cy.expect(routingListSection.find(MultiColumnListCell(name)).exists()); - }, - - openRoutingList: (name) => { - cy.do(routingListSection.find(MultiColumnListCell(name)).find(Link()).click()); - }, - - checkRoutingListNameDetails(name) { - cy.expect(KeyValue('Name').has({ value: name })); - }, - - checkRoutingListNotesDetails(notes) { - cy.expect(KeyValue('Notes').has({ value: notes })); - }, - - addRoutingListIsDisabled() { - cy.expect(addRoutingListButton.has({ disabled: true })); - }, - - clickActionsButtonInRoutingList() { - cy.do(routingListSection.find(actionsButton).click()); - }, - - deleteRoutingList() { - cy.do([ - actionsButton.click(), - Button('Delete').click(), - Modal('Delete Routing list') - .find(Button({ id: 'clickable-delete-routing-list-confirmation-confirm' })) - .click(), - ]); - }, - - editRoutingList() { - cy.do([actionsButton.click(), Button('Edit').click()]); - }, - - addUserToRoutingList() { - cy.do(Button({ id: 'clickable-plugin-find-user' }).click()); - }, - - unAssignAllUsers() { - cy.do([ - Button({ id: 'clickable-remove-all-permissions' }).click(), - Modal('Unassign all users').find(Button('Yes')).click(), - ]); - }, - - deleteUserFromRoutingList(user) { - cy.do(Button({ id: `clickable-remove-user-${user}` }).click()); - }, - - assignUser: (userName) => { - cy.do([ - findUserButton.click(), - userSearchModal.find(searchTextField).fillIn(userName), - searchButton.click(), - ]); - cy.wait(4000); - cy.do([ - userSearchModal.find(firstSearchResult).find(checkboxAll).click(), - userSearchModal.find(Button('Save')).click(), - ]); - }, - - checkUserIsAdded(user) { - cy.expect(MultiColumnListCell(including(user)).exists()); - }, - - checkUserIsAbsent(user) { - cy.expect(MultiColumnListCell(including(user)).absent()); - }, - checkBinderyActiveStatus(status) { cy.get('label:contains("Bindery active")').within(() => { cy.get('input[type="checkbox"]').should('have.prop', 'checked', status); @@ -2925,30 +2801,6 @@ export default { }); }, - createRoutingListViaApi(userIds, routingListName, polId) { - return cy.okapiRequest({ - method: 'POST', - path: 'orders/routing-lists', - body: { - userIds, - name: routingListName, - poLineId: polId, - }, - }); - }, - - fillInRoutingListInfo: (name) => { - cy.do(TextField({ id: 'input-routing-list-name' }).fillIn(name)); - }, - - saveRoutingList: () => { - cy.do(saveAndCloseButton.click()); - }, - - unAssignUserFromRoutingList(userID) { - cy.do(Button({ id: `clickable-remove-user-${userID}` }).click()); - }, - fillCostDetailsForElectronicOrderType(electronicPrice, quantity) { cy.do([ electronicUnitPriceTextField.fillIn(electronicPrice), diff --git a/cypress/support/fragments/orders/routingLists/newRoutingList.js b/cypress/support/fragments/orders/routingLists/newRoutingList.js new file mode 100644 index 0000000000..df7d21fd64 --- /dev/null +++ b/cypress/support/fragments/orders/routingLists/newRoutingList.js @@ -0,0 +1,83 @@ +import { + Button, + Checkbox, + including, + Modal, + MultiColumnListCell, + TextArea, + TextField, +} from '../../../../../interactors'; + +const saveAndCloseButton = Button('Save & close'); +const searchButton = Button('Search'); +const findUserButton = Button({ id: 'clickable-plugin-find-user' }); +const userSearchModal = Modal('Select User'); +const searchTextField = TextField({ type: 'search' }); +const firstSearchResult = MultiColumnListCell({ row: 0, columnIndex: 0 }); +const checkboxAll = Checkbox(); + +export default { + fillInRoutingListInfoAndSave: (name) => { + cy.do([TextField({ id: 'input-routing-list-name' }).fillIn(name), saveAndCloseButton.click()]); + }, + + fillInRoutingListAndCancel: (name) => { + cy.do([ + TextField({ id: 'input-routing-list-name' }).fillIn(name), + Button('Cancel').click(), + Modal('Are you sure?').find(Button('Close without saving')).click(), + ]); + }, + + fillInRoutingListInfoWithNotesAndSave: (name, notes) => { + cy.do([ + TextField({ id: 'input-routing-list-name' }).fillIn(name), + TextArea({ name: 'notes' }).fillIn(notes), + saveAndCloseButton.click(), + ]); + }, + + addUserToRoutingList() { + cy.do(Button({ id: 'clickable-plugin-find-user' }).click()); + }, + + unAssignAllUsers() { + cy.do([ + Button({ id: 'clickable-remove-all-permissions' }).click(), + Modal('Unassign all users').find(Button('Yes')).click(), + ]); + }, + + deleteUserFromRoutingList(user) { + cy.do(Button({ id: `clickable-remove-user-${user}` }).click()); + }, + + assignUser: (userName) => { + cy.do([ + findUserButton.click(), + userSearchModal.find(searchTextField).fillIn(userName), + searchButton.click(), + ]); + cy.wait(4000); + cy.do([ + userSearchModal.find(firstSearchResult).find(checkboxAll).click(), + userSearchModal.find(Button('Save')).click(), + ]); + }, + + checkUserIsAdded(user) { + cy.expect(MultiColumnListCell(including(user)).exists()); + }, + + checkUserIsAbsent(user) { + cy.expect(MultiColumnListCell(including(user)).absent()); + }, + + fillInRoutingListInfo: (name) => { + cy.do(TextField({ id: 'input-routing-list-name' }).fillIn(name)); + }, + + saveRoutingList: () => { + cy.do(saveAndCloseButton.click()); + }, +}; diff --git a/cypress/support/fragments/orders/routingLists/routingListDetails.js b/cypress/support/fragments/orders/routingLists/routingListDetails.js new file mode 100644 index 0000000000..f85764a8e1 --- /dev/null +++ b/cypress/support/fragments/orders/routingLists/routingListDetails.js @@ -0,0 +1,52 @@ +import { Accordion, Button, KeyValue, Modal, PaneHeader, Pane } from '../../../../../interactors'; + +const actionsButton = Button('Actions'); + +export default { + closeRoutingListDetails: () => { + cy.wait(1500); + cy.do( + PaneHeader({ id: 'paneHeaderrouting-list-pane' }) + .find(Button({ icon: 'times' })) + .click(), + ); + cy.wait(1500); + cy.expect(Pane({ id: 'routing-list-pane' }).absent()); + }, + + checkRoutingListNameDetails(name) { + cy.expect([ + KeyValue('Name').has({ value: name }), + actionsButton.exists(), + Button('Collapse all').exists(), + Accordion('General information').has({ open: true }), + Accordion('Users').has({ open: true }), + ]); + }, + + checkRoutingListNotesDetails(notes) { + cy.expect(KeyValue('Notes').has({ value: notes })); + }, + + editRoutingList() { + cy.do([actionsButton.click(), Button('Edit').click()]); + }, + + deleteRoutingList() { + cy.do([ + actionsButton.click(), + Button('Delete').click(), + Modal('Delete Routing list') + .find(Button({ id: 'clickable-delete-routing-list-confirmation-confirm' })) + .click(), + ]); + }, + + deleteRoutingListViaApi(id) { + return cy.okapiRequest({ + method: 'DELETE', + path: `orders/routing-lists/${id}`, + isDefaultSearchParamsRequired: false, + }); + }, +}; diff --git a/cypress/support/fragments/orders/routingLists/routingListEditForm.js b/cypress/support/fragments/orders/routingLists/routingListEditForm.js new file mode 100644 index 0000000000..4a12fd01a4 --- /dev/null +++ b/cypress/support/fragments/orders/routingLists/routingListEditForm.js @@ -0,0 +1,89 @@ +import { + Button, + including, + Modal, + MultiColumnListCell, + TextArea, + TextField, + Checkbox, +} from '../../../../../interactors'; + +const saveAndCloseButton = Button('Save & close'); +const searchButton = Button('Search'); +const findUserButton = Button({ id: 'clickable-plugin-find-user' }); +const userSearchModal = Modal('Select User'); +const searchTextField = TextField({ type: 'search' }); +const firstSearchResult = MultiColumnListCell({ row: 0, columnIndex: 0 }); +const checkboxAll = Checkbox(); + +export default { + fillInRoutingListInfoAndSave: (name) => { + cy.wait(1500); + cy.do([TextField({ id: 'input-routing-list-name' }).fillIn(name), saveAndCloseButton.click()]); + }, + + fillInRoutingListInfoWithNotesAndSave: (name, notes) => { + cy.do([ + TextField({ id: 'input-routing-list-name' }).fillIn(name), + TextArea({ name: 'notes' }).fillIn(notes), + saveAndCloseButton.click(), + ]); + }, + + verifyNameFieldWithError(message) { + cy.wait(1500); + cy.expect(TextField('Name*').has({ error: including(message) })); + }, + + addUserToRoutingList() { + cy.do(Button({ id: 'clickable-plugin-find-user' }).click()); + }, + + unAssignAllUsers() { + cy.do([ + Button({ id: 'clickable-remove-all-permissions' }).click(), + Modal('Unassign all users').find(Button('Yes')).click(), + ]); + }, + + deleteUserFromRoutingList(user) { + cy.do(Button({ id: `clickable-remove-user-${user}` }).click()); + }, + + assignUser: (userName) => { + cy.wait(1500); + cy.do([ + findUserButton.click(), + userSearchModal.find(searchTextField).fillIn(userName), + searchButton.click(), + ]); + cy.wait(4000); + cy.do([ + userSearchModal.find(firstSearchResult).find(checkboxAll).click(), + userSearchModal.find(Button('Save')).click(), + ]); + }, + + checkUserIsAdded(user) { + cy.expect(MultiColumnListCell(including(user)).exists()); + }, + + checkUserIsAbsent(user) { + cy.expect(MultiColumnListCell(including(user)).absent()); + }, + + fillInRoutingListInfo: (name) => { + cy.do(TextField({ id: 'input-routing-list-name' }).fillIn(name)); + }, + + save: () => { + cy.wait(1500); + cy.do(saveAndCloseButton.click()); + }, + + unAssignUserFromRoutingList(userID) { + cy.wait(1500); + cy.do(Button({ id: `clickable-remove-user-${userID}` }).click()); + cy.wait(1500); + }, +}; diff --git a/cypress/support/fragments/receiving/receiving.js b/cypress/support/fragments/receiving/receiving.js index 65b73ea716..17109af535 100644 --- a/cypress/support/fragments/receiving/receiving.js +++ b/cypress/support/fragments/receiving/receiving.js @@ -42,6 +42,8 @@ const filterOpenReceiving = () => { cy.do(Checkbox({ id: 'clickable-filter-purchaseOrder.workflowStatus-open' }).click()); }; const resetButton = Button('Reset all'); +const routingListSection = rootsection.find(Section({ id: 'routing-list' })); +const addRoutingListButton = routingListSection.find(Button('Add routing list')); export default { waitLoading(ms = DEFAULT_WAIT_TIME) { @@ -66,6 +68,25 @@ export default { return ReceivingDetails; }, + selectFromResultsListByPolNumber(polNumber) { + cy.do( + receivingResultsSection + .find(MultiColumnListCell({ content: polNumber })) + .perform((element) => { + const rowIndex = element.closest('[data-row-index]').getAttribute('data-row-index'); + + cy.do( + receivingResultsSection + .find(MultiColumnListRow({ indexRow: rowIndex })) + .find(Link()) + .click(), + ); + }), + ); + ReceivingDetails.waitLoading(); + + return ReceivingDetails; + }, expandActionsDropdown() { cy.do(receivingResultsSection.find(actionsButton).click()); }, @@ -496,16 +517,79 @@ export default { cy.expect(openedRequestModal.absent()); }, - varifyAddingRoutingList: (name) => { + openRoutingList: (name) => { + cy.do(routingListSection.find(MultiColumnListCell(name)).find(Link()).click()); + }, + + verifyRoutingListExists: (name) => { cy.expect(Section({ id: 'routing-list' }).find(MultiColumnListCell(name)).exists()); }, - openRoutingListsSection: () => { + verifyRoutingListAbsent: (name) => { + cy.expect(Section({ id: 'routing-list' }).find(MultiColumnListCell(name)).absent()); + }, + + openRoutingListsAccordionSection: () => { cy.do(Button({ id: 'accordion-toggle-button-routing-list' }).click()); }, - addRoutingListExist: () => { - cy.expect(Button('Add routing list').exists()); + addRoutingListIsDisabled() { + cy.do(routingListSection.find(actionsButton).click()); + cy.get('[class^=overlay-]') + .find('[data-test-routing-list-button="true"]') + .should('have.attr', 'disabled'); + }, + + addRoutingListButtonExist: () => { + cy.expect([addRoutingListButton.exists(), addRoutingListButton.has({ disabled: false })]); + }, + + clickAddRoutingListButton: () => { + cy.do(addRoutingListButton.click()); + }, + + addRoutingListByActions: () => { + cy.do([routingListSection.find(actionsButton).click(), Button('Add routing list').click()]); + }, + + verifyRoutingListWarning() { + cy.expect(rootsection.find(HTML(including('This title has routing.'))).exists()); + }, + + checkAssignedUsersInRoutingList(usernames = [], options = {}) { + const { rowIndex = 0 } = options; + + // Always use index-based selection to avoid multiple element matching + const targetRow = routingListSection.find(MultiColumnListRow({ index: rowIndex })); + + if (usernames.length === 0) { + // Check for empty users column + cy.expect(targetRow.find(MultiColumnListCell({ column: 'Users' })).has({ content: '' })); + return; + } + + // For single user, check directly + if (usernames.length === 1) { + cy.expect( + targetRow + .find(MultiColumnListCell({ column: 'Users' })) + .has({ content: including(usernames[0]) }), + ); + return; + } + + // For multiple users, verify each username is present in the content + usernames.forEach((username) => { + cy.expect( + targetRow + .find(MultiColumnListCell({ column: 'Users' })) + .has({ content: including(username) }), + ); + }); + }, + + checkNoRoutingListsText() { + cy.get('#routing-list').should('contain.text', 'No routing lists'); }, getPiecesViaApi(poLineId) { diff --git a/cypress/support/fragments/settings/finance/settingsFinance.js b/cypress/support/fragments/settings/finance/settingsFinance.js index dd928e7a8c..e81dfb5891 100644 --- a/cypress/support/fragments/settings/finance/settingsFinance.js +++ b/cypress/support/fragments/settings/finance/settingsFinance.js @@ -231,7 +231,7 @@ export default { }, checkExportedFundAndExpenseClassFile(fileName, expectedRows) { - cy.wait(3000); + cy.wait(6000); cy.readFile(`cypress/downloads/${fileName}`).then((content) => { const lines = content.trim().split(/\r?\n/); diff --git a/cypress/support/fragments/settings/inventory/instances/subjectSources.js b/cypress/support/fragments/settings/inventory/instances/subjectSources.js index e4a59f5357..3a2288e979 100644 --- a/cypress/support/fragments/settings/inventory/instances/subjectSources.js +++ b/cypress/support/fragments/settings/inventory/instances/subjectSources.js @@ -1,15 +1,22 @@ +import { including } from '@interactors/html'; import { Button, EditableListRow, - including, + Modal, MultiColumnListCell, MultiColumnListHeader, Pane, + TextField, } from '../../../../../../interactors'; import { REQUEST_METHOD } from '../../../../constants'; import DateTools from '../../../../utils/dateTools'; +import DeleteCancelReason from '../../../consortium-manager/modal/delete-cancel-reason'; const rootPane = Pane('Subject sources'); +const modalWithErrorMessage = Modal('Cannot delete Subject source'); +const newButton = Button('+ New'); +const saveButton = Button('Save'); +const cancelButton = Button('Cancel'); const COLUMN_INDEX = { NAME: 0, @@ -118,4 +125,88 @@ export default { cy.wrap($cell).invoke('text').should('not.eq', name); }); }, + + deleteSubjectSource(name) { + const actionsCell = MultiColumnListCell({ columnIndex: COLUMN_INDEX.ACTIONS }); + const rowSelector = MultiColumnListCell({ content: name }); + cy.do( + rowSelector.perform((element) => { + const rowIndex = getRowIndex(element); + const row = EditableListRow({ index: rowIndex }); + + cy.do( + row + .find(actionsCell) + .find(Button({ icon: ACTION_BUTTONS.TRASH })) + .click(), + ); + }), + ); + }, + + create(value, rowIndex = 0) { + cy.do([newButton.click(), TextField({ name: `items[${rowIndex}].name` }).fillIn(value)]); + }, + + editSubjectSourceName(oldValue, newValue) { + const actionsCell = MultiColumnListCell({ columnIndex: COLUMN_INDEX.ACTIONS }); + const rowSelector = MultiColumnListCell({ content: oldValue }); + cy.do( + rowSelector.perform((element) => { + const rowIndex = getRowIndex(element); + const row = EditableListRow({ index: rowIndex }); + + cy.do([ + row + .find(actionsCell) + .find(Button({ icon: ACTION_BUTTONS.EDIT })) + .click(), + TextField({ name: `items[${rowIndex}].name` }).fillIn(newValue), + ]); + }), + ); + }, + + validateButtonsState({ cancel = 'enabled', save = 'enabled' } = {}) { + const cancelButtonState = cancel === 'enabled' ? { disabled: false } : { disabled: true }; + const saveButtonState = save === 'enabled' ? { disabled: false } : { disabled: true }; + + cy.expect([saveButton.has(saveButtonState), cancelButton.has(cancelButtonState)]); + }, + + confirmDeletionOfSubjectSource(name) { + DeleteCancelReason.waitLoadingDeleteModal('Subject source', name); + DeleteCancelReason.clickDelete(); + }, + + verifySubjectSourceCannotBeDeleted() { + cy.expect( + modalWithErrorMessage.has({ + content: including( + 'This Subject source cannot be deleted, as it is in use by one or more records.', + ), + }), + ); + cy.do(Button('Okay').click()); + cy.expect(modalWithErrorMessage.absent()); + }, + + validateNameFieldWithError(message) { + cy.get('#controlled-vocab-pane') + .find('input[name*="items["][name*="].name"]') + .should('exist') + .then(($inputs) => { + const nameAttr = $inputs.first().attr('name'); + const indexMatch = nameAttr.match(/items\[(\d+)\]\.name/); + if (indexMatch) { + const rowIndex = parseInt(indexMatch[1], 10); + cy.expect([ + TextField({ name: `items[${rowIndex}].name` }).has({ error: message }), + cancelButton.has({ disabled: false }), + saveButton.has({ disabled: true }), + ]); + } + }); + cy.wait(1000); + }, }; diff --git a/cypress/support/fragments/settings/inventory/instances/subjectTypes.js b/cypress/support/fragments/settings/inventory/instances/subjectTypes.js index b33acf7ccb..1349973a84 100644 --- a/cypress/support/fragments/settings/inventory/instances/subjectTypes.js +++ b/cypress/support/fragments/settings/inventory/instances/subjectTypes.js @@ -2,14 +2,21 @@ import { including } from '@interactors/html'; import { Button, EditableListRow, + Modal, MultiColumnListCell, MultiColumnListHeader, Pane, + TextField, } from '../../../../../../interactors'; import { REQUEST_METHOD } from '../../../../constants'; import DateTools from '../../../../utils/dateTools'; +import DeleteCancelReason from '../../../consortium-manager/modal/delete-cancel-reason'; const rootPane = Pane('Subject types'); +const modalWithErrorMessage = Modal('Cannot delete Subject type'); +const newButton = Button('+ New'); +const saveButton = Button('Save'); +const cancelButton = Button('Cancel'); const COLUMN_INDEX = { NAME: 0, @@ -127,4 +134,81 @@ export default { }), ); }, + + createSubjectType(value, rowIndex = 0) { + cy.do([newButton.click(), TextField({ name: `items[${rowIndex}].name` }).fillIn(value)]); + }, + + deleteSubjectType(name) { + const actionsCell = MultiColumnListCell({ columnIndex: COLUMN_INDEX.ACTIONS }); + const rowSelector = MultiColumnListCell({ content: name }); + cy.do( + rowSelector.perform((element) => { + const rowIndex = getRowIndex(element); + const row = EditableListRow({ index: rowIndex }); + + cy.do( + row + .find(actionsCell) + .find(Button({ icon: ACTION_BUTTONS.TRASH })) + .click(), + ); + }), + ); + }, + + editSubjectTypeName(oldValue, newValue) { + const actionsCell = MultiColumnListCell({ columnIndex: COLUMN_INDEX.ACTIONS }); + const rowSelector = MultiColumnListCell({ content: oldValue }); + cy.do( + rowSelector.perform((element) => { + const rowIndex = getRowIndex(element); + const row = EditableListRow({ index: rowIndex }); + + cy.do([ + row + .find(actionsCell) + .find(Button({ icon: ACTION_BUTTONS.EDIT })) + .click(), + TextField({ name: `items[${rowIndex}].name` }).fillIn(newValue), + ]); + }), + ); + }, + + confirmDeletionOfSubjectType(name) { + DeleteCancelReason.waitLoadingDeleteModal('Subject type', name); + DeleteCancelReason.clickDelete(); + }, + + verifySubjectTypeCannotBeDeleted() { + cy.expect( + modalWithErrorMessage.has({ + content: including( + 'This Subject type cannot be deleted, as it is in use by one or more records.', + ), + }), + ); + cy.do(Button('Okay').click()); + cy.expect(modalWithErrorMessage.absent()); + }, + + validateNameFieldWithError(message) { + cy.get('#controlled-vocab-pane') + .find('input[name*="items["][name*="].name"]') + .should('exist') + .then(($inputs) => { + const nameAttr = $inputs.first().attr('name'); + const indexMatch = nameAttr.match(/items\[(\d+)\]\.name/); + if (indexMatch) { + const rowIndex = parseInt(indexMatch[1], 10); + cy.expect([ + TextField({ name: `items[${rowIndex}].name` }).has({ error: message }), + cancelButton.has({ disabled: false }), + saveButton.has({ disabled: true }), + ]); + } + }); + cy.wait(1000); + }, }; From 7a986ebf133a1c93c71f34bfc2e4bb332d0e68db Mon Sep 17 00:00:00 2001 From: Tetiana_Paranich Date: Thu, 26 Feb 2026 20:03:14 +0200 Subject: [PATCH 2/3] refactor tests --- ...rce-shared-to-all-affiliated-tenants.cy.js | 2 + ...dings-with-linked-central-and-member.cy.js | 359 +++++++-------- ...details-on-shadow-instance-on-member.cy.js | 2 - ...stance-from-member-on-another-member.cy.js | 4 +- ...oldings-are-added-to-shared-instance.cy.js | 2 +- ...ces-without-local-holdings-on-member.cy.js | 2 - ...ter-sharing-local-instance-on-member.cy.js | 24 +- ...ance-is-marked-as-deleted-on-central.cy.js | 1 - ...it-file-and-reimport-to-update-items.cy.js | 2 + ...ary-table-with-create-update-actions.cy.js | 1 + ...ctions-for-instance-holding-and-item.cy.js | 2 + ...iles-import-and-view-logs-permission.cy.js | 2 +- ...xpense-class-active-without-rollover.cy.js | 66 ++- ...one-without-rollover-with-ex-classes.cy.js | 286 +++++++----- ...xpense-classes-none-without-rollover.cy.js | 71 ++- .../expense-classes-none.cy.js | 287 +++++++----- .../export-settings-active-status.cy.js | 268 +++++++----- ...ettings-all-statuses-with-ex-classes.cy.js | 414 +++++++++++------- ...ses-without-rollover-with-ex-classes.cy.js | 210 +++++---- .../export-settings-all-statuses.cy.js | 206 +++++---- ...atus-with-rollover-and-2-exp-classes.cy.js | 408 ++++++++++------- ...-without-rollover-with-2-exp-classes.cy.js | 210 +++++---- .../export-settings-inactive-status.cy.js | 168 +++---- ...ngs-no-fiscal-year-each-class-status.cy.js | 278 +++++++----- ...order-format-from-pe-mix-to-physical.cy.js | 2 +- .../create-new-routing-list-from-poline.cy.js | 2 +- ...ignments-in-routing-list-from-orders.cy.js | 274 ++++++------ .../support/fragments/finance/funds/funds.js | 19 + .../fragments/finance/ledgers/ledgers.js | 50 ++- .../fragments/inventory/holdingsRecordView.js | 35 ++ .../fragments/inventory/instanceRecordView.js | 19 +- .../routingLists/routingListEditForm.js | 1 + .../support/fragments/receiving/receiving.js | 6 +- .../consortium-manager/consortium-manager.js | 33 ++ 34 files changed, 2158 insertions(+), 1558 deletions(-) diff --git a/cypress/e2e/consortia/consortium-manager/manage-shared-settings/manage-shared-subject-sources/user-is-able-add-delete-subject-source-shared-to-all-affiliated-tenants.cy.js b/cypress/e2e/consortia/consortium-manager/manage-shared-settings/manage-shared-subject-sources/user-is-able-add-delete-subject-source-shared-to-all-affiliated-tenants.cy.js index 4288c1586b..d92c6c75b5 100644 --- a/cypress/e2e/consortia/consortium-manager/manage-shared-settings/manage-shared-subject-sources/user-is-able-add-delete-subject-source-shared-to-all-affiliated-tenants.cy.js +++ b/cypress/e2e/consortia/consortium-manager/manage-shared-settings/manage-shared-subject-sources/user-is-able-add-delete-subject-source-shared-to-all-affiliated-tenants.cy.js @@ -112,8 +112,10 @@ describe('Consortia', () => { ConsortiumSubjectSources.deleteSubjectSourceByName(subjectSourceNames.name1); ConsortiumSubjectSources.cancelDelitionOfSubjectSource(subjectSourceNames.name1); + cy.wait(3000); ConsortiumSubjectSources.verifySharedSubjectSourceExists({ name: subjectSourceNames.name1, + user: 'No value set-', actions: ['edit', 'trash'], }); ConsortiumSubjectSources.deleteSubjectSourceByName(subjectSourceNames.name1); diff --git a/cypress/e2e/consortia/inventory/holdings/receiving-history-accordion-for-shared-holdings-with-linked-central-and-member.cy.js b/cypress/e2e/consortia/inventory/holdings/receiving-history-accordion-for-shared-holdings-with-linked-central-and-member.cy.js index 5abfe8d1f7..1ec408e1ea 100644 --- a/cypress/e2e/consortia/inventory/holdings/receiving-history-accordion-for-shared-holdings-with-linked-central-and-member.cy.js +++ b/cypress/e2e/consortia/inventory/holdings/receiving-history-accordion-for-shared-holdings-with-linked-central-and-member.cy.js @@ -3,7 +3,6 @@ import { APPLICATION_NAMES, LOCATION_NAMES, ORDER_STATUSES, - VENDOR_NAMES, } from '../../../../support/constants'; import Affiliations, { tenantNames } from '../../../../support/dictionary/affiliations'; import Permissions from '../../../../support/dictionary/permissions'; @@ -17,6 +16,7 @@ import BasicOrderLine from '../../../../support/fragments/orders/basicOrderLine' import NewOrder from '../../../../support/fragments/orders/newOrder'; import OrderLines from '../../../../support/fragments/orders/orderLines'; import Orders from '../../../../support/fragments/orders/orders'; +import NewOrganization from '../../../../support/fragments/organizations/newOrganization'; import Organizations from '../../../../support/fragments/organizations/organizations'; import Receiving from '../../../../support/fragments/receiving/receiving'; import ConsortiumManager from '../../../../support/fragments/settings/consortium-manager/consortium-manager'; @@ -31,6 +31,8 @@ describe('Inventory', () => { holdings: {}, instance: {}, user: {}, + memberVendor: { ...NewOrganization.defaultUiOrganizations }, + centralVendor: { ...NewOrganization.defaultUiOrganizations }, }; const userPermissions = [ Permissions.inventoryAll.gui, @@ -47,129 +49,6 @@ describe('Inventory', () => { orderLine: {}, piece: {}, }; - // create order for central tenant - const createOrderLineOnCentral = (purchaseOrderId, vendorId, acquisitionMethodId) => { - return { - ...BasicOrderLine.defaultOrderLine, - purchaseOrderId, - source: 'User', - claimingActive: false, - claimingInterval: 45, - cost: { - currency: 'USD', - discountType: 'percentage', - discount: 10, - listUnitPrice: 10, - quantityPhysical: 1, - }, - physical: { - createInventory: 'Instance, Holding', - materialSupplier: vendorId, - }, - locations: [ - { - tenantId: 'college', - holdingId: testData.holdings.holdingId, - quantityPhysical: 1, - }, - ], - isPackage: false, - checkinItems: false, - suppressInstanceFromDiscovery: false, - instanceId: testData.instance.instanceId, - titleOrPackage: testData.instance.instanceTitle, - acquisitionMethod: acquisitionMethodId, - orderFormat: 'Physical Resource', - }; - }; - const createOrderWithLineOnCentral = (vendorId, acquisitionMethodId) => { - const order = { - ...NewOrder.getDefaultOrder({ vendorId }), - orderType: 'One-Time', - reEncumber: true, - approved: true, - }; - - return Orders.createOrderViaApi(order).then((orderResponse) => { - centralData.order.id = orderResponse.id; - const orderLine = createOrderLineOnCentral( - orderResponse.id, - orderResponse.vendorId, - acquisitionMethodId, - ); - - return OrderLines.createOrderLineViaApi(orderLine).then((orderLineResponse) => { - centralData.orderLine = orderLineResponse; - - return Orders.updateOrderViaApi({ - ...orderResponse, - workflowStatus: ORDER_STATUSES.OPEN, - }); - }); - }); - }; - - // create order for member tenant - const createOrderLineOnMember = (purchaseOrderId, vendorId, acquisitionMethodId) => { - return { - ...BasicOrderLine.defaultOrderLine, - purchaseOrderId, - source: 'User', - claimingActive: false, - claimingInterval: 45, - cost: { - currency: 'USD', - discountType: 'percentage', - discount: 10, - listUnitPrice: 10, - quantityPhysical: 1, - }, - physical: { - createInventory: 'Instance, Holding', - materialSupplier: vendorId, - }, - locations: [ - { - holdingId: testData.holdings.holdingId, - quantityPhysical: 1, - }, - ], - isPackage: false, - checkinItems: false, - suppressInstanceFromDiscovery: false, - instanceId: testData.instance.instanceId, - titleOrPackage: testData.instance.instanceTitle, - acquisitionMethod: acquisitionMethodId, - orderFormat: 'Physical Resource', - }; - }; - const createOrderWithLineOnMember = (vendorId, acquisitionMethodId) => { - const order = { - ...NewOrder.getDefaultOrder({ vendorId }), - orderType: 'One-Time', - reEncumber: true, - approved: true, - }; - - return Orders.createOrderViaApi(order).then((orderResponse) => { - memberData.order.id = orderResponse.id; - const orderLine = createOrderLineOnMember( - orderResponse.id, - orderResponse.vendorId, - acquisitionMethodId, - testData.holdings.location.id, - ); - - return OrderLines.createOrderLineViaApi(orderLine).then((orderLineResponse) => { - memberData.orderLine = orderLineResponse; - - return Orders.updateOrderViaApi({ - ...orderResponse, - workflowStatus: ORDER_STATUSES.OPEN, - }); - }); - }); - }; before('Create test data', () => { cy.getAdminToken(); @@ -180,93 +59,179 @@ describe('Inventory', () => { testData.instance = instanceData; }) .then(() => { - cy.setTenant(Affiliations.College); - cy.getLocations({ query: `name="${LOCATION_NAMES.DCB_UI}"` }).then((res) => { - testData.holdings.location = res; - }); - InventoryHoldings.getHoldingsFolioSource().then((folioSource) => { - testData.holdings.sourceId = folioSource.id; - }); - cy.getAcquisitionMethodsApi({ - query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, - }).then((params) => { - memberData.acquisitionMethodId = params.body.acquisitionMethods[0].id; + cy.withinTenant(Affiliations.College, () => { + cy.getLocations({ query: `name="${LOCATION_NAMES.DCB_UI}"` }) + .then((res) => { + testData.holdings.location = res; + + InventoryHoldings.getHoldingsFolioSource().then((folioSource) => { + // create holding on member tenant + InventoryHoldings.createHoldingRecordViaApi({ + instanceId: testData.instance.instanceId, + permanentLocationId: testData.holdings.location.id, + sourceId: folioSource.id, + }).then((resp) => { + testData.holdings.holdingId = resp.id; + }); + }); + }) + .then(() => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((params) => { + Organizations.createOrganizationViaApi(testData.memberVendor).then( + (orgResponse) => { + memberData.vendorId = orgResponse; + + const memberOrder = { + ...NewOrder.getDefaultOrder({ vendorId: orgResponse }), + orderType: 'One-Time', + approved: true, + }; + const memberOrderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + currency: 'USD', + discountType: 'percentage', + discount: 10, + listUnitPrice: 10, + quantityPhysical: 1, + }, + physical: { + createInventory: 'Instance, Holding', + materialSupplier: orgResponse, + }, + locations: [ + { + holdingId: testData.holdings.holdingId, + quantityPhysical: 1, + }, + ], + checkinItems: false, + instanceId: testData.instance.instanceId, + titleOrPackage: testData.instance.instanceTitle, + acquisitionMethod: params.body.acquisitionMethods[0].id, + orderFormat: 'Physical Resource', + }; + + // create order with order line on member tenant + Orders.createOrderViaApi(memberOrder) + .then((orderResponse) => { + memberData.order.id = orderResponse.id; + memberOrderLine.purchaseOrderId = orderResponse.id; + + OrderLines.createOrderLineViaApi(memberOrderLine).then( + (orderLineResponse) => { + memberData.orderLine = orderLineResponse; + + Orders.updateOrderViaApi({ + ...orderResponse, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }, + ); + }) + .then(() => { + // receive piece for the order line on member tenant + return cy.wait(3000).then(() => { + return Receiving.getPiecesViaApi(memberData.orderLine.id).then( + (pieces) => { + return Receiving.receivePieceViaApi({ + poLineId: memberData.orderLine.id, + tenantId: Affiliations.College, + pieces: [ + { + id: pieces[0].id, + displayOnHolding: true, + }, + ], + }); + }, + ); + }); + }); + }, + ); + }); + }); }); - Organizations.getOrganizationViaApi({ query: `name="${VENDOR_NAMES.MOSAIC}"` }).then( - (organization) => { - memberData.vendorId = organization.id; - }, - ); - }) - .then(() => { - // create holding on member tenant - InventoryHoldings.createHoldingRecordViaApi({ - instanceId: testData.instance.instanceId, - permanentLocationId: testData.holdings.location.id, - sourceId: testData.holdings.sourceId, - }).then((resp) => { - testData.holdings.holdingId = resp.id; + }); - // create order with order line on member tenant - createOrderWithLineOnMember(memberData.vendorId, memberData.acquisitionMethodId).then( - () => { - // receive piece for the order line on member tenant + cy.resetTenant(); + cy.getAdminToken().then(() => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((params) => { + Organizations.createOrganizationViaApi(testData.centralVendor).then((orgResponse) => { + centralData.vendorId = orgResponse; + + // create order with order line on central tenant + const centralOrder = { + ...NewOrder.getDefaultOrder({ vendorId: orgResponse }), + orderType: 'One-Time', + approved: true, + }; + const centralOrderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + currency: 'USD', + discountType: 'percentage', + discount: 10, + listUnitPrice: 10, + quantityPhysical: 1, + }, + physical: { + createInventory: 'Instance, Holding', + materialSupplier: orgResponse, + }, + locations: [ + { + tenantId: Affiliations.College, + holdingId: testData.holdings.holdingId, + quantityPhysical: 1, + }, + ], + checkinItems: false, + instanceId: testData.instance.instanceId, + titleOrPackage: testData.instance.instanceTitle, + acquisitionMethod: params.body.acquisitionMethods[0].id, + orderFormat: 'Physical Resource', + }; + + Orders.createOrderViaApi(centralOrder) + .then((orderResponse) => { + centralData.order.id = orderResponse.id; + centralOrderLine.purchaseOrderId = orderResponse.id; + + OrderLines.createOrderLineViaApi(centralOrderLine).then((orderLineResponse) => { + centralData.orderLine = orderLineResponse; + + Orders.updateOrderViaApi({ + ...orderResponse, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); + }) + .then(() => { + // receive piece for the order line on central tenant return cy.wait(3000).then(() => { - return Receiving.getPiecesViaApi(memberData.orderLine.id).then((pieces) => { + return Receiving.getPiecesViaApi(centralData.orderLine.id).then((pieces) => { return Receiving.receivePieceViaApi({ - poLineId: memberData.orderLine.id, - tenantId: Affiliations.College, + poLineId: centralData.orderLine.id, pieces: [ { id: pieces[0].id, displayOnHolding: true, }, ], + tenantId: Affiliations.College, }); }); }); - }, - ); - }); - }); - - cy.resetTenant(); - cy.getAdminToken() - .then(() => { - cy.getAcquisitionMethodsApi({ - query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, - }).then((params) => { - centralData.acquisitionMethodId = params.body.acquisitionMethods[0].id; - }); - Organizations.getOrganizationViaApi({ query: `name="${VENDOR_NAMES.MOSAIC}"` }).then( - (organization) => { - centralData.vendorId = organization.id; - }, - ); - }) - .then(() => { - // create order with order line on central tenant - createOrderWithLineOnCentral( - centralData.vendorId, - centralData.acquisitionMethodId, - ).then(() => { - // receive piece for the order line on central tenant - return cy.wait(3000).then(() => { - return Receiving.getPiecesViaApi(centralData.orderLine.id).then((pieces) => { - return Receiving.receivePieceViaApi({ - poLineId: centralData.orderLine.id, - tenantId: Affiliations.College, - pieces: [ - { - id: pieces[0].id, - displayOnHolding: true, - }, - ], - }); }); - }); }); }); + }); cy.resetTenant(); cy.getAdminToken(); @@ -306,9 +271,8 @@ describe('Inventory', () => { 'C491283 Check Receiving history accordion for shared Holdings with linked central and member tenants (consortia) (folijet)', { tags: ['extendedPathECS', 'folijet', 'C491283'] }, () => { - const todayDate = DateTools.getFormattedDate({ date: new Date() }, 'MM/DD/YYYY'); + const todayDate = DateTools.getFormattedDate({ date: new Date() }, 'M/D/YYYY'); - InventorySearchAndFilter.clearDefaultFilter('Held by'); InventorySearchAndFilter.searchInstanceByTitle(testData.instance.instanceTitle); InventoryInstances.selectInstance(); InstanceRecordView.waitLoading(); @@ -320,7 +284,6 @@ describe('Inventory', () => { ConsortiumManager.switchActiveAffiliation(tenantNames.college, tenantNames.university); ConsortiumManager.checkCurrentTenantInTopMenu(tenantNames.university); - InventorySearchAndFilter.clearDefaultFilter('Held by'); InventorySearchAndFilter.searchInstanceByTitle(testData.instance.instanceTitle); InventoryInstances.selectInstance(); InstanceRecordView.waitLoading(); diff --git a/cypress/e2e/consortia/inventory/instance/closing-after-add-holdings-action-on-consortial-holdings-accordion-details-on-shadow-instance-on-member.cy.js b/cypress/e2e/consortia/inventory/instance/closing-after-add-holdings-action-on-consortial-holdings-accordion-details-on-shadow-instance-on-member.cy.js index 769bcc6754..027a233426 100644 --- a/cypress/e2e/consortia/inventory/instance/closing-after-add-holdings-action-on-consortial-holdings-accordion-details-on-shadow-instance-on-member.cy.js +++ b/cypress/e2e/consortia/inventory/instance/closing-after-add-holdings-action-on-consortial-holdings-accordion-details-on-shadow-instance-on-member.cy.js @@ -152,8 +152,6 @@ describe('Inventory', () => { InstanceRecordView.verifyIsHoldingsCreated([`${testData.location.name} >`]); ConsortiumManager.checkCurrentTenantInTopMenu(tenantNames.university); InstanceRecordView.verifyConsortiaHoldingsAccordion(testData.shadowInstance.id, true); - cy.wait(1000); - InstanceRecordView.verifyMemberSubHoldingsAccordion(Affiliations.College); }, ); }); diff --git a/cypress/e2e/consortia/inventory/instance/expand-all-collapse-all-button-for-consortial-holdings-accordion-on-shadow-instance-from-member-on-another-member.cy.js b/cypress/e2e/consortia/inventory/instance/expand-all-collapse-all-button-for-consortial-holdings-accordion-on-shadow-instance-from-member-on-another-member.cy.js index 8679af4454..065c189e80 100644 --- a/cypress/e2e/consortia/inventory/instance/expand-all-collapse-all-button-for-consortial-holdings-accordion-on-shadow-instance-from-member-on-another-member.cy.js +++ b/cypress/e2e/consortia/inventory/instance/expand-all-collapse-all-button-for-consortial-holdings-accordion-on-shadow-instance-from-member-on-another-member.cy.js @@ -103,7 +103,7 @@ describe('Inventory', () => { InstanceRecordView.verifySubHoldingsAccordion( Affiliations.College, testData.holdingId, - true, + 'true', ); InstanceRecordView.collapseAllInConsortialHoldingsAccordion(testData.instanceId); InstanceRecordView.verifyConsortiaHoldingsAccordion(testData.instanceId, false); @@ -118,7 +118,7 @@ describe('Inventory', () => { InstanceRecordView.verifySubHoldingsAccordion( Affiliations.College, testData.holdingId, - true, + 'true', ); InstanceRecordView.collapseAllInConsortialHoldingsAccordion(testData.instanceId); InstanceRecordView.verifyConsortiaHoldingsAccordion(testData.instanceId, false); diff --git a/cypress/e2e/consortia/inventory/instance/member-shadow-instance-and-central-consortial-instance-when-member-holdings-are-added-to-shared-instance.cy.js b/cypress/e2e/consortia/inventory/instance/member-shadow-instance-and-central-consortial-instance-when-member-holdings-are-added-to-shared-instance.cy.js index c68cd23c32..61cf0f39d4 100644 --- a/cypress/e2e/consortia/inventory/instance/member-shadow-instance-and-central-consortial-instance-when-member-holdings-are-added-to-shared-instance.cy.js +++ b/cypress/e2e/consortia/inventory/instance/member-shadow-instance-and-central-consortial-instance-when-member-holdings-are-added-to-shared-instance.cy.js @@ -97,7 +97,7 @@ describe('Inventory', () => { InstanceRecordView.verifyInstanceSource(testData.instanceSource); InstanceRecordView.verifyAddItemButtonVisibility({ holdingName: 'Consortial holdings', - shouldBePresent: true, + shouldBePresent: false, }); ConsortiumManager.switchActiveAffiliation(tenantNames.college, tenantNames.central); diff --git a/cypress/e2e/consortia/inventory/instance/move-items-within-instance-is-not-visible-for-shared-instances-without-local-holdings-on-member.cy.js b/cypress/e2e/consortia/inventory/instance/move-items-within-instance-is-not-visible-for-shared-instances-without-local-holdings-on-member.cy.js index 4293d6d9f8..6182aade76 100644 --- a/cypress/e2e/consortia/inventory/instance/move-items-within-instance-is-not-visible-for-shared-instances-without-local-holdings-on-member.cy.js +++ b/cypress/e2e/consortia/inventory/instance/move-items-within-instance-is-not-visible-for-shared-instances-without-local-holdings-on-member.cy.js @@ -120,7 +120,6 @@ describe('Inventory', () => { ConsortiumManager.switchActiveAffiliation(tenantNames.central, tenantNames.university); ConsortiumManager.checkCurrentTenantInTopMenu(tenantNames.university); - InventorySearchAndFilter.clearDefaultFilter('Held by'); InventoryInstances.searchByTitle(testData.instance.instanceId); InventoryInstances.selectInstance(); InstanceRecordView.waitLoading(); @@ -131,7 +130,6 @@ describe('Inventory', () => { ConsortiumManager.switchActiveAffiliation(tenantNames.university, tenantNames.college); ConsortiumManager.checkCurrentTenantInTopMenu(tenantNames.college); - InventorySearchAndFilter.clearDefaultFilter('Held by'); InventoryInstances.searchByTitle(testData.instance.instanceId); InventoryInstances.selectInstance(); InstanceRecordView.waitLoading(); diff --git a/cypress/e2e/consortia/inventory/instance/new-modal-for-shared-and-local-authority-record-after-sharing-local-instance-on-member.cy.js b/cypress/e2e/consortia/inventory/instance/new-modal-for-shared-and-local-authority-record-after-sharing-local-instance-on-member.cy.js index 6d2152dce3..6b56de0c4c 100644 --- a/cypress/e2e/consortia/inventory/instance/new-modal-for-shared-and-local-authority-record-after-sharing-local-instance-on-member.cy.js +++ b/cypress/e2e/consortia/inventory/instance/new-modal-for-shared-and-local-authority-record-after-sharing-local-instance-on-member.cy.js @@ -2,17 +2,18 @@ import { APPLICATION_NAMES, DEFAULT_JOB_PROFILE_NAMES } from '../../../../suppor import Affiliations, { tenantNames } from '../../../../support/dictionary/affiliations'; import CapabilitySets from '../../../../support/dictionary/capabilitySets'; import DataImport from '../../../../support/fragments/data_import/dataImport'; +import InstanceRecordView from '../../../../support/fragments/inventory/instanceRecordView'; import InventoryInstance from '../../../../support/fragments/inventory/inventoryInstance'; import InventoryInstances from '../../../../support/fragments/inventory/inventoryInstances'; import InventorySearchAndFilter from '../../../../support/fragments/inventory/inventorySearchAndFilter'; import LinkedToLocalAuthoritiesModal from '../../../../support/fragments/inventory/modals/linkedToLocalAuthoritiesModal'; import MarcAuthorities from '../../../../support/fragments/marcAuthority/marcAuthorities'; +import MarcAuthority from '../../../../support/fragments/marcAuthority/marcAuthority'; import QuickMarcEditor from '../../../../support/fragments/quickMarcEditor'; import ConsortiumManager from '../../../../support/fragments/settings/consortium-manager/consortium-manager'; import TopMenuNavigation from '../../../../support/fragments/topMenuNavigation'; import Users from '../../../../support/fragments/users/users'; import getRandomPostfix from '../../../../support/utils/stringTools'; -import MarcAuthority from '../../../../support/fragments/marcAuthority/marcAuthority'; describe('Inventory', () => { describe('Instance', () => { @@ -122,7 +123,6 @@ describe('Inventory', () => { CapabilitySets.uiInventory, CapabilitySets.uiMarcAuthoritiesAuthorityRecordView, CapabilitySets.uiConsortiaInventoryLocalSharingInstances, - CapabilitySets.uiQuickMarcQuickMarcEditor, ], ); cy.resetTenant(); @@ -172,14 +172,18 @@ describe('Inventory', () => { testData.sharedAuthorityHeading, testData.createdRecordIDs[0], ); - - InventoryInstance.editMarcBibliographicRecord(); - QuickMarcEditor.verifyTagFieldAfterUnlinking( - 32, - '650', - '\\', - '7', - '$a C411723 Lentz Local M1 $z Latin America $x Mexico. $0 http://id.loc.gov/authorities/names/n2011049161405560 $2 bisacsh', + InstanceRecordView.verifySubjectWithoutMarcAppIcon( + 3, + 'C411723 Lentz Local M1--Latin America--Mexico', + ); + InstanceRecordView.verifyInstanceSubject( + { + indexRow: 3, + subjectHeadings: 'C411723 Lentz Local M1--Latin America--Mexico', + subjectSource: 'No value set-', + subjectType: 'Topical term', + }, + false, ); }, ); diff --git a/cypress/e2e/consortia/inventory/set-record-for-deletion/shared-instance-is-marked-as-deleted-on-central.cy.js b/cypress/e2e/consortia/inventory/set-record-for-deletion/shared-instance-is-marked-as-deleted-on-central.cy.js index 61e212c0c1..a4847d4d93 100644 --- a/cypress/e2e/consortia/inventory/set-record-for-deletion/shared-instance-is-marked-as-deleted-on-central.cy.js +++ b/cypress/e2e/consortia/inventory/set-record-for-deletion/shared-instance-is-marked-as-deleted-on-central.cy.js @@ -67,7 +67,6 @@ describe('Inventory', () => { InventoryInstances.waitContentLoading(); ConsortiumManager.switchActiveAffiliation(tenantNames.central, tenantNames.college); ConsortiumManager.checkCurrentTenantInTopMenu(tenantNames.college); - InventorySearchAndFilter.clearDefaultFilter(testData.heldByAccordionName); InventorySearchAndFilter.searchInstanceByTitle(testData.instanceId); InventoryInstances.selectInstance(); }); diff --git a/cypress/e2e/data-import/importing-marc-bib-files/export-from-inventory-edit-file-and-reimport-to-update-items.cy.js b/cypress/e2e/data-import/importing-marc-bib-files/export-from-inventory-edit-file-and-reimport-to-update-items.cy.js index db6698837b..0db08224b1 100644 --- a/cypress/e2e/data-import/importing-marc-bib-files/export-from-inventory-edit-file-and-reimport-to-update-items.cy.js +++ b/cypress/e2e/data-import/importing-marc-bib-files/export-from-inventory-edit-file-and-reimport-to-update-items.cy.js @@ -223,7 +223,9 @@ describe('Data Import', () => { after('delete test data', () => { FileManager.deleteFile(`cypress/fixtures/${nameMarcFileForUpload}`); + FileManager.deleteFileFromDownloadsByMask(nameMarcFileForUpload); FileManager.deleteFile(`cypress/fixtures/${nameForCSVFile}`); + FileManager.deleteFileFromDownloadsByMask(nameForCSVFile); cy.getAdminToken().then(() => { Users.deleteViaApi(userId); Users.deleteViaApi(preconditionUserId); diff --git a/cypress/e2e/data-import/log-details/import-summary-table-with-create-update-actions.cy.js b/cypress/e2e/data-import/log-details/import-summary-table-with-create-update-actions.cy.js index 0ecab0e0a3..bd498f8286 100644 --- a/cypress/e2e/data-import/log-details/import-summary-table-with-create-update-actions.cy.js +++ b/cypress/e2e/data-import/log-details/import-summary-table-with-create-update-actions.cy.js @@ -260,6 +260,7 @@ describe('Data Import', () => { after('Delete test data', () => { // delete created files in fixtures FileManager.deleteFile(`cypress/fixtures/${exportedFileName}`); + FileManager.deleteFileFromDownloadsByMask(exportedFileName); FileManager.deleteFile(`cypress/fixtures/${fileNameWithUpdatedContent}`); FileManager.deleteFile(`cypress/fixtures/${nameForCSVFile}`); cy.getAdminToken().then(() => { diff --git a/cypress/e2e/data-import/log-details/import-summary-table-with-updated-actions-for-instance-holding-and-item.cy.js b/cypress/e2e/data-import/log-details/import-summary-table-with-updated-actions-for-instance-holding-and-item.cy.js index c355153329..39199e4e36 100644 --- a/cypress/e2e/data-import/log-details/import-summary-table-with-updated-actions-for-instance-holding-and-item.cy.js +++ b/cypress/e2e/data-import/log-details/import-summary-table-with-updated-actions-for-instance-holding-and-item.cy.js @@ -300,7 +300,9 @@ describe('Data Import', () => { after('Delete test data', () => { // delete created files in fixtures FileManager.deleteFile(`cypress/fixtures/${nameMarcFileForImportUpdate}`); + FileManager.deleteFileFromDownloadsByMask(nameMarcFileForImportUpdate); FileManager.deleteFile(`cypress/fixtures/${nameForCSVFile}`); + FileManager.deleteFileFromDownloadsByMask(nameForCSVFile); cy.getAdminToken().then(() => { Users.deleteViaApi(user.userId); SettingsJobProfiles.deleteJobProfileByNameViaApi(jobProfileForCreate.name); diff --git a/cypress/e2e/data-import/permissions/can-see-json-tab-for-imported-orders-with-data-import-can-upload-files-import-and-view-logs-permission.cy.js b/cypress/e2e/data-import/permissions/can-see-json-tab-for-imported-orders-with-data-import-can-upload-files-import-and-view-logs-permission.cy.js index 845443e351..9cf914a6de 100644 --- a/cypress/e2e/data-import/permissions/can-see-json-tab-for-imported-orders-with-data-import-can-upload-files-import-and-view-logs-permission.cy.js +++ b/cypress/e2e/data-import/permissions/can-see-json-tab-for-imported-orders-with-data-import-can-upload-files-import-and-view-logs-permission.cy.js @@ -137,7 +137,7 @@ describe('Data Import', () => { it( 'C377023 A user can see JSON tab for imported Orders with "Data import: Can upload files, import, and view logs" permission (folijet)', - { tags: ['extendedPath', 'folijet', 'C377023', 'eurekaPhase1'] }, + { tags: ['extendedPath', 'folijet', 'C377023'] }, () => { const message = `Import Log for Record 01 (${title})`; diff --git a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/expense-class-active-without-rollover.cy.js b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/expense-class-active-without-rollover.cy.js index 6767ad8aa8..42898344ed 100644 --- a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/expense-class-active-without-rollover.cy.js +++ b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/expense-class-active-without-rollover.cy.js @@ -5,46 +5,39 @@ 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 DateTools from '../../../../support/utils/dateTools'; -import getRandomPostfix from '../../../../support/utils/stringTools'; +import FileManager from '../../../../support/utils/fileManager'; describe('Finance: Ledgers', () => { - const firstFiscalYear = { ...FiscalYears.defaultRolloverFiscalYear }; - const secondFiscalYear = { - name: `autotest_year_${getRandomPostfix()}`, - code: DateTools.getRandomFiscalYearCodeForRollover(2000, 9999), - periodStart: `${DateTools.get3DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+00:00`, - periodEnd: `${DateTools.get4DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+00:00`, - description: `This is fiscal year created by E2E test automation script_${getRandomPostfix()}`, - series: 'FY', + const testData = { + user: {}, + fiscalYear: { ...FiscalYears.defaultRolloverFiscalYear }, + ledger: { ...Ledgers.defaultUiLedger }, + fund: { ...Funds.defaultUiFund }, }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const defaultFund = { ...Funds.defaultUiFund }; - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - let user; - let fileName; before(() => { cy.getAdminToken(); - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - secondFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '2'; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - defaultFund.ledgerId = defaultLedger.id; + FiscalYears.createViaApi(testData.fiscalYear).then((fiscalYearResponse) => { + testData.fiscalYear.id = fiscalYearResponse.id; + testData.ledger.fiscalYearOneId = testData.fiscalYear.id; + testData.ledger.code = testData.fiscalYear.code.slice(0, -1) + '2'; - Funds.createViaApi(defaultFund).then((fundResponse) => { - defaultFund.id = fundResponse.fund.id; + Ledgers.createViaApi(testData.ledger).then((ledgerResponse) => { + testData.ledger.id = ledgerResponse.id; + testData.fund.ledgerId = testData.ledger.id; + + Funds.createViaApi(testData.fund).then((fundResponse) => { + testData.fund.id = fundResponse.fund.id; }); }); - fileName = `Export-${defaultLedger.code}-${firstFiscalYear.code}`; + testData.fileName = `Export-${testData.ledger.code}-${testData.fiscalYear.code}`; }); + cy.createTempUser([ permissions.uiFinanceExportFinanceRecords.gui, permissions.uiFinanceViewLedger.gui, ]).then((userProperties) => { - user = userProperties; + testData.user = userProperties; cy.login(userProperties.username, userProperties.password, { path: TopMenu.ledgerPath, waiter: Ledgers.waitForLedgerDetailsLoading, @@ -52,26 +45,29 @@ describe('Finance: Ledgers', () => { }); }); - after(() => { + after('Clean up test data', () => { + FileManager.deleteFile(`cypress/downloads/${testData.fileName}.csv`); cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); }); it( 'C353214 Ledger export settings: current year Fund with NO budget, NO Classes, Export settings; Expense class - Active (thunderjet) (TaaS)', { tags: ['extendedPath', 'thunderjet', 'C353214'] }, () => { - FinanceHelp.searchByName(defaultLedger.name); - Ledgers.selectLedger(defaultLedger.name); + FinanceHelp.searchByName(testData.ledger.name); + Ledgers.selectLedger(testData.ledger.name); Ledgers.exportBudgetInformation(); - Ledgers.prepareExportSettings(firstFiscalYear.code, 'Active', defaultLedger); - Ledgers.checkColumnNamesInDownloadedLedgerExportFileWithExpClasses(`${fileName}.csv`); + Ledgers.prepareExportSettings(testData.fiscalYear.code, 'Active', testData.ledger); + Ledgers.checkColumnNamesInDownloadedLedgerExportFileWithExpClasses( + `${testData.fileName}.csv`, + ); Ledgers.checkColumnContentInDownloadedLedgerExportFileWithoutBudgets( - `${fileName}.csv`, + `${testData.fileName}.csv`, 1, - defaultFund, + testData.fund, ); - Ledgers.deleteDownloadedFile(`${fileName}.csv`); + // Ledgers.deleteDownloadedFile(`${testData.fileName}.csv`); }, ); }); diff --git a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/expense-classes-none-without-rollover-with-ex-classes.cy.js b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/expense-classes-none-without-rollover-with-ex-classes.cy.js index be401ce728..568d33d52d 100644 --- a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/expense-classes-none-without-rollover-with-ex-classes.cy.js +++ b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/expense-classes-none-without-rollover-with-ex-classes.cy.js @@ -1,142 +1,225 @@ -import permissions from '../../../../support/dictionary/permissions'; +import uuid from 'uuid'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + LOCATION_NAMES, + ORDER_STATUSES, +} from '../../../../support/constants'; +import Permissions from '../../../../support/dictionary/permissions'; +import { Budgets, Funds, Ledgers } from '../../../../support/fragments/finance'; 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 NewOrder from '../../../../support/fragments/orders/newOrder'; -import OrderLines from '../../../../support/fragments/orders/orderLines'; -import Orders from '../../../../support/fragments/orders/orders'; -import NewOrganization from '../../../../support/fragments/organizations/newOrganization'; -import Organizations from '../../../../support/fragments/organizations/organizations'; +import { BasicOrderLine, NewOrder, OrderLines, Orders } from '../../../../support/fragments/orders'; +import { NewOrganization, Organizations } from '../../../../support/fragments/organizations'; +import ExpenseClasses from '../../../../support/fragments/settings/finance/expenseClasses'; import TopMenu from '../../../../support/fragments/topMenu'; import Users from '../../../../support/fragments/users/users'; +import FileManager from '../../../../support/utils/fileManager'; describe('Finance: Ledgers', () => { - const firstFiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const defaultFund = { ...Funds.defaultUiFund }; + const organization = { ...NewOrganization.defaultUiOrganizations, isVendor: true }; + const testData = { + organization, + user: {}, + expenseClass1: { + name: 'Electronic', + code: 'Elec', + status: 'Active', + id: '', + }, + expenseClass2: { + name: 'Print', + code: 'Prn', + status: 'Active', + id: '', + }, + }; const firstOrder = { ...NewOrder.defaultOneTimeOrder, - orderType: 'One-time', + id: uuid(), approved: true, reEncumber: true, + vendorId: testData.organization.id, }; const secondOrder = { ...NewOrder.defaultOneTimeOrder, - orderType: 'One-time', + id: uuid(), approved: true, reEncumber: true, + vendorId: testData.organization.id, }; - const organization = { ...NewOrganization.defaultUiOrganizations }; - const allocatedQuantity = '100'; - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - let user; - let location; - let fileName; - before(() => { + before('Setup test data', () => { cy.getAdminToken(); - // create first Fiscal Year and prepere 2 Funds for Rollover - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - defaultFund.ledgerId = defaultLedger.id; + ExpenseClasses.getExpenseClassesViaApi({ + query: `name=="${testData.expenseClass1.name}"`, + limit: 1, + }).then((resp1) => { + testData.expenseClass1.id = resp1?.[0]?.id; - Funds.createViaApi(defaultFund).then((fundResponse) => { - defaultFund.id = fundResponse.fund.id; + ExpenseClasses.getExpenseClassesViaApi({ + query: `name=="${testData.expenseClass2.name}"`, + limit: 1, + }).then((resp2) => { + testData.expenseClass2.id = resp2?.[0]?.id; - cy.loginAsAdmin({ path: TopMenu.fundPath, waiter: Funds.waitLoading }); - FinanceHelp.searchByName(defaultFund.name); - Funds.selectFund(defaultFund.name); - Funds.addBudget(allocatedQuantity); - Funds.editBudget(); - Funds.addTwoExpensesClass('Electronic', 'Print'); + const { fiscalYear, ledger, fund, budget } = Budgets.createBudgetWithFundLedgerAndFYViaApi({ + ledger: { restrictEncumbrance: true, restrictExpenditures: true }, + budget: { + allocated: 100, + statusExpenseClasses: [ + { + status: testData.expenseClass1.status, + expenseClassId: testData.expenseClass1.id, + }, + { + status: testData.expenseClass2.status, + expenseClassId: testData.expenseClass2.id, + }, + ], + }, }); + testData.fiscalYear = fiscalYear; + testData.ledger = ledger; + testData.fund = fund; + testData.budget = budget; + + Organizations.createOrganizationViaApi(organization).then((orgResp) => { + organization.id = orgResp; + firstOrder.vendor = orgResp; + secondOrder.vendor = orgResp; + + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((amResp) => { + cy.getBookMaterialType().then((mtypeResp) => { + const firstOrderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + listUnitPrice: 25.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 25.0, + }, + fundDistribution: [ + { + code: testData.fund.code, + fundId: testData.fund.id, + expenseClassId: testData.expenseClass1.id, + value: 100, + }, + ], + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: amResp.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypeResp.id, + materialSupplier: orgResp.id, + volumes: [], + }, + }; + + // Create first open order + Orders.createOrderViaApi(firstOrder).then((orderResp) => { + firstOrder.id = orderResp.id; + firstOrder.poNumber = orderResp.poNumber; + firstOrderLine.purchaseOrderId = orderResp.id; + + OrderLines.createOrderLineViaApi(firstOrderLine); + Orders.updateOrderViaApi({ + ...orderResp, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); + + const secondOrderLine = { + ...BasicOrderLine.defaultOrderLine, + id: uuid(), + cost: { + listUnitPrice: 20.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 20.0, + }, + fundDistribution: [ + { + code: testData.fund.code, + fundId: testData.fund.id, + expenseClassId: testData.expenseClass2.id, + value: 100, + }, + ], + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: amResp.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypeResp.id, + materialSupplier: orgResp.id, + volumes: [], + }, + }; + // Create second open order + Orders.createOrderViaApi(secondOrder).then((orderResp) => { + secondOrder.id = orderResp.id; + secondOrder.poNumber = orderResp.poNumber; + secondOrderLine.purchaseOrderId = orderResp.id; + + OrderLines.createOrderLineViaApi(secondOrderLine); + Orders.updateOrderViaApi({ + ...orderResp, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); + }); + }); + }); + }); + testData.fileName = `Export-${testData.ledger.code}-${testData.fiscalYear.code}`; + + cy.loginAsAdmin(); + cy.visit(TopMenu.fundPath); + FinanceHelp.searchByName(testData.fund.name); + Funds.selectFund(testData.fund.name); + Funds.selectBudgetDetails(); + Funds.editBudget(); + Funds.changeStatusOfExpClassByName(testData.expenseClass2.name, 'Inactive'); }); - cy.getLocations({ limit: 1 }).then((res) => { - location = res; - }); - // Prepare Open Order for Rollover - Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { - organization.id = responseOrganizations; - }); - firstOrder.vendor = organization.name; - secondOrder.vendor = organization.name; - cy.visit(TopMenu.ordersPath); - Orders.createApprovedOrderForRollover(firstOrder, true).then((firstOrderResponse) => { - firstOrder.id = firstOrderResponse.id; - Orders.checkCreatedOrder(firstOrder); - OrderLines.addPOLine(); - OrderLines.selectRandomInstanceInTitleLookUP('*', 35); - OrderLines.rolloverPOLineInfoForPhysicalMaterialWithFundAndExpClass( - defaultFund, - 'Electronic', - '10', - '1', - '10', - location.name, - ); - OrderLines.backToEditingOrder(); - Orders.openOrder(); - }); - Orders.createApprovedOrderForRollover(secondOrder, true).then((secondOrderResponse) => { - secondOrder.id = secondOrderResponse.id; - Orders.checkCreatedOrder(secondOrder); - OrderLines.addPOLine(); - OrderLines.selectRandomInstanceInTitleLookUP('*', 35); - OrderLines.rolloverPOLineInfoForPhysicalMaterialWithFundAndExpClass( - defaultFund, - 'Print', - '10', - '1', - '10', - location.name, - ); - OrderLines.backToEditingOrder(); - Orders.openOrder(); - }); - cy.visit(TopMenu.fundPath); - FinanceHelp.searchByName(defaultFund.name); - Funds.selectFund(defaultFund.name); - Funds.selectBudgetDetails(); - Funds.editBudget(); - Funds.changeStatusOfExpClass(1, 'Inactive'); - fileName = `Export-${defaultLedger.code}-${firstFiscalYear.code}`; }); + cy.createTempUser([ - permissions.uiFinanceExportFinanceRecords.gui, - permissions.uiFinanceViewLedger.gui, + Permissions.uiFinanceExportFinanceRecords.gui, + Permissions.uiFinanceViewLedger.gui, ]).then((userProperties) => { - user = userProperties; + testData.user = userProperties; + cy.login(userProperties.username, userProperties.password, { path: TopMenu.ledgerPath, waiter: Ledgers.waitForLedgerDetailsLoading, - authRefresh: true, }); }); }); - after(() => { + after('Clean up test data', () => { + FileManager.deleteFile(`cypress/downloads/${testData.fileName}.csv`); cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); }); it( 'C353205 Ledger export settings: current year Fund with budget, Print (Active) and Economic (Inactive) Classes, Export settings-None statuses (thunderjet) (TaaS)', { tags: ['extendedPath', 'thunderjet', 'C353205'] }, () => { - FinanceHelp.searchByName(defaultLedger.name); - Ledgers.selectLedger(defaultLedger.name); + FinanceHelp.searchByName(testData.ledger.name); + Ledgers.selectLedger(testData.ledger.name); Ledgers.exportBudgetInformation(); - Ledgers.prepareExportSettings(firstFiscalYear.code, 'None', defaultLedger); - Ledgers.checkColumnNamesInDownloadedLedgerExportFileForNone(`${fileName}.csv`); + Ledgers.prepareExportSettings(testData.fiscalYear.code, 'None', testData.ledger); + Ledgers.checkColumnNamesInDownloadedLedgerExportFileForNone(`${testData.fileName}.csv`); Ledgers.checkColumnContentInDownloadedLedgerExportFileForNone( - `${fileName}.csv`, + `${testData.fileName}.csv`, 1, - defaultFund, - firstFiscalYear, + testData.fund, + testData.budget.name, '100', '100', '100', @@ -145,16 +228,15 @@ describe('Finance: Ledgers', () => { '100', '0', '100', - '20', + '45', '0', '0', - '20', + '45', '0', '0', '100', - '80', + '55', ); - Ledgers.deleteDownloadedFile(`${fileName}.csv`); }, ); }); diff --git a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/expense-classes-none-without-rollover.cy.js b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/expense-classes-none-without-rollover.cy.js index bbe815e4af..ea83ec3e1a 100644 --- a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/expense-classes-none-without-rollover.cy.js +++ b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/expense-classes-none-without-rollover.cy.js @@ -1,50 +1,43 @@ -import permissions from '../../../../support/dictionary/permissions'; +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 DateTools from '../../../../support/utils/dateTools'; -import getRandomPostfix from '../../../../support/utils/stringTools'; +import FileManager from '../../../../support/utils/fileManager'; describe('Finance: Ledgers', () => { - const firstFiscalYear = { ...FiscalYears.defaultRolloverFiscalYear }; - const secondFiscalYear = { - name: `autotest_year_${getRandomPostfix()}`, - code: DateTools.getRandomFiscalYearCodeForRollover(2000, 9999), - periodStart: `${DateTools.get3DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+00:00`, - periodEnd: `${DateTools.get4DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+00:00`, - description: `This is fiscal year created by E2E test automation script_${getRandomPostfix()}`, - series: 'FY', + const testData = { + user: {}, + fiscalYear: { ...FiscalYears.defaultRolloverFiscalYear }, + ledger: { ...Ledgers.defaultUiLedger }, + fund: { ...Funds.defaultUiFund }, }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const defaultFund = { ...Funds.defaultUiFund }; - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - let user; - let fileName; - before(() => { + before('Set up test data', () => { cy.getAdminToken(); - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - secondFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '2'; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - defaultFund.ledgerId = defaultLedger.id; + FiscalYears.createViaApi(testData.fiscalYear).then((fiscalYearResponse) => { + testData.fiscalYear.id = fiscalYearResponse.id; + testData.ledger.fiscalYearOneId = testData.fiscalYear.id; - Funds.createViaApi(defaultFund).then((fundResponse) => { - defaultFund.id = fundResponse.fund.id; + Ledgers.createViaApi(testData.ledger).then((ledgerResponse) => { + testData.ledger.id = ledgerResponse.id; + testData.fund.ledgerId = testData.ledger.id; + + Funds.createViaApi(testData.fund).then((fundResponse) => { + testData.fund.id = fundResponse.fund.id; }); }); - fileName = `Export-${defaultLedger.code}-${firstFiscalYear.code}`; + testData.fileName = `Export-${testData.ledger.code}-${testData.fiscalYear.code}`; }); + cy.createTempUser([ - permissions.uiFinanceExportFinanceRecords.gui, - permissions.uiFinanceViewLedger.gui, + Permissions.uiFinanceExportFinanceRecords.gui, + Permissions.uiFinanceViewLedger.gui, ]).then((userProperties) => { - user = userProperties; + testData.user = userProperties; + cy.login(userProperties.username, userProperties.password, { path: TopMenu.ledgerPath, waiter: Ledgers.waitForLedgerDetailsLoading, @@ -52,26 +45,26 @@ describe('Finance: Ledgers', () => { }); }); - after(() => { + after('Clean up test data', () => { + FileManager.deleteFile(`cypress/downloads/${testData.fileName}.csv`); cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); }); it( 'C353215 Ledger export settings: current year Fund with NO budget, NO Classes, Export settings; Expense class - NONE (thunderjet) (TaaS)', { tags: ['extendedPath', 'thunderjet', 'C353215'] }, () => { - FinanceHelp.searchByName(defaultLedger.name); - Ledgers.selectLedger(defaultLedger.name); + FinanceHelp.searchByName(testData.ledger.name); + Ledgers.selectLedger(testData.ledger.name); Ledgers.exportBudgetInformation(); - Ledgers.prepareExportSettings(firstFiscalYear.code, 'None', defaultLedger); - Ledgers.checkColumnNamesInDownloadedLedgerExportFileForNone(`${fileName}.csv`); + Ledgers.prepareExportSettings(testData.fiscalYear.code, 'None', testData.ledger); + Ledgers.checkColumnNamesInDownloadedLedgerExportFileForNone(`${testData.fileName}.csv`); Ledgers.checkColumnContentInDownloadedLedgerExportFileWithoutBudgets( - `${fileName}.csv`, + `${testData.fileName}.csv`, 1, - defaultFund, + testData.fund, ); - Ledgers.deleteDownloadedFile(`${fileName}.csv`); }, ); }); diff --git a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/expense-classes-none.cy.js b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/expense-classes-none.cy.js index d46cf3a965..8910080939 100644 --- a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/expense-classes-none.cy.js +++ b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/expense-classes-none.cy.js @@ -1,156 +1,206 @@ -import permissions from '../../../../support/dictionary/permissions'; +import uuid from 'uuid'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + LOCATION_NAMES, + ORDER_STATUSES, +} from '../../../../support/constants'; +import Permissions from '../../../../support/dictionary/permissions'; +import { + Budgets, + FiscalYears, + LedgerRollovers, + Ledgers, +} from '../../../../support/fragments/finance'; 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 NewOrder from '../../../../support/fragments/orders/newOrder'; -import OrderLines from '../../../../support/fragments/orders/orderLines'; -import Orders from '../../../../support/fragments/orders/orders'; -import NewOrganization from '../../../../support/fragments/organizations/newOrganization'; -import Organizations from '../../../../support/fragments/organizations/organizations'; +import { BasicOrderLine, NewOrder, OrderLines, Orders } from '../../../../support/fragments/orders'; +import { NewOrganization, Organizations } from '../../../../support/fragments/organizations'; +import ExpenseClasses from '../../../../support/fragments/settings/finance/expenseClasses'; import TopMenu from '../../../../support/fragments/topMenu'; import Users from '../../../../support/fragments/users/users'; -import DateTools from '../../../../support/utils/dateTools'; -import getRandomPostfix from '../../../../support/utils/stringTools'; +import { CodeTools, StringTools } from '../../../../support/utils'; +import FileManager from '../../../../support/utils/fileManager'; describe('Finance: Ledgers', () => { - const firstFiscalYear = { ...FiscalYears.defaultRolloverFiscalYear }; - const secondFiscalYear = { - name: `autotest_year_${getRandomPostfix()}`, - code: DateTools.getRandomFiscalYearCodeForRollover(2000, 9999), - periodStart: `${DateTools.get3DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+00:00`, - periodEnd: `${DateTools.get4DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+00:00`, - description: `This is fiscal year created by E2E test automation script_${getRandomPostfix()}`, - series: 'FY', + const date = new Date(); + const code = CodeTools(4); + const organization = { ...NewOrganization.defaultUiOrganizations }; + const testData = { + organization, + user: {}, + expenseClass: { + name: 'Electronic', + code: 'Elec', + status: 'Active', + id: '', + }, + }; + const fiscalYears = { + current: { + ...FiscalYears.getDefaultFiscalYear(), + code: `${code}${StringTools.randomTwoDigitNumber()}01`, + periodStart: new Date(date.getFullYear(), 0, 1), + periodEnd: new Date(date.getFullYear(), 11, 31), + }, + next: { + ...FiscalYears.getDefaultFiscalYear(), + code: `${code}${StringTools.randomTwoDigitNumber()}02`, + periodStart: new Date(date.getFullYear() + 1, 0, 1), + periodEnd: new Date(date.getFullYear() + 1, 11, 31), + }, }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const defaultFund = { ...Funds.defaultUiFund }; - const firstOrder = { + const order = { ...NewOrder.defaultOneTimeOrder, - orderType: 'One-time', + id: uuid(), approved: true, reEncumber: true, + vendorId: testData.organization.id, }; - const organization = { ...NewOrganization.defaultUiOrganizations }; - const allocatedQuantity = '100'; - const periodStartForFirstFY = DateTools.getThreePreviousDaysDateForFiscalYearOnUIEdit(); - const periodEndForFirstFY = DateTools.getTwoPreviousDaysDateForFiscalYearOnUIEdit(); - const periodStartForSecondFY = DateTools.getCurrentDateForFiscalYearOnUIEdit(); - const periodEndForSecondFY = DateTools.get3DaysAfterTomorrowDateForFiscalYearOnUIEdit(); - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - let user; - let location; - let fileName; - before(() => { + before('Setup test data', () => { cy.getAdminToken(); - // create first Fiscal Year and prepere 2 Funds for Rollover - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - secondFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '2'; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - defaultFund.ledgerId = defaultLedger.id; + // create first Fiscal Year with Expense Classes + ExpenseClasses.getExpenseClassesViaApi({ + query: `name=="${testData.expenseClass.name}"`, + limit: 1, + }).then((resp) => { + testData.expenseClass.id = resp?.[0]?.id; - Funds.createViaApi(defaultFund).then((fundResponse) => { - defaultFund.id = fundResponse.fund.id; - - cy.loginAsAdmin({ path: TopMenu.fundPath, waiter: Funds.waitLoading }); - FinanceHelp.searchByName(defaultFund.name); - Funds.selectFund(defaultFund.name); - Funds.addBudget(allocatedQuantity); - }); - }); - cy.getLocations({ limit: 1 }).then((res) => { - location = res; + const { ledger, fund } = Budgets.createBudgetWithFundLedgerAndFYViaApi({ + fiscalYear: fiscalYears.current, + ledger: { restrictEncumbrance: true, restrictExpenditures: true }, + budget: { + allocated: 100, + statusExpenseClasses: [ + { + status: 'Active', + expenseClassId: testData.expenseClass.id, + }, + ], + }, }); + testData.ledger = ledger; + testData.fund = fund; // Create second Fiscal Year for Rollover - FiscalYears.createViaApi(secondFiscalYear).then((secondFiscalYearResponse) => { - secondFiscalYear.id = secondFiscalYearResponse.id; - }); + FiscalYears.createViaApi(fiscalYears.next); + Organizations.createOrganizationViaApi(organization).then((orgResp) => { + organization.id = orgResp; + order.vendor = orgResp; + + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((amResp) => { + cy.getBookMaterialType().then((mtypeResp) => { + const orderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + listUnitPrice: 25.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 25.0, + }, + fundDistribution: [ + { + code: testData.fund.code, + fundId: testData.fund.id, + expenseClassId: testData.expenseClass.id, + value: 100, + }, + ], + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: amResp.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypeResp.id, + materialSupplier: orgResp.id, + volumes: [], + }, + }; - // Prepare Open Order for Rollover - Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { - organization.id = responseOrganizations; + // Create first open order + Orders.createOrderViaApi(order).then((orderResp) => { + order.id = orderResp.id; + order.poNumber = orderResp.poNumber; + orderLine.purchaseOrderId = orderResp.id; + + OrderLines.createOrderLineViaApi(orderLine); + Orders.updateOrderViaApi({ + ...orderResp, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); + }); + }); + }); }); - firstOrder.vendor = organization.name; - cy.visit(TopMenu.ordersPath); - Orders.createApprovedOrderForRollover(firstOrder, true).then((firstOrderResponse) => { - firstOrder.id = firstOrderResponse.id; - Orders.checkCreatedOrder(firstOrder); - OrderLines.addPOLine(); - OrderLines.selectRandomInstanceInTitleLookUP('*', 35); - OrderLines.rolloverPOLineInfoforPhysicalMaterialWithFund( - defaultFund, - '10', - '1', - '10', - location.name, - ); - OrderLines.backToEditingOrder(); - Orders.openOrder(); + const rollover = LedgerRollovers.generateLedgerRollover({ + ledger: testData.ledger, + fromFiscalYear: fiscalYears.current, + toFiscalYear: fiscalYears.next, + restrictEncumbrance: true, + restrictExpenditures: true, + needCloseBudgets: true, + budgetsRollover: [ + { + rolloverAllocation: true, + rolloverBudgetValue: 'None', + addAvailableTo: 'Allocation', + }, + ], + encumbrancesRollover: [{ orderType: 'One-time', basedOn: 'InitialAmount' }], }); - cy.visit(TopMenu.ledgerPath); - FinanceHelp.searchByName(defaultLedger.name); - Ledgers.selectLedger(defaultLedger.name); - Ledgers.rollover(); - Ledgers.fillInRolloverForOneTimeOrdersWithAllocation( - secondFiscalYear.code, - 'None', - 'Allocation', - ); - cy.wait(10000); // wait for rollover to finish - cy.visit(TopMenu.fiscalYearPath); - FinanceHelp.searchByName(firstFiscalYear.name); - FiscalYears.selectFY(firstFiscalYear.name); - FiscalYears.editFiscalYearDetails(); - FiscalYears.filltheStartAndEndDateonCalenderstartDateField( - periodStartForFirstFY, - periodEndForFirstFY, - ); - FinanceHelp.searchByName(secondFiscalYear.name); - FiscalYears.selectFY(secondFiscalYear.name); - FiscalYears.editFiscalYearDetails(); - FiscalYears.filltheStartAndEndDateonCalenderstartDateField( - periodStartForSecondFY, - periodEndForSecondFY, - ); - fileName = `Export-${defaultLedger.code}-${secondFiscalYear.code}`; + LedgerRollovers.createLedgerRolloverViaApi(rollover); + testData.fileName = `Export-${testData.ledger.code}-${fiscalYears.next.code}`; }); + FiscalYears.updateFiscalYearViaApi({ + ...fiscalYears.current, + _version: 1, + periodStart: new Date(date.getFullYear() - 1, 0, 1), + periodEnd: new Date(date.getFullYear() - 1, 11, 31), + }); + + FiscalYears.updateFiscalYearViaApi({ + ...fiscalYears.next, + _version: 1, + periodStart: new Date(date.getFullYear(), 0, 1), + periodEnd: new Date(date.getFullYear(), 11, 31), + }); + cy.createTempUser([ - permissions.uiFinanceExportFinanceRecords.gui, - permissions.uiFinanceViewLedger.gui, + Permissions.uiFinanceExportFinanceRecords.gui, + Permissions.uiFinanceViewLedger.gui, ]).then((userProperties) => { - user = userProperties; + testData.user = userProperties; + cy.login(userProperties.username, userProperties.password, { path: TopMenu.ledgerPath, waiter: Ledgers.waitForLedgerDetailsLoading, - authRefresh: true, }); }); }); - after(() => { + after('Clean up test data', () => { + FileManager.deleteFile(`cypress/downloads/${testData.fileName}.csv`); cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); }); it( - 'C350976: Ledger export settings: last year Fund with budget, Economic (Active) Class, Export settings; Expense classes- None (thunderjet) (TaaS)', + 'C350976 Ledger export settings: last year Fund with budget, Economic (Active) Class, Export settings; Expense classes- None (thunderjet) (TaaS)', { tags: ['extendedPath', 'thunderjet', 'C350976'] }, () => { - FinanceHelp.searchByName(defaultLedger.name); - Ledgers.selectLedger(defaultLedger.name); + FinanceHelp.searchByName(testData.ledger.name); + Ledgers.selectLedger(testData.ledger.name); Ledgers.exportBudgetInformation(); - Ledgers.prepareExportSettings(secondFiscalYear.code, 'None', defaultLedger); - Ledgers.checkColumnNamesInDownloadedLedgerExportFileForNone(`${fileName}.csv`); + Ledgers.prepareExportSettings(fiscalYears.next.code, 'None', testData.ledger); + Ledgers.checkColumnNamesInDownloadedLedgerExportFileForNone(`${testData.fileName}.csv`); Ledgers.checkColumnContentInDownloadedLedgerExportFileForNone( - `${fileName}.csv`, + `${testData.fileName}.csv`, 1, - defaultFund, - secondFiscalYear, + testData.fund, + fiscalYears.next, '100', '100', '100', @@ -159,16 +209,15 @@ describe('Finance: Ledgers', () => { '100', '0', '100', - '10', + '25', '0', '0', - '10', + '25', '0', '0', '100', - '90', + '75', ); - Ledgers.deleteDownloadedFile(`${fileName}.csv`); }, ); }); diff --git a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-active-status.cy.js b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-active-status.cy.js index 89c327d977..d6586169bf 100644 --- a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-active-status.cy.js +++ b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-active-status.cy.js @@ -1,146 +1,200 @@ -import permissions from '../../../../support/dictionary/permissions'; +import uuid from 'uuid'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + LOCATION_NAMES, + ORDER_STATUSES, +} from '../../../../support/constants'; +import Permissions from '../../../../support/dictionary/permissions'; +import { + Budgets, + FiscalYears, + LedgerRollovers, + Ledgers, +} from '../../../../support/fragments/finance'; 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 NewOrder from '../../../../support/fragments/orders/newOrder'; -import OrderLines from '../../../../support/fragments/orders/orderLines'; -import Orders from '../../../../support/fragments/orders/orders'; -import NewOrganization from '../../../../support/fragments/organizations/newOrganization'; -import Organizations from '../../../../support/fragments/organizations/organizations'; +import { BasicOrderLine, NewOrder, OrderLines, Orders } from '../../../../support/fragments/orders'; +import { NewOrganization, Organizations } from '../../../../support/fragments/organizations'; +import ExpenseClasses from '../../../../support/fragments/settings/finance/expenseClasses'; import TopMenu from '../../../../support/fragments/topMenu'; import Users from '../../../../support/fragments/users/users'; -import DateTools from '../../../../support/utils/dateTools'; -import getRandomPostfix from '../../../../support/utils/stringTools'; +import { CodeTools, StringTools } from '../../../../support/utils'; +import FileManager from '../../../../support/utils/fileManager'; describe('Finance: Ledgers', () => { - const firstFiscalYear = { ...FiscalYears.defaultRolloverFiscalYear }; - const secondFiscalYear = { - name: `autotest_year_${getRandomPostfix()}`, - code: DateTools.getRandomFiscalYearCodeForRollover(2000, 9999), - periodStart: `${DateTools.get3DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+00:00`, - periodEnd: `${DateTools.get4DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+00:00`, - description: `This is fiscal year created by E2E test automation script_${getRandomPostfix()}`, - series: 'FY', + const date = new Date(); + const code = CodeTools(4); + const organization = { ...NewOrganization.defaultUiOrganizations }; + const testData = { + organization, + user: {}, + expenseClass: { + name: 'Electronic', + code: 'Elec', + status: 'Active', + id: '', + }, + }; + const fiscalYears = { + current: { + ...FiscalYears.getDefaultFiscalYear(), + code: `${code}${StringTools.randomTwoDigitNumber()}01`, + periodStart: new Date(date.getFullYear(), 0, 1), + periodEnd: new Date(date.getFullYear(), 11, 31), + }, + next: { + ...FiscalYears.getDefaultFiscalYear(), + code: `${code}${StringTools.randomTwoDigitNumber()}02`, + periodStart: new Date(date.getFullYear() + 1, 0, 1), + periodEnd: new Date(date.getFullYear() + 1, 11, 31), + }, }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const defaultFund = { ...Funds.defaultUiFund }; - const firstOrder = { + const order = { ...NewOrder.defaultOneTimeOrder, - orderType: 'One-time', + id: uuid(), approved: true, reEncumber: true, + vendorId: testData.organization.id, }; - const organization = { ...NewOrganization.defaultUiOrganizations }; - const allocatedQuantity = '100'; - const periodStartForFirstFY = DateTools.getThreePreviousDaysDateForFiscalYearOnUIEdit(); - const periodEndForFirstFY = DateTools.getDayTomorrowDateForFiscalYearOnUIEdit(); - const periodStartForSecondFY = DateTools.get2DaysAfterTomorrowDateForFiscalYearOnUIEdit(); - const periodEndForSecondFY = DateTools.get4DaysAfterTomorrowDateForFiscalYearOnUIEdit(); - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - let user; - let location; - let fileName; before(() => { - cy.loginAsAdmin({ path: TopMenu.fundPath, waiter: Funds.waitLoading, authRefresh: true }); - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - secondFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '2'; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - defaultFund.ledgerId = defaultLedger.id; - Funds.createViaApi(defaultFund).then((fundResponse) => { - defaultFund.id = fundResponse.fund.id; - FinanceHelp.searchByName(defaultFund.name); - Funds.selectFund(defaultFund.name); - Funds.addBudget(allocatedQuantity); - }); - }); - cy.getLocations({ limit: 1 }).then((res) => { - location = res; + cy.getAdminToken(); + // create first Fiscal Year with Expense Classes + ExpenseClasses.getExpenseClassesViaApi({ + query: `name=="${testData.expenseClass.name}"`, + limit: 1, + }).then((resp) => { + testData.expenseClass.id = resp?.[0]?.id; + + const { ledger, fund } = Budgets.createBudgetWithFundLedgerAndFYViaApi({ + fiscalYear: fiscalYears.current, + ledger: { restrictEncumbrance: true, restrictExpenditures: true }, + budget: { + allocated: 100, + statusExpenseClasses: [ + { + status: 'Active', + expenseClassId: testData.expenseClass.id, + }, + ], + }, }); + testData.ledger = ledger; + testData.fund = fund; // Create second Fiscal Year for Rollover - FiscalYears.createViaApi(secondFiscalYear).then((secondFiscalYearResponse) => { - secondFiscalYear.id = secondFiscalYearResponse.id; - }); + FiscalYears.createViaApi(fiscalYears.next); + Organizations.createOrganizationViaApi(organization).then((orgResp) => { + organization.id = orgResp; + order.vendor = orgResp; + + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((amResp) => { + cy.getBookMaterialType().then((mtypeResp) => { + const orderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + listUnitPrice: 25.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 25.0, + }, + fundDistribution: [ + { + code: testData.fund.code, + fundId: testData.fund.id, + expenseClassId: testData.expenseClass.id, + value: 100, + }, + ], + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: amResp.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypeResp.id, + materialSupplier: orgResp.id, + volumes: [], + }, + }; + + // Create first open order + Orders.createOrderViaApi(order).then((orderResp) => { + order.id = orderResp.id; + order.poNumber = orderResp.poNumber; + orderLine.purchaseOrderId = orderResp.id; - // Prepare Open Order for Rollover - Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { - organization.id = responseOrganizations; + OrderLines.createOrderLineViaApi(orderLine); + Orders.updateOrderViaApi({ + ...orderResp, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); + }); + }); + }); }); - firstOrder.vendor = organization.name; - cy.visit(TopMenu.ordersPath); - Orders.createApprovedOrderForRollover(firstOrder, true).then((firstOrderResponse) => { - firstOrder.id = firstOrderResponse.id; - Orders.checkCreatedOrder(firstOrder); - OrderLines.addPOLine(); - OrderLines.selectRandomInstanceInTitleLookUP('*', 35); - OrderLines.rolloverPOLineInfoforPhysicalMaterialWithFund( - defaultFund, - '10', - '1', - '10', - location.name, - ); - OrderLines.backToEditingOrder(); - Orders.openOrder(); + const rollover = LedgerRollovers.generateLedgerRollover({ + ledger: testData.ledger, + fromFiscalYear: fiscalYears.current, + toFiscalYear: fiscalYears.next, + restrictEncumbrance: true, + restrictExpenditures: true, + needCloseBudgets: true, + budgetsRollover: [ + { + rolloverAllocation: true, + rolloverBudgetValue: 'None', + addAvailableTo: 'Allocation', + }, + ], + encumbrancesRollover: [{ orderType: 'One-time', basedOn: 'InitialAmount' }], }); - cy.visit(TopMenu.ledgerPath); - FinanceHelp.searchByName(defaultLedger.name); - Ledgers.selectLedger(defaultLedger.name); - Ledgers.rollover(); - Ledgers.fillInRolloverForOneTimeOrdersWithAllocation( - secondFiscalYear.code, - 'None', - 'Allocation', - ); - cy.visit(TopMenu.fiscalYearPath); - FinanceHelp.searchByName(firstFiscalYear.name); - FiscalYears.selectFY(firstFiscalYear.name); - FiscalYears.editFiscalYearDetails(); - FiscalYears.filltheStartAndEndDateonCalenderstartDateField( - periodStartForFirstFY, - periodEndForFirstFY, - ); - FinanceHelp.searchByName(secondFiscalYear.name); - FiscalYears.selectFY(secondFiscalYear.name); - FiscalYears.editFiscalYearDetails(); - FiscalYears.filltheStartAndEndDateonCalenderstartDateField( - periodStartForSecondFY, - periodEndForSecondFY, - ); - fileName = `Export${defaultLedger.code}-${secondFiscalYear.code}`; + LedgerRollovers.createLedgerRolloverViaApi(rollover); + testData.fileName = `Export-${testData.ledger.code}-${fiscalYears.next.code}`; + }); + FiscalYears.updateFiscalYearViaApi({ + ...fiscalYears.current, + _version: 1, + periodStart: new Date(date.getFullYear() - 1, 0, 1), + periodEnd: new Date(date.getFullYear() - 1, 11, 31), }); + + FiscalYears.updateFiscalYearViaApi({ + ...fiscalYears.next, + _version: 1, + periodStart: new Date(date.getFullYear(), 0, 1), + periodEnd: new Date(date.getFullYear(), 11, 31), + }); + cy.createTempUser([ - permissions.uiFinanceExportFinanceRecords.gui, - permissions.uiFinanceViewLedger.gui, + Permissions.uiFinanceExportFinanceRecords.gui, + Permissions.uiFinanceViewLedger.gui, ]).then((userProperties) => { - user = userProperties; + testData.user = userProperties; + cy.login(userProperties.username, userProperties.password, { path: TopMenu.ledgerPath, waiter: Ledgers.waitForLedgerDetailsLoading, - authRefresh: true, }); }); }); - after(() => { + after('Clean up test data', () => { + FileManager.deleteFile(`cypress/downloads/${testData.fileName}.csv`); cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); }); it( 'C350974 Ledger export settings: last year Fund with budget, Electronic (Active) Class, Export settings- Active status (thunderjet) (TaaS)', { tags: ['extendedPath', 'thunderjet', 'C350974'] }, () => { - FinanceHelp.searchByName(defaultLedger.name); - Ledgers.selectLedger(defaultLedger.name); + FinanceHelp.searchByName(testData.ledger.name); + Ledgers.selectLedger(testData.ledger.name); Ledgers.exportBudgetInformation(); - Ledgers.prepareExportSettings(secondFiscalYear.code, 'Active', defaultLedger); - Ledgers.deleteDownloadedFile(`${fileName}.csv`); + Ledgers.prepareExportSettings(fiscalYears.next.code, 'Active', testData.ledger); }, ); }); diff --git a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-all-statuses-with-ex-classes.cy.js b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-all-statuses-with-ex-classes.cy.js index c1f786fc41..320fa15019 100644 --- a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-all-statuses-with-ex-classes.cy.js +++ b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-all-statuses-with-ex-classes.cy.js @@ -1,185 +1,272 @@ -import permissions from '../../../../support/dictionary/permissions'; +import uuid from 'uuid'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + LOCATION_NAMES, + ORDER_STATUSES, +} from '../../../../support/constants'; +import Permissions from '../../../../support/dictionary/permissions'; +import { + Budgets, + FiscalYears, + Funds, + LedgerRollovers, + Ledgers, +} from '../../../../support/fragments/finance'; 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 NewOrder from '../../../../support/fragments/orders/newOrder'; -import OrderLines from '../../../../support/fragments/orders/orderLines'; -import Orders from '../../../../support/fragments/orders/orders'; -import NewOrganization from '../../../../support/fragments/organizations/newOrganization'; -import Organizations from '../../../../support/fragments/organizations/organizations'; +import { BasicOrderLine, NewOrder, OrderLines, Orders } from '../../../../support/fragments/orders'; +import { NewOrganization, Organizations } from '../../../../support/fragments/organizations'; +import ExpenseClasses from '../../../../support/fragments/settings/finance/expenseClasses'; import TopMenu from '../../../../support/fragments/topMenu'; import Users from '../../../../support/fragments/users/users'; -import DateTools from '../../../../support/utils/dateTools'; +import { CodeTools, StringTools } from '../../../../support/utils'; +import FileManager from '../../../../support/utils/fileManager'; import getRandomPostfix from '../../../../support/utils/stringTools'; describe('Finance: Ledgers', () => { - const firstFiscalYear = { ...FiscalYears.defaultRolloverFiscalYear }; - const secondFiscalYear = { - name: `autotest_year_${getRandomPostfix()}`, - code: DateTools.getRandomFiscalYearCodeForRollover(2000, 9999), - periodStart: `${DateTools.get3DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+00:00`, - periodEnd: `${DateTools.get4DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+00:00`, - description: `This is fiscal year created by E2E test automation script_${getRandomPostfix()}`, - series: 'FY', + const date = new Date(); + const code = CodeTools(4); + const organization = { ...NewOrganization.defaultUiOrganizations }; + const testData = { + organization, + user: {}, + }; + const fiscalYears = { + current: { + ...FiscalYears.getDefaultFiscalYear(), + code: `${code}${StringTools.randomTwoDigitNumber()}01`, + periodStart: new Date(date.getFullYear(), 0, 1), + periodEnd: new Date(date.getFullYear(), 11, 31), + }, + next: { + ...FiscalYears.getDefaultFiscalYear(), + code: `${code}${StringTools.randomTwoDigitNumber()}02`, + periodStart: new Date(date.getFullYear() + 1, 0, 1), + periodEnd: new Date(date.getFullYear() + 1, 11, 31), + }, + }; + const expenseClass1 = { ...ExpenseClasses.getDefaultExpenseClass() }; + const expenseClass2 = { + ...ExpenseClasses.getDefaultExpenseClass(), + name: `autotest_class_2_name_${getRandomPostfix()}`, }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const defaultFund = { ...Funds.defaultUiFund }; const firstOrder = { ...NewOrder.defaultOneTimeOrder, - orderType: 'One-time', + id: uuid(), approved: true, reEncumber: true, + vendorId: testData.organization.id, }; const secondOrder = { ...NewOrder.defaultOneTimeOrder, - orderType: 'One-time', + id: uuid(), approved: true, reEncumber: true, + vendorId: testData.organization.id, }; - const organization = { ...NewOrganization.defaultUiOrganizations }; - const allocatedQuantity = '100'; - const periodStartForFirstFY = DateTools.getThreePreviousDaysDateForFiscalYearOnUIEdit(); - const periodEndForFirstFY = DateTools.getPreviousDayDateForFiscalYearOnUIEdit(); - const periodStartForSecondFY = DateTools.getCurrentDateForFiscalYearOnUIEdit(); - const periodEndForSecondFY = DateTools.getDayTomorrowDateForFiscalYearOnUIEdit(); - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - let user; - let location; - let fileName; - - before(() => { + + before('Setup test data', () => { cy.getAdminToken(); - // create first Fiscal Year and prepere 2 Funds for Rollover - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - secondFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '2'; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - defaultFund.ledgerId = defaultLedger.id; - - Funds.createViaApi(defaultFund).then((fundResponse) => { - defaultFund.id = fundResponse.fund.id; - - cy.loginAsAdmin({ path: TopMenu.fundPath, waiter: Funds.waitLoading }); - FinanceHelp.searchByName(defaultFund.name); - Funds.selectFund(defaultFund.name); - Funds.addBudget(allocatedQuantity); - Funds.editBudget(); - Funds.addTwoExpensesClass('Electronic', 'Print'); + ExpenseClasses.createExpenseClassViaApi(expenseClass1).then((ec1) => { + testData.expenseClass1 = ec1; + + ExpenseClasses.createExpenseClassViaApi(expenseClass2).then((ec2) => { + testData.expenseClass2 = ec2; + + // create first Fiscal Year with Expense Classes + const { ledger, fund } = Budgets.createBudgetWithFundLedgerAndFYViaApi({ + fiscalYear: fiscalYears.current, + ledger: { restrictEncumbrance: true, restrictExpenditures: true }, + budget: { + allocated: 100, + statusExpenseClasses: [ + { + status: 'Active', + expenseClassId: testData.expenseClass1.id, + }, + { + status: 'Active', + expenseClassId: testData.expenseClass2.id, + }, + ], + }, }); - }); + testData.ledger = ledger; + testData.fund = fund; - cy.getLocations({ limit: 1 }).then((res) => { - location = res; - }); - // Create second Fiscal Year for Rollover - FiscalYears.createViaApi(secondFiscalYear).then((secondFiscalYearResponse) => { - secondFiscalYear.id = secondFiscalYearResponse.id; - }); - // Prepare Open Order for Rollover - Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { - organization.id = responseOrganizations; + // Create second Fiscal Year for Rollover + FiscalYears.createViaApi(fiscalYears.next); + Organizations.createOrganizationViaApi(organization).then((orgResp) => { + organization.id = orgResp; + firstOrder.vendor = orgResp; + secondOrder.vendor = orgResp; + + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((amResp) => { + cy.getBookMaterialType().then((mtypeResp) => { + const firstOrderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + listUnitPrice: 25.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 25.0, + }, + fundDistribution: [ + { + code: testData.fund.code, + fundId: testData.fund.id, + expenseClassId: testData.expenseClass1.id, + value: 100, + }, + ], + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: amResp.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypeResp.id, + materialSupplier: orgResp.id, + volumes: [], + }, + }; + + // Create first open order + Orders.createOrderViaApi(firstOrder).then((orderResp) => { + firstOrder.id = orderResp.id; + firstOrder.poNumber = orderResp.poNumber; + firstOrderLine.purchaseOrderId = orderResp.id; + + OrderLines.createOrderLineViaApi(firstOrderLine); + Orders.updateOrderViaApi({ + ...orderResp, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); + + const secondOrderLine = { + ...BasicOrderLine.defaultOrderLine, + id: uuid(), + cost: { + listUnitPrice: 20.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 20.0, + }, + fundDistribution: [ + { + code: testData.fund.code, + fundId: testData.fund.id, + expenseClassId: testData.expenseClass2.id, + value: 100, + }, + ], + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: amResp.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypeResp.id, + materialSupplier: orgResp.id, + volumes: [], + }, + }; + // Create second open order + Orders.createOrderViaApi(secondOrder).then((orderResp) => { + secondOrder.id = orderResp.id; + secondOrder.poNumber = orderResp.poNumber; + secondOrderLine.purchaseOrderId = orderResp.id; + + OrderLines.createOrderLineViaApi(secondOrderLine); + Orders.updateOrderViaApi({ + ...orderResp, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); + }); + }); + }); + }); + + cy.loginAsAdmin(); + cy.visit(TopMenu.fundPath); + FinanceHelp.searchByName(testData.fund.name); + Funds.selectFund(testData.fund.name); + Funds.selectBudgetDetails(); + Funds.editBudget(); + Funds.changeStatusOfExpClassByName(expenseClass2.name, 'Inactive'); + + const rollover = LedgerRollovers.generateLedgerRollover({ + ledger: testData.ledger, + fromFiscalYear: fiscalYears.current, + toFiscalYear: fiscalYears.next, + restrictEncumbrance: true, + restrictExpenditures: true, + needCloseBudgets: true, + budgetsRollover: [ + { + rolloverAllocation: true, + rolloverBudgetValue: 'None', + addAvailableTo: 'Allocation', + }, + ], + encumbrancesRollover: [{ orderType: 'One-time', basedOn: 'InitialAmount' }], + }); + LedgerRollovers.createLedgerRolloverViaApi(rollover); + testData.fileName = `Export-${testData.ledger.code}-${fiscalYears.next.code}`; }); - firstOrder.vendor = organization.name; - secondOrder.vendor = organization.name; - cy.visit(TopMenu.ordersPath); - Orders.createApprovedOrderForRollover(firstOrder, true).then((firstOrderResponse) => { - firstOrder.id = firstOrderResponse.id; - Orders.checkCreatedOrder(firstOrder); - OrderLines.addPOLine(); - OrderLines.selectRandomInstanceInTitleLookUP('*', 35); - OrderLines.rolloverPOLineInfoForPhysicalMaterialWithFundAndExpClass( - defaultFund, - 'Electronic', - '10', - '1', - '10', - location.name, - ); - OrderLines.backToEditingOrder(); - Orders.openOrder(); + + FiscalYears.updateFiscalYearViaApi({ + ...fiscalYears.current, + _version: 1, + periodStart: new Date(date.getFullYear() - 1, 0, 1), + periodEnd: new Date(date.getFullYear() - 1, 11, 31), }); - Orders.createApprovedOrderForRollover(secondOrder, true).then((secondOrderResponse) => { - secondOrder.id = secondOrderResponse.id; - Orders.checkCreatedOrder(secondOrder); - OrderLines.addPOLine(); - OrderLines.selectRandomInstanceInTitleLookUP('*', 35); - OrderLines.rolloverPOLineInfoForPhysicalMaterialWithFundAndExpClass( - defaultFund, - 'Print', - '10', - '1', - '10', - location.name, - ); - OrderLines.backToEditingOrder(); - Orders.openOrder(); + + FiscalYears.updateFiscalYearViaApi({ + ...fiscalYears.next, + _version: 1, + periodStart: new Date(date.getFullYear(), 0, 1), + periodEnd: new Date(date.getFullYear(), 11, 31), }); - cy.visit(TopMenu.fundPath); - FinanceHelp.searchByName(defaultFund.name); - Funds.selectFund(defaultFund.name); - Funds.selectBudgetDetails(); - Funds.editBudget(); - Funds.changeStatusOfExpClass(1, 'Inactive'); - cy.visit(TopMenu.ledgerPath); - FinanceHelp.searchByName(defaultLedger.name); - Ledgers.selectLedger(defaultLedger.name); - Ledgers.rollover(); - Ledgers.fillInRolloverForOneTimeOrdersWithAllocation( - secondFiscalYear.code, - 'None', - 'Allocation', - ); - cy.visit(TopMenu.fiscalYearPath); - FinanceHelp.searchByName(firstFiscalYear.name); - FiscalYears.selectFY(firstFiscalYear.name); - FiscalYears.editFiscalYearDetails(); - FiscalYears.filltheStartAndEndDateonCalenderstartDateField( - periodStartForFirstFY, - periodEndForFirstFY, - ); - FinanceHelp.searchByName(secondFiscalYear.name); - FiscalYears.selectFY(secondFiscalYear.name); - FiscalYears.editFiscalYearDetails(); - FiscalYears.filltheStartAndEndDateonCalenderstartDateField( - periodStartForSecondFY, - periodEndForSecondFY, - ); - fileName = `Export-${defaultLedger.code}-${secondFiscalYear.code}`; - }); - cy.createTempUser([ - permissions.uiFinanceExportFinanceRecords.gui, - permissions.uiFinanceViewLedger.gui, - ]).then((userProperties) => { - user = userProperties; - cy.login(userProperties.username, userProperties.password, { - path: TopMenu.ledgerPath, - waiter: Ledgers.waitForLedgerDetailsLoading, + + cy.createTempUser([ + Permissions.uiFinanceExportFinanceRecords.gui, + Permissions.uiFinanceViewLedger.gui, + ]).then((userProperties) => { + testData.user = userProperties; + + cy.login(userProperties.username, userProperties.password, { + path: TopMenu.ledgerPath, + waiter: Ledgers.waitForLedgerDetailsLoading, + }); }); }); }); - after(() => { + after('Clean up test data', () => { + FileManager.deleteFile(`cypress/downloads/${testData.fileName}.csv`); cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); }); it( 'C350975 Ledger export settings: last year Fund with budget, Print (Active) and Electronic (Inactive) Classes, Export settings- All statuses (thunderjet) (TaaS)', { tags: ['extendedPath', 'thunderjet', 'C350975'] }, () => { - FinanceHelp.searchByName(defaultLedger.name); - Ledgers.selectLedger(defaultLedger.name); + FinanceHelp.searchByName(testData.ledger.name); + Ledgers.selectLedger(testData.ledger.name); Ledgers.exportBudgetInformation(); - Ledgers.prepareExportSettings(secondFiscalYear.code, 'All', defaultLedger); - Ledgers.checkColumnNamesInDownloadedLedgerExportFileWithExpClasses(`${fileName}.csv`); + Ledgers.prepareExportSettings(fiscalYears.next.code, 'All', testData.ledger); + Ledgers.checkColumnNamesInDownloadedLedgerExportFileWithExpClasses( + `${testData.fileName}.csv`, + ); Ledgers.checkColumnContentInDownloadedLedgerExportFileWithExpClasses( - `${fileName}.csv`, - 1, - defaultFund, - secondFiscalYear, + `${testData.fileName}.csv`, + expenseClass1.name, + testData.fund, + fiscalYears.next, '100', '100', '100', @@ -188,26 +275,25 @@ describe('Finance: Ledgers', () => { '100', '0', '100', - '20', + '45', '0', '0', - '20', + '45', '0', '0', '100', - '80', - 'Print', - 'Prn', - 'Inactive', - '10', + '55', + expenseClass1.code, + 'Active', + '25', '0', '0', ); Ledgers.checkColumnContentInDownloadedLedgerExportFileWithExpClasses( - `${fileName}.csv`, - 2, - defaultFund, - secondFiscalYear, + `${testData.fileName}.csv`, + expenseClass2.name, + testData.fund, + fiscalYears.next, '100', '100', '100', @@ -216,22 +302,20 @@ describe('Finance: Ledgers', () => { '100', '0', '100', - '20', + '45', '0', '0', - '20', + '45', '0', '0', '100', - '80', - 'Electronic', - 'Elec', - 'Active', - '10', + '55', + expenseClass2.code, + 'Inactive', + '20', '0', '0', ); - Ledgers.deleteDownloadedFile(`${fileName}.csv`); }, ); }); diff --git a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-all-statuses-without-rollover-with-ex-classes.cy.js b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-all-statuses-without-rollover-with-ex-classes.cy.js index 1b736a0e46..34d0a47d26 100644 --- a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-all-statuses-without-rollover-with-ex-classes.cy.js +++ b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-all-statuses-without-rollover-with-ex-classes.cy.js @@ -1,122 +1,150 @@ -import { APPLICATION_NAMES } from '../../../../support/constants'; -import permissions from '../../../../support/dictionary/permissions'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + LOCATION_NAMES, + ORDER_STATUSES, +} from '../../../../support/constants'; +import Permissions from '../../../../support/dictionary/permissions'; +import { Budgets, Ledgers } from '../../../../support/fragments/finance'; 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 NewOrder from '../../../../support/fragments/orders/newOrder'; -import OrderLines from '../../../../support/fragments/orders/orderLines'; -import Orders from '../../../../support/fragments/orders/orders'; -import NewOrganization from '../../../../support/fragments/organizations/newOrganization'; -import Organizations from '../../../../support/fragments/organizations/organizations'; +import { BasicOrderLine, NewOrder, OrderLines, Orders } from '../../../../support/fragments/orders'; +import { NewOrganization, Organizations } from '../../../../support/fragments/organizations'; +import ExpenseClasses from '../../../../support/fragments/settings/finance/expenseClasses'; import TopMenu from '../../../../support/fragments/topMenu'; -import TopMenuNavigation from '../../../../support/fragments/topMenuNavigation'; import Users from '../../../../support/fragments/users/users'; +import FileManager from '../../../../support/utils/fileManager'; describe('Finance: Ledgers', () => { - const firstFiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const defaultFund = { ...Funds.defaultUiFund }; - const firstOrder = { - ...NewOrder.defaultOneTimeOrder, - orderType: 'One-time', - approved: true, - reEncumber: true, + const organization = { ...NewOrganization.defaultUiOrganizations }; + const testData = { + organization, + user: {}, + expenseClass: { + name: 'Electronic', + code: 'Elec', + status: 'Active', + id: '', + }, }; - const secondOrder = { + const order = { ...NewOrder.defaultOneTimeOrder, - orderType: 'One-time', approved: true, reEncumber: true, + vendorId: testData.organization.id, }; - const organization = { ...NewOrganization.defaultUiOrganizations }; - const allocatedQuantity = '100'; - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - let user; - let location; - let fileName; - before(() => { + before('Setup test data', () => { cy.getAdminToken(); - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - defaultFund.ledgerId = defaultLedger.id; + ExpenseClasses.getExpenseClassesViaApi({ + query: `name=="${testData.expenseClass.name}"`, + limit: 1, + }).then((response) => { + testData.expenseClass.id = response?.[0]?.id; + const { fiscalYear, ledger, fund, budget } = Budgets.createBudgetWithFundLedgerAndFYViaApi({ + ledger: { restrictEncumbrance: true, restrictExpenditures: true }, + budget: { + allocated: 100, + statusExpenseClasses: [ + { + status: testData.expenseClass.status, + expenseClassId: testData.expenseClass.id, + }, + ], + }, + }); + testData.fiscalYear = fiscalYear; + testData.ledger = ledger; + testData.fund = fund; + testData.budget = budget; - Funds.createViaApi(defaultFund).then((fundResponse) => { - defaultFund.id = fundResponse.fund.id; + Organizations.createOrganizationViaApi(organization).then((orgResp) => { + organization.id = orgResp; + order.vendor = orgResp; - cy.loginAsAdmin({ path: TopMenu.fundPath, waiter: Funds.waitLoading }); - FinanceHelp.searchByName(defaultFund.name); - Funds.selectFund(defaultFund.name); - Funds.addBudget(allocatedQuantity); - Funds.editBudget(); - Funds.addExpensesClass('Electronic'); - }); - }); + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((amResp) => { + cy.getBookMaterialType().then((mtypeResp) => { + const orderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + listUnitPrice: 25.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 25.0, + }, + fundDistribution: [ + { + code: testData.fund.code, + fundId: testData.fund.id, + expenseClassId: testData.expenseClass.id, + value: 100, + }, + ], + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: amResp.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypeResp.id, + materialSupplier: orgResp.id, + volumes: [], + }, + }; - cy.getLocations({ limit: 1 }).then((res) => { - location = res; - }); - Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { - organization.id = responseOrganizations; - }); - firstOrder.vendor = organization.name; - secondOrder.vendor = organization.name; - TopMenuNavigation.openAppFromDropdown(APPLICATION_NAMES.ORDERS); - Orders.selectOrdersPane(); - Orders.createApprovedOrderForRollover(firstOrder, true).then((firstOrderResponse) => { - firstOrder.id = firstOrderResponse.id; - Orders.checkCreatedOrder(firstOrder); - OrderLines.addPOLine(); - OrderLines.selectRandomInstanceInTitleLookUP('*', 35); - OrderLines.rolloverPOLineInfoForPhysicalMaterialWithFundAndExpClass( - defaultFund, - 'Electronic', - '10', - '1', - '10', - location.name, - ); - OrderLines.backToEditingOrder(); - Orders.openOrder(); + // Create first open order + Orders.createOrderViaApi(order).then((orderResp) => { + order.id = orderResp.id; + orderLine.purchaseOrderId = orderResp.id; + + OrderLines.createOrderLineViaApi(orderLine); + Orders.updateOrderViaApi({ + ...orderResp, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); + }); + }); + }); }); - fileName = `Export-${defaultLedger.code}-${firstFiscalYear.code}`; + testData.fileName = `Export-${testData.ledger.code}-${fiscalYear.code}`; }); + cy.createTempUser([ - permissions.uiFinanceExportFinanceRecords.gui, - permissions.uiFinanceViewLedger.gui, + Permissions.uiFinanceExportFinanceRecords.gui, + Permissions.uiFinanceViewLedger.gui, ]).then((userProperties) => { - user = userProperties; + testData.user = userProperties; + cy.login(userProperties.username, userProperties.password, { path: TopMenu.ledgerPath, waiter: Ledgers.waitForLedgerDetailsLoading, - authRefresh: true, }); }); }); - after(() => { + after('Clean up test data', () => { + FileManager.deleteFile(`cypress/downloads/${testData.fileName}.csv`); cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); }); it( 'C353207 Ledger export settings: current year Fund with budget, Print (Active) Class, Export settings - All statuses (thunderjet) (TaaS)', { tags: ['extendedPath', 'thunderjet', 'C353207'] }, () => { - FinanceHelp.searchByName(defaultLedger.name); - Ledgers.selectLedger(defaultLedger.name); + FinanceHelp.searchByName(testData.ledger.name); + Ledgers.selectLedger(testData.ledger.name); Ledgers.exportBudgetInformation(); - Ledgers.prepareExportSettings(firstFiscalYear.code, 'All', defaultLedger); - Ledgers.checkColumnNamesInDownloadedLedgerExportFileWithExpClasses(`${fileName}.csv`); + Ledgers.prepareExportSettings(testData.fiscalYear.code, 'All', testData.ledger); + Ledgers.checkColumnNamesInDownloadedLedgerExportFileWithExpClasses( + `${testData.fileName}.csv`, + ); Ledgers.checkColumnContentInDownloadedLedgerExportFileWithExpClasses( - `${fileName}.csv`, - 1, - defaultFund, - firstFiscalYear, + `${testData.fileName}.csv`, + testData.expenseClass.name, + testData.fund, + testData.budget.name, '100', '100', '100', @@ -125,22 +153,20 @@ describe('Finance: Ledgers', () => { '100', '0', '100', - '10', + '25', '0', '0', - '10', + '25', '0', '0', '100', - '90', - 'Electronic', - 'Elec', - 'Active', - '10', + '75', + testData.expenseClass.code, + testData.expenseClass.status, + '25', '0', '0', ); - Ledgers.deleteDownloadedFile(`${fileName}.csv`); }, ); }); diff --git a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-all-statuses.cy.js b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-all-statuses.cy.js index 42fc8febf5..f091ab0ca7 100644 --- a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-all-statuses.cy.js +++ b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-all-statuses.cy.js @@ -1,129 +1,143 @@ -import permissions from '../../../../support/dictionary/permissions'; +import Permissions from '../../../../support/dictionary/permissions'; +import { + FiscalYears, + Funds, + LedgerRollovers, + Ledgers, +} from '../../../../support/fragments/finance'; 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 { NewOrganization } from '../../../../support/fragments/organizations'; import TopMenu from '../../../../support/fragments/topMenu'; import Users from '../../../../support/fragments/users/users'; -import DateTools from '../../../../support/utils/dateTools'; -import getRandomPostfix from '../../../../support/utils/stringTools'; +import { CodeTools, StringTools } from '../../../../support/utils'; +import FileManager from '../../../../support/utils/fileManager'; describe('Finance: Ledgers', () => { - const firstFiscalYear = { ...FiscalYears.defaultRolloverFiscalYear }; - const secondFiscalYear = { - name: `autotest_year_${getRandomPostfix()}`, - code: DateTools.getRandomFiscalYearCodeForRollover(2000, 9999), - periodStart: `${DateTools.get3DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+00:00`, - periodEnd: `${DateTools.get4DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+00:00`, - description: `This is fiscal year created by E2E test automation script_${getRandomPostfix()}`, - series: 'FY', + const date = new Date(); + const code = CodeTools(4); + const organization = { ...NewOrganization.defaultUiOrganizations }; + const testData = { + organization, + user: {}, }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const defaultFund = { ...Funds.defaultUiFund }; - const allocatedQuantity = '100'; - const periodStartForFirstFY = DateTools.getThreePreviousDaysDateForFiscalYearOnUIEdit(); - const periodEndForFirstFY = DateTools.getPreviousDayDateForFiscalYearOnUIEdit(); - const periodStartForSecondFY = DateTools.getCurrentDateForFiscalYearOnUIEdit(); - const periodEndForSecondFY = DateTools.getDayTomorrowDateForFiscalYearOnUIEdit(); - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - let user; - let fileName; + const fiscalYears = { + current: { + ...FiscalYears.getDefaultFiscalYear(), + code: `${code}${StringTools.randomTwoDigitNumber()}01`, + periodStart: new Date(date.getFullYear(), 0, 1), + periodEnd: new Date(date.getFullYear(), 11, 31), + }, + next: { + ...FiscalYears.getDefaultFiscalYear(), + code: `${code}${StringTools.randomTwoDigitNumber()}02`, + periodStart: new Date(date.getFullYear() + 1, 0, 1), + periodEnd: new Date(date.getFullYear() + 1, 11, 31), + }, + }; + const ledger = { ...Ledgers.defaultUiLedger }; + const fund = { ...Funds.defaultUiFund }; + + before('Setup test data', () => { + cy.getAdminToken(); + FiscalYears.createViaApi(fiscalYears.current).then((fiscalYearResponse) => { + fiscalYears.current.id = fiscalYearResponse.id; + ledger.fiscalYearOneId = fiscalYears.current.id; - before(() => { - cy.loginAsAdmin({ path: TopMenu.fundPath, waiter: Funds.waitLoading, authRefresh: true }); - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - secondFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '2'; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - defaultFund.ledgerId = defaultLedger.id; - Funds.createViaApi(defaultFund).then((fundResponse) => { - defaultFund.id = fundResponse.fund.id; - FinanceHelp.searchByName(defaultFund.name); - Funds.selectFund(defaultFund.name); - Funds.addBudget(allocatedQuantity); + Ledgers.createViaApi(ledger).then((ledgerResponse) => { + ledger.id = ledgerResponse.id; + fund.ledgerId = ledgerResponse.id; + Funds.createViaApi(fund).then((fundResponse) => { + fund.id = fundResponse.fund.id; }); + + // Create second Fiscal Year for Rollover + FiscalYears.createViaApi(fiscalYears.next); + const rollover = LedgerRollovers.generateLedgerRollover({ + ledger, + fromFiscalYear: fiscalYears.current, + toFiscalYear: fiscalYears.next, + restrictEncumbrance: true, + restrictExpenditures: true, + needCloseBudgets: true, + budgetsRollover: [ + { + rolloverAllocation: true, + rolloverBudgetValue: 'None', + addAvailableTo: 'Allocation', + }, + ], + encumbrancesRollover: [{ orderType: 'One-time', basedOn: 'InitialAmount' }], + }); + LedgerRollovers.createLedgerRolloverViaApi(rollover); + FiscalYears.updateFiscalYearViaApi({ + ...fiscalYears.current, + _version: 1, + periodStart: new Date(date.getFullYear() - 1, 0, 1), + periodEnd: new Date(date.getFullYear() - 1, 11, 31), + }); + + FiscalYears.updateFiscalYearViaApi({ + ...fiscalYears.next, + _version: 1, + periodStart: new Date(date.getFullYear(), 0, 1), + periodEnd: new Date(date.getFullYear(), 11, 31), + }); + testData.fileName = `Export-${ledger.code}-${fiscalYears.next.code}`; }); - FiscalYears.createViaApi(secondFiscalYear).then((secondFiscalYearResponse) => { - secondFiscalYear.id = secondFiscalYearResponse.id; - }); - cy.visit(TopMenu.ledgerPath); - FinanceHelp.searchByName(defaultLedger.name); - Ledgers.selectLedger(defaultLedger.name); - Ledgers.rollover(); - Ledgers.fillInRolloverForOneTimeOrdersWithAllocation( - secondFiscalYear.code, - 'None', - 'Allocation', - ); - cy.visit(TopMenu.fiscalYearPath); - FinanceHelp.searchByName(firstFiscalYear.name); - FiscalYears.selectFY(firstFiscalYear.name); - FiscalYears.editFiscalYearDetails(); - FiscalYears.filltheStartAndEndDateonCalenderstartDateField( - periodStartForFirstFY, - periodEndForFirstFY, - ); - FinanceHelp.searchByName(secondFiscalYear.name); - FiscalYears.selectFY(secondFiscalYear.name); - FiscalYears.editFiscalYearDetails(); - FiscalYears.filltheStartAndEndDateonCalenderstartDateField( - periodStartForSecondFY, - periodEndForSecondFY, - ); - fileName = `Export-${defaultLedger.code}-${secondFiscalYear.code}`; }); + cy.createTempUser([ - permissions.uiFinanceExportFinanceRecords.gui, - permissions.uiFinanceViewLedger.gui, + Permissions.uiFinanceExportFinanceRecords.gui, + Permissions.uiFinanceViewLedger.gui, ]).then((userProperties) => { - user = userProperties; + testData.user = userProperties; + cy.login(userProperties.username, userProperties.password, { path: TopMenu.ledgerPath, waiter: Ledgers.waitForLedgerDetailsLoading, - authRefresh: true, }); }); }); - after(() => { + after('Cleanup test data', () => { + FileManager.deleteFile(`cypress/downloads/${testData.fileName}.csv`); cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); }); it( 'C353212 Ledger export settings: last year Fund with NO budget, NO Classes, Export settings-All statuses (thunderjet) (TaaS)', { tags: ['extendedPath', 'thunderjet', 'C353212'] }, () => { - FinanceHelp.searchByName(defaultLedger.name); - Ledgers.selectLedger(defaultLedger.name); + FinanceHelp.searchByName(ledger.name); + Ledgers.selectLedger(ledger.name); Ledgers.exportBudgetInformation(); - Ledgers.prepareExportSettings(secondFiscalYear.code, 'All', defaultLedger); - Ledgers.checkColumnNamesInDownloadedLedgerExportFileWithExpClasses(`${fileName}.csv`); + Ledgers.prepareExportSettings(fiscalYears.next.code, 'All', ledger); + Ledgers.checkColumnNamesInDownloadedLedgerExportFileWithExpClasses( + `${testData.fileName}.csv`, + ); Ledgers.checkColumnContentInDownloadedLedgerExportFileForNone( - `${fileName}.csv`, + `${testData.fileName}.csv`, 1, - defaultFund, - secondFiscalYear, - '100', - '100', - '100', - '0', - '0', - '100', - '0', - '100', - '0', - '0', - '0', - '0', - '0', - '0', - '100', - '100', + fund, + 'No budget found', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', ); - Ledgers.deleteDownloadedFile(`${fileName}.csv`); }, ); }); diff --git a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-inactive-status-with-rollover-and-2-exp-classes.cy.js b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-inactive-status-with-rollover-and-2-exp-classes.cy.js index ef8d950062..f8771e4183 100644 --- a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-inactive-status-with-rollover-and-2-exp-classes.cy.js +++ b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-inactive-status-with-rollover-and-2-exp-classes.cy.js @@ -1,185 +1,283 @@ -import { APPLICATION_NAMES } from '../../../../support/constants'; -import permissions from '../../../../support/dictionary/permissions'; +import uuid from 'uuid'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + LOCATION_NAMES, + ORDER_STATUSES, +} from '../../../../support/constants'; +import Permissions from '../../../../support/dictionary/permissions'; +import { + Budgets, + FiscalYears, + Funds, + LedgerRollovers, + Ledgers, +} from '../../../../support/fragments/finance'; 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 NewOrder from '../../../../support/fragments/orders/newOrder'; -import OrderLines from '../../../../support/fragments/orders/orderLines'; -import Orders from '../../../../support/fragments/orders/orders'; -import NewOrganization from '../../../../support/fragments/organizations/newOrganization'; -import Organizations from '../../../../support/fragments/organizations/organizations'; +import { BasicOrderLine, NewOrder, OrderLines, Orders } from '../../../../support/fragments/orders'; +import { NewOrganization, Organizations } from '../../../../support/fragments/organizations'; +import ExpenseClasses from '../../../../support/fragments/settings/finance/expenseClasses'; import TopMenu from '../../../../support/fragments/topMenu'; -import TopMenuNavigation from '../../../../support/fragments/topMenuNavigation'; import Users from '../../../../support/fragments/users/users'; -import DateTools from '../../../../support/utils/dateTools'; -import getRandomPostfix from '../../../../support/utils/stringTools'; +import { CodeTools, StringTools } from '../../../../support/utils'; +import FileManager from '../../../../support/utils/fileManager'; describe('Finance: Ledgers', () => { - const firstFiscalYear = { ...FiscalYears.defaultRolloverFiscalYear }; - const secondFiscalYear = { - name: `autotest_year_${getRandomPostfix()}`, - code: DateTools.getRandomFiscalYearCodeForRollover(2000, 9999), - periodStart: `${DateTools.get3DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+00:00`, - periodEnd: `${DateTools.get4DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+00:00`, - description: `This is fiscal year created by E2E test automation script_${getRandomPostfix()}`, - series: 'FY', + const date = new Date(); + const code = CodeTools(4); + const organization = { ...NewOrganization.defaultUiOrganizations }; + const testData = { + organization, + user: {}, + expenseClass1: { + name: 'Print', + code: 'Prn', + status: 'Active', + id: '', + }, + expenseClass2: { + name: 'Electronic', + code: 'Elec', + status: 'Active', + id: '', + }, + }; + const fiscalYears = { + current: { + ...FiscalYears.getDefaultFiscalYear(), + code: `${code}${StringTools.randomTwoDigitNumber()}01`, + periodStart: new Date(date.getFullYear(), 0, 1), + periodEnd: new Date(date.getFullYear(), 11, 31), + }, + next: { + ...FiscalYears.getDefaultFiscalYear(), + code: `${code}${StringTools.randomTwoDigitNumber()}02`, + periodStart: new Date(date.getFullYear() + 1, 0, 1), + periodEnd: new Date(date.getFullYear() + 1, 11, 31), + }, }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const defaultFund = { ...Funds.defaultUiFund }; const firstOrder = { ...NewOrder.defaultOneTimeOrder, - orderType: 'One-time', + id: uuid(), approved: true, reEncumber: true, + vendorId: testData.organization.id, }; const secondOrder = { ...NewOrder.defaultOneTimeOrder, - orderType: 'One-time', + id: uuid(), approved: true, reEncumber: true, + vendorId: testData.organization.id, }; - const organization = { ...NewOrganization.defaultUiOrganizations }; - const allocatedQuantity = '100'; - const periodStartForFirstFY = DateTools.getThreePreviousDaysDateForFiscalYearOnUIEdit(); - const periodEndForFirstFY = DateTools.getPreviousDayDateForFiscalYearOnUIEdit(); - const periodStartForSecondFY = DateTools.getCurrentDateForFiscalYearOnUIEdit(); - const periodEndForSecondFY = DateTools.getDayTomorrowDateForFiscalYearOnUIEdit(); - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - let user; - let location; - let fileName; - - before(() => { - cy.loginAsAdmin({ path: TopMenu.fundPath, waiter: Funds.waitLoading, authRefresh: true }); - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - secondFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '2'; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - defaultFund.ledgerId = defaultLedger.id; - Funds.createViaApi(defaultFund).then((fundResponse) => { - defaultFund.id = fundResponse.fund.id; - FinanceHelp.searchByName(defaultFund.name); - Funds.selectFund(defaultFund.name); - Funds.addBudget(allocatedQuantity); - Funds.editBudget(); - Funds.addTwoExpensesClass('Electronic', 'Print'); + + before('Setup test data', () => { + cy.getAdminToken(); + ExpenseClasses.getExpenseClassesViaApi({ + query: `name=="${testData.expenseClass1.name}"`, + limit: 1, + }).then((resp1) => { + testData.expenseClass1.id = resp1?.[0]?.id; + + ExpenseClasses.getExpenseClassesViaApi({ + query: `name=="${testData.expenseClass2.name}"`, + limit: 1, + }).then((resp2) => { + testData.expenseClass2.id = resp2?.[0]?.id; + + // create first Fiscal Year with Expense Classes + const { ledger, fund } = Budgets.createBudgetWithFundLedgerAndFYViaApi({ + fiscalYear: fiscalYears.current, + ledger: { restrictEncumbrance: true, restrictExpenditures: true }, + budget: { + allocated: 100, + statusExpenseClasses: [ + { + status: 'Active', + expenseClassId: testData.expenseClass1.id, + }, + { + status: 'Active', + expenseClassId: testData.expenseClass2.id, + }, + ], + }, }); + testData.ledger = ledger; + testData.fund = fund; + + // Create second Fiscal Year for Rollover + FiscalYears.createViaApi(fiscalYears.next); + Organizations.createOrganizationViaApi(organization).then((orgResp) => { + organization.id = orgResp; + firstOrder.vendor = orgResp; + secondOrder.vendor = orgResp; + + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((amResp) => { + cy.getBookMaterialType().then((mtypeResp) => { + const firstOrderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + listUnitPrice: 25.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 25.0, + }, + fundDistribution: [ + { + code: testData.fund.code, + fundId: testData.fund.id, + expenseClassId: testData.expenseClass1.id, + value: 100, + }, + ], + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: amResp.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypeResp.id, + materialSupplier: orgResp.id, + volumes: [], + }, + }; + + // Create first open order + Orders.createOrderViaApi(firstOrder).then((orderResp) => { + firstOrder.id = orderResp.id; + firstOrder.poNumber = orderResp.poNumber; + firstOrderLine.purchaseOrderId = orderResp.id; + + OrderLines.createOrderLineViaApi(firstOrderLine); + Orders.updateOrderViaApi({ + ...orderResp, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); + + const secondOrderLine = { + ...BasicOrderLine.defaultOrderLine, + id: uuid(), + cost: { + listUnitPrice: 20.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 20.0, + }, + fundDistribution: [ + { + code: testData.fund.code, + fundId: testData.fund.id, + expenseClassId: testData.expenseClass2.id, + value: 100, + }, + ], + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: amResp.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypeResp.id, + materialSupplier: orgResp.id, + volumes: [], + }, + }; + // Create second open order + Orders.createOrderViaApi(secondOrder).then((orderResp) => { + secondOrder.id = orderResp.id; + secondOrder.poNumber = orderResp.poNumber; + secondOrderLine.purchaseOrderId = orderResp.id; + + OrderLines.createOrderLineViaApi(secondOrderLine); + Orders.updateOrderViaApi({ + ...orderResp, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); + }); + }); + }); + }); + cy.loginAsAdmin(); + cy.visit(TopMenu.fundPath); + FinanceHelp.searchByName(testData.fund.name); + Funds.selectFund(testData.fund.name); + Funds.selectBudgetDetails(); + Funds.editBudget(); + Funds.changeStatusOfExpClassByName(testData.expenseClass2.name, 'Inactive'); + + const rollover = LedgerRollovers.generateLedgerRollover({ + ledger: testData.ledger, + fromFiscalYear: fiscalYears.current, + toFiscalYear: fiscalYears.next, + restrictEncumbrance: true, + restrictExpenditures: true, + needCloseBudgets: true, + budgetsRollover: [ + { + rolloverAllocation: true, + rolloverBudgetValue: 'None', + addAvailableTo: 'Allocation', + }, + ], + encumbrancesRollover: [{ orderType: 'One-time', basedOn: 'InitialAmount' }], + }); + LedgerRollovers.createLedgerRolloverViaApi(rollover); + testData.fileName = `Export-${testData.ledger.code}-${fiscalYears.next.code}`; }); - cy.getLocations({ limit: 1 }).then((res) => { - location = res; - }); - // Create second Fiscal Year for Rollover - FiscalYears.createViaApi(secondFiscalYear).then((secondFiscalYearResponse) => { - secondFiscalYear.id = secondFiscalYearResponse.id; - }); - // Prepare Open Order for Rollover - Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { - organization.id = responseOrganizations; - }); - firstOrder.vendor = organization.name; - secondOrder.vendor = organization.name; - TopMenuNavigation.openAppFromDropdown(APPLICATION_NAMES.ORDERS); - Orders.selectOrdersPane(); - Orders.createApprovedOrderForRollover(firstOrder, true).then((firstOrderResponse) => { - firstOrder.id = firstOrderResponse.id; - Orders.checkCreatedOrder(firstOrder); - OrderLines.addPOLine(); - OrderLines.selectRandomInstanceInTitleLookUP('*', 35); - OrderLines.rolloverPOLineInfoForPhysicalMaterialWithFundAndExpClass( - defaultFund, - 'Electronic', - '10', - '1', - '10', - location.name, - ); - OrderLines.backToEditingOrder(); - Orders.openOrder(); + + FiscalYears.updateFiscalYearViaApi({ + ...fiscalYears.current, + _version: 1, + periodStart: new Date(date.getFullYear() - 1, 0, 1), + periodEnd: new Date(date.getFullYear() - 1, 11, 31), }); - Orders.createApprovedOrderForRollover(secondOrder, true).then((secondOrderResponse) => { - secondOrder.id = secondOrderResponse.id; - Orders.checkCreatedOrder(secondOrder); - OrderLines.addPOLine(); - OrderLines.selectRandomInstanceInTitleLookUP('*', 35); - OrderLines.rolloverPOLineInfoForPhysicalMaterialWithFundAndExpClass( - defaultFund, - 'Print', - '10', - '1', - '10', - location.name, - ); - OrderLines.backToEditingOrder(); - Orders.openOrder(); + + FiscalYears.updateFiscalYearViaApi({ + ...fiscalYears.next, + _version: 1, + periodStart: new Date(date.getFullYear(), 0, 1), + periodEnd: new Date(date.getFullYear(), 11, 31), }); - cy.visit(TopMenu.fundPath); - FinanceHelp.searchByName(defaultFund.name); - Funds.selectFund(defaultFund.name); - Funds.selectBudgetDetails(); - Funds.editBudget(); - Funds.changeStatusOfExpClass(1, 'Inactive'); - cy.visit(TopMenu.ledgerPath); - FinanceHelp.searchByName(defaultLedger.name); - Ledgers.selectLedger(defaultLedger.name); - Ledgers.rollover(); - Ledgers.fillInRolloverForOneTimeOrdersWithAllocation( - secondFiscalYear.code, - 'None', - 'Allocation', - ); - cy.wait(4000); - cy.visit(TopMenu.fiscalYearPath); - FinanceHelp.searchByName(firstFiscalYear.name); - FiscalYears.selectFY(firstFiscalYear.name); - FiscalYears.editFiscalYearDetails(); - FiscalYears.filltheStartAndEndDateonCalenderstartDateField( - periodStartForFirstFY, - periodEndForFirstFY, - ); - FinanceHelp.searchByName(secondFiscalYear.name); - FiscalYears.selectFY(secondFiscalYear.name); - FiscalYears.editFiscalYearDetails(); - FiscalYears.filltheStartAndEndDateonCalenderstartDateField( - periodStartForSecondFY, - periodEndForSecondFY, - ); - fileName = `Export-${defaultLedger.code}-${secondFiscalYear.code}`; - }); - cy.createTempUser([ - permissions.uiFinanceExportFinanceRecords.gui, - permissions.uiFinanceViewLedger.gui, - ]).then((userProperties) => { - user = userProperties; - cy.login(userProperties.username, userProperties.password, { - path: TopMenu.ledgerPath, - waiter: Ledgers.waitForLedgerDetailsLoading, - authRefresh: true, + + cy.createTempUser([ + Permissions.uiFinanceExportFinanceRecords.gui, + Permissions.uiFinanceViewLedger.gui, + ]).then((userProperties) => { + testData.user = userProperties; + + cy.login(userProperties.username, userProperties.password, { + path: TopMenu.ledgerPath, + waiter: Ledgers.waitForLedgerDetailsLoading, + }); }); }); }); - after(() => { + after('Clean up test data', () => { + FileManager.deleteFile(`cypress/downloads/${testData.fileName}.csv`); cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); }); it( 'C350977 Ledger export settings: current year Fund with budget, Print (Active) and Electronic (Inactive) Classes, Export settings-Inactive status (thunderjet) (TaaS)', { tags: ['extendedPath', 'thunderjet', 'C350977'] }, () => { - FinanceHelp.searchByName(defaultLedger.name); - Ledgers.selectLedger(defaultLedger.name); + FinanceHelp.searchByName(testData.ledger.name); + Ledgers.selectLedger(testData.ledger.name); Ledgers.exportBudgetInformation(); - Ledgers.prepareExportSettings(secondFiscalYear.code, 'Inactive', defaultLedger); - Ledgers.checkColumnNamesInDownloadedLedgerExportFileWithExpClasses(`${fileName}.csv`); + Ledgers.prepareExportSettings(fiscalYears.next.code, 'Inactive', testData.ledger); + Ledgers.checkColumnNamesInDownloadedLedgerExportFileWithExpClasses( + `${testData.fileName}.csv`, + ); Ledgers.checkColumnContentInDownloadedLedgerExportFileWithExpClasses( - `${fileName}.csv`, - 1, - defaultFund, - secondFiscalYear, + `${testData.fileName}.csv`, + testData.expenseClass2.name, + testData.fund, + fiscalYears.next, '100', '100', '100', @@ -188,22 +286,20 @@ describe('Finance: Ledgers', () => { '100', '0', '100', - '20', + '45', '0', '0', - '20', + '45', '0', '0', '100', - '80', - 'Print', - 'Prn', + '55', + testData.expenseClass2.code, 'Inactive', - '10', + '20', '0', '0', ); - Ledgers.deleteDownloadedFile(`${fileName}.csv`); }, ); }); diff --git a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-inactive-status-without-rollover-with-2-exp-classes.cy.js b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-inactive-status-without-rollover-with-2-exp-classes.cy.js index baba12aa31..d37e549dcf 100644 --- a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-inactive-status-without-rollover-with-2-exp-classes.cy.js +++ b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-inactive-status-without-rollover-with-2-exp-classes.cy.js @@ -1,120 +1,159 @@ -import permissions from '../../../../support/dictionary/permissions'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + LOCATION_NAMES, + ORDER_STATUSES, +} from '../../../../support/constants'; +import Permissions from '../../../../support/dictionary/permissions'; +import { Budgets, Funds, Ledgers } from '../../../../support/fragments/finance'; 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 NewOrder from '../../../../support/fragments/orders/newOrder'; -import OrderLines from '../../../../support/fragments/orders/orderLines'; -import Orders from '../../../../support/fragments/orders/orders'; -import NewOrganization from '../../../../support/fragments/organizations/newOrganization'; -import Organizations from '../../../../support/fragments/organizations/organizations'; +import { BasicOrderLine, NewOrder, OrderLines, Orders } from '../../../../support/fragments/orders'; +import { NewOrganization, Organizations } from '../../../../support/fragments/organizations'; +import ExpenseClasses from '../../../../support/fragments/settings/finance/expenseClasses'; import TopMenu from '../../../../support/fragments/topMenu'; import Users from '../../../../support/fragments/users/users'; +import FileManager from '../../../../support/utils/fileManager'; describe('Finance: Ledgers', () => { - const firstFiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const defaultFund = { ...Funds.defaultUiFund }; - const firstOrder = { + const organization = { ...NewOrganization.defaultUiOrganizations }; + const testData = { + organization, + user: {}, + expenseClass: { + name: 'Electronic', + code: 'Elec', + status: 'Active', + id: '', + }, + }; + const order = { ...NewOrder.defaultOneTimeOrder, - orderType: 'One-time', approved: true, reEncumber: true, + vendorId: testData.organization.id, }; - const organization = { ...NewOrganization.defaultUiOrganizations }; - const allocatedQuantity = '100'; - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - let user; - let location; - let fileName; - before(() => { + before('Setup test data', () => { cy.getAdminToken(); - // create first Fiscal Year and prepare 2 Funds for Rollover - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - defaultFund.ledgerId = defaultLedger.id; + ExpenseClasses.getExpenseClassesViaApi({ + query: `name=="${testData.expenseClass.name}"`, + limit: 1, + }).then((response) => { + testData.expenseClass.id = response?.[0]?.id; - Funds.createViaApi(defaultFund).then((fundResponse) => { - defaultFund.id = fundResponse.fund.id; - - cy.loginAsAdmin({ path: TopMenu.fundPath, waiter: Funds.waitLoading }); - FinanceHelp.searchByName(defaultFund.name); - Funds.selectFund(defaultFund.name); - Funds.addBudget(allocatedQuantity); - Funds.editBudget(); - Funds.addExpensesClass('Electronic'); - }); + const { fiscalYear, ledger, fund, budget } = Budgets.createBudgetWithFundLedgerAndFYViaApi({ + ledger: { restrictEncumbrance: true, restrictExpenditures: true }, + budget: { + allocated: 100, + statusExpenseClasses: [ + { + status: testData.expenseClass.status, + expenseClassId: testData.expenseClass.id, + }, + ], + }, }); + testData.fiscalYear = fiscalYear; + testData.ledger = ledger; + testData.fund = fund; + testData.budget = budget; - cy.getLocations({ limit: 1 }).then((res) => { - location = res; - }); + Organizations.createOrganizationViaApi(organization).then((orgResp) => { + organization.id = orgResp; + order.vendor = orgResp; - Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { - organization.id = responseOrganizations; - }); - firstOrder.vendor = organization.name; - cy.visit(TopMenu.ordersPath); - Orders.createApprovedOrderForRollover(firstOrder, true).then((firstOrderResponse) => { - firstOrder.id = firstOrderResponse.id; - Orders.checkCreatedOrder(firstOrder); - OrderLines.addPOLine(); - OrderLines.selectRandomInstanceInTitleLookUP('*', 35); - OrderLines.rolloverPOLineInfoForPhysicalMaterialWithFundAndExpClass( - defaultFund, - 'Electronic', - '10', - '1', - '10', - location.name, - ); - OrderLines.backToEditingOrder(); - Orders.openOrder(); + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((amResp) => { + cy.getBookMaterialType().then((mtypeResp) => { + const orderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + listUnitPrice: 25.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 25.0, + }, + fundDistribution: [ + { + code: testData.fund.code, + fundId: testData.fund.id, + expenseClassId: testData.expenseClass.id, + value: 100, + }, + ], + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: amResp.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypeResp.id, + materialSupplier: orgResp.id, + volumes: [], + }, + }; + + // Create first open order + Orders.createOrderViaApi(order).then((orderResp) => { + order.id = orderResp.id; + orderLine.purchaseOrderId = orderResp.id; + + OrderLines.createOrderLineViaApi(orderLine); + Orders.updateOrderViaApi({ + ...orderResp, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); + }); + }); + }); }); + testData.fileName = `Export-${testData.ledger.code}-${fiscalYear.code}`; + + cy.loginAsAdmin(); cy.visit(TopMenu.fundPath); - FinanceHelp.searchByName(defaultFund.name); - Funds.selectFund(defaultFund.name); + FinanceHelp.searchByName(testData.fund.name); + Funds.selectFund(testData.fund.name); Funds.selectBudgetDetails(); Funds.editBudget(); - Funds.changeStatusOfExpClass(0, 'Inactive'); - fileName = `Export-${defaultLedger.code}-${firstFiscalYear.code}`; + Funds.changeStatusOfExpClassByName(testData.expenseClass.name, 'Inactive'); }); + cy.createTempUser([ - permissions.uiFinanceExportFinanceRecords.gui, - permissions.uiFinanceViewLedger.gui, + Permissions.uiFinanceExportFinanceRecords.gui, + Permissions.uiFinanceViewLedger.gui, ]).then((userProperties) => { - user = userProperties; + testData.user = userProperties; + cy.login(userProperties.username, userProperties.password, { path: TopMenu.ledgerPath, waiter: Ledgers.waitForLedgerDetailsLoading, - authRefresh: true, }); }); }); - after(() => { + after('Clean up test data', () => { + FileManager.deleteFile(`cypress/downloads/${testData.fileName}.csv`); cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); }); it( 'C350978 Ledger export settings: current year Fund with budget, Economic (Inactive) Class, Export settings-Inactive status (thunderjet) (TaaS)', { tags: ['extendedPath', 'thunderjet', 'C350978'] }, () => { - FinanceHelp.searchByName(defaultLedger.name); - Ledgers.selectLedger(defaultLedger.name); + FinanceHelp.searchByName(testData.ledger.name); + Ledgers.selectLedger(testData.ledger.name); Ledgers.exportBudgetInformation(); - Ledgers.prepareExportSettings(firstFiscalYear.code, 'Inactive', defaultLedger); - Ledgers.checkColumnNamesInDownloadedLedgerExportFileWithExpClasses(`${fileName}.csv`); + Ledgers.prepareExportSettings(testData.fiscalYear.code, 'Inactive', testData.ledger); + Ledgers.checkColumnNamesInDownloadedLedgerExportFileWithExpClasses( + `${testData.fileName}.csv`, + ); Ledgers.checkColumnContentInDownloadedLedgerExportFileWithExpClasses( - `${fileName}.csv`, - 1, - defaultFund, - firstFiscalYear, + `${testData.fileName}.csv`, + testData.expenseClass.name, + testData.fund, + testData.budget.name, '100', '100', '100', @@ -123,22 +162,21 @@ describe('Finance: Ledgers', () => { '100', '0', '100', - '10', + '25', '0', '0', - '10', + '25', '0', '0', '100', - '90', - 'Electronic', - 'Elec', + '75', + testData.expenseClass.code, 'Inactive', - '10', + '25', '0', '0', ); - Ledgers.deleteDownloadedFile(`${fileName}.csv`); + Ledgers.deleteDownloadedFile(`${testData.fileName}.csv`); }, ); }); diff --git a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-inactive-status.cy.js b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-inactive-status.cy.js index 45ef88851e..189d8d18e4 100644 --- a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-inactive-status.cy.js +++ b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-inactive-status.cy.js @@ -1,108 +1,126 @@ -import permissions from '../../../../support/dictionary/permissions'; +import Permissions from '../../../../support/dictionary/permissions'; +import { + FiscalYears, + Funds, + LedgerRollovers, + Ledgers, +} from '../../../../support/fragments/finance'; 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 { NewOrganization } from '../../../../support/fragments/organizations'; import TopMenu from '../../../../support/fragments/topMenu'; import Users from '../../../../support/fragments/users/users'; -import DateTools from '../../../../support/utils/dateTools'; -import getRandomPostfix from '../../../../support/utils/stringTools'; +import { CodeTools, StringTools } from '../../../../support/utils'; +import FileManager from '../../../../support/utils/fileManager'; describe('Finance: Ledgers', () => { - const firstFiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const secondFiscalYear = { - name: `autotest_year_${getRandomPostfix()}`, - code: DateTools.getRandomFiscalYearCode(2000, 9999), - periodStart: `${DateTools.get3DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+00:00`, - periodEnd: `${DateTools.get4DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+00:00`, - description: `This is fiscal year created by E2E test automation script_${getRandomPostfix()}`, - series: 'FY', + const date = new Date(); + const code = CodeTools(4); + const organization = { ...NewOrganization.defaultUiOrganizations }; + const testData = { + organization, + user: {}, }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const defaultFund = { ...Funds.defaultUiFund }; - const periodStartForFirstFY = DateTools.getThreePreviousDaysDateForFiscalYearOnUIEdit(); - const periodEndForFirstFY = DateTools.getPreviousDayDateForFiscalYearOnUIEdit(); - const periodStartForSecondFY = DateTools.getCurrentDateForFiscalYearOnUIEdit(); - const periodEndForSecondFY = DateTools.getDayTomorrowDateForFiscalYearOnUIEdit(); - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - let user; - let fileName; + const fiscalYears = { + current: { + ...FiscalYears.getDefaultFiscalYear(), + code: `${code}${StringTools.randomTwoDigitNumber()}01`, + periodStart: new Date(date.getFullYear(), 0, 1), + periodEnd: new Date(date.getFullYear(), 11, 31), + }, + next: { + ...FiscalYears.getDefaultFiscalYear(), + code: `${code}${StringTools.randomTwoDigitNumber()}02`, + periodStart: new Date(date.getFullYear() + 1, 0, 1), + periodEnd: new Date(date.getFullYear() + 1, 11, 31), + }, + }; + const ledger = { ...Ledgers.defaultUiLedger }; + const fund = { ...Funds.defaultUiFund }; + + before('Setup test data', () => { + cy.getAdminToken(); + FiscalYears.createViaApi(fiscalYears.current).then((fiscalYearResponse) => { + fiscalYears.current.id = fiscalYearResponse.id; + ledger.fiscalYearOneId = fiscalYears.current.id; - before(() => { - cy.loginAsAdmin({ path: TopMenu.fundPath, waiter: Funds.waitLoading, authRefresh: true }); - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - secondFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '2'; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - defaultFund.ledgerId = defaultLedger.id; - Funds.createViaApi(defaultFund).then((fundResponse) => { - defaultFund.id = fundResponse.fund.id; + Ledgers.createViaApi(ledger).then((ledgerResponse) => { + ledger.id = ledgerResponse.id; + fund.ledgerId = ledgerResponse.id; + Funds.createViaApi(fund).then((fundResponse) => { + fund.id = fundResponse.fund.id; }); + + // Create second Fiscal Year for Rollover + FiscalYears.createViaApi(fiscalYears.next); + const rollover = LedgerRollovers.generateLedgerRollover({ + ledger, + fromFiscalYear: fiscalYears.current, + toFiscalYear: fiscalYears.next, + restrictEncumbrance: true, + restrictExpenditures: true, + needCloseBudgets: true, + budgetsRollover: [ + { + rolloverAllocation: true, + rolloverBudgetValue: 'None', + addAvailableTo: 'Allocation', + }, + ], + encumbrancesRollover: [{ orderType: 'One-time', basedOn: 'InitialAmount' }], + }); + LedgerRollovers.createLedgerRolloverViaApi(rollover); + FiscalYears.updateFiscalYearViaApi({ + ...fiscalYears.current, + _version: 1, + periodStart: new Date(date.getFullYear() - 1, 0, 1), + periodEnd: new Date(date.getFullYear() - 1, 11, 31), + }); + + FiscalYears.updateFiscalYearViaApi({ + ...fiscalYears.next, + _version: 1, + periodStart: new Date(date.getFullYear(), 0, 1), + periodEnd: new Date(date.getFullYear(), 11, 31), + }); + testData.fileName = `Export-${ledger.code}-${fiscalYears.next.code}`; }); - FiscalYears.createViaApi(secondFiscalYear).then((secondFiscalYearResponse) => { - secondFiscalYear.id = secondFiscalYearResponse.id; - }); - cy.visit(TopMenu.ledgerPath); - FinanceHelp.searchByName(defaultLedger.name); - Ledgers.selectLedger(defaultLedger.name); - Ledgers.rollover(); - Ledgers.fillInRolloverForOneTimeOrdersWithoutBudgets( - secondFiscalYear.code, - 'None', - 'Allocation', - ); - cy.visit(TopMenu.fiscalYearPath); - FinanceHelp.searchByName(firstFiscalYear.name); - FiscalYears.selectFY(firstFiscalYear.name); - FiscalYears.editFiscalYearDetails(); - FiscalYears.filltheStartAndEndDateonCalenderstartDateField( - periodStartForFirstFY, - periodEndForFirstFY, - ); - FinanceHelp.searchByName(secondFiscalYear.name); - FiscalYears.selectFY(secondFiscalYear.name); - FiscalYears.editFiscalYearDetails(); - FiscalYears.filltheStartAndEndDateonCalenderstartDateField( - periodStartForSecondFY, - periodEndForSecondFY, - ); - fileName = `Export-${defaultLedger.code}-${secondFiscalYear.code}`; }); + cy.createTempUser([ - permissions.uiFinanceExportFinanceRecords.gui, - permissions.uiFinanceViewLedger.gui, + Permissions.uiFinanceExportFinanceRecords.gui, + Permissions.uiFinanceViewLedger.gui, ]).then((userProperties) => { - user = userProperties; + testData.user = userProperties; + cy.login(userProperties.username, userProperties.password, { path: TopMenu.ledgerPath, waiter: Ledgers.waitForLedgerDetailsLoading, - authRefresh: true, }); }); }); - after(() => { + after('Clean up test data', () => { + FileManager.deleteFile(`cypress/downloads/${testData.fileName}.csv`); cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); }); it( 'C353213 Ledger export settings: last year Fund with NO budget, NO Classes, Export settings-Inactive status (thunderjet) (TaaS)', { tags: ['extendedPath', 'thunderjet', 'C353213'] }, () => { - FinanceHelp.searchByName(defaultLedger.name); - Ledgers.selectLedger(defaultLedger.name); + FinanceHelp.searchByName(ledger.name); + Ledgers.selectLedger(ledger.name); Ledgers.exportBudgetInformation(); - Ledgers.prepareExportSettings(secondFiscalYear.code, 'Inactive', defaultLedger); - Ledgers.checkColumnNamesInDownloadedLedgerExportFileWithExpClasses(`${fileName}.csv`); + Ledgers.prepareExportSettings(fiscalYears.next.code, 'Inactive', ledger); + Ledgers.checkColumnNamesInDownloadedLedgerExportFileWithExpClasses( + `${testData.fileName}.csv`, + ); Ledgers.checkColumnContentInDownloadedLedgerExportFileWithoutBudgets( - `${fileName}.csv`, + `${testData.fileName}.csv`, 1, - defaultFund, + fund, ); - Ledgers.deleteDownloadedFile(`${fileName}.csv`); }, ); }); diff --git a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-no-fiscal-year-each-class-status.cy.js b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-no-fiscal-year-each-class-status.cy.js index 7e02e7b23b..5e90240fdb 100644 --- a/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-no-fiscal-year-each-class-status.cy.js +++ b/cypress/e2e/finance/ledgers/ledger-export-settings-pairwise-variants/export-settings-no-fiscal-year-each-class-status.cy.js @@ -1,148 +1,214 @@ -import permissions from '../../../../support/dictionary/permissions'; +import uuid from 'uuid'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + LOCATION_NAMES, + ORDER_STATUSES, +} from '../../../../support/constants'; +import Permissions from '../../../../support/dictionary/permissions'; +import { Budgets, Funds, Ledgers } from '../../../../support/fragments/finance'; 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 NewOrder from '../../../../support/fragments/orders/newOrder'; -import OrderLines from '../../../../support/fragments/orders/orderLines'; -import Orders from '../../../../support/fragments/orders/orders'; -import NewOrganization from '../../../../support/fragments/organizations/newOrganization'; -import Organizations from '../../../../support/fragments/organizations/organizations'; +import { BasicOrderLine, NewOrder, OrderLines, Orders } from '../../../../support/fragments/orders'; +import { NewOrganization, Organizations } from '../../../../support/fragments/organizations'; +import ExpenseClasses from '../../../../support/fragments/settings/finance/expenseClasses'; import TopMenu from '../../../../support/fragments/topMenu'; import Users from '../../../../support/fragments/users/users'; -import DateTools from '../../../../support/utils/dateTools'; -import getRandomPostfix from '../../../../support/utils/stringTools'; +import FileManager from '../../../../support/utils/fileManager'; describe('Finance: Ledgers', () => { - const firstFiscalYear = { ...FiscalYears.defaultRolloverFiscalYear }; - const secondFiscalYear = { - name: `autotest_year_${getRandomPostfix()}`, - code: DateTools.getRandomFiscalYearCodeForRollover(2000, 9999), - periodStart: `${DateTools.get3DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+00:00`, - periodEnd: `${DateTools.get4DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+00:00`, - description: `This is fiscal year created by E2E test automation script_${getRandomPostfix()}`, - series: 'FY', + const organization = { ...NewOrganization.defaultUiOrganizations, isVendor: true }; + const testData = { + organization, + user: {}, + expenseClass1: { + name: 'Electronic', + code: 'Elec', + status: 'Active', + id: '', + }, + expenseClass2: { + name: 'Print', + code: 'Prn', + status: 'Active', + id: '', + }, }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const defaultFund = { ...Funds.defaultUiFund }; const firstOrder = { ...NewOrder.defaultOneTimeOrder, - orderType: 'One-time', + id: uuid(), approved: true, reEncumber: true, + vendorId: testData.organization.id, }; const secondOrder = { ...NewOrder.defaultOneTimeOrder, - orderType: 'One-time', + id: uuid(), approved: true, reEncumber: true, + vendorId: testData.organization.id, }; - const organization = { ...NewOrganization.defaultUiOrganizations }; - const allocatedQuantity = '100'; - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - let user; - let location; - before(() => { + before('Setup test data', () => { cy.getAdminToken(); - // create first Fiscal Year and prepere 2 Funds for Rollover - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - secondFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '2'; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - defaultFund.ledgerId = defaultLedger.id; + ExpenseClasses.getExpenseClassesViaApi({ + query: `name=="${testData.expenseClass1.name}"`, + limit: 1, + }).then((resp1) => { + testData.expenseClass1.id = resp1?.[0]?.id; - Funds.createViaApi(defaultFund).then((fundResponse) => { - defaultFund.id = fundResponse.fund.id; + ExpenseClasses.getExpenseClassesViaApi({ + query: `name=="${testData.expenseClass2.name}"`, + limit: 1, + }).then((resp2) => { + testData.expenseClass2.id = resp2?.[0]?.id; - cy.loginAsAdmin({ path: TopMenu.fundPath, waiter: Funds.waitLoading }); - FinanceHelp.searchByName(defaultFund.name); - Funds.selectFund(defaultFund.name); - Funds.addBudget(allocatedQuantity); - Funds.editBudget(); - Funds.addTwoExpensesClass('Electronic', 'Print'); + const { fiscalYear, ledger, fund } = Budgets.createBudgetWithFundLedgerAndFYViaApi({ + ledger: { restrictEncumbrance: true, restrictExpenditures: true }, + budget: { + allocated: 100, + statusExpenseClasses: [ + { + status: testData.expenseClass1.status, + expenseClassId: testData.expenseClass1.id, + }, + { + status: testData.expenseClass2.status, + expenseClassId: testData.expenseClass2.id, + }, + ], + }, }); - }); + testData.fiscalYear = fiscalYear; + testData.ledger = ledger; + testData.fund = fund; - cy.getLocations({ limit: 1 }).then((res) => { - location = res; - }); - // Create second Fiscal Year for Rollover - FiscalYears.createViaApi(secondFiscalYear).then((secondFiscalYearResponse) => { - secondFiscalYear.id = secondFiscalYearResponse.id; - }); - // Prepare Open Order for Rollover - Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { - organization.id = responseOrganizations; - }); - firstOrder.vendor = organization.name; - secondOrder.vendor = organization.name; - cy.visit(TopMenu.ordersPath); - Orders.createApprovedOrderForRollover(firstOrder, true).then((firstOrderResponse) => { - firstOrder.id = firstOrderResponse.id; - Orders.checkCreatedOrder(firstOrder); - OrderLines.addPOLine(); - OrderLines.selectRandomInstanceInTitleLookUP('*', 20); - OrderLines.rolloverPOLineInfoForPhysicalMaterialWithFundAndExpClass( - defaultFund, - 'Electronic', - '10', - '1', - '10', - location.name, - ); - OrderLines.backToEditingOrder(); - Orders.openOrder(); - }); - Orders.createApprovedOrderForRollover(secondOrder, true).then((secondOrderResponse) => { - secondOrder.id = secondOrderResponse.id; - Orders.checkCreatedOrder(secondOrder); - OrderLines.addPOLine(); - OrderLines.selectRandomInstanceInTitleLookUP('*', 15); - OrderLines.rolloverPOLineInfoForPhysicalMaterialWithFundAndExpClass( - defaultFund, - 'Print', - '10', - '1', - '10', - location.name, - ); - OrderLines.backToEditingOrder(); - Orders.openOrder(); + Organizations.createOrganizationViaApi(organization).then((orgResp) => { + organization.id = orgResp; + firstOrder.vendor = orgResp; + secondOrder.vendor = orgResp; + + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((amResp) => { + cy.getBookMaterialType().then((mtypeResp) => { + const firstOrderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + listUnitPrice: 25.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 25.0, + }, + fundDistribution: [ + { + code: testData.fund.code, + fundId: testData.fund.id, + expenseClassId: testData.expenseClass1.id, + value: 100, + }, + ], + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: amResp.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypeResp.id, + materialSupplier: orgResp.id, + volumes: [], + }, + }; + + // Create first open order + Orders.createOrderViaApi(firstOrder).then((orderResp) => { + firstOrder.id = orderResp.id; + firstOrder.poNumber = orderResp.poNumber; + firstOrderLine.purchaseOrderId = orderResp.id; + + OrderLines.createOrderLineViaApi(firstOrderLine); + Orders.updateOrderViaApi({ + ...orderResp, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); + + const secondOrderLine = { + ...BasicOrderLine.defaultOrderLine, + id: uuid(), + cost: { + listUnitPrice: 20.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 20.0, + }, + fundDistribution: [ + { + code: testData.fund.code, + fundId: testData.fund.id, + expenseClassId: testData.expenseClass2.id, + value: 100, + }, + ], + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: amResp.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypeResp.id, + materialSupplier: orgResp.id, + volumes: [], + }, + }; + // Create second open order + Orders.createOrderViaApi(secondOrder).then((orderResp) => { + secondOrder.id = orderResp.id; + secondOrder.poNumber = orderResp.poNumber; + secondOrderLine.purchaseOrderId = orderResp.id; + + OrderLines.createOrderLineViaApi(secondOrderLine); + Orders.updateOrderViaApi({ + ...orderResp, + workflowStatus: ORDER_STATUSES.OPEN, + }); + }); + }); + }); + }); + }); + cy.loginAsAdmin(); + cy.visit(TopMenu.fundPath); + FinanceHelp.searchByName(testData.fund.name); + Funds.selectFund(testData.fund.name); + Funds.selectBudgetDetails(); + Funds.editBudget(); + Funds.changeStatusOfExpClassByName(testData.expenseClass2.name, 'Inactive'); }); - cy.visit(TopMenu.fundPath); - FinanceHelp.searchByName(defaultFund.name); - Funds.selectFund(defaultFund.name); - Funds.selectBudgetDetails(); - Funds.editBudget(); - Funds.changeStatusOfExpClass(1, 'Inactive'); }); + cy.createTempUser([ - permissions.uiFinanceExportFinanceRecords.gui, - permissions.uiFinanceViewLedger.gui, + Permissions.uiFinanceExportFinanceRecords.gui, + Permissions.uiFinanceViewLedger.gui, ]).then((userProperties) => { - user = userProperties; + testData.user = userProperties; + cy.login(userProperties.username, userProperties.password, { path: TopMenu.ledgerPath, waiter: Ledgers.waitForLedgerDetailsLoading, - authRefresh: true, }); }); }); - after(() => { + after('Clean up test data', () => { + FileManager.deleteFile(`cypress/downloads/${testData.fileName}.csv`); cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.user.userId); }); it( 'C353211 Ledger export settings: current year Fund with budget, Print (Active) and Economic (Inactive) Classes, Export settings: No fiscal year, Each class status (thunderjet) (TaaS)', - { tags: ['extendedPathFlaky', 'thunderjet', 'C353211'] }, + { tags: ['extendedPath', 'thunderjet', 'C353211'] }, () => { - FinanceHelp.searchByName(defaultLedger.name); - Ledgers.selectLedger(defaultLedger.name); + FinanceHelp.searchByName(testData.ledger.name); + Ledgers.selectLedger(testData.ledger.name); Ledgers.exportBudgetInformation(); Ledgers.checkPreparationExportSettings(); }, diff --git a/cypress/e2e/orders/changing-order-format-from-pe-mix-to-physical.cy.js b/cypress/e2e/orders/changing-order-format-from-pe-mix-to-physical.cy.js index d3438577c3..3ca692fb85 100644 --- a/cypress/e2e/orders/changing-order-format-from-pe-mix-to-physical.cy.js +++ b/cypress/e2e/orders/changing-order-format-from-pe-mix-to-physical.cy.js @@ -49,7 +49,7 @@ describe('Orders', () => { }; Orders.createOrderWithOrderLineViaApi(testData.order, testData.orderLine).then((order) => { - testData.order = order; + testData.order.poNumber = order.poNumber; }); }); }); diff --git a/cypress/e2e/orders/create-new-routing-list-from-poline.cy.js b/cypress/e2e/orders/create-new-routing-list-from-poline.cy.js index db96252539..cb3996cf95 100644 --- a/cypress/e2e/orders/create-new-routing-list-from-poline.cy.js +++ b/cypress/e2e/orders/create-new-routing-list-from-poline.cy.js @@ -115,7 +115,7 @@ describe('Orders', () => { Receiving.selectLinkFromResultsList(); Receiving.waitLoading(); Receiving.verifyRoutingListWarning(); - Receiving.verifyAddingRoutingList(routingList); + Receiving.verifyRoutingListExists(routingList); }, ); }); diff --git a/cypress/e2e/orders/manage-user-assignments-in-routing-list-from-orders.cy.js b/cypress/e2e/orders/manage-user-assignments-in-routing-list-from-orders.cy.js index 2ad3b8caf9..ea05ce4518 100644 --- a/cypress/e2e/orders/manage-user-assignments-in-routing-list-from-orders.cy.js +++ b/cypress/e2e/orders/manage-user-assignments-in-routing-list-from-orders.cy.js @@ -1,34 +1,27 @@ -import permissions from '../../support/dictionary/permissions'; -import getRandomPostfix from '../../support/utils/stringTools'; -import FiscalYears from '../../support/fragments/finance/fiscalYears/fiscalYears'; -import TopMenu from '../../support/fragments/topMenu'; -import Ledgers from '../../support/fragments/finance/ledgers/ledgers'; +import { + ACQUISITION_METHOD_NAMES_IN_PROFILE, + APPLICATION_NAMES, + LOCATION_NAMES, + ORDER_STATUSES, +} from '../../support/constants'; +import Permissions from '../../support/dictionary/permissions'; +import { + BasicOrderLine, + NewOrder, + OrderLineDetails, + OrderLines, + Orders, +} from '../../support/fragments/orders'; +import RoutingListDetails from '../../support/fragments/orders/routingLists/routingListDetails'; +import RoutingListEditForm from '../../support/fragments/orders/routingLists/routingListEditForm'; +import { NewOrganization, Organizations } from '../../support/fragments/organizations'; +import TopMenuNavigation from '../../support/fragments/topMenuNavigation'; import Users from '../../support/fragments/users/users'; -import Funds from '../../support/fragments/finance/funds/funds'; -import NewOrder from '../../support/fragments/orders/newOrder'; -import Orders from '../../support/fragments/orders/orders'; -import Organizations from '../../support/fragments/organizations/organizations'; -import NewOrganization from '../../support/fragments/organizations/newOrganization'; -import ServicePoints from '../../support/fragments/settings/tenant/servicePoints/servicePoints'; -import NewLocation from '../../support/fragments/settings/tenant/locations/newLocation'; -import Budgets from '../../support/fragments/finance/budgets/budgets'; -import { ACQUISITION_METHOD_NAMES_IN_PROFILE, ORDER_STATUSES } from '../../support/constants'; -import BasicOrderLine from '../../support/fragments/orders/basicOrderLine'; -import MaterialTypes from '../../support/fragments/settings/inventory/materialTypes'; -import OrderLines from '../../support/fragments/orders/orderLines'; +import getRandomPostfix from '../../support/utils/stringTools'; -describe('Receiving', () => { - const firstFiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const defaultLedger = { ...Ledgers.defaultUiLedger }; - const firstFund = { ...Funds.defaultUiFund }; - const secondFund = { - name: `autotest_fund2_${getRandomPostfix()}`, - code: getRandomPostfix(), - externalAccountNo: getRandomPostfix(), - fundStatus: 'Active', - description: `This is fund created by E2E test automation script_${getRandomPostfix()}`, - }; - const firstOrder = { +describe('Orders', () => { + const testData = {}; + const order = { ...NewOrder.getDefaultOngoingOrder, orderType: 'Ongoing', ongoing: { isSubscription: false, manualRenewal: false }, @@ -36,142 +29,131 @@ describe('Receiving', () => { reEncumber: true, }; const organization = { ...NewOrganization.defaultUiOrganizations }; - firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; - const firstBudget = { - ...Budgets.getDefaultBudget(), - allocated: 1000, - }; - const routingList1 = `routingList_1${getRandomPostfix()}`; - let user; - let firstOrderNumber; - let servicePointId; - let location; - let secondUser; + const routingList = `routingList_1${getRandomPostfix()}`; - before(() => { - cy.loginAsAdmin({ - path: TopMenu.ordersPath, - waiter: Orders.waitLoading, - authRefresh: true, - }); - FiscalYears.createViaApi(firstFiscalYear).then((firstFiscalYearResponse) => { - firstFiscalYear.id = firstFiscalYearResponse.id; - firstBudget.fiscalYearId = firstFiscalYearResponse.id; - defaultLedger.fiscalYearOneId = firstFiscalYear.id; - Ledgers.createViaApi(defaultLedger).then((ledgerResponse) => { - defaultLedger.id = ledgerResponse.id; - firstFund.ledgerId = defaultLedger.id; - secondFund.ledgerId = defaultLedger.id; - - Funds.createViaApi(firstFund).then((fundResponse) => { - firstFund.id = fundResponse.fund.id; - firstBudget.fundId = fundResponse.fund.id; - Budgets.createViaApi(firstBudget); + before('Setup test data', () => { + cy.getAdminToken(); + cy.getLocations({ query: `name="${LOCATION_NAMES.ANNEX_UI}"` }).then((locationResp) => { + cy.getBookMaterialType().then((mtypes) => { + cy.getAcquisitionMethodsApi({ + query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, + }).then((params) => { + Organizations.createOrganizationViaApi(organization).then((responseOrganizations) => { + organization.id = responseOrganizations; + order.vendor = organization.id; + const orderLine = { + ...BasicOrderLine.defaultOrderLine, + cost: { + listUnitPrice: 5.0, + currency: 'USD', + discountType: 'percentage', + quantityPhysical: 1, + poLineEstimatedPrice: 5.0, + }, + locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + acquisitionMethod: params.body.acquisitionMethods[0].id, + physical: { + createInventory: 'Instance, Holding, Item', + materialType: mtypes.id, + materialSupplier: responseOrganizations, + volumes: [], + }, + }; + Orders.createOrderViaApi(order).then((orderResponse) => { + order.id = orderResponse.id; + testData.orderNumber = orderResponse.poNumber; + orderLine.purchaseOrderId = orderResponse.id; - ServicePoints.getViaApi().then((servicePoint) => { - servicePointId = servicePoint[0].id; - NewLocation.createViaApi(NewLocation.getDefaultLocation(servicePointId)).then((res) => { - location = res; + OrderLines.createOrderLineViaApi(orderLine).then((orderLineResponse) => { + testData.orderLineId = orderLineResponse.id; + }); - MaterialTypes.createMaterialTypeViaApi(MaterialTypes.getDefaultMaterialType()).then( - (mtypes) => { - cy.getAcquisitionMethodsApi({ - query: `value="${ACQUISITION_METHOD_NAMES_IN_PROFILE.PURCHASE_AT_VENDOR_SYSTEM}"`, - }).then((params) => { - Organizations.createOrganizationViaApi(organization).then( - (responseOrganizations) => { - organization.id = responseOrganizations; - firstOrder.vendor = organization.id; - const firstOrderLine = { - ...BasicOrderLine.defaultOrderLine, - cost: { - listUnitPrice: 100.0, - currency: 'USD', - discountType: 'percentage', - quantityPhysical: 2, - poLineEstimatedPrice: 100.0, - }, - fundDistribution: [ - { code: firstFund.code, fundId: firstFund.id, value: 100 }, - ], - locations: [ - { locationId: location.id, quantity: 2, quantityPhysical: 2 }, - ], - acquisitionMethod: params.body.acquisitionMethods[0].id, - physical: { - createInventory: 'Instance, Holding, Item', - materialType: mtypes.body.id, - materialSupplier: responseOrganizations, - volumes: [], - }, - }; - Orders.createOrderViaApi(firstOrder).then((firstOrderResponse) => { - firstOrder.id = firstOrderResponse.id; - firstOrderNumber = firstOrderResponse.poNumber; - firstOrderLine.purchaseOrderId = firstOrderResponse.id; - OrderLines.createOrderLineViaApi(firstOrderLine); - Orders.updateOrderViaApi({ - ...firstOrderResponse, - workflowStatus: ORDER_STATUSES.OPEN, - }); - Orders.searchByParameter('PO number', firstOrderNumber); - Orders.selectFromResultsList(firstOrderNumber); - OrderLines.selectPOLInOrder(); - OrderLines.openRoutingLists(); - OrderLines.addRoutingList(); - OrderLines.fillInRoutingListInfoAndSave(routingList1); - OrderLines.varifyAddingRoutingList(routingList1); - }); - }, - ); - }); - }, - ); + Orders.updateOrderViaApi({ + ...orderResponse, + workflowStatus: ORDER_STATUSES.OPEN, + }); }); }); }); }); }); - cy.createTempUser([permissions.uiOrdersEdit.gui]).then((secondUserProperties) => { - secondUser = secondUserProperties; + + cy.createTempUser([Permissions.uiOrdersEdit.gui]).then((secondUserProperties) => { + testData.secondUser = secondUserProperties; + + cy.getUsers({ limit: 1, query: `username=${secondUserProperties.username}` }).then( + (users) => { + cy.updateUser({ + ...users[0], + personal: { + ...users[0].personal, + addresses: [ + { + addressLine1: 'Broadway', + city: 'New York', + // should be changed to existing on environment value + addressTypeId: '93d3d88d-499b-45d0-9bc7-ac73c3a19880', + countryId: 'US', + }, + ], + }, + }); + }, + ); }); - cy.createTempUser([permissions.uiOrdersEdit.gui]).then((userProperties) => { - user = userProperties; - cy.login(userProperties.username, userProperties.password, { - path: TopMenu.ordersPath, - waiter: Orders.waitLoading, - authRefresh: true, - }); + cy.createTempUser([Permissions.uiOrdersEdit.gui]).then((userProperties) => { + testData.firstUser = userProperties; + + OrderLineDetails.createRoutingListViaApi([], routingList, testData.orderLineId).then( + (routingListResponse) => { + testData.routingListId = routingListResponse; + }, + ); + + cy.login(userProperties.username, userProperties.password); + TopMenuNavigation.navigateToApp(APPLICATION_NAMES.ORDERS); + Orders.selectOrdersPane(); + Orders.waitLoading(); }); }); - after(() => { + after('Clean up test data', () => { cy.getAdminToken(); - Users.deleteViaApi(user.userId); + Users.deleteViaApi(testData.firstUser.userId); + Users.deleteViaApi(testData.secondUser.userId); + RoutingListDetails.deleteRoutingListViaApi(testData.routingListId); + Orders.deleteOrderViaApi(order.id); + Organizations.deleteOrganizationViaApi(organization.id); }); it( 'C468163 Manage user assignments in routing list from "Orders" app (thunderjet)', - { tags: ['criticalPathBroken', 'thunderjet', 'C468163'] }, + { tags: ['criticalPath', 'thunderjet', 'C468163'] }, () => { - Orders.searchByParameter('PO number', firstOrderNumber); - Orders.selectFromResultsList(firstOrderNumber); + Orders.searchByParameter('PO number', testData.orderNumber); + Orders.selectFromResultsList(testData.orderNumber); OrderLines.selectPOLInOrder(); - OrderLines.openRoutingLists(); - OrderLines.openRoutingList(routingList1); - OrderLines.editRoutingList(); - OrderLines.addUserToRoutingList(); - OrderLines.assignUser(user.username); - OrderLines.checkUserIsAdded(user.username); - OrderLines.addUserToRoutingList(); - OrderLines.assignUser(secondUser.username); - OrderLines.checkUserIsAdded(secondUser.username); - OrderLines.saveOrderLine(); - OrderLines.editRoutingList(); - OrderLines.unAssignAllUsers(); - OrderLines.saveOrderLine(); - OrderLines.checkUserIsAbsent(user.username); - OrderLines.checkUserIsAbsent(secondUser.username); + OrderLineDetails.openRoutingListsAccordion(); + OrderLineDetails.openRoutingList(routingList); + RoutingListDetails.editRoutingList(); + RoutingListEditForm.addUserToRoutingList(); + RoutingListEditForm.assignUser(testData.firstUser.username); + RoutingListEditForm.checkUserIsAdded(testData.firstUser.username); + RoutingListEditForm.addUserToRoutingList(); + RoutingListEditForm.assignUser(testData.secondUser.username); + RoutingListEditForm.checkUserIsAdded(testData.secondUser.username); + RoutingListEditForm.save(); + RoutingListDetails.closeRoutingListDetails(); + OrderLineDetails.checkAssignedUsersInRoutingList([ + testData.firstUser.username, + testData.secondUser.username, + ]); + OrderLineDetails.openRoutingList(routingList); + RoutingListDetails.editRoutingList(); + RoutingListEditForm.unAssignAllUsers(); + RoutingListEditForm.save(); + RoutingListDetails.closeRoutingListDetails(); + OrderLineDetails.checkAssignedUsersInRoutingList([]); }, ); }); diff --git a/cypress/support/fragments/finance/funds/funds.js b/cypress/support/fragments/finance/funds/funds.js index caabab9263..d1dc4f6b02 100644 --- a/cypress/support/fragments/finance/funds/funds.js +++ b/cypress/support/fragments/finance/funds/funds.js @@ -1228,6 +1228,25 @@ export default { cy.wait(2000); }, + changeStatusOfExpClassByName: (expenseClassName, statusName) => { + cy.get('section#expense-classes fieldset#budget-status-expense-classes').within(() => { + cy.get('li[data-test-repeatable-field-list-item="true"]').each(($li, index) => { + cy.wrap($li).within(() => { + cy.get('button[name*="expenseClassId"]').then(($button) => { + if ($button.text().includes(expenseClassName)) { + cy.do(Select({ name: `statusExpenseClasses[${index}].status` }).choose(statusName)); + return false; + } + return true; + }); + }); + }); + }); + cy.wait(2000); + cy.do(saveAndCloseButton.click()); + cy.wait(2000); + }, + deleteExpensesClass: () => { // eslint-disable-next-line cypress/no-unnecessary-waiting cy.wait(2000); diff --git a/cypress/support/fragments/finance/ledgers/ledgers.js b/cypress/support/fragments/finance/ledgers/ledgers.js index 2456e4fdd1..a782eabace 100644 --- a/cypress/support/fragments/finance/ledgers/ledgers.js +++ b/cypress/support/fragments/finance/ledgers/ledgers.js @@ -1442,7 +1442,7 @@ export default { fileName, fileRow, fund, - secondFiscalYear, + fiscalYear, allowableEncumbrance, allowableExpenditure, initialAllocation, @@ -1470,7 +1470,7 @@ export default { expect(actualData[0]).to.equal(`"${fund.name}"`); expect(actualData[1]).to.equal(`"${fund.code}"`); expect(actualData[9]).to.equal(`"${fund.description}"`); - expect(actualData[10]).to.equal(`"${fund.code}-${secondFiscalYear.code}"`); + expect([`"${fund.code}-${fiscalYear.code}"`, `"${fiscalYear}"`]).to.include(actualData[10]); expect(actualData[12]).to.equal(allowableEncumbrance); expect(actualData[13]).to.equal(allowableExpenditure); expect(actualData[16]).to.equal(initialAllocation); @@ -1492,9 +1492,9 @@ export default { checkColumnContentInDownloadedLedgerExportFileWithExpClasses( fileName, - fileRow, + expClassName, fund, - secondFiscalYear, + fiscalYear, allowableEncumbrance, allowableExpenditure, initialAllocation, @@ -1511,7 +1511,6 @@ export default { overExpended, cashBalance, available, - expClassName, expClassCode, expClassStatus, expClassEncumbered, @@ -1522,13 +1521,27 @@ export default { cy.wait(3000); // wait for the file to load cy.readFile(`cypress/downloads/${fileName}`).then((fileContent) => { // Split the contents of a file into lines - const fileRows = fileContent.split('\n'); + const fileRows = fileContent.split('\n').filter(Boolean); + + // Find the row by expense class name (column 31) + let actualData; + for (let i = 1; i < fileRows.length; i++) { + const currentRow = fileRows[i].split(','); + if (currentRow[31] && currentRow[31].includes(expClassName)) { + actualData = currentRow; + break; + } + } - const actualData = fileRows[fileRow].trim().split(','); + if (!actualData) { + throw new Error( + `Row with expense class name "${expClassName}" not found in the export file`, + ); + } expect(actualData[0]).to.equal(`"${fund.name}"`); expect(actualData[1]).to.equal(`"${fund.code}"`); expect(actualData[9]).to.equal(`"${fund.description}"`); - expect(actualData[10]).to.equal(`"${fund.code}-${secondFiscalYear.code}"`); + expect([`"${fund.code}-${fiscalYear.code}"`, `"${fiscalYear}"`]).to.include(actualData[10]); expect(actualData[12]).to.equal(allowableEncumbrance); expect(actualData[13]).to.equal(allowableExpenditure); expect(actualData[16]).to.equal(initialAllocation); @@ -1714,9 +1727,9 @@ export default { checkColumnContentInDownloadedLedgerExport( fileName, - fileRow, + expenseClassName, fund, - budgetNameExpected, // pass the actual budget.name here + budgetNameExpected, allowableEncumbrance, allowableExpenditure, initialAllocation, @@ -1736,7 +1749,22 @@ export default { ) { cy.readFile(`cypress/downloads/${fileName}`, 'utf8', { timeout: 15000 }).then((fileContent) => { const lines = fileContent.split(/\r?\n/).filter(Boolean); - const row = this.parseCsvLine(lines[fileRow]); + + // Find the row by expense class name (column 30) + let row; + for (let i = 1; i < lines.length; i++) { + const currentRow = this.parseCsvLine(lines[i]); + if (this.clean(currentRow[30]) === this.clean(expenseClassName)) { + row = currentRow; + break; + } + } + + if (!row) { + throw new Error( + `Row with expense class name "${expenseClassName}" not found in the export file`, + ); + } expect(row[0]).to.equal(fund.name); // Name (Fund) expect(row[1]).to.equal(fund.code); // Code (Fund) diff --git a/cypress/support/fragments/inventory/holdingsRecordView.js b/cypress/support/fragments/inventory/holdingsRecordView.js index 21c9f5f40c..20e0794c5a 100644 --- a/cypress/support/fragments/inventory/holdingsRecordView.js +++ b/cypress/support/fragments/inventory/holdingsRecordView.js @@ -17,6 +17,7 @@ import InventoryNewHoldings from './inventoryNewHoldings'; import InventoryViewSource from './inventoryViewSource'; import SelectLocationModal from './modals/selectLocationModal'; import InteractorsTools from '../../utils/interactorsTools'; +import { Affiliations } from '../../dictionary'; const holdingsRecordViewSection = Section({ id: 'view-holdings-record-pane' }); const actionsButton = Button('Actions'); @@ -394,6 +395,40 @@ export default { else cy.expect(actionsButton.absent()); }, + checkReceivingHistoryForTenant(tenantName, receiptDate, source) { + const accordionConfigs = { + member: { + listId: `${Affiliations.College}-receiving-history-list`, + }, + central: { + listId: `${Affiliations.Consortia}-receiving-history-list`, + }, + }; + + const config = accordionConfigs[tenantName]; + // Find the receiving history list by ID within any section (including consortial holdings) + const receivingHistoryList = MultiColumnList({ id: config.listId }); + + cy.expect( + receivingHistoryList + .find(MultiColumnListCell({ column: 'Receipt date', content: receiptDate })) + .exists(), + ); + cy.expect( + receivingHistoryList + .find(MultiColumnListCell({ column: 'Source', content: source })) + .exists(), + ); + }, + + checkReceivingHistoryAccordionForMemberTenant(receiptDate, source) { + this.checkReceivingHistoryForTenant('member', receiptDate, source); + }, + + checkReceivingHistoryAccordionForCentralTenant(receiptDate, source) { + this.checkReceivingHistoryForTenant('central', receiptDate, source); + }, + checkNumberOfItems: (numberOfItems) => cy.expect(numberOfItemsKeyValue.has({ value: numberOfItems })), copyHoldingsHrid() { diff --git a/cypress/support/fragments/inventory/instanceRecordView.js b/cypress/support/fragments/inventory/instanceRecordView.js index 1e631c74b6..c33b0bb52a 100644 --- a/cypress/support/fragments/inventory/instanceRecordView.js +++ b/cypress/support/fragments/inventory/instanceRecordView.js @@ -616,6 +616,14 @@ export default { ); }, + verifySubjectWithoutMarcAppIcon: (row, value) => { + cy.expect( + subjectList + .find(MultiColumnListCell({ row, content: including(value) })) + .has({ content: not(including('Linked to MARC authority')) }), + ); + }, + expandContributorAccordion() { cy.do(contributorAccordion.clickHeader()); }, @@ -726,6 +734,7 @@ export default { }, expandAllInConsortialHoldingsAccordion(instanceId) { + cy.wait(3000); cy.do([ Section({ id: `consortialHoldings.${instanceId}` }) .find(Button('Expand all')) @@ -734,6 +743,7 @@ export default { }, collapseAllInConsortialHoldingsAccordion(instanceId) { + cy.wait(3000); cy.do([ Section({ id: `consortialHoldings.${instanceId}` }) .find(Button('Collapse all')) @@ -971,10 +981,13 @@ export default { ]); }, - verifySubHoldingsAccordion(memberId, holdingId, isOpen = true) { - cy.wait(1000); + verifySubHoldingsAccordion(memberId, holdingId, isOpen = 'false') { + cy.wait(2000); cy.expect([ - Accordion({ id: `consortialHoldings.${memberId}.${holdingId}` }).has({ open: isOpen }), + Accordion({ id: `consortialHoldings.${memberId}.${holdingId}` }).exists(), + Button({ id: `accordion-toggle-button-consortialHoldings.${memberId}.${holdingId}` }).has({ + ariaExpanded: isOpen, + }), ]); }, diff --git a/cypress/support/fragments/orders/routingLists/routingListEditForm.js b/cypress/support/fragments/orders/routingLists/routingListEditForm.js index 4a12fd01a4..f6aec91647 100644 --- a/cypress/support/fragments/orders/routingLists/routingListEditForm.js +++ b/cypress/support/fragments/orders/routingLists/routingListEditForm.js @@ -79,6 +79,7 @@ export default { save: () => { cy.wait(1500); cy.do(saveAndCloseButton.click()); + cy.wait(4000); }, unAssignUserFromRoutingList(userID) { diff --git a/cypress/support/fragments/receiving/receiving.js b/cypress/support/fragments/receiving/receiving.js index 17109af535..23effacb7f 100644 --- a/cypress/support/fragments/receiving/receiving.js +++ b/cypress/support/fragments/receiving/receiving.js @@ -604,7 +604,7 @@ export default { .then(({ body }) => body?.pieces || []); }, - receivePieceViaApi({ poLineId, pieces }) { + receivePieceViaApi({ poLineId, pieces, tenantId }) { return this.getPiecesViaApi(poLineId).then((allPieces) => { const checkInPieces = pieces.map((currentPiece) => { const piece = allPieces.find((p) => p.id === currentPiece.id); @@ -631,6 +631,9 @@ export default { sequenceNumber: piece.sequenceNumber, supplement: currentPiece.supplement !== undefined ? currentPiece.supplement : piece.supplement, + ...(tenantId || currentPiece.receivingTenantId + ? { receivingTenantId: tenantId || currentPiece.receivingTenantId } + : {}), }; }); @@ -641,6 +644,7 @@ export default { toBeCheckedIn: [{ poLineId, checkedIn: checkInPieces.length, checkInPieces }], totalRecords: checkInPieces.length, }, + isDefaultSearchParamsRequired: false, }); }); }, diff --git a/cypress/support/fragments/settings/consortium-manager/consortium-manager.js b/cypress/support/fragments/settings/consortium-manager/consortium-manager.js index d9895b0867..dd528f0a30 100644 --- a/cypress/support/fragments/settings/consortium-manager/consortium-manager.js +++ b/cypress/support/fragments/settings/consortium-manager/consortium-manager.js @@ -9,11 +9,13 @@ import { TextField, including, } from '../../../../../interactors'; +import OrderStorageSettings from '../../orders/orderStorageSettings'; const myProfileButton = Dropdown({ id: 'profileDropdown' }).find( Button({ className: including('navButton') }), ); const switchActiveAffiliationButton = Button('Switch active affiliation'); +const CENTRAL_ORDERING_SETTINGS_KEY = 'ALLOW_ORDERING_WITH_AFFILIATED_LOCATIONS'; export default { waitLoading() { @@ -124,4 +126,35 @@ export default { cy.expect(NavListItem('Membership').exists()); cy.expect(NavListItem('Central ordering').exists()); }, + + getCentralOrderingSettingsViaApi() { + return OrderStorageSettings.getSettingsViaApi({ key: CENTRAL_ORDERING_SETTINGS_KEY }); + }, + + updateCentralOrderingSettingsViaApi(settings) { + return OrderStorageSettings.updateSettingViaApi(settings); + }, + + createCentralOrderingSettingsViaApi(setting) { + return OrderStorageSettings.createSettingViaApi(setting); + }, + + enableCentralOrderingViaApi() { + const enabledCentralOrdering = 'true'; + return this.getCentralOrderingSettingsViaApi().then((settings) => { + if (settings?.length !== 0 && settings.value !== enabledCentralOrdering) { + return this.updateCentralOrderingSettingsViaApi({ + ...settings[0], + value: enabledCentralOrdering, + }); + } + if (settings?.length === 0) { + return this.createCentralOrderingSettingsViaApi({ + key: CENTRAL_ORDERING_SETTINGS_KEY, + value: enabledCentralOrdering, + }); + } + return settings[0]; + }); + }, }; From 92fee1308aa2c3940bc323524800df695f773d5b Mon Sep 17 00:00:00 2001 From: Tetiana_Paranich Date: Tue, 3 Mar 2026 15:51:56 +0200 Subject: [PATCH 3/3] fixed tests --- .../e2e/edi-import-large-invoice-file.cy.js | 2 +- .../allocation-tools-not-available.cy.js | 96 ++-- .../batchAllocation/batch-edit-budgets.cy.js | 284 +++++------ ...eate-and-update-budget-for-future-fy.cy.js | 388 ++++++++------- .../create-new-budget-for-current-fy.cy.js | 220 +++++---- .../download-allocation-worksheet.cy.js | 466 +++++++++--------- ...ecalculate-and-save-batch-allocation.cy.js | 434 ++++++++-------- ...batch-allocation-on-batch-edit-funds.cy.js | 312 ++++++------ ...rch-and-filter-batch-allocation-logs.cy.js | 342 ++++++------- ...ser-can-delete-batch-allocation-logs.cy.js | 450 ++++++++--------- ...assigned-to-acq-unit-cannot-see-logs.cy.js | 232 ++++----- ...s-updating-to-active-during-rollover.cy.js | 2 +- ...line-contains-two-fund-distributions.cy.js | 5 +- .../create-holdings-as-different-user.cy.js | 2 +- cypress/e2e/invoices/filter-invoices.cy.js | 1 + .../save-invoice-FY-after-fund-change.cy.js | 28 +- .../invoices.exportBatchVoucher.cy.js | 2 +- .../delete-routing-list-from-orders.cy.js | 8 +- ...ing-received-piece-when-order-closed.cy.js | 22 +- .../e2e/settings/orders/adjust-instance.cy.js | 2 +- .../support/fragments/finance/funds/funds.js | 6 +- .../support/fragments/invoices/invoices.js | 1 + 22 files changed, 1669 insertions(+), 1636 deletions(-) diff --git a/cypress/e2e/data-import/e2e/edi-import-large-invoice-file.cy.js b/cypress/e2e/data-import/e2e/edi-import-large-invoice-file.cy.js index 345986b8d3..1512a15a84 100644 --- a/cypress/e2e/data-import/e2e/edi-import-large-invoice-file.cy.js +++ b/cypress/e2e/data-import/e2e/edi-import-large-invoice-file.cy.js @@ -79,7 +79,7 @@ describe('Data Import', () => { it( 'C347615 Import a large EDIFACT invoice file (folijet)', - { tags: ['smoke', 'folijet', 'C347615', 'eurekaPhase1'] }, + { tags: ['smoke', 'folijet', 'C347615'] }, () => { // create Field mapping profile FieldMappingProfiles.createInvoiceMappingProfile(mappingProfile, profileForDuplicate); diff --git a/cypress/e2e/finance/batchAllocation/allocation-tools-not-available.cy.js b/cypress/e2e/finance/batchAllocation/allocation-tools-not-available.cy.js index 3d1265dcdb..267b203e7c 100644 --- a/cypress/e2e/finance/batchAllocation/allocation-tools-not-available.cy.js +++ b/cypress/e2e/finance/batchAllocation/allocation-tools-not-available.cy.js @@ -1,61 +1,63 @@ import permissions from '../../../support/dictionary/permissions'; -import TopMenu from '../../../support/fragments/topMenu'; +import FinanceHelper from '../../../support/fragments/finance/financeHelper'; import FiscalYears from '../../../support/fragments/finance/fiscalYears/fiscalYears'; import Funds from '../../../support/fragments/finance/funds/funds'; -import Users from '../../../support/fragments/users/users'; import Ledgers from '../../../support/fragments/finance/ledgers/ledgers'; -import FinanceHelper from '../../../support/fragments/finance/financeHelper'; +import TopMenu from '../../../support/fragments/topMenu'; +import Users from '../../../support/fragments/users/users'; -describe('Finance › Batch allocation', () => { - let user; - const fiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const ledger = { ...Ledgers.defaultUiLedger }; - const fund = { ...Funds.defaultUiFund }; +describe('Finance', () => { + describe('Batch allocation', () => { + let user; + const fiscalYear = { ...FiscalYears.defaultUiFiscalYear }; + const ledger = { ...Ledgers.defaultUiLedger }; + const fund = { ...Funds.defaultUiFund }; - before('Setup data', () => { - cy.getAdminToken(); - FiscalYears.createViaApi(fiscalYear).then((fy) => { - fiscalYear.id = fy.id; - ledger.fiscalYearOneId = fy.id; - Ledgers.createViaApi(ledger).then((lg) => { - ledger.id = lg.id; - fund.ledgerId = lg.id; - Funds.createViaApi(fund).then((fundResponse) => { - fund.id = fundResponse.fund.id; + before('Setup data', () => { + cy.getAdminToken(); + FiscalYears.createViaApi(fiscalYear).then((fy) => { + fiscalYear.id = fy.id; + ledger.fiscalYearOneId = fy.id; + Ledgers.createViaApi(ledger).then((lg) => { + ledger.id = lg.id; + fund.ledgerId = lg.id; + Funds.createViaApi(fund).then((fundResponse) => { + fund.id = fundResponse.fund.id; + }); }); }); - }); - cy.createTempUser([ - permissions.uiFinanceCreateAllocations.gui, - permissions.uiFinanceViewEditCreateFundAndBudget.gui, - permissions.uiFinanceViewFiscalYear.gui, - ]).then((userProperties) => { - user = userProperties; - cy.login(user.username, user.password, { - path: TopMenu.fiscalYearPath, - waiter: FiscalYears.waitLoading, + cy.createTempUser([ + permissions.uiFinanceCreateAllocations.gui, + permissions.uiFinanceViewEditCreateFundAndBudget.gui, + permissions.uiFinanceViewFiscalYear.gui, + ]).then((userProperties) => { + user = userProperties; + cy.login(user.username, user.password, { + path: TopMenu.fiscalYearPath, + waiter: FiscalYears.waitLoading, + }); }); }); - }); - after('Clean up', () => { - cy.getAdminToken(); - Users.deleteViaApi(user.userId); - }); + after('Clean up', () => { + cy.getAdminToken(); + Users.deleteViaApi(user.userId); + }); - it( - 'C648520 "Allocation tools" submenu is not available in "Actions" menu on "Fiscal year" and "Fund" panes (thunderjet)', - { tags: ['criticalPath', 'thunderjet', 'C648520'] }, - () => { - FiscalYears.searchByName(fiscalYear.name); - FiscalYears.selectFisacalYear(fiscalYear.name); - FiscalYears.clickActionsButtonInFY(); - FiscalYears.assertAllocationToolsSubmenuAbsent(); - FinanceHelper.selectFundsNavigation(); - Funds.searchByName(fund.name); - Funds.selectFund(fund.name); - Funds.assertAllocationToolsSubmenuAbsent(); - }, - ); + it( + 'C648520 "Allocation tools" submenu is not available in "Actions" menu on "Fiscal year" and "Fund" panes (thunderjet)', + { tags: ['criticalPath', 'thunderjet', 'C648520'] }, + () => { + FiscalYears.searchByName(fiscalYear.name); + FiscalYears.selectFisacalYear(fiscalYear.name); + FiscalYears.clickActionsButtonInFY(); + FiscalYears.assertAllocationToolsSubmenuAbsent(); + FinanceHelper.selectFundsNavigation(); + Funds.searchByName(fund.name); + Funds.selectFund(fund.name); + Funds.assertAllocationToolsSubmenuAbsent(); + }, + ); + }); }); diff --git a/cypress/e2e/finance/batchAllocation/batch-edit-budgets.cy.js b/cypress/e2e/finance/batchAllocation/batch-edit-budgets.cy.js index c921649419..fe0fb79223 100644 --- a/cypress/e2e/finance/batchAllocation/batch-edit-budgets.cy.js +++ b/cypress/e2e/finance/batchAllocation/batch-edit-budgets.cy.js @@ -1,164 +1,166 @@ import permissions from '../../../support/dictionary/permissions'; -import TopMenu from '../../../support/fragments/topMenu'; +import Budgets from '../../../support/fragments/finance/budgets/budgets'; import FiscalYears from '../../../support/fragments/finance/fiscalYears/fiscalYears'; -import Ledgers from '../../../support/fragments/finance/ledgers/ledgers'; import Funds from '../../../support/fragments/finance/funds/funds'; +import BatchEditBudget from '../../../support/fragments/finance/ledgers/batchEditBudget'; +import Ledgers from '../../../support/fragments/finance/ledgers/ledgers'; +import TopMenu from '../../../support/fragments/topMenu'; import Users from '../../../support/fragments/users/users'; -import Budgets from '../../../support/fragments/finance/budgets/budgets'; import DateTools from '../../../support/utils/dateTools'; import getRandomPostfix from '../../../support/utils/stringTools'; -import BatchEditBudget from '../../../support/fragments/finance/ledgers/batchEditBudget'; -describe('Finance › Batch allocation', () => { - let user; - const fiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const pastFiscalYear = { - ...FiscalYears.defaultUiFiscalYear, - name: `${FiscalYears.defaultUiFiscalYear.name}_Past`, - periodStart: `${DateTools.getThreePreviousDaysDateForFiscalYear()}T00:00:00.000+12:00`, - periodEnd: `${DateTools.getPreviousDayDateForFiscalYear()}T00:00:00.000+12:00`, - }; - const ledger = { ...Ledgers.defaultUiLedger }; - const funds = [ - { ...Funds.defaultUiFund, name: 'Fund A', code: `${getRandomPostfix()}_1` }, - { ...Funds.defaultUiFund, name: 'Fund B', code: `${getRandomPostfix()}_2` }, - { - ...Funds.defaultUiFund, - name: 'Fund C', - fundStatus: 'Inactive', - code: `${getRandomPostfix()}_3`, - }, - { ...Funds.defaultUiFund, name: 'Fund D', code: `${getRandomPostfix()}_4` }, - ]; +describe('Finance', () => { + describe('Batch allocation', () => { + let user; + const fiscalYear = { ...FiscalYears.defaultUiFiscalYear }; + const pastFiscalYear = { + ...FiscalYears.defaultUiFiscalYear, + name: `${FiscalYears.defaultUiFiscalYear.name}_Past`, + periodStart: `${DateTools.getThreePreviousDaysDateForFiscalYear()}T00:00:00.000+12:00`, + periodEnd: `${DateTools.getPreviousDayDateForFiscalYear()}T00:00:00.000+12:00`, + }; + const ledger = { ...Ledgers.defaultUiLedger }; + const funds = [ + { ...Funds.defaultUiFund, name: 'Fund A', code: `${getRandomPostfix()}_1` }, + { ...Funds.defaultUiFund, name: 'Fund B', code: `${getRandomPostfix()}_2` }, + { + ...Funds.defaultUiFund, + name: 'Fund C', + fundStatus: 'Inactive', + code: `${getRandomPostfix()}_3`, + }, + { ...Funds.defaultUiFund, name: 'Fund D', code: `${getRandomPostfix()}_4` }, + ]; - const budgets = [ - { ...Budgets.getDefaultBudget(), allocated: 100 }, - {}, - { ...Budgets.getDefaultBudget(), allocated: 100 }, - { ...Budgets.getDefaultBudget(), allocated: 100 }, - ]; + const budgets = [ + { ...Budgets.getDefaultBudget(), allocated: 100 }, + {}, + { ...Budgets.getDefaultBudget(), allocated: 100 }, + { ...Budgets.getDefaultBudget(), allocated: 100 }, + ]; - before('Setup data', () => { - cy.getAdminToken(); + before('Setup data', () => { + cy.getAdminToken(); - FiscalYears.createViaApi(fiscalYear).then((fy) => { - fiscalYear.id = fy.id; - ledger.fiscalYearOneId = fy.id; - pastFiscalYear.code = fiscalYear.code.slice(0, -1) + '2'; - budgets[0].fiscalYearId = fy.id; - budgets[2].fiscalYearId = fy.id; - budgets[3].fiscalYearId = fy.id; - FiscalYears.createViaApi(pastFiscalYear).then((pastFy) => { - pastFiscalYear.id = pastFy.id; - Ledgers.createViaApi(ledger).then((ledgerResponse) => { - ledger.id = ledgerResponse.id; - funds[0].ledgerId = ledger.id; - funds[1].ledgerId = ledger.id; - funds[2].ledgerId = ledger.id; - funds[3].ledgerId = ledger.id; + FiscalYears.createViaApi(fiscalYear).then((fy) => { + fiscalYear.id = fy.id; + ledger.fiscalYearOneId = fy.id; + pastFiscalYear.code = fiscalYear.code.slice(0, -1) + '2'; + budgets[0].fiscalYearId = fy.id; + budgets[2].fiscalYearId = fy.id; + budgets[3].fiscalYearId = fy.id; + FiscalYears.createViaApi(pastFiscalYear).then((pastFy) => { + pastFiscalYear.id = pastFy.id; + Ledgers.createViaApi(ledger).then((ledgerResponse) => { + ledger.id = ledgerResponse.id; + funds[0].ledgerId = ledger.id; + funds[1].ledgerId = ledger.id; + funds[2].ledgerId = ledger.id; + funds[3].ledgerId = ledger.id; - Funds.createViaApi(funds[0]).then((fundResponseA) => { - funds[0].id = fundResponseA.fund.id; - budgets[0].fundId = fundResponseA.fund.id; - Budgets.createViaApi(budgets[0]); - }); + Funds.createViaApi(funds[0]).then((fundResponseA) => { + funds[0].id = fundResponseA.fund.id; + budgets[0].fundId = fundResponseA.fund.id; + Budgets.createViaApi(budgets[0]); + }); - Funds.createViaApi(funds[1]).then((fundResponseB) => { - funds[1].id = fundResponseB.fund.id; - }); + Funds.createViaApi(funds[1]).then((fundResponseB) => { + funds[1].id = fundResponseB.fund.id; + }); - Funds.createViaApi(funds[2]).then((fundResponseC) => { - funds[2].id = fundResponseC.fund.id; - budgets[2].fundId = fundResponseC.fund.id; - Budgets.createViaApi(budgets[2]); - }); + Funds.createViaApi(funds[2]).then((fundResponseC) => { + funds[2].id = fundResponseC.fund.id; + budgets[2].fundId = fundResponseC.fund.id; + Budgets.createViaApi(budgets[2]); + }); - Funds.createViaApi(funds[3]).then((fundResponseD) => { - funds[3].id = fundResponseD.fund.id; - budgets[3].fundId = fundResponseD.fund.id; - Budgets.createViaApi(budgets[3]); + Funds.createViaApi(funds[3]).then((fundResponseD) => { + funds[3].id = fundResponseD.fund.id; + budgets[3].fundId = fundResponseD.fund.id; + Budgets.createViaApi(budgets[3]); + }); }); }); }); - }); - // Create user - cy.createTempUser([ - permissions.uiFinanceCreateAllocations.gui, - permissions.uiFinanceViewEditCreateFundAndBudget.gui, - permissions.uiFinanceViewLedger.gui, - ]).then((userProperties) => { - user = userProperties; - cy.login(user.username, user.password, { - path: TopMenu.ledgerPath, - waiter: Ledgers.waitLoading, + // Create user + cy.createTempUser([ + permissions.uiFinanceCreateAllocations.gui, + permissions.uiFinanceViewEditCreateFundAndBudget.gui, + permissions.uiFinanceViewLedger.gui, + ]).then((userProperties) => { + user = userProperties; + cy.login(user.username, user.password, { + path: TopMenu.ledgerPath, + waiter: Ledgers.waitLoading, + }); }); }); - }); - after('Clean up', () => { - cy.getAdminToken(); - Users.deleteViaApi(user.userId); - }); + after('Clean up', () => { + cy.getAdminToken(); + Users.deleteViaApi(user.userId); + }); - it( - 'C648486 User can access "Batch edit budgets" screen from Ledger, edit and cancel changes (thunderjet)', - { tags: ['criticalPath', 'thunderjet', 'C648486'] }, - () => { - Ledgers.searchByName(ledger.name); - Ledgers.selectLedger(ledger.name); - BatchEditBudget.clickBatchAllocationButton(); - BatchEditBudget.cancelBatchAllocation(); - BatchEditBudget.clickBatchAllocationButton(); - BatchEditBudget.searchFiscalYearInBatchAllocation(pastFiscalYear); - BatchEditBudget.expectEmptySelectionList(); - BatchEditBudget.cancelBatchAllocation(); - BatchEditBudget.clickBatchAllocationButton(); - BatchEditBudget.searchFiscalYearInBatchAllocation(fiscalYear); - BatchEditBudget.selectFiscalYearInBatchAllocation(fiscalYear); - BatchEditBudget.saveAndCloseBatchAllocation(); - BatchEditBudget.verifyBatchEditBudget([ - { - fundName: funds[0].name, - fundStatus: funds[0].fundStatus, - budgetName: budgets[0].name, - allocatedBefore: `$${budgets[0].allocated}.00`, - }, - { - fundName: funds[1].name, - fundStatus: funds[1].fundStatus, - budgetName: 'No value set-', - allocatedBefore: 'No value set-', - }, - { - fundName: funds[2].name, - fundStatus: funds[2].fundStatus, - budgetName: budgets[2].name, - allocatedBefore: `$${budgets[2].allocated}.00`, - }, - { - fundName: funds[3].name, - fundStatus: funds[3].fundStatus, - budgetName: budgets[3].name, - allocatedBefore: `$${budgets[3].allocated}.00`, - }, - ]); - BatchEditBudget.verifySortingByColumn('Fund name', 0); - BatchEditBudget.verifySortingByColumn('Budget Name', 2); - BatchEditBudget.increaseAllocationForFund(funds[0].name, 50); - BatchEditBudget.assertSortingAvailability('Fund name', false); - BatchEditBudget.assertSortingAvailability('Budget Name', false); - BatchEditBudget.increaseAllocationForFund(funds[0].name, 0); - BatchEditBudget.assertSortingAvailability('Fund name', 0, true); - BatchEditBudget.assertSortingAvailability('Budget Name', 2, true); - BatchEditBudget.setFundStatus(funds[1].name, 'Inactive'); - BatchEditBudget.setBudgetStatus(funds[2].name, 'Closed'); - BatchEditBudget.setAllocationChange(funds[0].name, 100); - BatchEditBudget.setAllowableEncumbrance(funds[3].name, 50); - BatchEditBudget.setAllowableExpenditure(funds[2].name, 50); - BatchEditBudget.addTransactionTags(funds[1].name, ['important']); - BatchEditBudget.cancelBatchEditBudget(); - BatchEditBudget.closeWithoutSavingBatchEditBudget(); - }, - ); + it( + 'C648486 User can access "Batch edit budgets" screen from Ledger, edit and cancel changes (thunderjet)', + { tags: ['criticalPath', 'thunderjet', 'C648486'] }, + () => { + Ledgers.searchByName(ledger.name); + Ledgers.selectLedger(ledger.name); + BatchEditBudget.clickBatchAllocationButton(); + BatchEditBudget.cancelBatchAllocation(); + BatchEditBudget.clickBatchAllocationButton(); + BatchEditBudget.searchFiscalYearInBatchAllocation(pastFiscalYear); + BatchEditBudget.expectEmptySelectionList(); + BatchEditBudget.cancelBatchAllocation(); + BatchEditBudget.clickBatchAllocationButton(); + BatchEditBudget.searchFiscalYearInBatchAllocation(fiscalYear); + BatchEditBudget.selectFiscalYearInBatchAllocation(fiscalYear); + BatchEditBudget.saveAndCloseBatchAllocation(); + BatchEditBudget.verifyBatchEditBudget([ + { + fundName: funds[0].name, + fundStatus: funds[0].fundStatus, + budgetName: budgets[0].name, + allocatedBefore: `$${budgets[0].allocated}.00`, + }, + { + fundName: funds[1].name, + fundStatus: funds[1].fundStatus, + budgetName: 'No value set-', + allocatedBefore: 'No value set-', + }, + { + fundName: funds[2].name, + fundStatus: funds[2].fundStatus, + budgetName: budgets[2].name, + allocatedBefore: `$${budgets[2].allocated}.00`, + }, + { + fundName: funds[3].name, + fundStatus: funds[3].fundStatus, + budgetName: budgets[3].name, + allocatedBefore: `$${budgets[3].allocated}.00`, + }, + ]); + BatchEditBudget.verifySortingByColumn('Fund name', 0); + BatchEditBudget.verifySortingByColumn('Budget Name', 2); + BatchEditBudget.increaseAllocationForFund(funds[0].name, 50); + BatchEditBudget.assertSortingAvailability('Fund name', false); + BatchEditBudget.assertSortingAvailability('Budget Name', false); + BatchEditBudget.increaseAllocationForFund(funds[0].name, 0); + BatchEditBudget.assertSortingAvailability('Fund name', 0, true); + BatchEditBudget.assertSortingAvailability('Budget Name', 2, true); + BatchEditBudget.setFundStatus(funds[1].name, 'Inactive'); + BatchEditBudget.setBudgetStatus(funds[2].name, 'Closed'); + BatchEditBudget.setAllocationChange(funds[0].name, 100); + BatchEditBudget.setAllowableEncumbrance(funds[3].name, 50); + BatchEditBudget.setAllowableExpenditure(funds[2].name, 50); + BatchEditBudget.addTransactionTags(funds[1].name, ['important']); + BatchEditBudget.cancelBatchEditBudget(); + BatchEditBudget.closeWithoutSavingBatchEditBudget(); + }, + ); + }); }); diff --git a/cypress/e2e/finance/batchAllocation/create-and-update-budget-for-future-fy.cy.js b/cypress/e2e/finance/batchAllocation/create-and-update-budget-for-future-fy.cy.js index 31977b4575..f2f1d6ec4e 100644 --- a/cypress/e2e/finance/batchAllocation/create-and-update-budget-for-future-fy.cy.js +++ b/cypress/e2e/finance/batchAllocation/create-and-update-budget-for-future-fy.cy.js @@ -1,208 +1,222 @@ import permissions from '../../../support/dictionary/permissions'; -import TopMenu from '../../../support/fragments/topMenu'; +import BudgetDetails from '../../../support/fragments/finance/budgets/budgetDetails'; +import Budgets from '../../../support/fragments/finance/budgets/budgets'; +import FinanceHelper from '../../../support/fragments/finance/financeHelper'; import FiscalYears from '../../../support/fragments/finance/fiscalYears/fiscalYears'; -import Ledgers from '../../../support/fragments/finance/ledgers/ledgers'; +import FundDetails from '../../../support/fragments/finance/funds/fundDetails'; import Funds from '../../../support/fragments/finance/funds/funds'; +import BatchEditBudget from '../../../support/fragments/finance/ledgers/batchEditBudget'; +import LedgerDetails from '../../../support/fragments/finance/ledgers/ledgerDetails'; +import Ledgers from '../../../support/fragments/finance/ledgers/ledgers'; +import TopMenu from '../../../support/fragments/topMenu'; import Users from '../../../support/fragments/users/users'; import DateTools from '../../../support/utils/dateTools'; -import getRandomPostfix from '../../../support/utils/stringTools'; -import BatchEditBudget from '../../../support/fragments/finance/ledgers/batchEditBudget'; import InteractorsTools from '../../../support/utils/interactorsTools'; -import LedgerDetails from '../../../support/fragments/finance/ledgers/ledgerDetails'; -import FundDetails from '../../../support/fragments/finance/funds/fundDetails'; -import BudgetDetails from '../../../support/fragments/finance/budgets/budgetDetails'; -import FinanceHelper from '../../../support/fragments/finance/financeHelper'; -import Budgets from '../../../support/fragments/finance/budgets/budgets'; +import getRandomPostfix from '../../../support/utils/stringTools'; -describe('Finance › Batch allocation', () => { - let user; - const fiscalYear1 = { ...FiscalYears.defaultUiFiscalYear }; - const fiscalYear2 = { - ...FiscalYears.defaultUiFiscalYear, - name: `${FiscalYears.defaultUiFiscalYear.name}_Next`, - periodStart: `${DateTools.get5DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+12:00`, - periodEnd: `${DateTools.get7DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+12:00`, - }; - const ledger = { ...Ledgers.defaultUiLedger }; - const funds = [ - { - ...Funds.defaultUiFund, - name: `autotest_fund_A_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_1`, - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_B_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_2`, - fundStatus: 'Inactive', - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_C_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_3`, - }, - ]; +describe('Finance', () => { + describe('Batch allocation', () => { + let user; + const fiscalYear1 = { ...FiscalYears.defaultUiFiscalYear }; + const fiscalYear2 = { + ...FiscalYears.defaultUiFiscalYear, + name: `${FiscalYears.defaultUiFiscalYear.name}_Next`, + periodStart: `${DateTools.get5DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+12:00`, + periodEnd: `${DateTools.get7DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+12:00`, + }; + const ledger = { ...Ledgers.defaultUiLedger }; + const funds = [ + { + ...Funds.defaultUiFund, + name: `autotest_fund_A_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_1`, + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_B_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_2`, + fundStatus: 'Inactive', + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_C_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_3`, + }, + ]; - const budgets = [ - { ...Budgets.getDefaultBudget() }, - { ...Budgets.getDefaultBudget() }, - { ...Budgets.getDefaultBudget() }, - ]; + const budgets = [ + { ...Budgets.getDefaultBudget() }, + { ...Budgets.getDefaultBudget() }, + { ...Budgets.getDefaultBudget() }, + ]; - before('Setup data', () => { - cy.getAdminToken(); + before('Setup data', () => { + cy.getAdminToken(); - FiscalYears.createViaApi(fiscalYear1).then((fy1) => { - fiscalYear1.id = fy1.id; - ledger.fiscalYearOneId = fy1.id; - budgets.forEach((b) => { - b.fiscalYearId = fy1.id; - }); - fiscalYear2.code = fiscalYear1.code.slice(0, -1) + '2'; - FiscalYears.createViaApi(fiscalYear2).then((fy2) => { - fiscalYear2.id = fy2.id; - Ledgers.createViaApi(ledger).then((ledgerResponse) => { - ledger.id = ledgerResponse.id; - funds.forEach((fund, index) => { - fund.ledgerId = ledger.id; - Funds.createViaApi(fund).then((fundResp) => { - fund.id = fundResp.fund.id; - const budgetToUse = budgets[index]; - budgetToUse.fundId = fund.id; - Budgets.createViaApi(budgetToUse).then((budgetResp) => { - budgetToUse.id = budgetResp.id; + FiscalYears.createViaApi(fiscalYear1).then((fy1) => { + fiscalYear1.id = fy1.id; + ledger.fiscalYearOneId = fy1.id; + budgets.forEach((b) => { + b.fiscalYearId = fy1.id; + }); + fiscalYear2.code = fiscalYear1.code.slice(0, -1) + '2'; + FiscalYears.createViaApi(fiscalYear2).then((fy2) => { + fiscalYear2.id = fy2.id; + Ledgers.createViaApi(ledger).then((ledgerResponse) => { + ledger.id = ledgerResponse.id; + funds.forEach((fund, index) => { + fund.ledgerId = ledger.id; + Funds.createViaApi(fund).then((fundResp) => { + fund.id = fundResp.fund.id; + const budgetToUse = budgets[index]; + budgetToUse.fundId = fund.id; + Budgets.createViaApi(budgetToUse).then((budgetResp) => { + budgetToUse.id = budgetResp.id; + }); }); }); }); }); }); - }); - cy.createTempUser([ - permissions.uiFinanceCreateAllocations.gui, - permissions.uiFinanceViewEditCreateFundAndBudget.gui, - permissions.uiFinanceViewLedger.gui, - ]).then((userProperties) => { - user = userProperties; - cy.login(user.username, user.password, { - path: TopMenu.ledgerPath, - waiter: Ledgers.waitLoading, + cy.createTempUser([ + permissions.uiFinanceCreateAllocations.gui, + permissions.uiFinanceViewEditCreateFundAndBudget.gui, + permissions.uiFinanceViewLedger.gui, + ]).then((userProperties) => { + user = userProperties; + cy.login(user.username, user.password, { + path: TopMenu.ledgerPath, + waiter: Ledgers.waitLoading, + }); }); }); - }); - after('Clean up', () => { - cy.getAdminToken(); - Users.deleteViaApi(user.userId); - }); + after('Clean up', () => { + cy.getAdminToken(); + Users.deleteViaApi(user.userId); + }); - it( - 'C651433 Create new budget for future FY on batch allocation screen, accessed from Ledger (thunderjet)', - { tags: ['criticalPath', 'thunderjet', 'C651433'] }, - () => { - Ledgers.searchByName(ledger.name); - Ledgers.selectLedger(ledger.name); - BatchEditBudget.clickBatchAllocationButton(); - BatchEditBudget.selectFiscalYearInConfirmModal(fiscalYear2); - BatchEditBudget.saveAndCloseBatchAllocation(); - BatchEditBudget.increaseAllocationForFund(funds[0].name, '-50'); - BatchEditBudget.clickRecalculateButton(); - cy.wait(1000); - BatchEditBudget.checkErrorMessageForNegativeAllocation(); - BatchEditBudget.increaseAllocationForFund(funds[0].name, '50'); - BatchEditBudget.setAllowableExpenditure(funds[0].name, '-10'); - BatchEditBudget.clickRecalculateButton(); - cy.wait(1000); - BatchEditBudget.checkErrorMessageForNegativeEncumbranceOrExpenditure(); - BatchEditBudget.setAllowableExpenditure(funds[0].name, '80'); - BatchEditBudget.increaseAllocationForFund(funds[0].name, '50'); - BatchEditBudget.addTransactionTags(funds[0].name, ['important']); - BatchEditBudget.increaseAllocationForFund(funds[1].name, '75'); - BatchEditBudget.setAllowableEncumbrance(funds[1].name, '85'); - BatchEditBudget.setBudgetStatus(funds[2].name, 'Planned'); - BatchEditBudget.clickRecalculateButton(); - cy.wait(1000); - BatchEditBudget.assertTotalAllocatedAfter(funds[0].name, '50.00'); - BatchEditBudget.assertTotalAllocatedAfter(funds[1].name, '75.00'); - BatchEditBudget.assertTotalAllocatedAfter(funds[2].name, ''); - BatchEditBudget.increaseAllocationForFund(funds[0].name, '20'); - BatchEditBudget.clickRecalculateButton(); - cy.wait(1000); - BatchEditBudget.assertTotalAllocatedAfter(funds[0].name, '20.00'); - BatchEditBudget.clickSaveAndCloseButton(); - InteractorsTools.checkCalloutMessage('Allocations have been updated successfully.'); - LedgerDetails.openFundDetails(funds[0].name); - FundDetails.checkFundDetails({ - plannedBudgets: [{ name: `${funds[0].code}-${fiscalYear2.code}`, allocated: '$20.00' }], - }); - Funds.selectPlannedBudgetDetails(); - BudgetDetails.checkBudgetDetails({ - summary: [ - { key: 'Initial allocation', value: '$20.00' }, - { key: 'Total allocated', value: '$20.00' }, - { key: 'Total funding', value: '$20.00' }, - ], - }); - BudgetDetails.checkBudgetDetails({ - information: [ - { key: 'Name', value: `${funds[0].code}-${fiscalYear2.code}` }, - { key: 'Status', value: 'Planned' }, - { key: 'Allowable expenditure', value: '80%' }, - ], - }); - Funds.viewTransactions(); - Funds.checkPaymentInTransactionDetails(0, fiscalYear2.code, 'User', funds[0].name, '$20.00'); - Funds.assertHasTagWithInteractors('important'); - Funds.closePaneHeader(); - Funds.closeBudgetDetails(); - FinanceHelper.selectLedgersNavigation(); - Ledgers.searchByName(ledger.name); - Ledgers.selectLedger(ledger.name); - LedgerDetails.openFundDetails(funds[1].name); - Funds.checkFundStatus('Active'); - FundDetails.checkFundDetails({ - plannedBudgets: [{ name: `${funds[1].code}-${fiscalYear2.code}`, allocated: '$75.00' }], - }); - Funds.selectPlannedBudgetDetails(); - BudgetDetails.checkBudgetDetails({ - summary: [ - { key: 'Initial allocation', value: '$75.00' }, - { key: 'Total allocated', value: '$75.00' }, - { key: 'Total funding', value: '$75.00' }, - ], - }); - BudgetDetails.checkBudgetDetails({ - information: [ - { key: 'Name', value: `${funds[1].code}-${fiscalYear2.code}` }, - { key: 'Status', value: 'Planned' }, - { key: 'Allowable encumbrance', value: '85%' }, - ], - }); - Funds.viewTransactions(); - Funds.checkPaymentInTransactionDetails(0, fiscalYear2.code, 'User', funds[1].name, '$75.00'); - Funds.closePaneHeader(); - Funds.closeBudgetDetails(); - FinanceHelper.selectLedgersNavigation(); - Ledgers.searchByName(ledger.name); - Ledgers.selectLedger(ledger.name); - LedgerDetails.openFundDetails(funds[2].name); - FundDetails.checkFundDetails({ - plannedBudgets: [{ name: `${funds[2].code}-${fiscalYear2.code}`, allocated: '$0.00' }], - }); - Funds.selectPlannedBudgetDetails(); - BudgetDetails.checkBudgetDetails({ - summary: [ - { key: 'Initial allocation', value: '$0.00' }, - { key: 'Total allocated', value: '$0.00' }, - { key: 'Total funding', value: '$0.00' }, - ], - }); - BudgetDetails.checkBudgetDetails({ - information: [ - { key: 'Name', value: `${funds[2].code}-${fiscalYear2.code}` }, - { key: 'Status', value: 'Planned' }, - ], - }); - }, - ); + it( + 'C651433 Create new budget for future FY on batch allocation screen, accessed from Ledger (thunderjet)', + { tags: ['criticalPath', 'thunderjet', 'C651433'] }, + () => { + Ledgers.searchByName(ledger.name); + Ledgers.selectLedger(ledger.name); + BatchEditBudget.clickBatchAllocationButton(); + BatchEditBudget.selectFiscalYearInConfirmModal(fiscalYear2); + BatchEditBudget.saveAndCloseBatchAllocation(); + BatchEditBudget.increaseAllocationForFund(funds[0].name, '-50'); + BatchEditBudget.clickRecalculateButton(); + cy.wait(1000); + BatchEditBudget.checkErrorMessageForNegativeAllocation(); + BatchEditBudget.increaseAllocationForFund(funds[0].name, '50'); + BatchEditBudget.setAllowableExpenditure(funds[0].name, '-10'); + BatchEditBudget.clickRecalculateButton(); + cy.wait(1000); + BatchEditBudget.checkErrorMessageForNegativeEncumbranceOrExpenditure(); + BatchEditBudget.setAllowableExpenditure(funds[0].name, '80'); + BatchEditBudget.increaseAllocationForFund(funds[0].name, '50'); + BatchEditBudget.addTransactionTags(funds[0].name, ['important']); + BatchEditBudget.increaseAllocationForFund(funds[1].name, '75'); + BatchEditBudget.setAllowableEncumbrance(funds[1].name, '85'); + BatchEditBudget.setBudgetStatus(funds[2].name, 'Planned'); + BatchEditBudget.clickRecalculateButton(); + cy.wait(1000); + BatchEditBudget.assertTotalAllocatedAfter(funds[0].name, '50.00'); + BatchEditBudget.assertTotalAllocatedAfter(funds[1].name, '75.00'); + BatchEditBudget.assertTotalAllocatedAfter(funds[2].name, ''); + BatchEditBudget.increaseAllocationForFund(funds[0].name, '20'); + BatchEditBudget.clickRecalculateButton(); + cy.wait(1000); + BatchEditBudget.assertTotalAllocatedAfter(funds[0].name, '20.00'); + BatchEditBudget.clickSaveAndCloseButton(); + InteractorsTools.checkCalloutMessage('Allocations have been updated successfully.'); + LedgerDetails.openFundDetails(funds[0].name); + FundDetails.checkFundDetails({ + plannedBudgets: [{ name: `${funds[0].code}-${fiscalYear2.code}`, allocated: '$20.00' }], + }); + Funds.selectPlannedBudgetDetails(); + BudgetDetails.checkBudgetDetails({ + summary: [ + { key: 'Initial allocation', value: '$20.00' }, + { key: 'Total allocated', value: '$20.00' }, + { key: 'Total funding', value: '$20.00' }, + ], + }); + BudgetDetails.checkBudgetDetails({ + information: [ + { key: 'Name', value: `${funds[0].code}-${fiscalYear2.code}` }, + { key: 'Status', value: 'Planned' }, + { key: 'Allowable expenditure', value: '80%' }, + ], + }); + Funds.viewTransactions(); + Funds.checkPaymentInTransactionDetails( + 0, + fiscalYear2.code, + 'User', + funds[0].name, + '$20.00', + ); + Funds.assertHasTagWithInteractors('important'); + Funds.closePaneHeader(); + Funds.closeBudgetDetails(); + FinanceHelper.selectLedgersNavigation(); + Ledgers.searchByName(ledger.name); + Ledgers.selectLedger(ledger.name); + LedgerDetails.openFundDetails(funds[1].name); + Funds.checkFundStatus('Active'); + FundDetails.checkFundDetails({ + plannedBudgets: [{ name: `${funds[1].code}-${fiscalYear2.code}`, allocated: '$75.00' }], + }); + Funds.selectPlannedBudgetDetails(); + BudgetDetails.checkBudgetDetails({ + summary: [ + { key: 'Initial allocation', value: '$75.00' }, + { key: 'Total allocated', value: '$75.00' }, + { key: 'Total funding', value: '$75.00' }, + ], + }); + BudgetDetails.checkBudgetDetails({ + information: [ + { key: 'Name', value: `${funds[1].code}-${fiscalYear2.code}` }, + { key: 'Status', value: 'Planned' }, + { key: 'Allowable encumbrance', value: '85%' }, + ], + }); + Funds.viewTransactions(); + Funds.checkPaymentInTransactionDetails( + 0, + fiscalYear2.code, + 'User', + funds[1].name, + '$75.00', + ); + Funds.closePaneHeader(); + Funds.closeBudgetDetails(); + FinanceHelper.selectLedgersNavigation(); + Ledgers.searchByName(ledger.name); + Ledgers.selectLedger(ledger.name); + LedgerDetails.openFundDetails(funds[2].name); + FundDetails.checkFundDetails({ + plannedBudgets: [{ name: `${funds[2].code}-${fiscalYear2.code}`, allocated: '$0.00' }], + }); + Funds.selectPlannedBudgetDetails(); + BudgetDetails.checkBudgetDetails({ + summary: [ + { key: 'Initial allocation', value: '$0.00' }, + { key: 'Total allocated', value: '$0.00' }, + { key: 'Total funding', value: '$0.00' }, + ], + }); + BudgetDetails.checkBudgetDetails({ + information: [ + { key: 'Name', value: `${funds[2].code}-${fiscalYear2.code}` }, + { key: 'Status', value: 'Planned' }, + ], + }); + }, + ); + }); }); diff --git a/cypress/e2e/finance/batchAllocation/create-new-budget-for-current-fy.cy.js b/cypress/e2e/finance/batchAllocation/create-new-budget-for-current-fy.cy.js index df0c83e4a6..f1a050f05c 100644 --- a/cypress/e2e/finance/batchAllocation/create-new-budget-for-current-fy.cy.js +++ b/cypress/e2e/finance/batchAllocation/create-new-budget-for-current-fy.cy.js @@ -1,125 +1,127 @@ import permissions from '../../../support/dictionary/permissions'; -import TopMenu from '../../../support/fragments/topMenu'; -import Ledgers from '../../../support/fragments/finance/ledgers/ledgers'; -import Users from '../../../support/fragments/users/users'; -import getRandomPostfix from '../../../support/utils/stringTools'; +import BudgetDetails from '../../../support/fragments/finance/budgets/budgetDetails'; +import FinanceHelper from '../../../support/fragments/finance/financeHelper'; import FiscalYears from '../../../support/fragments/finance/fiscalYears/fiscalYears'; +import FundDetails from '../../../support/fragments/finance/funds/fundDetails'; import Funds from '../../../support/fragments/finance/funds/funds'; import BatchEditBudget from '../../../support/fragments/finance/ledgers/batchEditBudget'; -import InteractorsTools from '../../../support/utils/interactorsTools'; -import FundDetails from '../../../support/fragments/finance/funds/fundDetails'; -import BudgetDetails from '../../../support/fragments/finance/budgets/budgetDetails'; -import FinanceHelper from '../../../support/fragments/finance/financeHelper'; import LedgerDetails from '../../../support/fragments/finance/ledgers/ledgerDetails'; +import Ledgers from '../../../support/fragments/finance/ledgers/ledgers'; +import TopMenu from '../../../support/fragments/topMenu'; +import Users from '../../../support/fragments/users/users'; +import InteractorsTools from '../../../support/utils/interactorsTools'; +import getRandomPostfix from '../../../support/utils/stringTools'; -describe('Finance › Batch allocation', () => { - let user; - const fiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const ledger = { ...Ledgers.defaultUiLedger }; - const funds = [ - { - ...Funds.defaultUiFund, - name: `autotest_fund_A_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_1`, - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_B_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_2`, - fundStatus: 'Inactive', - }, - ]; +describe('Finance', () => { + describe('Batch allocation', () => { + let user; + const fiscalYear = { ...FiscalYears.defaultUiFiscalYear }; + const ledger = { ...Ledgers.defaultUiLedger }; + const funds = [ + { + ...Funds.defaultUiFund, + name: `autotest_fund_A_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_1`, + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_B_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_2`, + fundStatus: 'Inactive', + }, + ]; - before('Create test data', () => { - cy.getAdminToken(); - FiscalYears.createViaApi(fiscalYear).then((fy) => { - fiscalYear.id = fy.id; - ledger.fiscalYearOneId = fy.id; - Ledgers.createViaApi(ledger).then((ledgerResponse) => { - ledger.id = ledgerResponse.id; - funds.forEach((fund) => { - fund.ledgerId = ledger.id; - Funds.createViaApi(fund).then((fundResp) => { - fund.id = fundResp.fund.id; + before('Create test data', () => { + cy.getAdminToken(); + FiscalYears.createViaApi(fiscalYear).then((fy) => { + fiscalYear.id = fy.id; + ledger.fiscalYearOneId = fy.id; + Ledgers.createViaApi(ledger).then((ledgerResponse) => { + ledger.id = ledgerResponse.id; + funds.forEach((fund) => { + fund.ledgerId = ledger.id; + Funds.createViaApi(fund).then((fundResp) => { + fund.id = fundResp.fund.id; + }); }); }); }); - }); - cy.createTempUser([ - permissions.uiFinanceCreateAllocations.gui, - permissions.uiFinanceViewEditCreateFundAndBudget.gui, - permissions.uiFinanceViewLedger.gui, - ]).then((userProperties) => { - user = userProperties; - cy.login(user.username, user.password, { - path: TopMenu.ledgerPath, - waiter: Ledgers.waitLoading, + cy.createTempUser([ + permissions.uiFinanceCreateAllocations.gui, + permissions.uiFinanceViewEditCreateFundAndBudget.gui, + permissions.uiFinanceViewLedger.gui, + ]).then((userProperties) => { + user = userProperties; + cy.login(user.username, user.password, { + path: TopMenu.ledgerPath, + waiter: Ledgers.waitLoading, + }); }); }); - }); - after('Clean up', () => { - cy.getAdminToken(); - Users.deleteViaApi(user.userId); - }); + after('Clean up', () => { + cy.getAdminToken(); + Users.deleteViaApi(user.userId); + }); - it( - 'C651440 Create new budget for current FY on batch allocation screen, accessed from Ledger (thunderjet)', - { tags: ['criticalPath', 'thunderjet', 'C651440'] }, - () => { - Ledgers.searchByName(ledger.name); - Ledgers.selectLedger(ledger.name); - BatchEditBudget.clickBatchAllocationButton(); - BatchEditBudget.saveAndCloseBatchAllocation(); - BatchEditBudget.increaseAllocationForFund(funds[0].name, '-50'); - BatchEditBudget.clickRecalculateButton(); - cy.wait(1000); - BatchEditBudget.checkErrorMessageForNegativeAllocation(); - BatchEditBudget.increaseAllocationForFund(funds[0].name, '100'); - BatchEditBudget.setAllowableExpenditure(funds[0].name, '80'); - BatchEditBudget.increaseAllocationForFund(funds[1].name, '150'); - BatchEditBudget.clickRecalculateButton(); - cy.wait(1000); - BatchEditBudget.assertTotalAllocatedAfter(funds[0].name, '100.00'); - BatchEditBudget.assertTotalAllocatedAfter(funds[1].name, '150.00'); - BatchEditBudget.clickSaveAndCloseButton(); - InteractorsTools.checkCalloutMessage('Allocations have been updated successfully.'); - LedgerDetails.openFundDetails(funds[0].name); - Funds.checkFundStatus('Active'); - FundDetails.checkFundDetails({ - currentBudget: [{ name: `${funds[0].code}-${fiscalYear.code}`, allocated: '$100.00' }], - }); - Funds.selectBudgetDetails(); - BudgetDetails.checkBudgetDetails({ - summary: [{ key: 'Total funding', value: '$100.00' }], - }); - BudgetDetails.checkBudgetDetails({ - information: [ - { key: 'Name', value: `${funds[0].code}-${fiscalYear.code}` }, - { key: 'Status', value: 'Active' }, - { key: 'Allowable expenditure', value: '80%' }, - ], - }); - Funds.closeBudgetDetails(); - FinanceHelper.selectLedgersNavigation(); - Ledgers.searchByName(ledger.name); - Ledgers.selectLedger(ledger.name); - LedgerDetails.openFundDetails(funds[1].name); - Funds.checkFundStatus('Active'); - FundDetails.checkFundDetails({ - currentBudget: [{ name: `${funds[1].code}-${fiscalYear.code}`, allocated: '$150.00' }], - }); - Funds.selectBudgetDetails(); - BudgetDetails.checkBudgetDetails({ - summary: [{ key: 'Total funding', value: '$150.00' }], - }); - BudgetDetails.checkBudgetDetails({ - information: [ - { key: 'Name', value: `${funds[1].code}-${fiscalYear.code}` }, - { key: 'Status', value: 'Active' }, - ], - }); - }, - ); + it( + 'C651440 Create new budget for current FY on batch allocation screen, accessed from Ledger (thunderjet)', + { tags: ['criticalPath', 'thunderjet', 'C651440'] }, + () => { + Ledgers.searchByName(ledger.name); + Ledgers.selectLedger(ledger.name); + BatchEditBudget.clickBatchAllocationButton(); + BatchEditBudget.saveAndCloseBatchAllocation(); + BatchEditBudget.increaseAllocationForFund(funds[0].name, '-50'); + BatchEditBudget.clickRecalculateButton(); + cy.wait(1000); + BatchEditBudget.checkErrorMessageForNegativeAllocation(); + BatchEditBudget.increaseAllocationForFund(funds[0].name, '100'); + BatchEditBudget.setAllowableExpenditure(funds[0].name, '80'); + BatchEditBudget.increaseAllocationForFund(funds[1].name, '150'); + BatchEditBudget.clickRecalculateButton(); + cy.wait(1000); + BatchEditBudget.assertTotalAllocatedAfter(funds[0].name, '100.00'); + BatchEditBudget.assertTotalAllocatedAfter(funds[1].name, '150.00'); + BatchEditBudget.clickSaveAndCloseButton(); + InteractorsTools.checkCalloutMessage('Allocations have been updated successfully.'); + LedgerDetails.openFundDetails(funds[0].name); + Funds.checkFundStatus('Active'); + FundDetails.checkFundDetails({ + currentBudget: [{ name: `${funds[0].code}-${fiscalYear.code}`, allocated: '$100.00' }], + }); + Funds.selectBudgetDetails(); + BudgetDetails.checkBudgetDetails({ + summary: [{ key: 'Total funding', value: '$100.00' }], + }); + BudgetDetails.checkBudgetDetails({ + information: [ + { key: 'Name', value: `${funds[0].code}-${fiscalYear.code}` }, + { key: 'Status', value: 'Active' }, + { key: 'Allowable expenditure', value: '80%' }, + ], + }); + Funds.closeBudgetDetails(); + FinanceHelper.selectLedgersNavigation(); + Ledgers.searchByName(ledger.name); + Ledgers.selectLedger(ledger.name); + LedgerDetails.openFundDetails(funds[1].name); + Funds.checkFundStatus('Active'); + FundDetails.checkFundDetails({ + currentBudget: [{ name: `${funds[1].code}-${fiscalYear.code}`, allocated: '$150.00' }], + }); + Funds.selectBudgetDetails(); + BudgetDetails.checkBudgetDetails({ + summary: [{ key: 'Total funding', value: '$150.00' }], + }); + BudgetDetails.checkBudgetDetails({ + information: [ + { key: 'Name', value: `${funds[1].code}-${fiscalYear.code}` }, + { key: 'Status', value: 'Active' }, + ], + }); + }, + ); + }); }); diff --git a/cypress/e2e/finance/batchAllocation/download-allocation-worksheet.cy.js b/cypress/e2e/finance/batchAllocation/download-allocation-worksheet.cy.js index a8e26332f1..26dc5ce3c3 100644 --- a/cypress/e2e/finance/batchAllocation/download-allocation-worksheet.cy.js +++ b/cypress/e2e/finance/batchAllocation/download-allocation-worksheet.cy.js @@ -1,255 +1,257 @@ import uuid from 'uuid'; import permissions from '../../../support/dictionary/permissions'; -import TopMenu from '../../../support/fragments/topMenu'; +import Budgets from '../../../support/fragments/finance/budgets/budgets'; import FiscalYears from '../../../support/fragments/finance/fiscalYears/fiscalYears'; -import Ledgers from '../../../support/fragments/finance/ledgers/ledgers'; import Funds from '../../../support/fragments/finance/funds/funds'; -import Budgets from '../../../support/fragments/finance/budgets/budgets'; +import BatchEditBudget from '../../../support/fragments/finance/ledgers/batchEditBudget'; +import Ledgers from '../../../support/fragments/finance/ledgers/ledgers'; +import TopMenu from '../../../support/fragments/topMenu'; import Users from '../../../support/fragments/users/users'; import DateTools from '../../../support/utils/dateTools'; -import getRandomPostfix from '../../../support/utils/stringTools'; -import BatchEditBudget from '../../../support/fragments/finance/ledgers/batchEditBudget'; import InteractorsTools from '../../../support/utils/interactorsTools'; +import getRandomPostfix from '../../../support/utils/stringTools'; -describe('Finance › Batch allocation', () => { - let user; - const fiscalYear1 = { ...FiscalYears.defaultUiFiscalYear }; - const fiscalYear2 = { - ...FiscalYears.defaultUiFiscalYear, - name: `${FiscalYears.defaultUiFiscalYear.name}_Next`, - periodStart: `${DateTools.get5DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+12:00`, - periodEnd: `${DateTools.get7DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+12:00`, - }; - const ledger = { ...Ledgers.defaultUiLedger }; - const funds = [ - { - ...Funds.defaultUiFund, - name: `autotest_fund_A_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_1`, - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_B_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_2`, - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_C_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_3`, - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_D_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_4`, - }, - ]; +describe('Finance', () => { + describe('Batch allocation', () => { + let user; + const fiscalYear1 = { ...FiscalYears.defaultUiFiscalYear }; + const fiscalYear2 = { + ...FiscalYears.defaultUiFiscalYear, + name: `${FiscalYears.defaultUiFiscalYear.name}_Next`, + periodStart: `${DateTools.get5DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+12:00`, + periodEnd: `${DateTools.get7DaysAfterTomorrowDateForFiscalYear()}T00:00:00.000+12:00`, + }; + const ledger = { ...Ledgers.defaultUiLedger }; + const funds = [ + { + ...Funds.defaultUiFund, + name: `autotest_fund_A_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_1`, + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_B_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_2`, + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_C_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_3`, + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_D_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_4`, + }, + ]; - const budgets = [ - { - ...Budgets.getDefaultBudget(), - allocated: 100, - allowableEncumbrance: 110, - allowableExpenditure: 110, - }, - { ...Budgets.getDefaultBudget(), allocated: 200 }, - { ...Budgets.getDefaultBudget(), allocated: 300 }, - {}, - ]; - let fileName1 = ''; - let fileName2 = ''; - let moveAllocationTransaction; + const budgets = [ + { + ...Budgets.getDefaultBudget(), + allocated: 100, + allowableEncumbrance: 110, + allowableExpenditure: 110, + }, + { ...Budgets.getDefaultBudget(), allocated: 200 }, + { ...Budgets.getDefaultBudget(), allocated: 300 }, + {}, + ]; + let fileName1 = ''; + let fileName2 = ''; + let moveAllocationTransaction; - before('Setup data', () => { - cy.loginAsAdmin({ - path: TopMenu.fundPath, - waiter: Funds.waitLoading, - }); + before('Setup data', () => { + cy.loginAsAdmin({ + path: TopMenu.fundPath, + waiter: Funds.waitLoading, + }); - FiscalYears.createViaApi(fiscalYear1) - .then((fy1) => { - fiscalYear1.id = fy1.id; - ledger.fiscalYearOneId = fy1.id; - fiscalYear2.code = fiscalYear1.code.slice(0, -1) + '2'; - budgets.forEach((b) => { - b.fiscalYearId = fy1.id; - }); - FiscalYears.createViaApi(fiscalYear2).then((fy2) => { - fiscalYear2.id = fy2.id; - Ledgers.createViaApi(ledger).then((ledgerResponse) => { - ledger.id = ledgerResponse.id; - funds.forEach((fund, idx) => { - fund.ledgerId = ledger.id; - Funds.createViaApi(fund).then((fundResp) => { - fund.id = fundResp.fund.id; - if (idx < 3) { - const budgetToUse = budgets[idx]; - budgetToUse.fundId = fund.id; - Budgets.createViaApi(budgetToUse).then((budgetResp) => { - budgetToUse.id = budgetResp.id; - }); - } + FiscalYears.createViaApi(fiscalYear1) + .then((fy1) => { + fiscalYear1.id = fy1.id; + ledger.fiscalYearOneId = fy1.id; + fiscalYear2.code = fiscalYear1.code.slice(0, -1) + '2'; + budgets.forEach((b) => { + b.fiscalYearId = fy1.id; + }); + FiscalYears.createViaApi(fiscalYear2).then((fy2) => { + fiscalYear2.id = fy2.id; + Ledgers.createViaApi(ledger).then((ledgerResponse) => { + ledger.id = ledgerResponse.id; + funds.forEach((fund, idx) => { + fund.ledgerId = ledger.id; + Funds.createViaApi(fund).then((fundResp) => { + fund.id = fundResp.fund.id; + if (idx < 3) { + const budgetToUse = budgets[idx]; + budgetToUse.fundId = fund.id; + Budgets.createViaApi(budgetToUse).then((budgetResp) => { + budgetToUse.id = budgetResp.id; + }); + } + }); }); }); }); + }) + .then(() => { + moveAllocationTransaction = { + transactionsToCreate: [ + { + amount: 10.5, + currency: 'USD', + fiscalYearId: fiscalYear1.id, + fromFundId: funds[0].id, + toFundId: funds[1].id, + transactionType: 'Allocation', + source: 'User', + id: uuid(), + }, + ], + }; + return Budgets.batchProcessTransactions(moveAllocationTransaction); }); - }) - .then(() => { - moveAllocationTransaction = { - transactionsToCreate: [ - { - amount: 10.5, - currency: 'USD', - fiscalYearId: fiscalYear1.id, - fromFundId: funds[0].id, - toFundId: funds[1].id, - transactionType: 'Allocation', - source: 'User', - id: uuid(), - }, - ], - }; - return Budgets.batchProcessTransactions(moveAllocationTransaction); - }); - Funds.searchByName(funds[0].name); - Funds.selectFund(funds[0].name); - Funds.selectBudgetDetails(); - Funds.increaseAllocation('10'); - cy.wait(4000); - Funds.decreaseAllocation('5'); - cy.wait(4000); + Funds.searchByName(funds[0].name); + Funds.selectFund(funds[0].name); + Funds.selectBudgetDetails(); + Funds.increaseAllocation('10'); + cy.wait(4000); + Funds.decreaseAllocation('5'); + cy.wait(4000); - fileName1 = `${fiscalYear2.code}${ledger.code}.csv`; - fileName2 = `${fiscalYear1.code}${ledger.code}.csv`; + fileName1 = `${fiscalYear2.code}${ledger.code}.csv`; + fileName2 = `${fiscalYear1.code}${ledger.code}.csv`; - cy.createTempUser([ - permissions.uiFinanceViewLedger.gui, - permissions.uiFinanceViewFiscalYear.gui, - ]).then((userProperties) => { - user = userProperties; - cy.login(user.username, user.password, { - path: TopMenu.ledgerPath, - waiter: Ledgers.waitLoading, + cy.createTempUser([ + permissions.uiFinanceViewLedger.gui, + permissions.uiFinanceViewFiscalYear.gui, + ]).then((userProperties) => { + user = userProperties; + cy.login(user.username, user.password, { + path: TopMenu.ledgerPath, + waiter: Ledgers.waitLoading, + }); }); }); - }); - after('Clean up', () => { - cy.getAdminToken(); - Users.deleteViaApi(user.userId); - }); + after('Clean up', () => { + cy.getAdminToken(); + Users.deleteViaApi(user.userId); + }); - it( - 'C648502 Download allocation worksheet (CSV) from Ledger view (thunderjet)', - { tags: ['criticalPath', 'thunderjet', 'C648502'] }, - () => { - Ledgers.searchByName(ledger.name); - Ledgers.selectLedger(ledger.name); - BatchEditBudget.clickDownloadAllocationWorksheet(); - BatchEditBudget.cancelBatchEditBudget(); - BatchEditBudget.clickDownloadAllocationWorksheet(); - BatchEditBudget.clickConfirmButton(); - InteractorsTools.checkCalloutMessage( - 'Please wait while the worksheet is generated. Your download will start automatically', - ); - Ledgers.checkColumnNamesInDownloadedLedgerAllocationWorksheet( - `${fiscalYear2.code}${ledger.code}.csv`, - ); - Ledgers.deleteDownloadedFile(fileName1); - BatchEditBudget.clickDownloadAllocationWorksheet(); - BatchEditBudget.selectFiscalYearInConfirmModal(fiscalYear1); - BatchEditBudget.clickConfirmButton(); - InteractorsTools.checkCalloutMessage( - 'Please wait while the worksheet is generated. Your download will start automatically', - ); - Ledgers.checkColumnNamesInDownloadedLedgerAllocationWorksheet( - `${fiscalYear1.code}${ledger.code}.csv`, - ); - Ledgers.checkLedgerExportRow( - fileName2, - { fundName: funds[0].name }, - { - fiscalYear: fileName1.code, - fundName: funds[0].name, - fundCode: funds[0].code, - fundUUID: funds[0].id, - fundStatus: 'Active', - budgetName: budgets[0].name, - budgetUUID: budgets[0].id, - budgetStatus: 'Active', - budgetInitialAllocation: budgets[0].allocated, - budgetCurrentAllocation: '94.5', - budgetAllowableEncumbrance: '110', - budgetAllowableExpenditure: '110', - allocationAdjustment: '0', - transactionTag: '', - transactionDescription: '', - }, - ); - Ledgers.checkLedgerExportRow( - fileName2, - { fundName: funds[1].name }, - { - fiscalYear: fileName1.code, - fundName: funds[1].name, - fundCode: funds[1].code, - fundUUID: funds[1].id, - fundStatus: 'Active', - budgetName: budgets[1].name, - budgetUUID: budgets[1].id, - budgetStatus: 'Active', - budgetInitialAllocation: budgets[1].allocated, - budgetCurrentAllocation: '210.5', - budgetAllowableEncumbrance: '100', - budgetAllowableExpenditure: '100', - allocationAdjustment: '0', - transactionTag: '', - transactionDescription: '', - }, - ); - Ledgers.checkLedgerExportRow( - fileName2, - { fundName: funds[2].name }, - { - fiscalYear: fileName1.code, - fundName: funds[2].name, - fundCode: funds[2].code, - fundUUID: funds[2].id, - fundStatus: 'Active', - budgetName: budgets[2].name, - budgetUUID: budgets[2].id, - budgetStatus: 'Active', - budgetInitialAllocation: budgets[2].allocated, - budgetCurrentAllocation: '300', - budgetAllowableEncumbrance: '100', - budgetAllowableExpenditure: '100', - allocationAdjustment: '0', - transactionTag: '', - transactionDescription: '', - }, - ); - Ledgers.checkLedgerExportRow( - fileName2, - { fundName: funds[3].name }, - { - fiscalYear: fileName1.code, - fundName: funds[3].name, - fundCode: funds[3].code, - fundUUID: funds[3].id, - fundStatus: 'Active', - budgetName: '', - budgetUUID: '', - budgetStatus: '', - budgetInitialAllocation: '', - budgetCurrentAllocation: '', - budgetAllowableEncumbrance: '', - budgetAllowableExpenditure: '', - allocationAdjustment: '0', - transactionTag: '', - transactionDescription: '', - }, - ); - Ledgers.deleteDownloadedFile(fileName2); - }, - ); + it( + 'C648502 Download allocation worksheet (CSV) from Ledger view (thunderjet)', + { tags: ['criticalPath', 'thunderjet', 'C648502'] }, + () => { + Ledgers.searchByName(ledger.name); + Ledgers.selectLedger(ledger.name); + BatchEditBudget.clickDownloadAllocationWorksheet(); + BatchEditBudget.cancelBatchEditBudget(); + BatchEditBudget.clickDownloadAllocationWorksheet(); + BatchEditBudget.clickConfirmButton(); + InteractorsTools.checkCalloutMessage( + 'Please wait while the worksheet is generated. Your download will start automatically', + ); + Ledgers.checkColumnNamesInDownloadedLedgerAllocationWorksheet( + `${fiscalYear2.code}${ledger.code}.csv`, + ); + Ledgers.deleteDownloadedFile(fileName1); + BatchEditBudget.clickDownloadAllocationWorksheet(); + BatchEditBudget.selectFiscalYearInConfirmModal(fiscalYear1); + BatchEditBudget.clickConfirmButton(); + InteractorsTools.checkCalloutMessage( + 'Please wait while the worksheet is generated. Your download will start automatically', + ); + Ledgers.checkColumnNamesInDownloadedLedgerAllocationWorksheet( + `${fiscalYear1.code}${ledger.code}.csv`, + ); + Ledgers.checkLedgerExportRow( + fileName2, + { fundName: funds[0].name }, + { + fiscalYear: fileName1.code, + fundName: funds[0].name, + fundCode: funds[0].code, + fundUUID: funds[0].id, + fundStatus: 'Active', + budgetName: budgets[0].name, + budgetUUID: budgets[0].id, + budgetStatus: 'Active', + budgetInitialAllocation: budgets[0].allocated, + budgetCurrentAllocation: '94.5', + budgetAllowableEncumbrance: '110', + budgetAllowableExpenditure: '110', + allocationAdjustment: '0', + transactionTag: '', + transactionDescription: '', + }, + ); + Ledgers.checkLedgerExportRow( + fileName2, + { fundName: funds[1].name }, + { + fiscalYear: fileName1.code, + fundName: funds[1].name, + fundCode: funds[1].code, + fundUUID: funds[1].id, + fundStatus: 'Active', + budgetName: budgets[1].name, + budgetUUID: budgets[1].id, + budgetStatus: 'Active', + budgetInitialAllocation: budgets[1].allocated, + budgetCurrentAllocation: '210.5', + budgetAllowableEncumbrance: '100', + budgetAllowableExpenditure: '100', + allocationAdjustment: '0', + transactionTag: '', + transactionDescription: '', + }, + ); + Ledgers.checkLedgerExportRow( + fileName2, + { fundName: funds[2].name }, + { + fiscalYear: fileName1.code, + fundName: funds[2].name, + fundCode: funds[2].code, + fundUUID: funds[2].id, + fundStatus: 'Active', + budgetName: budgets[2].name, + budgetUUID: budgets[2].id, + budgetStatus: 'Active', + budgetInitialAllocation: budgets[2].allocated, + budgetCurrentAllocation: '300', + budgetAllowableEncumbrance: '100', + budgetAllowableExpenditure: '100', + allocationAdjustment: '0', + transactionTag: '', + transactionDescription: '', + }, + ); + Ledgers.checkLedgerExportRow( + fileName2, + { fundName: funds[3].name }, + { + fiscalYear: fileName1.code, + fundName: funds[3].name, + fundCode: funds[3].code, + fundUUID: funds[3].id, + fundStatus: 'Active', + budgetName: '', + budgetUUID: '', + budgetStatus: '', + budgetInitialAllocation: '', + budgetCurrentAllocation: '', + budgetAllowableEncumbrance: '', + budgetAllowableExpenditure: '', + allocationAdjustment: '0', + transactionTag: '', + transactionDescription: '', + }, + ); + Ledgers.deleteDownloadedFile(fileName2); + }, + ); + }); }); diff --git a/cypress/e2e/finance/batchAllocation/recalculate-and-save-batch-allocation.cy.js b/cypress/e2e/finance/batchAllocation/recalculate-and-save-batch-allocation.cy.js index b90bc5432c..6ce5fd92da 100644 --- a/cypress/e2e/finance/batchAllocation/recalculate-and-save-batch-allocation.cy.js +++ b/cypress/e2e/finance/batchAllocation/recalculate-and-save-batch-allocation.cy.js @@ -1,234 +1,236 @@ import permissions from '../../../support/dictionary/permissions'; -import TopMenu from '../../../support/fragments/topMenu'; +import BudgetDetails from '../../../support/fragments/finance/budgets/budgetDetails'; +import Budgets from '../../../support/fragments/finance/budgets/budgets'; +import FinanceHelper from '../../../support/fragments/finance/financeHelper'; import FiscalYears from '../../../support/fragments/finance/fiscalYears/fiscalYears'; -import Ledgers from '../../../support/fragments/finance/ledgers/ledgers'; +import FundDetails from '../../../support/fragments/finance/funds/fundDetails'; import Funds from '../../../support/fragments/finance/funds/funds'; -import Budgets from '../../../support/fragments/finance/budgets/budgets'; -import Users from '../../../support/fragments/users/users'; -import getRandomPostfix from '../../../support/utils/stringTools'; import BatchEditBudget from '../../../support/fragments/finance/ledgers/batchEditBudget'; import LedgerDetails from '../../../support/fragments/finance/ledgers/ledgerDetails'; -import FinanceHelper from '../../../support/fragments/finance/financeHelper'; -import FundDetails from '../../../support/fragments/finance/funds/fundDetails'; -import BudgetDetails from '../../../support/fragments/finance/budgets/budgetDetails'; +import Ledgers from '../../../support/fragments/finance/ledgers/ledgers'; +import TopMenu from '../../../support/fragments/topMenu'; +import Users from '../../../support/fragments/users/users'; +import getRandomPostfix from '../../../support/utils/stringTools'; -describe('Finance › Batch allocation', () => { - let user; - const fiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const ledger = { ...Ledgers.defaultUiLedger }; - const funds = [ - { - ...Funds.defaultUiFund, - name: `autotest_fund_A_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_1`, - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_B_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_2`, - fundStatus: 'Inactive', - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_C_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_3`, - fundStatus: 'Inactive', - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_D_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_4`, - fundStatus: 'Inactive', - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_E_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_5`, - fundStatus: 'Inactive', - }, - ]; +describe('Finance', () => { + describe('Batch allocation', () => { + let user; + const fiscalYear = { ...FiscalYears.defaultUiFiscalYear }; + const ledger = { ...Ledgers.defaultUiLedger }; + const funds = [ + { + ...Funds.defaultUiFund, + name: `autotest_fund_A_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_1`, + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_B_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_2`, + fundStatus: 'Inactive', + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_C_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_3`, + fundStatus: 'Inactive', + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_D_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_4`, + fundStatus: 'Inactive', + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_E_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_5`, + fundStatus: 'Inactive', + }, + ]; - const budgets = [ - { ...Budgets.getDefaultBudget(), allocated: 100 }, - { ...Budgets.getDefaultBudget(), allocated: 200 }, - { ...Budgets.getDefaultBudget(), allocated: 300 }, - { ...Budgets.getDefaultBudget(), allocated: 400 }, - { ...Budgets.getDefaultBudget(), allocated: 500, budgetStatus: 'Inactive' }, - ]; + const budgets = [ + { ...Budgets.getDefaultBudget(), allocated: 100 }, + { ...Budgets.getDefaultBudget(), allocated: 200 }, + { ...Budgets.getDefaultBudget(), allocated: 300 }, + { ...Budgets.getDefaultBudget(), allocated: 400 }, + { ...Budgets.getDefaultBudget(), allocated: 500, budgetStatus: 'Inactive' }, + ]; - before('Setup data', () => { - cy.getAdminToken(); + before('Setup data', () => { + cy.getAdminToken(); - FiscalYears.createViaApi(fiscalYear).then((fy) => { - fiscalYear.id = fy.id; - ledger.fiscalYearOneId = fy.id; - budgets.forEach((b) => { - b.fiscalYearId = fy.id; - }); - Ledgers.createViaApi(ledger).then((ledgerResponse) => { - ledger.id = ledgerResponse.id; - funds.forEach((fund, idx) => { - fund.ledgerId = ledger.id; - Funds.createViaApi(fund).then((fundResp) => { - fund.id = fundResp.fund.id; - const budgetToUse = budgets[idx]; - budgetToUse.fundId = fund.id; - Budgets.createViaApi(budgetToUse).then((budgetResp) => { - budgetToUse.id = budgetResp.id; + FiscalYears.createViaApi(fiscalYear).then((fy) => { + fiscalYear.id = fy.id; + ledger.fiscalYearOneId = fy.id; + budgets.forEach((b) => { + b.fiscalYearId = fy.id; + }); + Ledgers.createViaApi(ledger).then((ledgerResponse) => { + ledger.id = ledgerResponse.id; + funds.forEach((fund, idx) => { + fund.ledgerId = ledger.id; + Funds.createViaApi(fund).then((fundResp) => { + fund.id = fundResp.fund.id; + const budgetToUse = budgets[idx]; + budgetToUse.fundId = fund.id; + Budgets.createViaApi(budgetToUse).then((budgetResp) => { + budgetToUse.id = budgetResp.id; + }); }); }); }); }); - }); - cy.createTempUser([ - permissions.uiFinanceCreateAllocations.gui, - permissions.uiFinanceViewEditCreateFundAndBudget.gui, - permissions.uiFinanceViewLedger.gui, - ]).then((userProperties) => { - user = userProperties; - cy.login(user.username, user.password, { - path: TopMenu.ledgerPath, - waiter: Ledgers.waitLoading, + cy.createTempUser([ + permissions.uiFinanceCreateAllocations.gui, + permissions.uiFinanceViewEditCreateFundAndBudget.gui, + permissions.uiFinanceViewLedger.gui, + ]).then((userProperties) => { + user = userProperties; + cy.login(user.username, user.password, { + path: TopMenu.ledgerPath, + waiter: Ledgers.waitLoading, + }); }); }); - }); - after('Clean up', () => { - cy.getAdminToken(); - Users.deleteViaApi(user.userId); - }); + after('Clean up', () => { + cy.getAdminToken(); + Users.deleteViaApi(user.userId); + }); - it( - 'C651420 Recalculate and save batch allocations (with status change for Funds or Budgets) on the "Batch edit funds" screen accessed from Ledger (thunderjet)', - { tags: ['criticalPath', 'thunderjet', 'C651420'] }, - () => { - Ledgers.searchByName(ledger.name); - Ledgers.selectLedger(ledger.name); - BatchEditBudget.clickBatchAllocationButton(); - BatchEditBudget.saveAndCloseBatchAllocation(); - BatchEditBudget.setFundStatus(funds[0].name, 'Inactive'); - BatchEditBudget.setBudgetStatus(funds[0].name, 'Inactive'); - BatchEditBudget.setAllocationChange(funds[1].name, '50'); - BatchEditBudget.setAllocationChange(funds[2].name, '-50'); - BatchEditBudget.setAllowableEncumbrance(funds[3].name, '75'); - BatchEditBudget.setBudgetStatus(funds[4].name, 'Active'); - BatchEditBudget.setAllocationChange(funds[4].name, '100'); - BatchEditBudget.clickRecalculateButton(); - cy.wait(4000); - BatchEditBudget.assertTotalAllocatedAfter(funds[1].name, '250.00'); - BatchEditBudget.assertTotalAllocatedAfter(funds[2].name, '250.00'); - BatchEditBudget.assertTotalAllocatedAfter(funds[4].name, '600.00'); - BatchEditBudget.clickSaveAndCloseButton(); - LedgerDetails.checkLedgerDetails({ - funds: [ - { - name: funds[0].name, - allocated: '100.00', - }, - { - name: funds[1].name, - allocated: '250.00', - }, - { - name: funds[2].name, - allocated: '250.00', - }, - { - name: funds[3].name, - allocated: '400.00', - }, - { - name: funds[4].name, - allocated: '600.00', - }, - ], - }); - LedgerDetails.openFundDetails(funds[0].name); - Funds.checkFundStatus('Inactive'); - Funds.selectBudgetDetails(); - Funds.checkBudgetStatus('Inactive'); - Funds.closeBudgetDetails(); - FinanceHelper.selectLedgersNavigation(); - Ledgers.searchByName(ledger.name); - Ledgers.selectLedger(ledger.name); - LedgerDetails.openFundDetails(funds[1].name); - Funds.checkFundStatus('Active'); - FundDetails.checkFundDetails({ - currentBudget: { name: budgets[1].name, allocated: '$250.00' }, - }); - Funds.selectBudgetDetails(); - BudgetDetails.checkBudgetDetails({ - summary: [ - { key: 'Initial allocation', value: '$200.00' }, - { key: 'Increase in allocation', value: '$50.00' }, - { key: 'Decrease in allocation', value: '$0.00' }, - { key: 'Total allocated', value: '$250.00' }, - ], - }); - Funds.checkBudgetStatus('Active'); - Funds.closeBudgetDetails(); - FinanceHelper.selectLedgersNavigation(); - Ledgers.searchByName(ledger.name); - Ledgers.selectLedger(ledger.name); - LedgerDetails.openFundDetails(funds[2].name); - Funds.checkFundStatus('Inactive'); - FundDetails.checkFundDetails({ - currentBudget: { name: budgets[2].name, allocated: '$250.00' }, - }); - Funds.selectBudgetDetails(); - BudgetDetails.checkBudgetDetails({ - summary: [ - { key: 'Initial allocation', value: '$300.00' }, - { key: 'Increase in allocation', value: '$0.00' }, - { key: 'Decrease in allocation', value: '$50.00' }, - { key: 'Total allocated', value: '$250.00' }, - { key: 'Net transfers', value: '$0.00' }, - { key: 'Total funding', value: '$250.00' }, - ], - }); - Funds.checkBudgetStatus('Active'); - Funds.closeBudgetDetails(); - FinanceHelper.selectLedgersNavigation(); - Ledgers.searchByName(ledger.name); - Ledgers.selectLedger(ledger.name); - LedgerDetails.openFundDetails(funds[3].name); - Funds.checkFundStatus('Inactive'); - FundDetails.checkFundDetails({ - currentBudget: { name: budgets[3].name, allocated: '$400.00' }, - }); - Funds.selectBudgetDetails(); - BudgetDetails.checkBudgetDetails({ - summary: [ - { key: 'Initial allocation', value: '$400.00' }, - { key: 'Total funding', value: '$400.00' }, - ], - }); - BudgetDetails.checkBudgetDetails({ - information: [ - { key: 'Name', value: budgets[3].name }, - { key: 'Status', value: 'Active' }, - { key: 'Allowable expenditure', value: '100%' }, - { key: 'Allowable encumbrance', value: '75%' }, - ], - }); - Funds.closeBudgetDetails(); - FinanceHelper.selectLedgersNavigation(); - Ledgers.searchByName(ledger.name); - Ledgers.selectLedger(ledger.name); - LedgerDetails.openFundDetails(funds[4].name); - Funds.checkFundStatus('Active'); - FundDetails.checkFundDetails({ - currentBudget: { name: budgets[4].name, allocated: '$600.00' }, - }); - Funds.selectBudgetDetails(); - BudgetDetails.checkBudgetDetails({ - summary: [ - { key: 'Initial allocation', value: '$500.00' }, - { key: 'Increase in allocation', value: '$100.00' }, - { key: 'Total funding', value: '$600.00' }, - ], - }); - Funds.checkBudgetStatus('Active'); - }, - ); + it( + 'C651420 Recalculate and save batch allocations (with status change for Funds or Budgets) on the "Batch edit funds" screen accessed from Ledger (thunderjet)', + { tags: ['criticalPath', 'thunderjet', 'C651420'] }, + () => { + Ledgers.searchByName(ledger.name); + Ledgers.selectLedger(ledger.name); + BatchEditBudget.clickBatchAllocationButton(); + BatchEditBudget.saveAndCloseBatchAllocation(); + BatchEditBudget.setFundStatus(funds[0].name, 'Inactive'); + BatchEditBudget.setBudgetStatus(funds[0].name, 'Inactive'); + BatchEditBudget.setAllocationChange(funds[1].name, '50'); + BatchEditBudget.setAllocationChange(funds[2].name, '-50'); + BatchEditBudget.setAllowableEncumbrance(funds[3].name, '75'); + BatchEditBudget.setBudgetStatus(funds[4].name, 'Active'); + BatchEditBudget.setAllocationChange(funds[4].name, '100'); + BatchEditBudget.clickRecalculateButton(); + cy.wait(4000); + BatchEditBudget.assertTotalAllocatedAfter(funds[1].name, '250.00'); + BatchEditBudget.assertTotalAllocatedAfter(funds[2].name, '250.00'); + BatchEditBudget.assertTotalAllocatedAfter(funds[4].name, '600.00'); + BatchEditBudget.clickSaveAndCloseButton(); + LedgerDetails.checkLedgerDetails({ + funds: [ + { + name: funds[0].name, + allocated: '100.00', + }, + { + name: funds[1].name, + allocated: '250.00', + }, + { + name: funds[2].name, + allocated: '250.00', + }, + { + name: funds[3].name, + allocated: '400.00', + }, + { + name: funds[4].name, + allocated: '600.00', + }, + ], + }); + LedgerDetails.openFundDetails(funds[0].name); + Funds.checkFundStatus('Inactive'); + Funds.selectBudgetDetails(); + Funds.checkBudgetStatus('Inactive'); + Funds.closeBudgetDetails(); + FinanceHelper.selectLedgersNavigation(); + Ledgers.searchByName(ledger.name); + Ledgers.selectLedger(ledger.name); + LedgerDetails.openFundDetails(funds[1].name); + Funds.checkFundStatus('Active'); + FundDetails.checkFundDetails({ + currentBudget: { name: budgets[1].name, allocated: '$250.00' }, + }); + Funds.selectBudgetDetails(); + BudgetDetails.checkBudgetDetails({ + summary: [ + { key: 'Initial allocation', value: '$200.00' }, + { key: 'Increase in allocation', value: '$50.00' }, + { key: 'Decrease in allocation', value: '$0.00' }, + { key: 'Total allocated', value: '$250.00' }, + ], + }); + Funds.checkBudgetStatus('Active'); + Funds.closeBudgetDetails(); + FinanceHelper.selectLedgersNavigation(); + Ledgers.searchByName(ledger.name); + Ledgers.selectLedger(ledger.name); + LedgerDetails.openFundDetails(funds[2].name); + Funds.checkFundStatus('Inactive'); + FundDetails.checkFundDetails({ + currentBudget: { name: budgets[2].name, allocated: '$250.00' }, + }); + Funds.selectBudgetDetails(); + BudgetDetails.checkBudgetDetails({ + summary: [ + { key: 'Initial allocation', value: '$300.00' }, + { key: 'Increase in allocation', value: '$0.00' }, + { key: 'Decrease in allocation', value: '$50.00' }, + { key: 'Total allocated', value: '$250.00' }, + { key: 'Net transfers', value: '$0.00' }, + { key: 'Total funding', value: '$250.00' }, + ], + }); + Funds.checkBudgetStatus('Active'); + Funds.closeBudgetDetails(); + FinanceHelper.selectLedgersNavigation(); + Ledgers.searchByName(ledger.name); + Ledgers.selectLedger(ledger.name); + LedgerDetails.openFundDetails(funds[3].name); + Funds.checkFundStatus('Inactive'); + FundDetails.checkFundDetails({ + currentBudget: { name: budgets[3].name, allocated: '$400.00' }, + }); + Funds.selectBudgetDetails(); + BudgetDetails.checkBudgetDetails({ + summary: [ + { key: 'Initial allocation', value: '$400.00' }, + { key: 'Total funding', value: '$400.00' }, + ], + }); + BudgetDetails.checkBudgetDetails({ + information: [ + { key: 'Name', value: budgets[3].name }, + { key: 'Status', value: 'Active' }, + { key: 'Allowable expenditure', value: '100%' }, + { key: 'Allowable encumbrance', value: '75%' }, + ], + }); + Funds.closeBudgetDetails(); + FinanceHelper.selectLedgersNavigation(); + Ledgers.searchByName(ledger.name); + Ledgers.selectLedger(ledger.name); + LedgerDetails.openFundDetails(funds[4].name); + Funds.checkFundStatus('Active'); + FundDetails.checkFundDetails({ + currentBudget: { name: budgets[4].name, allocated: '$600.00' }, + }); + Funds.selectBudgetDetails(); + BudgetDetails.checkBudgetDetails({ + summary: [ + { key: 'Initial allocation', value: '$500.00' }, + { key: 'Increase in allocation', value: '$100.00' }, + { key: 'Total funding', value: '$600.00' }, + ], + }); + Funds.checkBudgetStatus('Active'); + }, + ); + }); }); diff --git a/cypress/e2e/finance/batchAllocation/recalculate-batch-allocation-on-batch-edit-funds.cy.js b/cypress/e2e/finance/batchAllocation/recalculate-batch-allocation-on-batch-edit-funds.cy.js index d18386bbc4..d527f79cff 100644 --- a/cypress/e2e/finance/batchAllocation/recalculate-batch-allocation-on-batch-edit-funds.cy.js +++ b/cypress/e2e/finance/batchAllocation/recalculate-batch-allocation-on-batch-edit-funds.cy.js @@ -1,171 +1,179 @@ import permissions from '../../../support/dictionary/permissions'; -import TopMenu from '../../../support/fragments/topMenu'; +import Budgets from '../../../support/fragments/finance/budgets/budgets'; +import FinanceHelper from '../../../support/fragments/finance/financeHelper'; import FiscalYears from '../../../support/fragments/finance/fiscalYears/fiscalYears'; -import Ledgers from '../../../support/fragments/finance/ledgers/ledgers'; import Funds from '../../../support/fragments/finance/funds/funds'; -import Budgets from '../../../support/fragments/finance/budgets/budgets'; -import Users from '../../../support/fragments/users/users'; -import getRandomPostfix from '../../../support/utils/stringTools'; import Groups from '../../../support/fragments/finance/groups/groups'; import BatchEditBudget from '../../../support/fragments/finance/ledgers/batchEditBudget'; import LedgerDetails from '../../../support/fragments/finance/ledgers/ledgerDetails'; -import FinanceHelper from '../../../support/fragments/finance/financeHelper'; +import Ledgers from '../../../support/fragments/finance/ledgers/ledgers'; +import TopMenu from '../../../support/fragments/topMenu'; +import Users from '../../../support/fragments/users/users'; +import getRandomPostfix from '../../../support/utils/stringTools'; -describe('Finance › Batch allocation', () => { - let user; - const fiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const ledger = { ...Ledgers.defaultUiLedger }; - const funds = [ - { - ...Funds.defaultUiFund, - name: `autotest_fund_A_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_1`, - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_B_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_2`, - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_C_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_3`, - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_D_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_4`, - }, - ]; +describe('Finance', () => { + describe('Batch allocation', () => { + let user; + const fiscalYear = { ...FiscalYears.defaultUiFiscalYear }; + const ledger = { ...Ledgers.defaultUiLedger }; + const funds = [ + { + ...Funds.defaultUiFund, + name: `autotest_fund_A_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_1`, + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_B_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_2`, + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_C_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_3`, + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_D_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_4`, + }, + ]; - const groupA = { ...Groups.defaultUiGroup }; - const groupB = { - ...Groups.defaultUiGroup, - name: `autotest_group_2_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_2`, - }; + const groupA = { ...Groups.defaultUiGroup }; + const groupB = { + ...Groups.defaultUiGroup, + name: `autotest_group_2_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_2`, + }; - const budgets = [ - { ...Budgets.getDefaultBudget(), allocated: 100 }, - { ...Budgets.getDefaultBudget(), allocated: 200 }, - { ...Budgets.getDefaultBudget(), allocated: 300 }, - { ...Budgets.getDefaultBudget(), allocated: 400 }, - ]; - before('Setup data', () => { - cy.getAdminToken(); + const budgets = [ + { ...Budgets.getDefaultBudget(), allocated: 100 }, + { ...Budgets.getDefaultBudget(), allocated: 200 }, + { ...Budgets.getDefaultBudget(), allocated: 300 }, + { ...Budgets.getDefaultBudget(), allocated: 400 }, + ]; + before('Setup data', () => { + cy.getAdminToken(); - FiscalYears.createViaApi(fiscalYear).then((fy) => { - fiscalYear.id = fy.id; - ledger.fiscalYearOneId = fy.id; - budgets[0].fiscalYearId = fy.id; - budgets[1].fiscalYearId = fy.id; - budgets[2].fiscalYearId = fy.id; - budgets[3].fiscalYearId = fy.id; - Ledgers.createViaApi(ledger).then((ledgerResponse) => { - ledger.id = ledgerResponse.id; - funds[0].ledgerId = ledger.id; - funds[1].ledgerId = ledger.id; - funds[2].ledgerId = ledger.id; - funds[3].ledgerId = ledger.id; - Groups.createViaApi(groupA).then((groupAResponse) => { - groupA.id = groupAResponse.id; - Groups.createViaApi(groupB).then((groupBResponse) => { - groupB.id = groupBResponse.id; - Funds.createViaApi(funds[0], [groupA.id, groupB.id]).then((fundResponseA) => { - funds[0].id = fundResponseA.fund.id; - budgets[0].fundId = fundResponseA.fund.id; - Budgets.createViaApi(budgets[0]); - }); - Funds.createViaApi(funds[1]).then((fundResponseB) => { - funds[1].id = fundResponseB.fund.id; - budgets[1].fundId = fundResponseB.fund.id; - Budgets.createViaApi(budgets[1]); - }); - Funds.createViaApi(funds[2]).then((fundResponseC) => { - funds[2].id = fundResponseC.fund.id; - budgets[2].fundId = fundResponseC.fund.id; - Budgets.createViaApi(budgets[2]); - }); - Funds.createViaApi(funds[3]).then((fundResponseD) => { - funds[3].id = fundResponseD.fund.id; - budgets[3].fundId = fundResponseD.fund.id; - Budgets.createViaApi(budgets[3]); + FiscalYears.createViaApi(fiscalYear).then((fy) => { + fiscalYear.id = fy.id; + ledger.fiscalYearOneId = fy.id; + budgets[0].fiscalYearId = fy.id; + budgets[1].fiscalYearId = fy.id; + budgets[2].fiscalYearId = fy.id; + budgets[3].fiscalYearId = fy.id; + Ledgers.createViaApi(ledger).then((ledgerResponse) => { + ledger.id = ledgerResponse.id; + funds[0].ledgerId = ledger.id; + funds[1].ledgerId = ledger.id; + funds[2].ledgerId = ledger.id; + funds[3].ledgerId = ledger.id; + Groups.createViaApi(groupA).then((groupAResponse) => { + groupA.id = groupAResponse.id; + Groups.createViaApi(groupB).then((groupBResponse) => { + groupB.id = groupBResponse.id; + Funds.createViaApi(funds[0], [groupA.id, groupB.id]).then((fundResponseA) => { + funds[0].id = fundResponseA.fund.id; + budgets[0].fundId = fundResponseA.fund.id; + Budgets.createViaApi(budgets[0]); + }); + Funds.createViaApi(funds[1]).then((fundResponseB) => { + funds[1].id = fundResponseB.fund.id; + budgets[1].fundId = fundResponseB.fund.id; + Budgets.createViaApi(budgets[1]); + }); + Funds.createViaApi(funds[2]).then((fundResponseC) => { + funds[2].id = fundResponseC.fund.id; + budgets[2].fundId = fundResponseC.fund.id; + Budgets.createViaApi(budgets[2]); + }); + Funds.createViaApi(funds[3]).then((fundResponseD) => { + funds[3].id = fundResponseD.fund.id; + budgets[3].fundId = fundResponseD.fund.id; + Budgets.createViaApi(budgets[3]); + }); }); }); }); }); - }); - cy.createTempUser([ - permissions.uiFinanceCreateAllocations.gui, - permissions.uiFinanceViewEditCreateFundAndBudget.gui, - permissions.uiFinanceViewLedger.gui, - permissions.uiFinanceViewGroups.gui, - ]).then((userProperties) => { - user = userProperties; - cy.login(user.username, user.password, { - path: TopMenu.ledgerPath, - waiter: Ledgers.waitLoading, + cy.createTempUser([ + permissions.uiFinanceCreateAllocations.gui, + permissions.uiFinanceViewEditCreateFundAndBudget.gui, + permissions.uiFinanceViewLedger.gui, + permissions.uiFinanceViewGroups.gui, + ]).then((userProperties) => { + user = userProperties; + cy.login(user.username, user.password, { + path: TopMenu.ledgerPath, + waiter: Ledgers.waitLoading, + }); }); }); - }); - after('Clean up', () => { - cy.getAdminToken(); - Users.deleteViaApi(user.userId); - }); + after('Clean up', () => { + cy.getAdminToken(); + Users.deleteViaApi(user.userId); + }); - it( - 'C648530 Recalculate and save batch allocation on "Batch edit funds" window, accessed from Ledger (thunderjet)', - { tags: ['criticalPath', 'thunderjet', 'C648530'] }, - () => { - Ledgers.searchByName(ledger.name); - Ledgers.selectLedger(ledger.name); - BatchEditBudget.clickBatchAllocationButton(); - BatchEditBudget.saveAndCloseBatchAllocation(); - BatchEditBudget.setAllocationChange(funds[0].name, '-150'); - BatchEditBudget.clickRecalculateButton(); - BatchEditBudget.checkErrorMessageForNegativeAllocation(); - BatchEditBudget.setAllocationChange(funds[0].name, '-50'); - BatchEditBudget.clickRecalculateButton(); - cy.wait(4000); - BatchEditBudget.assertTotalAllocatedAfter(funds[0].name, '50.00'); - BatchEditBudget.cancelBatchEditBudget(); - BatchEditBudget.clickBatchAllocationButton(); - BatchEditBudget.saveAndCloseBatchAllocation(); - BatchEditBudget.setAllocationChange(funds[0].name, '50'); - BatchEditBudget.addTransactionTags(funds[0].name, ['important']); - BatchEditBudget.setAllocationChange(funds[1].name, '-50'); - BatchEditBudget.setAllowableExpenditure(funds[2].name, '50'); - BatchEditBudget.clickRecalculateButton(); - cy.wait(4000); - BatchEditBudget.assertTotalAllocatedAfter(funds[0].name, '150.00'); - BatchEditBudget.assertTotalAllocatedAfter(funds[1].name, '150.00'); - BatchEditBudget.clickSaveAndCloseButton(); - LedgerDetails.checkLedgerDetails({ - funds: [ - { - name: funds[0].name, - allocated: '150.00', - }, - { - name: funds[1].name, - allocated: '150.00', - }, - ], - }); - LedgerDetails.openFundDetails(funds[0].name); - Funds.selectBudgetDetails(); - Funds.viewTransactions(); - Funds.checkPaymentInTransactionDetails(0, fiscalYear.code, 'User', funds[0].name, '$50.00'); - Funds.assertHasTagWithInteractors('important'); - Funds.closePaneHeader(); - Funds.closeBudgetDetails(); - FinanceHelper.selectLedgersNavigation(); - Ledgers.searchByName(ledger.name); - Ledgers.selectLedger(ledger.name); - LedgerDetails.openFundDetails(funds[0].name); - Funds.viewTransactionsForCurrentBudget(); - Funds.checkPaymentInTransactionDetails(0, fiscalYear.code, 'User', funds[1].name, '($50.00)'); - }, - ); + it( + 'C648530 Recalculate and save batch allocation on "Batch edit funds" window, accessed from Ledger (thunderjet)', + { tags: ['criticalPath', 'thunderjet', 'C648530'] }, + () => { + Ledgers.searchByName(ledger.name); + Ledgers.selectLedger(ledger.name); + BatchEditBudget.clickBatchAllocationButton(); + BatchEditBudget.saveAndCloseBatchAllocation(); + BatchEditBudget.setAllocationChange(funds[0].name, '-150'); + BatchEditBudget.clickRecalculateButton(); + BatchEditBudget.checkErrorMessageForNegativeAllocation(); + BatchEditBudget.setAllocationChange(funds[0].name, '-50'); + BatchEditBudget.clickRecalculateButton(); + cy.wait(4000); + BatchEditBudget.assertTotalAllocatedAfter(funds[0].name, '50.00'); + BatchEditBudget.cancelBatchEditBudget(); + BatchEditBudget.clickBatchAllocationButton(); + BatchEditBudget.saveAndCloseBatchAllocation(); + BatchEditBudget.setAllocationChange(funds[0].name, '50'); + BatchEditBudget.addTransactionTags(funds[0].name, ['important']); + BatchEditBudget.setAllocationChange(funds[1].name, '-50'); + BatchEditBudget.setAllowableExpenditure(funds[2].name, '50'); + BatchEditBudget.clickRecalculateButton(); + cy.wait(4000); + BatchEditBudget.assertTotalAllocatedAfter(funds[0].name, '150.00'); + BatchEditBudget.assertTotalAllocatedAfter(funds[1].name, '150.00'); + BatchEditBudget.clickSaveAndCloseButton(); + LedgerDetails.checkLedgerDetails({ + funds: [ + { + name: funds[0].name, + allocated: '150.00', + }, + { + name: funds[1].name, + allocated: '150.00', + }, + ], + }); + LedgerDetails.openFundDetails(funds[0].name); + Funds.selectBudgetDetails(); + Funds.viewTransactions(); + Funds.checkPaymentInTransactionDetails(0, fiscalYear.code, 'User', funds[0].name, '$50.00'); + Funds.assertHasTagWithInteractors('important'); + Funds.closePaneHeader(); + Funds.closeBudgetDetails(); + FinanceHelper.selectLedgersNavigation(); + Ledgers.searchByName(ledger.name); + Ledgers.selectLedger(ledger.name); + LedgerDetails.openFundDetails(funds[0].name); + Funds.viewTransactionsForCurrentBudget(); + Funds.checkPaymentInTransactionDetails( + 0, + fiscalYear.code, + 'User', + funds[1].name, + '($50.00)', + ); + }, + ); + }); }); diff --git a/cypress/e2e/finance/batchAllocation/search-and-filter-batch-allocation-logs.cy.js b/cypress/e2e/finance/batchAllocation/search-and-filter-batch-allocation-logs.cy.js index 153391bc7e..34c0085996 100644 --- a/cypress/e2e/finance/batchAllocation/search-and-filter-batch-allocation-logs.cy.js +++ b/cypress/e2e/finance/batchAllocation/search-and-filter-batch-allocation-logs.cy.js @@ -10,190 +10,192 @@ import Groups from '../../../support/fragments/finance/groups/groups'; import BatchEditBudget from '../../../support/fragments/finance/ledgers/batchEditBudget'; import DateTools from '../../../support/utils/dateTools'; -describe('Finance › Batch allocation', () => { - let user; - const fiscalYear1 = { - ...FiscalYears.defaultUiFiscalYear, - code: DateTools.getRandomFiscalYearCodeFY(2000, 9999), - }; - const fiscalYear2 = { - ...FiscalYears.defaultUiFiscalYear, - name: `${FiscalYears.defaultUiFiscalYear.name}_2`, - }; - const ledgers = [ - { - ...Ledgers.defaultUiLedger, - name: `Ledger_A_${getRandomPostfix()}`, - code: `test_automation_code_1_${getRandomPostfix()}`, - }, - { - ...Ledgers.defaultUiLedger, - name: `Ledger_B_${getRandomPostfix()}`, - code: `test_automation_code_2_${getRandomPostfix()}`, - }, - ]; - const funds = [ - { - ...Funds.defaultUiFund, - name: `autotest_fund_A_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_1`, - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_B_${getRandomPostfix()}`, +describe('Finance', () => { + describe('Batch allocation', () => { + let user; + const fiscalYear1 = { + ...FiscalYears.defaultUiFiscalYear, + code: DateTools.getRandomFiscalYearCodeFY(2000, 9999), + }; + const fiscalYear2 = { + ...FiscalYears.defaultUiFiscalYear, + name: `${FiscalYears.defaultUiFiscalYear.name}_2`, + }; + const ledgers = [ + { + ...Ledgers.defaultUiLedger, + name: `Ledger_A_${getRandomPostfix()}`, + code: `test_automation_code_1_${getRandomPostfix()}`, + }, + { + ...Ledgers.defaultUiLedger, + name: `Ledger_B_${getRandomPostfix()}`, + code: `test_automation_code_2_${getRandomPostfix()}`, + }, + ]; + const funds = [ + { + ...Funds.defaultUiFund, + name: `autotest_fund_A_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_1`, + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_B_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_2`, + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_C_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_3`, + }, + ]; + const budgets = [ + { ...Budgets.getDefaultBudget(), allocated: 100 }, + { ...Budgets.getDefaultBudget(), allocated: 200 }, + { ...Budgets.getDefaultBudget(), allocated: 300 }, + ]; + const groupA = { ...Groups.defaultUiGroup }; + const groupB = { + ...Groups.defaultUiGroup, + name: `autotest_group_2_${getRandomPostfix()}`, code: `${getRandomPostfix()}_2`, - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_C_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_3`, - }, - ]; - const budgets = [ - { ...Budgets.getDefaultBudget(), allocated: 100 }, - { ...Budgets.getDefaultBudget(), allocated: 200 }, - { ...Budgets.getDefaultBudget(), allocated: 300 }, - ]; - const groupA = { ...Groups.defaultUiGroup }; - const groupB = { - ...Groups.defaultUiGroup, - name: `autotest_group_2_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_2`, - }; - const today = DateTools.getFormattedDate({ date: new Date() }, 'MM/DD/YYYY'); - let logId; + }; + const today = DateTools.getFormattedDate({ date: new Date() }, 'MM/DD/YYYY'); + let logId; - before('Create test data', () => { - cy.loginAsAdmin({ - path: TopMenu.ledgerPath, - waiter: Ledgers.waitLoading, - }); + before('Create test data', () => { + cy.loginAsAdmin({ + path: TopMenu.ledgerPath, + waiter: Ledgers.waitLoading, + }); - FiscalYears.createViaApi(fiscalYear1).then((fiscalYearOneResponse) => { - fiscalYear1.id = fiscalYearOneResponse.id; - ledgers[0].fiscalYearOneId = fiscalYear1.id; - budgets[0].fiscalYearId = fiscalYearOneResponse.id; - fiscalYear2.code = 'PO' + fiscalYear1.code.slice(2); - FiscalYears.createViaApi(fiscalYear2).then((fiscalYearTwoResponse) => { - fiscalYear2.id = fiscalYearTwoResponse.id; - ledgers[1].fiscalYearOneId = fiscalYear2.id; - budgets[1].fiscalYearId = fiscalYearTwoResponse.id; - budgets[2].fiscalYearId = fiscalYearTwoResponse.id; - Ledgers.createViaApi(ledgers[0]).then((ledgerOneResponse) => { - ledgers[0].id = ledgerOneResponse.id; - funds[0].ledgerId = ledgerOneResponse.id; - Ledgers.createViaApi(ledgers[1]).then((ledgerTwoResponse) => { - ledgers[1].id = ledgerTwoResponse.id; - funds[1].ledgerId = ledgerTwoResponse.id; - funds[2].ledgerId = ledgerTwoResponse.id; - Groups.createViaApi(groupA).then((groupAResponse) => { - groupA.id = groupAResponse.id; - Groups.createViaApi(groupB).then((groupBResponse) => { - groupB.id = groupBResponse.id; - Funds.createViaApi(funds[0], [groupAResponse.id]).then((fundOneResponse) => { - funds[0].id = fundOneResponse.fund.id; - budgets[0].fundId = fundOneResponse.fund.id; - Budgets.createViaApi(budgets[0]); - }); - Funds.createViaApi(funds[1], [groupBResponse.id]).then((fundTwoResponse) => { - funds[1].id = fundTwoResponse.fund.id; - budgets[1].fundId = fundTwoResponse.fund.id; - Budgets.createViaApi(budgets[1]); - }); - Funds.createViaApi(funds[2]).then((fundThreeResponse) => { - funds[2].id = fundThreeResponse.fund.id; - budgets[2].fundId = fundThreeResponse.fund.id; - Budgets.createViaApi(budgets[2]); + FiscalYears.createViaApi(fiscalYear1).then((fiscalYearOneResponse) => { + fiscalYear1.id = fiscalYearOneResponse.id; + ledgers[0].fiscalYearOneId = fiscalYear1.id; + budgets[0].fiscalYearId = fiscalYearOneResponse.id; + fiscalYear2.code = 'PO' + fiscalYear1.code.slice(2); + FiscalYears.createViaApi(fiscalYear2).then((fiscalYearTwoResponse) => { + fiscalYear2.id = fiscalYearTwoResponse.id; + ledgers[1].fiscalYearOneId = fiscalYear2.id; + budgets[1].fiscalYearId = fiscalYearTwoResponse.id; + budgets[2].fiscalYearId = fiscalYearTwoResponse.id; + Ledgers.createViaApi(ledgers[0]).then((ledgerOneResponse) => { + ledgers[0].id = ledgerOneResponse.id; + funds[0].ledgerId = ledgerOneResponse.id; + Ledgers.createViaApi(ledgers[1]).then((ledgerTwoResponse) => { + ledgers[1].id = ledgerTwoResponse.id; + funds[1].ledgerId = ledgerTwoResponse.id; + funds[2].ledgerId = ledgerTwoResponse.id; + Groups.createViaApi(groupA).then((groupAResponse) => { + groupA.id = groupAResponse.id; + Groups.createViaApi(groupB).then((groupBResponse) => { + groupB.id = groupBResponse.id; + Funds.createViaApi(funds[0], [groupAResponse.id]).then((fundOneResponse) => { + funds[0].id = fundOneResponse.fund.id; + budgets[0].fundId = fundOneResponse.fund.id; + Budgets.createViaApi(budgets[0]); + }); + Funds.createViaApi(funds[1], [groupBResponse.id]).then((fundTwoResponse) => { + funds[1].id = fundTwoResponse.fund.id; + budgets[1].fundId = fundTwoResponse.fund.id; + Budgets.createViaApi(budgets[1]); + }); + Funds.createViaApi(funds[2]).then((fundThreeResponse) => { + funds[2].id = fundThreeResponse.fund.id; + budgets[2].fundId = fundThreeResponse.fund.id; + Budgets.createViaApi(budgets[2]); + }); }); }); }); }); }); }); - }); - Ledgers.searchByName(ledgers[0].name); - Ledgers.selectLedger(ledgers[0].name); - BatchEditBudget.clickBatchAllocationButton(); - BatchEditBudget.saveAndCloseBatchAllocation(); - BatchEditBudget.setAllocationChange(funds[0].name, '100'); - BatchEditBudget.clickRecalculateButton(); - cy.wait(1000); - BatchEditBudget.assertTotalAllocatedAfter(funds[0].name, '200.00'); - BatchEditBudget.clickSaveAndCloseButton(); - cy.wait(4000); + Ledgers.searchByName(ledgers[0].name); + Ledgers.selectLedger(ledgers[0].name); + BatchEditBudget.clickBatchAllocationButton(); + BatchEditBudget.saveAndCloseBatchAllocation(); + BatchEditBudget.setAllocationChange(funds[0].name, '100'); + BatchEditBudget.clickRecalculateButton(); + cy.wait(1000); + BatchEditBudget.assertTotalAllocatedAfter(funds[0].name, '200.00'); + BatchEditBudget.clickSaveAndCloseButton(); + cy.wait(4000); - cy.createTempUser([ - permissions.uiFinanceViewFiscalYear.gui, - permissions.uiFinanceViewLedger.gui, - permissions.uiFinanceViewGroups.gui, - permissions.uiUsersView.gui, - permissions.uiFinanceCreateAllocations.gui, - permissions.uiFinanceViewEditCreateFundAndBudget.gui, - permissions.uiFinanceFundUpdateLogsView.gui, - ]).then((userProperties) => { - user = userProperties; - cy.login(user.username, user.password, { - path: TopMenu.ledgerPath, - waiter: Ledgers.waitLoading, + cy.createTempUser([ + permissions.uiFinanceViewFiscalYear.gui, + permissions.uiFinanceViewLedger.gui, + permissions.uiFinanceViewGroups.gui, + permissions.uiUsersView.gui, + permissions.uiFinanceCreateAllocations.gui, + permissions.uiFinanceViewEditCreateFundAndBudget.gui, + permissions.uiFinanceFundUpdateLogsView.gui, + ]).then((userProperties) => { + user = userProperties; + cy.login(user.username, user.password, { + path: TopMenu.ledgerPath, + waiter: Ledgers.waitLoading, + }); }); + Ledgers.searchByName(ledgers[1].name); + Ledgers.selectLedger(ledgers[1].name); + BatchEditBudget.clickBatchAllocationButton(); + BatchEditBudget.saveAndCloseBatchAllocation(); + BatchEditBudget.setAllocationChange(funds[1].name, '100'); + BatchEditBudget.setAllocationChange(funds[2].name, '100'); + BatchEditBudget.clickRecalculateButton(); + cy.wait(1000); + BatchEditBudget.assertTotalAllocatedAfter(funds[1].name, '300.00'); + BatchEditBudget.assertTotalAllocatedAfter(funds[2].name, '400.00'); + BatchEditBudget.clickSaveAndCloseButton(); + cy.wait(4000); + Ledgers.closeOpenedPage(); }); - Ledgers.searchByName(ledgers[1].name); - Ledgers.selectLedger(ledgers[1].name); - BatchEditBudget.clickBatchAllocationButton(); - BatchEditBudget.saveAndCloseBatchAllocation(); - BatchEditBudget.setAllocationChange(funds[1].name, '100'); - BatchEditBudget.setAllocationChange(funds[2].name, '100'); - BatchEditBudget.clickRecalculateButton(); - cy.wait(1000); - BatchEditBudget.assertTotalAllocatedAfter(funds[1].name, '300.00'); - BatchEditBudget.assertTotalAllocatedAfter(funds[2].name, '400.00'); - BatchEditBudget.clickSaveAndCloseButton(); - cy.wait(4000); - Ledgers.closeOpenedPage(); - }); - after('Clean up', () => { - cy.getAdminToken(); - Users.deleteViaApi(user.userId); - }); + after('Clean up', () => { + cy.getAdminToken(); + Users.deleteViaApi(user.userId); + }); - it( - 'C692072 Search and filter pane on Batch allocation logs screen (thunderjet)', - { tags: ['criticalPath', 'thunderjet', 'C692072'] }, - () => { - BatchEditBudget.openBatchAllocationLogsFromLedgerList(); - BatchEditBudget.filterLogsByFiscalYear(fiscalYear1.code); - BatchEditBudget.verifyLogExists(fiscalYear1.code, ledgers[0].code); - BatchEditBudget.filterLogsByFiscalYear(fiscalYear2.code); - BatchEditBudget.verifyLogExists(fiscalYear2.code, ledgers[1].code); - BatchEditBudget.getLogsId().then((idValue) => { - logId = idValue; - BatchEditBudget.collapseSearchPane(); - BatchEditBudget.openSearchPane(); - BatchEditBudget.resetFiltersIfActive(); - BatchEditBudget.filterByDate(today, today); - BatchEditBudget.verifyLogExists(fiscalYear2.code, ledgers[1].code); - BatchEditBudget.resetFiltersIfActive(); - BatchEditBudget.filterLogsByLedger(ledgers[0].name); + it( + 'C692072 Search and filter pane on Batch allocation logs screen (thunderjet)', + { tags: ['criticalPath', 'thunderjet', 'C692072'] }, + () => { + BatchEditBudget.openBatchAllocationLogsFromLedgerList(); + BatchEditBudget.filterLogsByFiscalYear(fiscalYear1.code); BatchEditBudget.verifyLogExists(fiscalYear1.code, ledgers[0].code); - BatchEditBudget.filterLogsByGroup(groupA.name); - BatchEditBudget.verifyLogExists(fiscalYear1.code, ledgers[0].code); - BatchEditBudget.resetFiltersIfActive(); - BatchEditBudget.filterLogsByLedger(ledgers[1].name); - BatchEditBudget.verifyLogExists(fiscalYear2.code, ledgers[1].code); - BatchEditBudget.filterLogsByGroup(groupB.name); + BatchEditBudget.filterLogsByFiscalYear(fiscalYear2.code); BatchEditBudget.verifyLogExists(fiscalYear2.code, ledgers[1].code); - BatchEditBudget.resetFiltersIfActive(); - BatchEditBudget.filterLogsByUser(user.username); - BatchEditBudget.verifyLogExists(fiscalYear2.code, ledgers[1].code); - BatchEditBudget.resetFiltersIfActive(); - BatchEditBudget.searchLogs(fiscalYear2.code, ledgers[1].code); - BatchEditBudget.resetFiltersIfActive(); - BatchEditBudget.searchByParameters('ID', String(logId)); - BatchEditBudget.verifyLogExists(fiscalYear2.code, ledgers[1].code); - BatchEditBudget.searchByParameters('ID', '10000'); - BatchEditBudget.verifyNoResultsMessage('10000'); - }); - }, - ); + BatchEditBudget.getLogsId().then((idValue) => { + logId = idValue; + BatchEditBudget.collapseSearchPane(); + BatchEditBudget.openSearchPane(); + BatchEditBudget.resetFiltersIfActive(); + BatchEditBudget.filterByDate(today, today); + BatchEditBudget.verifyLogExists(fiscalYear2.code, ledgers[1].code); + BatchEditBudget.resetFiltersIfActive(); + BatchEditBudget.filterLogsByLedger(ledgers[0].name); + BatchEditBudget.verifyLogExists(fiscalYear1.code, ledgers[0].code); + BatchEditBudget.filterLogsByGroup(groupA.name); + BatchEditBudget.verifyLogExists(fiscalYear1.code, ledgers[0].code); + BatchEditBudget.resetFiltersIfActive(); + BatchEditBudget.filterLogsByLedger(ledgers[1].name); + BatchEditBudget.verifyLogExists(fiscalYear2.code, ledgers[1].code); + BatchEditBudget.filterLogsByGroup(groupB.name); + BatchEditBudget.verifyLogExists(fiscalYear2.code, ledgers[1].code); + BatchEditBudget.resetFiltersIfActive(); + BatchEditBudget.filterLogsByUser(user.username); + BatchEditBudget.verifyLogExists(fiscalYear2.code, ledgers[1].code); + BatchEditBudget.resetFiltersIfActive(); + BatchEditBudget.searchLogs(fiscalYear2.code, ledgers[1].code); + BatchEditBudget.resetFiltersIfActive(); + BatchEditBudget.searchByParameters('ID', String(logId)); + BatchEditBudget.verifyLogExists(fiscalYear2.code, ledgers[1].code); + BatchEditBudget.searchByParameters('ID', '10000'); + BatchEditBudget.verifyNoResultsMessage('10000'); + }); + }, + ); + }); }); diff --git a/cypress/e2e/finance/batchAllocation/user-can-delete-batch-allocation-logs.cy.js b/cypress/e2e/finance/batchAllocation/user-can-delete-batch-allocation-logs.cy.js index 9fcf38b4b7..112456f691 100644 --- a/cypress/e2e/finance/batchAllocation/user-can-delete-batch-allocation-logs.cy.js +++ b/cypress/e2e/finance/batchAllocation/user-can-delete-batch-allocation-logs.cy.js @@ -1,131 +1,133 @@ import permissions from '../../../support/dictionary/permissions'; -import TopMenu from '../../../support/fragments/topMenu'; -import Ledgers from '../../../support/fragments/finance/ledgers/ledgers'; -import Users from '../../../support/fragments/users/users'; -import getRandomPostfix from '../../../support/utils/stringTools'; +import Budgets from '../../../support/fragments/finance/budgets/budgets'; import FiscalYears from '../../../support/fragments/finance/fiscalYears/fiscalYears'; import Funds from '../../../support/fragments/finance/funds/funds'; -import Budgets from '../../../support/fragments/finance/budgets/budgets'; import BatchEditBudget from '../../../support/fragments/finance/ledgers/batchEditBudget'; +import Ledgers from '../../../support/fragments/finance/ledgers/ledgers'; +import TopMenu from '../../../support/fragments/topMenu'; +import Users from '../../../support/fragments/users/users'; import InteractorsTools from '../../../support/utils/interactorsTools'; +import getRandomPostfix from '../../../support/utils/stringTools'; -describe('Finance › Batch allocation', () => { - let user; - const fiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const ledgers = [ - { - ...Ledgers.defaultUiLedger, - name: `Ledger_A_${getRandomPostfix()}`, - code: `test_automation_code_1_${getRandomPostfix()}`, - }, - { - ...Ledgers.defaultUiLedger, - name: `Ledger_B_${getRandomPostfix()}`, - code: `test_automation_code_2_${getRandomPostfix()}`, - }, - { - ...Ledgers.defaultUiLedger, - name: `Ledger_C_${getRandomPostfix()}`, - code: `test_automation_code_3_${getRandomPostfix()}`, - }, - { - ...Ledgers.defaultUiLedger, - name: `Ledger_D_${getRandomPostfix()}`, - code: `test_automation_code_4_${getRandomPostfix()}`, - }, - ]; - - const funds = [ - { - ...Funds.defaultUiFund, - name: `autotest_fund_A_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_1`, - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_B_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_2`, - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_C_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_3`, - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_D_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_4`, - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_E_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_5`, - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_F_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_6`, - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_G_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_7`, - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_J_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_8`, - }, - ]; +describe('Finance', () => { + describe('Batch allocation', () => { + let user; + const fiscalYear = { ...FiscalYears.defaultUiFiscalYear }; + const ledgers = [ + { + ...Ledgers.defaultUiLedger, + name: `Ledger_A_${getRandomPostfix()}`, + code: `test_automation_code_1_${getRandomPostfix()}`, + }, + { + ...Ledgers.defaultUiLedger, + name: `Ledger_B_${getRandomPostfix()}`, + code: `test_automation_code_2_${getRandomPostfix()}`, + }, + { + ...Ledgers.defaultUiLedger, + name: `Ledger_C_${getRandomPostfix()}`, + code: `test_automation_code_3_${getRandomPostfix()}`, + }, + { + ...Ledgers.defaultUiLedger, + name: `Ledger_D_${getRandomPostfix()}`, + code: `test_automation_code_4_${getRandomPostfix()}`, + }, + ]; - const budgets = [ - { ...Budgets.getDefaultBudget(), allocated: 50 }, - { ...Budgets.getDefaultBudget(), allocated: 100 }, - { ...Budgets.getDefaultBudget(), allocated: 150 }, - { ...Budgets.getDefaultBudget(), allocated: 200 }, - { ...Budgets.getDefaultBudget(), allocated: 250 }, - { ...Budgets.getDefaultBudget(), allocated: 300 }, - { ...Budgets.getDefaultBudget(), allocated: 350 }, - { ...Budgets.getDefaultBudget(), allocated: 400 }, - ]; + const funds = [ + { + ...Funds.defaultUiFund, + name: `autotest_fund_A_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_1`, + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_B_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_2`, + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_C_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_3`, + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_D_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_4`, + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_E_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_5`, + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_F_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_6`, + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_G_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_7`, + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_J_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_8`, + }, + ]; - before('Create test data', () => { - cy.loginAsAdmin({ - path: TopMenu.ledgerPath, - waiter: Ledgers.waitLoading, - }); + const budgets = [ + { ...Budgets.getDefaultBudget(), allocated: 50 }, + { ...Budgets.getDefaultBudget(), allocated: 100 }, + { ...Budgets.getDefaultBudget(), allocated: 150 }, + { ...Budgets.getDefaultBudget(), allocated: 200 }, + { ...Budgets.getDefaultBudget(), allocated: 250 }, + { ...Budgets.getDefaultBudget(), allocated: 300 }, + { ...Budgets.getDefaultBudget(), allocated: 350 }, + { ...Budgets.getDefaultBudget(), allocated: 400 }, + ]; - FiscalYears.createViaApi(fiscalYear).then((fy) => { - fiscalYear.id = fy.id; - ledgers.forEach((ledger) => { - ledger.fiscalYearOneId = fy.id; - }); - budgets.forEach((b) => { - b.fiscalYearId = fy.id; + before('Create test data', () => { + cy.loginAsAdmin({ + path: TopMenu.ledgerPath, + waiter: Ledgers.waitLoading, }); - Ledgers.createViaApi(ledgers[0]).then((ledger1Response) => { - ledgers[0].id = ledger1Response.id; - funds[0].ledgerId = ledger1Response.id; - funds[1].ledgerId = ledger1Response.id; - Ledgers.createViaApi(ledgers[1]).then((ledger2Response) => { - ledgers[1].id = ledger2Response.id; - funds[2].ledgerId = ledger2Response.id; - funds[3].ledgerId = ledger2Response.id; - Ledgers.createViaApi(ledgers[2]).then((ledger3Response) => { - ledgers[2].id = ledger2Response.id; - funds[4].ledgerId = ledger3Response.id; - funds[5].ledgerId = ledger3Response.id; - Ledgers.createViaApi(ledgers[3]).then((ledger4Response) => { - ledgers[3].id = ledger2Response.id; - funds[6].ledgerId = ledger4Response.id; - funds[7].ledgerId = ledger4Response.id; - funds.forEach((fund, idx) => { - Funds.createViaApi(fund).then((fundResp) => { - fund.id = fundResp.fund.id; - const budgetToUse = budgets[idx]; - budgetToUse.fundId = fund.id; - Budgets.createViaApi(budgetToUse).then((budgetResp) => { - budgetToUse.id = budgetResp.id; + + FiscalYears.createViaApi(fiscalYear).then((fy) => { + fiscalYear.id = fy.id; + ledgers.forEach((ledger) => { + ledger.fiscalYearOneId = fy.id; + }); + budgets.forEach((b) => { + b.fiscalYearId = fy.id; + }); + Ledgers.createViaApi(ledgers[0]).then((ledger1Response) => { + ledgers[0].id = ledger1Response.id; + funds[0].ledgerId = ledger1Response.id; + funds[1].ledgerId = ledger1Response.id; + Ledgers.createViaApi(ledgers[1]).then((ledger2Response) => { + ledgers[1].id = ledger2Response.id; + funds[2].ledgerId = ledger2Response.id; + funds[3].ledgerId = ledger2Response.id; + Ledgers.createViaApi(ledgers[2]).then((ledger3Response) => { + ledgers[2].id = ledger2Response.id; + funds[4].ledgerId = ledger3Response.id; + funds[5].ledgerId = ledger3Response.id; + Ledgers.createViaApi(ledgers[3]).then((ledger4Response) => { + ledgers[3].id = ledger2Response.id; + funds[6].ledgerId = ledger4Response.id; + funds[7].ledgerId = ledger4Response.id; + funds.forEach((fund, idx) => { + Funds.createViaApi(fund).then((fundResp) => { + fund.id = fundResp.fund.id; + const budgetToUse = budgets[idx]; + budgetToUse.fundId = fund.id; + Budgets.createViaApi(budgetToUse).then((budgetResp) => { + budgetToUse.id = budgetResp.id; + }); }); }); }); @@ -133,115 +135,115 @@ describe('Finance › Batch allocation', () => { }); }); }); - }); - Ledgers.searchByName(ledgers[0].name); - Ledgers.selectLedger(ledgers[0].name); - BatchEditBudget.clickBatchAllocationButton(); - BatchEditBudget.saveAndCloseBatchAllocation(); - BatchEditBudget.setAllocationChange(funds[0].name, '100'); - BatchEditBudget.setAllocationChange(funds[1].name, '100'); - BatchEditBudget.clickRecalculateButton(); - cy.wait(1000); - BatchEditBudget.assertTotalAllocatedAfter(funds[0].name, '150.00'); - BatchEditBudget.assertTotalAllocatedAfter(funds[1].name, '200.00'); - BatchEditBudget.clickSaveAndCloseButton(); - cy.wait(4000); - Ledgers.searchByName(ledgers[1].name); - Ledgers.selectLedger(ledgers[1].name); - BatchEditBudget.clickBatchAllocationButton(); - BatchEditBudget.saveAndCloseBatchAllocation(); - BatchEditBudget.setAllocationChange(funds[2].name, '100'); - BatchEditBudget.setAllocationChange(funds[3].name, '100'); - BatchEditBudget.clickRecalculateButton(); - cy.wait(1000); - BatchEditBudget.assertTotalAllocatedAfter(funds[2].name, '250.00'); - BatchEditBudget.assertTotalAllocatedAfter(funds[3].name, '300.00'); - BatchEditBudget.clickSaveAndCloseButton(); - cy.wait(4000); - Ledgers.searchByName(ledgers[2].name); - Ledgers.selectLedger(ledgers[2].name); - BatchEditBudget.clickBatchAllocationButton(); - BatchEditBudget.saveAndCloseBatchAllocation(); - BatchEditBudget.setAllocationChange(funds[4].name, '100'); - BatchEditBudget.setAllocationChange(funds[5].name, '100'); - BatchEditBudget.clickRecalculateButton(); - cy.wait(1000); - BatchEditBudget.assertTotalAllocatedAfter(funds[4].name, '350.00'); - BatchEditBudget.assertTotalAllocatedAfter(funds[5].name, '400.00'); - BatchEditBudget.clickSaveAndCloseButton(); - cy.wait(4000); - Ledgers.searchByName(ledgers[3].name); - Ledgers.selectLedger(ledgers[3].name); - BatchEditBudget.clickBatchAllocationButton(); - BatchEditBudget.saveAndCloseBatchAllocation(); - BatchEditBudget.setAllocationChange(funds[6].name, '100'); - BatchEditBudget.setAllocationChange(funds[7].name, '100'); - BatchEditBudget.clickRecalculateButton(); - cy.wait(1000); - BatchEditBudget.assertTotalAllocatedAfter(funds[6].name, '450.00'); - BatchEditBudget.assertTotalAllocatedAfter(funds[7].name, '500.00'); - BatchEditBudget.clickSaveAndCloseButton(); - cy.wait(4000); + Ledgers.searchByName(ledgers[0].name); + Ledgers.selectLedger(ledgers[0].name); + BatchEditBudget.clickBatchAllocationButton(); + BatchEditBudget.saveAndCloseBatchAllocation(); + BatchEditBudget.setAllocationChange(funds[0].name, '100'); + BatchEditBudget.setAllocationChange(funds[1].name, '100'); + BatchEditBudget.clickRecalculateButton(); + cy.wait(1000); + BatchEditBudget.assertTotalAllocatedAfter(funds[0].name, '150.00'); + BatchEditBudget.assertTotalAllocatedAfter(funds[1].name, '200.00'); + BatchEditBudget.clickSaveAndCloseButton(); + cy.wait(4000); + Ledgers.searchByName(ledgers[1].name); + Ledgers.selectLedger(ledgers[1].name); + BatchEditBudget.clickBatchAllocationButton(); + BatchEditBudget.saveAndCloseBatchAllocation(); + BatchEditBudget.setAllocationChange(funds[2].name, '100'); + BatchEditBudget.setAllocationChange(funds[3].name, '100'); + BatchEditBudget.clickRecalculateButton(); + cy.wait(1000); + BatchEditBudget.assertTotalAllocatedAfter(funds[2].name, '250.00'); + BatchEditBudget.assertTotalAllocatedAfter(funds[3].name, '300.00'); + BatchEditBudget.clickSaveAndCloseButton(); + cy.wait(4000); + Ledgers.searchByName(ledgers[2].name); + Ledgers.selectLedger(ledgers[2].name); + BatchEditBudget.clickBatchAllocationButton(); + BatchEditBudget.saveAndCloseBatchAllocation(); + BatchEditBudget.setAllocationChange(funds[4].name, '100'); + BatchEditBudget.setAllocationChange(funds[5].name, '100'); + BatchEditBudget.clickRecalculateButton(); + cy.wait(1000); + BatchEditBudget.assertTotalAllocatedAfter(funds[4].name, '350.00'); + BatchEditBudget.assertTotalAllocatedAfter(funds[5].name, '400.00'); + BatchEditBudget.clickSaveAndCloseButton(); + cy.wait(4000); + Ledgers.searchByName(ledgers[3].name); + Ledgers.selectLedger(ledgers[3].name); + BatchEditBudget.clickBatchAllocationButton(); + BatchEditBudget.saveAndCloseBatchAllocation(); + BatchEditBudget.setAllocationChange(funds[6].name, '100'); + BatchEditBudget.setAllocationChange(funds[7].name, '100'); + BatchEditBudget.clickRecalculateButton(); + cy.wait(1000); + BatchEditBudget.assertTotalAllocatedAfter(funds[6].name, '450.00'); + BatchEditBudget.assertTotalAllocatedAfter(funds[7].name, '500.00'); + BatchEditBudget.clickSaveAndCloseButton(); + cy.wait(4000); - cy.createTempUser([ - permissions.uiFinanceViewLedger.gui, - permissions.uiFinanceFundUpdateLogsView.gui, - permissions.uiFinanceFundUpdateLogsDelete.gui, - ]).then((userProperties) => { - user = userProperties; - cy.login(user.username, user.password, { - path: TopMenu.ledgerPath, - waiter: Ledgers.waitLoading, + cy.createTempUser([ + permissions.uiFinanceViewLedger.gui, + permissions.uiFinanceFundUpdateLogsView.gui, + permissions.uiFinanceFundUpdateLogsDelete.gui, + ]).then((userProperties) => { + user = userProperties; + cy.login(user.username, user.password, { + path: TopMenu.ledgerPath, + waiter: Ledgers.waitLoading, + }); }); }); - }); - after('Clean up', () => { - cy.getAdminToken(); - Users.deleteViaApi(user.userId); - }); + after('Clean up', () => { + cy.getAdminToken(); + Users.deleteViaApi(user.userId); + }); - it( - 'C651498 User can delete Batch allocation logs (thunderjet)', - { tags: ['criticalPath', 'thunderjet', 'C651498'] }, - () => { - BatchEditBudget.openBatchAllocationLogsFromLedgerList(); - BatchEditBudget.clickActionsButton(); - BatchEditBudget.assertDeleteLogsOptionDisabled(); - cy.wait(1000); - BatchEditBudget.selectLogWithNamePart(fiscalYear.code, ledgers[0].code); - BatchEditBudget.clickActionsButton(); - BatchEditBudget.clickDeleteAllocationLogs(); - BatchEditBudget.cancelBatchEditBudget(); - BatchEditBudget.clickActionsButton(); - BatchEditBudget.clickDeleteAllocationLogs(); - BatchEditBudget.clickConfirmButton(); - InteractorsTools.checkCalloutMessage('Log(s) successfully deleted'); - BatchEditBudget.searchLogs(fiscalYear.code, ledgers[0].code); - BatchEditBudget.verifyNoResultsMessage(`${fiscalYear.code}-${ledgers[0].code}`); - BatchEditBudget.resetFiltersIfActive(); - BatchEditBudget.selectLogWithNamePart(fiscalYear.code, ledgers[1].code); - BatchEditBudget.selectLogWithNamePart(fiscalYear.code, ledgers[2].code); - BatchEditBudget.clickActionsButton(); - BatchEditBudget.clickDeleteAllocationLogs(); - BatchEditBudget.clickConfirmButton(); - InteractorsTools.checkCalloutMessage('Log(s) successfully deleted'); - BatchEditBudget.searchLogs(fiscalYear.code, ledgers[1].code); - BatchEditBudget.verifyNoResultsMessage(`${fiscalYear.code}-${ledgers[1].code}`); - BatchEditBudget.resetFiltersIfActive(); - BatchEditBudget.searchLogs(fiscalYear.code, ledgers[2].code); - BatchEditBudget.verifyNoResultsMessage(`${fiscalYear.code}-${ledgers[2].code}`); - BatchEditBudget.resetFiltersIfActive(); - BatchEditBudget.clickLogForLedger(fiscalYear.code, ledgers[3].code); - BatchEditBudget.clickActionsButton(); - BatchEditBudget.clickDeleteButton(); - BatchEditBudget.cancelBatchEditBudget(); - BatchEditBudget.clickActionsButton(); - BatchEditBudget.clickDeleteButton(); - BatchEditBudget.clickDeleteButton(); - InteractorsTools.checkCalloutMessage('Log(s) successfully deleted'); - BatchEditBudget.searchLogs(fiscalYear.code, ledgers[3].code); - BatchEditBudget.verifyNoResultsMessage(`${fiscalYear.code}-${ledgers[3].code}`); - }, - ); + it( + 'C651498 User can delete Batch allocation logs (thunderjet)', + { tags: ['criticalPath', 'thunderjet', 'C651498'] }, + () => { + BatchEditBudget.openBatchAllocationLogsFromLedgerList(); + BatchEditBudget.clickActionsButton(); + BatchEditBudget.assertDeleteLogsOptionDisabled(); + cy.wait(1000); + BatchEditBudget.selectLogWithNamePart(fiscalYear.code, ledgers[0].code); + BatchEditBudget.clickActionsButton(); + BatchEditBudget.clickDeleteAllocationLogs(); + BatchEditBudget.cancelBatchEditBudget(); + BatchEditBudget.clickActionsButton(); + BatchEditBudget.clickDeleteAllocationLogs(); + BatchEditBudget.clickConfirmButton(); + InteractorsTools.checkCalloutMessage('Log(s) successfully deleted'); + BatchEditBudget.searchLogs(fiscalYear.code, ledgers[0].code); + BatchEditBudget.verifyNoResultsMessage(`${fiscalYear.code}-${ledgers[0].code}`); + BatchEditBudget.resetFiltersIfActive(); + BatchEditBudget.selectLogWithNamePart(fiscalYear.code, ledgers[1].code); + BatchEditBudget.selectLogWithNamePart(fiscalYear.code, ledgers[2].code); + BatchEditBudget.clickActionsButton(); + BatchEditBudget.clickDeleteAllocationLogs(); + BatchEditBudget.clickConfirmButton(); + InteractorsTools.checkCalloutMessage('Log(s) successfully deleted'); + BatchEditBudget.searchLogs(fiscalYear.code, ledgers[1].code); + BatchEditBudget.verifyNoResultsMessage(`${fiscalYear.code}-${ledgers[1].code}`); + BatchEditBudget.resetFiltersIfActive(); + BatchEditBudget.searchLogs(fiscalYear.code, ledgers[2].code); + BatchEditBudget.verifyNoResultsMessage(`${fiscalYear.code}-${ledgers[2].code}`); + BatchEditBudget.resetFiltersIfActive(); + BatchEditBudget.clickLogForLedger(fiscalYear.code, ledgers[3].code); + BatchEditBudget.clickActionsButton(); + BatchEditBudget.clickDeleteButton(); + BatchEditBudget.cancelBatchEditBudget(); + BatchEditBudget.clickActionsButton(); + BatchEditBudget.clickDeleteButton(); + BatchEditBudget.clickDeleteButton(); + InteractorsTools.checkCalloutMessage('Log(s) successfully deleted'); + BatchEditBudget.searchLogs(fiscalYear.code, ledgers[3].code); + BatchEditBudget.verifyNoResultsMessage(`${fiscalYear.code}-${ledgers[3].code}`); + }, + ); + }); }); diff --git a/cypress/e2e/finance/batchAllocation/user-not-assigned-to-acq-unit-cannot-see-logs.cy.js b/cypress/e2e/finance/batchAllocation/user-not-assigned-to-acq-unit-cannot-see-logs.cy.js index 50ffd8bc91..081d5281a2 100644 --- a/cypress/e2e/finance/batchAllocation/user-not-assigned-to-acq-unit-cannot-see-logs.cy.js +++ b/cypress/e2e/finance/batchAllocation/user-not-assigned-to-acq-unit-cannot-see-logs.cy.js @@ -10,132 +10,134 @@ import Budgets from '../../../support/fragments/finance/budgets/budgets'; import Groups from '../../../support/fragments/finance/groups/groups'; import BatchEditBudget from '../../../support/fragments/finance/ledgers/batchEditBudget'; -describe('Finance › Batch allocation', () => { - let user; - const fiscalYear = { ...FiscalYears.defaultUiFiscalYear }; - const acqUnit = AcquisitionUnits.getDefaultAcquisitionUnit({ protectRead: true }); - let membershipAdminId; - const ledgers = [ - { - ...Ledgers.defaultUiLedger, - name: `Ledger_A_${getRandomPostfix()}`, - code: `test_automation_code_1_${getRandomPostfix()}`, - acqUnitIds: [], - }, - { - ...Ledgers.defaultUiLedger, - name: `Ledger_B_${getRandomPostfix()}`, - code: `test_automation_code_2_${getRandomPostfix()}`, - }, - ]; - const funds = [ - { - ...Funds.defaultUiFund, - name: `autotest_fund_A_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_1`, - }, - { - ...Funds.defaultUiFund, - name: `autotest_fund_B_${getRandomPostfix()}`, - code: `${getRandomPostfix()}_2`, - }, - ]; - const group = { ...Groups.defaultUiGroup }; - const budgets = [ - { ...Budgets.getDefaultBudget(), allocated: 100 }, - { ...Budgets.getDefaultBudget(), allocated: 100 }, - ]; +describe('Finance', () => { + describe('Batch allocation', () => { + let user; + const fiscalYear = { ...FiscalYears.defaultUiFiscalYear }; + const acqUnit = AcquisitionUnits.getDefaultAcquisitionUnit({ protectRead: true }); + let membershipAdminId; + const ledgers = [ + { + ...Ledgers.defaultUiLedger, + name: `Ledger_A_${getRandomPostfix()}`, + code: `test_automation_code_1_${getRandomPostfix()}`, + acqUnitIds: [], + }, + { + ...Ledgers.defaultUiLedger, + name: `Ledger_B_${getRandomPostfix()}`, + code: `test_automation_code_2_${getRandomPostfix()}`, + }, + ]; + const funds = [ + { + ...Funds.defaultUiFund, + name: `autotest_fund_A_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_1`, + }, + { + ...Funds.defaultUiFund, + name: `autotest_fund_B_${getRandomPostfix()}`, + code: `${getRandomPostfix()}_2`, + }, + ]; + const group = { ...Groups.defaultUiGroup }; + const budgets = [ + { ...Budgets.getDefaultBudget(), allocated: 100 }, + { ...Budgets.getDefaultBudget(), allocated: 100 }, + ]; - before('Create test data', () => { - cy.loginAsAdmin({ - path: TopMenu.ledgerPath, - waiter: Ledgers.waitLoading, - }); - AcquisitionUnits.createAcquisitionUnitViaApi(acqUnit).then(() => { - ledgers[0].acqUnitIds.push(acqUnit.id); - cy.getAdminUserDetails().then((u) => { - AcquisitionUnits.assignUserViaApi(u.id, acqUnit.id).then((id) => { - membershipAdminId = id; + before('Create test data', () => { + cy.loginAsAdmin({ + path: TopMenu.ledgerPath, + waiter: Ledgers.waitLoading, + }); + AcquisitionUnits.createAcquisitionUnitViaApi(acqUnit).then(() => { + ledgers[0].acqUnitIds.push(acqUnit.id); + cy.getAdminUserDetails().then((u) => { + AcquisitionUnits.assignUserViaApi(u.id, acqUnit.id).then((id) => { + membershipAdminId = id; + }); }); }); - }); - FiscalYears.createViaApi(fiscalYear).then((fy) => { - fiscalYear.id = fy.id; - ledgers.forEach((ledger) => { - ledger.fiscalYearOneId = fy.id; - }); - budgets.forEach((b) => { - b.fiscalYearId = fy.id; - }); - Ledgers.createViaApi(ledgers[0]).then((ledger1Response) => { - ledgers[0].id = ledger1Response.id; - funds[0].ledgerId = ledger1Response.id; - Ledgers.createViaApi(ledgers[1]).then((ledger2Response) => { - ledgers[1].id = ledger2Response.id; - funds[1].ledgerId = ledger2Response.id; - Groups.createViaApi(group).then((groupAResponse) => { - group.id = groupAResponse.id; - Funds.createViaApi(funds[0]).then((fundResponseA) => { - funds[0].id = fundResponseA.fund.id; - budgets[0].fundId = fundResponseA.fund.id; - Budgets.createViaApi(budgets[0]); - }); - Funds.createViaApi(funds[1], [groupAResponse.id]).then((fundResponseB) => { - funds[1].id = fundResponseB.fund.id; - budgets[1].fundId = fundResponseB.fund.id; - Budgets.createViaApi(budgets[1]); + FiscalYears.createViaApi(fiscalYear).then((fy) => { + fiscalYear.id = fy.id; + ledgers.forEach((ledger) => { + ledger.fiscalYearOneId = fy.id; + }); + budgets.forEach((b) => { + b.fiscalYearId = fy.id; + }); + Ledgers.createViaApi(ledgers[0]).then((ledger1Response) => { + ledgers[0].id = ledger1Response.id; + funds[0].ledgerId = ledger1Response.id; + Ledgers.createViaApi(ledgers[1]).then((ledger2Response) => { + ledgers[1].id = ledger2Response.id; + funds[1].ledgerId = ledger2Response.id; + Groups.createViaApi(group).then((groupAResponse) => { + group.id = groupAResponse.id; + Funds.createViaApi(funds[0]).then((fundResponseA) => { + funds[0].id = fundResponseA.fund.id; + budgets[0].fundId = fundResponseA.fund.id; + Budgets.createViaApi(budgets[0]); + }); + Funds.createViaApi(funds[1], [groupAResponse.id]).then((fundResponseB) => { + funds[1].id = fundResponseB.fund.id; + budgets[1].fundId = fundResponseB.fund.id; + Budgets.createViaApi(budgets[1]); + }); }); }); }); }); - }); - Ledgers.searchByName(ledgers[0].name); - Ledgers.selectLedger(ledgers[0].name); - BatchEditBudget.clickBatchAllocationButton(); - BatchEditBudget.saveAndCloseBatchAllocation(); - BatchEditBudget.setAllocationChange(funds[0].name, '100'); - BatchEditBudget.clickRecalculateButton(); - cy.wait(1000); - BatchEditBudget.assertTotalAllocatedAfter(funds[0].name, '200.00'); - BatchEditBudget.clickSaveAndCloseButton(); - cy.wait(4000); - Ledgers.closeOpenedPage(); - BatchEditBudget.openBatchAllocationLogsFromLedgerList(); - BatchEditBudget.searchLogs(fiscalYear.code, ledgers[0].code); - BatchEditBudget.clickLogForLedger(fiscalYear.code, ledgers[0].code); + Ledgers.searchByName(ledgers[0].name); + Ledgers.selectLedger(ledgers[0].name); + BatchEditBudget.clickBatchAllocationButton(); + BatchEditBudget.saveAndCloseBatchAllocation(); + BatchEditBudget.setAllocationChange(funds[0].name, '100'); + BatchEditBudget.clickRecalculateButton(); + cy.wait(1000); + BatchEditBudget.assertTotalAllocatedAfter(funds[0].name, '200.00'); + BatchEditBudget.clickSaveAndCloseButton(); + cy.wait(4000); + Ledgers.closeOpenedPage(); + BatchEditBudget.openBatchAllocationLogsFromLedgerList(); + BatchEditBudget.searchLogs(fiscalYear.code, ledgers[0].code); + BatchEditBudget.clickLogForLedger(fiscalYear.code, ledgers[0].code); - cy.createTempUser([ - permissions.uiFinanceViewLedger.gui, - permissions.uiFinanceViewGroups.gui, - permissions.uiFinanceFundUpdateLogsView.gui, - ]).then((userProperties) => { - user = userProperties; - cy.login(user.username, user.password, { - path: TopMenu.ledgerPath, - waiter: Ledgers.waitLoading, + cy.createTempUser([ + permissions.uiFinanceViewLedger.gui, + permissions.uiFinanceViewGroups.gui, + permissions.uiFinanceFundUpdateLogsView.gui, + ]).then((userProperties) => { + user = userProperties; + cy.login(user.username, user.password, { + path: TopMenu.ledgerPath, + waiter: Ledgers.waitLoading, + }); }); }); - }); - after('Clean up', () => { - cy.getAdminToken(); - AcquisitionUnits.unAssignUserViaApi(membershipAdminId); - AcquisitionUnits.deleteAcquisitionUnitViaApi(acqUnit.id); - Users.deleteViaApi(user.userId); - }); + after('Clean up', () => { + cy.getAdminToken(); + AcquisitionUnits.unAssignUserViaApi(membershipAdminId); + AcquisitionUnits.deleteAcquisitionUnitViaApi(acqUnit.id); + Users.deleteViaApi(user.userId); + }); - it( - 'C688780 User not assigned to Acq unit cannot see batch allocation logs associated with ledger or group with acquisition units (thunderjet)', - { tags: ['criticalPath', 'thunderjet', 'C688780'] }, - () => { - Ledgers.searchByName(ledgers[0].name); - Ledgers.checkNoResultsMessage( - `No results found for "${ledgers[0].name}". Please check your spelling and filters.`, - ); - BatchEditBudget.openBatchAllocationLogsFromLedgerList(); - BatchEditBudget.searchLogs(fiscalYear.code, ledgers[0].code); - BatchEditBudget.verifyNoResultsMessage(`${fiscalYear.code}-${ledgers[0].code}`); - }, - ); + it( + 'C688780 User not assigned to Acq unit cannot see batch allocation logs associated with ledger or group with acquisition units (thunderjet)', + { tags: ['criticalPath', 'thunderjet', 'C688780'] }, + () => { + Ledgers.searchByName(ledgers[0].name); + Ledgers.checkNoResultsMessage( + `No results found for "${ledgers[0].name}". Please check your spelling and filters.`, + ); + BatchEditBudget.openBatchAllocationLogsFromLedgerList(); + BatchEditBudget.searchLogs(fiscalYear.code, ledgers[0].code); + BatchEditBudget.verifyNoResultsMessage(`${fiscalYear.code}-${ledgers[0].code}`); + }, + ); + }); }); diff --git a/cypress/e2e/finance/fiscalYears/fiscalYearRollover/planned-budget-status-is-updating-to-active-during-rollover.cy.js b/cypress/e2e/finance/fiscalYears/fiscalYearRollover/planned-budget-status-is-updating-to-active-during-rollover.cy.js index adf85bf314..d18c58cd41 100644 --- a/cypress/e2e/finance/fiscalYears/fiscalYearRollover/planned-budget-status-is-updating-to-active-during-rollover.cy.js +++ b/cypress/e2e/finance/fiscalYears/fiscalYearRollover/planned-budget-status-is-updating-to-active-during-rollover.cy.js @@ -252,7 +252,7 @@ describe('Fiscal Year Rollover', () => { }); it( - 'C359186: "Planned" budget status is updating to "Active" during FY rollover (based on "Expended") (TaaS)', + 'C359186 "Planned" budget status is updating to "Active" during FY rollover (based on "Expended") (TaaS)', { tags: ['extendedPath', 'thunderjet', 'C359186'] }, () => { FinanceHelp.searchByName(testData.ledger.name); diff --git a/cypress/e2e/finance/fiscalYears/fiscalYearRollover/rollover-when-po-line-contains-two-fund-distributions.cy.js b/cypress/e2e/finance/fiscalYears/fiscalYearRollover/rollover-when-po-line-contains-two-fund-distributions.cy.js index e3957f3220..ab8c056880 100644 --- a/cypress/e2e/finance/fiscalYears/fiscalYearRollover/rollover-when-po-line-contains-two-fund-distributions.cy.js +++ b/cypress/e2e/finance/fiscalYears/fiscalYearRollover/rollover-when-po-line-contains-two-fund-distributions.cy.js @@ -137,7 +137,6 @@ describe('Finance', () => { cy.login(testData.user.username, testData.user.password, { path: TopMenu.ledgerPath, waiter: Ledgers.waitForLedgerDetailsLoading, - authRefresh: true, }); }); }); @@ -232,13 +231,13 @@ describe('Finance', () => { cy.visit(`${TopMenu.fundPath}/view/${funds.first.id}`); FundDetails.checkFundDetails({ currentBudget: { unavailable: '$40.00' }, - plannedBudgets: [{ unavailable: '$10.00' }], + plannedBudgets: [{ unavailable: '$40.00' }], }); // Click budget record in "Planned budget" accordion const BudgetDetails = FundDetails.openPlannedBudgetDetails(); BudgetDetails.checkBudgetDetails({ - summary: [{ key: 'Unavailable', value: '$10.00' }], + summary: [{ key: 'Unavailable', value: '$40.00' }], }); // Click "View transactions" link in "Budget information" accordion diff --git a/cypress/e2e/inventory/holdings/create-holdings-as-different-user.cy.js b/cypress/e2e/inventory/holdings/create-holdings-as-different-user.cy.js index 5cf2cc950a..7ae14cd603 100644 --- a/cypress/e2e/inventory/holdings/create-holdings-as-different-user.cy.js +++ b/cypress/e2e/inventory/holdings/create-holdings-as-different-user.cy.js @@ -68,7 +68,7 @@ describe('Inventory', () => { it( 'C1294 Create a Holdings record as another user than the one that created the Instance (folijet)', - { tags: ['smoke', 'folijet', 'shiftLeft', 'C1294', 'eurekaPhase1'] }, + { tags: ['smoke', 'folijet', 'shiftLeft', 'C1294'] }, () => { const InventoryNewInstance = InventoryInstances.addNewInventory(); InventoryNewInstance.fillRequiredValues(recordsData.instanceTitle); diff --git a/cypress/e2e/invoices/filter-invoices.cy.js b/cypress/e2e/invoices/filter-invoices.cy.js index c8a544f534..54a594b482 100644 --- a/cypress/e2e/invoices/filter-invoices.cy.js +++ b/cypress/e2e/invoices/filter-invoices.cy.js @@ -155,6 +155,7 @@ describe('Invoices', () => { { tags: ['criticalPath', 'thunderjet', 'C6724'] }, () => { filter.filterActions(); + Invoices.searchByParameter('Vendor invoice number', testData.invoice.vendorInvoiceNo); Invoices.selectInvoice(testData.invoice.vendorInvoiceNo); Invoices.closeInvoiceDetailsPane(); Invoices.resetFilters(); diff --git a/cypress/e2e/invoices/save-invoice-FY-after-fund-change.cy.js b/cypress/e2e/invoices/save-invoice-FY-after-fund-change.cy.js index 0df0200bc8..587af7c4d3 100644 --- a/cypress/e2e/invoices/save-invoice-FY-after-fund-change.cy.js +++ b/cypress/e2e/invoices/save-invoice-FY-after-fund-change.cy.js @@ -52,20 +52,20 @@ describe('Invoices', () => { first: { ...FiscalYears.getDefaultFiscalYear(), code: `${code}${randomNumber}01`, - periodStart: new Date(), - periodEnd: new Date(date.getFullYear() + 0, 1, 28), + periodStart: new Date(date.getFullYear() - 0, 0, 1), + periodEnd: new Date(date.getFullYear() - 0, 11, 31), }, second: { ...FiscalYears.getDefaultFiscalYear(), code: `${code}${randomNumber}02`, - periodStart: new Date(date.getFullYear() + 0, 2, 1), - periodEnd: new Date(date.getFullYear() + 0, 2, 31), + periodStart: new Date(date.getFullYear() + 1, 0, 1), + periodEnd: new Date(date.getFullYear() + 1, 11, 31), }, third: { ...FiscalYears.getDefaultFiscalYear(), code: `${code}${randomNumber}03`, - periodStart: new Date(date.getFullYear() + 0, 3, 1), - periodEnd: new Date(date.getFullYear() + 0, 3, 30), + periodStart: new Date(date.getFullYear() + 2, 0, 1), + periodEnd: new Date(date.getFullYear() + 2, 11, 31), }, }; @@ -172,8 +172,8 @@ describe('Invoices', () => { FiscalYears.updateFiscalYearViaApi({ ...fiscalYears.first, _version: 1, - periodStart: new Date(date.getFullYear() - 0, 0, 1), - periodEnd: new Date(date.getFullYear() - 0, 0, 20), + periodStart: new Date(date.getFullYear() - 1, 0, 1), + periodEnd: new Date(date.getFullYear() - 1, 11, 31), }); FiscalYears.updateFiscalYearViaApi({ ...fiscalYears.second, @@ -311,12 +311,12 @@ describe('Invoices', () => { }); DateTools.getFormattedDate({ date: new Date() }, 'YYYY-MM-DD'); - const periodStartForFirstFY2 = DateTools.getFormattedDate( - { date: new Date(date.getFullYear() - 0, 0, 21) }, + const periodStartForSecondFY = DateTools.getFormattedDate( + { date: new Date(date.getFullYear() + 0, 0, 1) }, 'MM/DD/YYYY', ); - const periodEndForFirstFY2 = DateTools.getFormattedDate( - { date: new Date(date.getFullYear() - 0, 0, 26) }, + const periodEndForSecondFY = DateTools.getFormattedDate( + { date: new Date(date.getFullYear(), date.getMonth(), date.getDate() - 1) }, 'MM/DD/YYYY', ); const periodStartForThirdFY = DateTools.getFormattedDate({ date: new Date() }, 'MM/DD/YYYY'); @@ -343,8 +343,8 @@ describe('Invoices', () => { FiscalYears.selectFY(fiscalYears.second.name); FiscalYears.editFiscalYearDetails(); FiscalYears.filltheStartAndEndDateonCalenderstartDateField( - periodStartForFirstFY2, - periodEndForFirstFY2, + periodStartForSecondFY, + periodEndForSecondFY, ); FinanceHelper.searchByName(fiscalYears.third.name); FiscalYears.selectFY(fiscalYears.third.name); diff --git a/cypress/e2e/invoices/settings/invoices.exportBatchVoucher.cy.js b/cypress/e2e/invoices/settings/invoices.exportBatchVoucher.cy.js index 591788b45a..139b099208 100644 --- a/cypress/e2e/invoices/settings/invoices.exportBatchVoucher.cy.js +++ b/cypress/e2e/invoices/settings/invoices.exportBatchVoucher.cy.js @@ -66,7 +66,7 @@ describe('Invoices', () => { after('Delete storage', () => { cy.getAdminToken(); - FileManager.deleteFolder(Cypress.config('downloadsFolder')); + FileManager.deleteFileFromDownloadsByMask('*.json'); Organizations.deleteOrganizationViaApi(organization.id); }); diff --git a/cypress/e2e/orders/delete-routing-list-from-orders.cy.js b/cypress/e2e/orders/delete-routing-list-from-orders.cy.js index a2ae5e3c0b..8dac500f3e 100644 --- a/cypress/e2e/orders/delete-routing-list-from-orders.cy.js +++ b/cypress/e2e/orders/delete-routing-list-from-orders.cy.js @@ -70,6 +70,7 @@ describe('Orders', () => { ...orderResponse, workflowStatus: ORDER_STATUSES.OPEN, }); + OrderLineDetails.createRoutingListViaApi([], routingList, testData.orderLineId); }); }); }); @@ -83,13 +84,6 @@ describe('Orders', () => { ]).then((userProperties) => { testData.user = userProperties; - cy.getAdminToken(); - OrderLineDetails.createRoutingListViaApi( - [userProperties.userId], - routingList, - testData.orderLineId, - ); - cy.login(userProperties.username, userProperties.password); }); }); diff --git a/cypress/e2e/orders/encumbered-amount-is-not-changed-after-deleting-received-piece-when-order-closed.cy.js b/cypress/e2e/orders/encumbered-amount-is-not-changed-after-deleting-received-piece-when-order-closed.cy.js index 30c8a37f4a..c0ea5000d3 100644 --- a/cypress/e2e/orders/encumbered-amount-is-not-changed-after-deleting-received-piece-when-order-closed.cy.js +++ b/cypress/e2e/orders/encumbered-amount-is-not-changed-after-deleting-received-piece-when-order-closed.cy.js @@ -61,11 +61,11 @@ describe('Orders', () => { const orderLine = { ...BasicOrderLine.defaultOrderLine, cost: { - listUnitPrice: 90.0, + listUnitPrice: 10.0, currency: 'USD', discountType: 'percentage', - quantityPhysical: 1, - poLineEstimatedPrice: 90.0, + quantityPhysical: 2, + poLineEstimatedPrice: 20.0, }, fundDistribution: [ { @@ -74,7 +74,7 @@ describe('Orders', () => { value: 100, }, ], - locations: [{ locationId: locationResp.id, quantity: 1, quantityPhysical: 1 }], + locations: [{ locationId: locationResp.id, quantity: 2, quantityPhysical: 2 }], acquisitionMethod: amResp.body.acquisitionMethods[0].id, physical: { createInventory: 'Instance, Holding, Item', @@ -115,7 +115,7 @@ describe('Orders', () => { poLineId: testData.orderLine.id, fundDistributions: testData.orderLine.fundDistribution, accountingCode: testData.organization.erpCode, - subTotal: 25, + subTotal: 20, releaseEncumbrance: true, }).then((invoice) => { testData.invoice = invoice; @@ -181,7 +181,7 @@ describe('Orders', () => { const ReceivingDetails = Receivings.selectFromResultsList(testData.orderLine.titleOrPackage); ReceivingDetails.checkReceivingDetails({ orderLineDetails: [{ key: 'POL number', value: `${testData.orderNumber}-1` }], - expected: [], + expected: [{ format: 'Physical' }], received: [{ barcode: testData.barcode, format: 'Physical' }], }); @@ -194,13 +194,13 @@ describe('Orders', () => { // Click "Delete" button Receiving.openDropDownInEditPieceModal(); - const DeletePieceModal = EditPieceModal.clickDeleteButton(); + const DeletePieceModal = EditPieceModal.clickDeleteButton({ isLastPiece: false }); // Click "Delete item" button - DeletePieceModal.clickDeleteItemButton(); + DeletePieceModal.confirmDelete({ pieceDeleted: true }); ReceivingDetails.checkReceivingDetails({ orderLineDetails: [{ key: 'POL number', value: `${testData.orderNumber}-1` }], - expected: [], + expected: [{ format: 'Physical' }], received: [], }); @@ -219,8 +219,8 @@ describe('Orders', () => { { key: 'Source', value: `${testData.orderNumber}-1` }, { key: 'Type', value: 'Encumbrance' }, { key: 'From', value: testData.fund.name }, - { key: 'Initial encumbrance', value: '$0.00' }, - { key: 'Awaiting payment', value: '$25.00' }, + { key: 'Initial encumbrance', value: '$10.00' }, + { key: 'Awaiting payment', value: '$20.00' }, { key: 'Expended', value: '$0.00' }, { key: 'Status', value: 'Released' }, ], diff --git a/cypress/e2e/settings/orders/adjust-instance.cy.js b/cypress/e2e/settings/orders/adjust-instance.cy.js index e2e34904b7..501aaaf83d 100644 --- a/cypress/e2e/settings/orders/adjust-instance.cy.js +++ b/cypress/e2e/settings/orders/adjust-instance.cy.js @@ -112,7 +112,7 @@ describe('Orders', () => { OrderLines.openInstance(); InventoryInstance.openHoldingsAccordion(testData.location.name); InventoryInstance.verifyLoan(testData.loanType); - InstanceRecordView.verifyResourceType(testData.instanceType); + InstanceRecordView.verifyResourceType(`${testData.instanceType} `); InstanceRecordView.verifyInstanceStatusTerm(testData.instanceStatus); }, ); diff --git a/cypress/support/fragments/finance/funds/funds.js b/cypress/support/fragments/finance/funds/funds.js index d1dc4f6b02..8659d7cb68 100644 --- a/cypress/support/fragments/finance/funds/funds.js +++ b/cypress/support/fragments/finance/funds/funds.js @@ -152,7 +152,7 @@ export default { return FundEditForm; }, createFund(fund) { - cy.do([newButton.click()]); + cy.do([fundResultsPane.find(newButton).click()]); cy.wait(2000); cy.do([ nameField.fillIn(fund.name), @@ -182,7 +182,7 @@ export default { newFund() { cy.wait(2000); - cy.do(Section({ id: 'fund-results-pane' }).find(newButton).click()); + cy.do(fundResultsPane.find(newButton).click()); }, clickRestrictByLocationsCheckbox() { @@ -398,7 +398,7 @@ export default { tryToCreateFundWithoutMandatoryFields: (fundName) => { cy.do([ - newButton.click(), + fundResultsPane.find(newButton).click(), nameField.fillIn(fundName), saveAndClose.click(), codeField.fillIn('some code'), diff --git a/cypress/support/fragments/invoices/invoices.js b/cypress/support/fragments/invoices/invoices.js index ca62961f2c..de89b50686 100644 --- a/cypress/support/fragments/invoices/invoices.js +++ b/cypress/support/fragments/invoices/invoices.js @@ -1127,6 +1127,7 @@ export default { cy.wait(1500); cy.do(resetButton.click()); cy.expect(resetButton.is({ disabled: true })); + cy.wait(1500); }, editInvoiceLine: () => {