diff --git a/cypress/e2e/orders/prioritize-users-in-routing-list-in-pol-and-receiving-title.cy.js b/cypress/e2e/orders/prioritize-users-in-routing-list-in-pol-and-receiving-title.cy.js new file mode 100644 index 0000000000..cc89913fde --- /dev/null +++ b/cypress/e2e/orders/prioritize-users-in-routing-list-in-pol-and-receiving-title.cy.js @@ -0,0 +1,202 @@ +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 Receiving from '../../support/fragments/receiving/receiving'; + +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 organization = { ...NewOrganization.defaultUiOrganizations }; + firstFiscalYear.code = firstFiscalYear.code.slice(0, -1) + '1'; + const firstBudget = { + ...Budgets.getDefaultBudget(), + allocated: 1000, + }; + const routingList1 = `routingList_1${getRandomPostfix()}`; + let enterUser; + let firstUser; + let secondUser; + let thirdUser; + let firstOrderNumber; + let servicePointId; + let location; + let orderLine; + + 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.createTempUser([ + permissions.uiOrdersEdit.gui, + permissions.uiReceivingViewEdit.gui, + ]).then((firstUserProperties) => { + firstUser = firstUserProperties; + cy.createTempUser([ + permissions.uiOrdersEdit.gui, + permissions.uiReceivingViewEdit.gui, + ]).then((secondUserProperties) => { + secondUser = secondUserProperties; + cy.createTempUser([ + permissions.uiOrdersEdit.gui, + permissions.uiReceivingViewEdit.gui, + ]).then((thirdUserProperties) => { + thirdUser = thirdUserProperties; + 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({ + path: TopMenu.ordersPath, + waiter: Orders.waitLoading, + }); + Orders.searchByParameter('PO number', firstOrderNumber); + Orders.selectFromResultsList(firstOrderNumber); + OrderLines.selectPOLInOrder(); + OrderLines.openRoutingLists(); + OrderLines.addRoutingListExist(); + OrderLines.addRoutingList(); + OrderLines.fillInRoutingListInfo(routingList1); + OrderLines.assignUser(firstUser.username); + OrderLines.assignUser(secondUser.username); + OrderLines.assignUser(thirdUser.username); + OrderLines.saveRoutingList(); + OrderLines.backToEditingOrder(); + }); + }, + ); + }); + }); + }, + ); + }); + }); + }); + }); + }); + }); + }); + + cy.createTempUser([ + permissions.uiOrdersEdit.gui, + permissions.uiReceivingViewEditDelete.gui, + ]).then((userProperties) => { + enterUser = userProperties; + cy.login(userProperties.username, userProperties.password, { + path: TopMenu.ordersPath, + waiter: Orders.waitLoading, + }); + }); + }); + + after(() => { + cy.getAdminToken(); + Users.deleteViaApi(enterUser.userId); + Users.deleteViaApi(enterUser.userId); + Users.deleteViaApi(enterUser.userId); + Users.deleteViaApi(enterUser.userId); + }); + + it( + 'C468198 Prioritize users in Routing list in POL and Receiving title (thunderjet)', + { tags: ['criticalPath', 'thunderjet'] }, + () => { + Orders.searchByParameter('PO number', firstOrderNumber); + Orders.selectFromResultsList(firstOrderNumber); + OrderLines.selectPOLInOrder(); + OrderLines.openRoutingList(routingList1); + OrderLines.editRoutingList(); + OrderLines.assignUser(enterUser.username); + OrderLines.unAssignUserFromRoutingList(firstUser.id); + OrderLines.checkUserIsAbsent(firstUser.username); + OrderLines.saveRoutingList(); + OrderLines.backToEditingOrder(); + Orders.receiveOrderViaActions(); + Receiving.selectPOLInReceive(orderLine.titleOrPackage); + }, + ); +}); diff --git a/cypress/support/dictionary/permissions.js b/cypress/support/dictionary/permissions.js index c072fe0f67..ffc51840b9 100644 --- a/cypress/support/dictionary/permissions.js +++ b/cypress/support/dictionary/permissions.js @@ -624,6 +624,10 @@ export default { internal: 'ui-receiving.create', gui: 'Receiving: View, edit, create', }, + uiReceivingViewEdit: { + internal: 'ui-receiving.edit', + gui: 'Receiving: View, edit', + }, uiReceivingViewEditDelete: { internal: 'ui-receiving.delete', gui: 'Receiving: View, edit, delete', diff --git a/cypress/support/fragments/orders/orderLines.js b/cypress/support/fragments/orders/orderLines.js index 009da363e5..9fb070ad61 100644 --- a/cypress/support/fragments/orders/orderLines.js +++ b/cypress/support/fragments/orders/orderLines.js @@ -2482,6 +2482,14 @@ export default { cy.do([TextField({ id: 'input-routing-list-name' }).fillIn(name), saveAndCloseButton.click()]); }, + fillInRoutingListInfo: (name) => { + cy.do(TextField({ id: 'input-routing-list-name' }).fillIn(name)); + }, + + saveRoutingList: () => { + cy.do(saveAndCloseButton.click()); + }, + fillInRoutingListInfoWithNotesAndSave: (name, notes) => { cy.do([ TextField({ id: 'input-routing-list-name' }).fillIn(name), @@ -2539,6 +2547,10 @@ export default { ]); }, + unAssignUserFromRoutingList(userID) { + cy.do(Button({ id: `clickable-remove-user-${userID}` }).click()); + }, + deleteUserFromRoutingList(user) { cy.do(Button({ id: `clickable-remove-user-${user}` }).click()); },