From 8504eece1bac4bae6b80e1c5aad2cf1e06004270 Mon Sep 17 00:00:00 2001 From: Katarzyna Date: Wed, 29 Oct 2025 14:16:02 +0100 Subject: [PATCH 1/4] add deactivation of receiving bin to receiving tests --- .../receiving/assertBinLocationField.test.ts | 68 +++++-- .../assertCreationOfGoodsReceiptNote.test.ts | 47 ++++- .../assertCreationOfReceivingBin.test.ts | 44 ++++- src/tests/receiving/assertQtyInputs.test.ts | 65 +++++-- .../receiving/assertRecipientField.test.ts | 69 +++++-- .../receiving/cancelRemainingQty.test.ts | 69 +++++-- .../editBinLocationWhenReceive.test.ts | 61 ++++++- .../receiving/editOriginalLineQtyTo0.test.ts | 136 ++++++++++---- src/tests/receiving/editsInReceiving.test.ts | 69 +++++-- .../receiving/exportReceivingTemplate.test.ts | 54 ++++-- .../receiving/importReceivingTemplate.test.ts | 75 ++++++-- .../lotExpirySystemUpdateOnReceiving.test.ts | 81 ++++++--- src/tests/receiving/receiveInbound.test.ts | 170 +++++++++++++----- src/tests/receiving/receiveToHoldBin.test.ts | 21 ++- .../receiving/receivingStatusChanges.test.ts | 68 +++++-- .../receiving/rollbackStatusChanges.test.ts | 45 ++++- ...ByAlphabeticalOrderAndRemainInputs.test.ts | 69 +++++-- .../tableShortcutsInReceiving.test.ts | 81 +++++++-- .../validationsOnDeliverOnDate.test.ts | 45 ++++- .../validationsOnEditAndReceive.test.ts | 102 +++++++++-- 20 files changed, 1130 insertions(+), 309 deletions(-) diff --git a/src/tests/receiving/assertBinLocationField.test.ts b/src/tests/receiving/assertBinLocationField.test.ts index 7dcd40b4..8a80abcf 100644 --- a/src/tests/receiving/assertBinLocationField.test.ts +++ b/src/tests/receiving/assertBinLocationField.test.ts @@ -35,24 +35,58 @@ test.describe('Assert bin location not clearable', () => { } ); - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - const isRollbackLastReceiptButtonVisible = - await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); - const isRollbackButtonVisible = - await stockMovementShowPage.rollbackButton.isVisible(); + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + mainLocationService, + page, + locationListPage, + createLocationPage, + }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + const isRollbackLastReceiptButtonVisible = + await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); + const isRollbackButtonVisible = + await stockMovementShowPage.rollbackButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button - if (isRollbackLastReceiptButtonVisible) { - await stockMovementShowPage.rollbackLastReceiptButton.click(); - } + // due to failed test, shipment might not be received which will not show the button + if (isRollbackLastReceiptButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } - if (isRollbackButtonVisible) { - await stockMovementShowPage.rollbackButton.click(); - } + if (isRollbackButtonVisible) { + await stockMovementShowPage.rollbackButton.click(); + } - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - }); + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + await test.step('Deactivate receiving bin', async () => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); + } + ); test('Assert bin location not clearable', async ({ stockMovementShowPage, @@ -69,7 +103,7 @@ test.describe('Assert bin location not clearable', () => { }); await test.step('Assert bin location cant be cleared', async () => { - await expect( + await expect( receivingPage.receivingStep.table .row(1) .binLocationSelect.locator('.react-select__clear-indicator') @@ -89,7 +123,7 @@ test.describe('Assert bin location not clearable', () => { await receivingPage.receivingStep.editModal.saveButton.click(); }); - await test.step('Assertbin location field content after split linw', async () => { + await test.step('Assert bin location field content after split line', async () => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; await expect( diff --git a/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts b/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts index 05eead7e..d1676ca2 100644 --- a/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts +++ b/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts @@ -1,3 +1,4 @@ +import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; @@ -34,12 +35,46 @@ test.describe('Assert Goods Receipt Note is created and opened', () => { } ); - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.rollbackLastReceiptButton.click(); - await stockMovementShowPage.rollbackButton.click(); - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - }); + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + mainLocationService, + page, + locationListPage, + createLocationPage, + }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await stockMovementShowPage.rollbackLastReceiptButton.click(); + await stockMovementShowPage.rollbackButton.click(); + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + await test.step('Deactivate receiving bin', async () => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); + } + ); test('Assert Goods Receipt note is created', async ({ stockMovementShowPage, diff --git a/src/tests/receiving/assertCreationOfReceivingBin.test.ts b/src/tests/receiving/assertCreationOfReceivingBin.test.ts index 6245728a..155f954c 100644 --- a/src/tests/receiving/assertCreationOfReceivingBin.test.ts +++ b/src/tests/receiving/assertCreationOfReceivingBin.test.ts @@ -42,11 +42,45 @@ test.describe('Assert creation of receiving bin', () => { } ); - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.rollbackButton.click(); - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - }); + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + mainLocationService, + page, + locationListPage, + createLocationPage, + }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await stockMovementShowPage.rollbackButton.click(); + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + await test.step('Deactivate receiving bin', async () => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); + } + ); test('Assert receiving bin is not created when shipment is shipped', async ({ stockMovementShowPage, diff --git a/src/tests/receiving/assertQtyInputs.test.ts b/src/tests/receiving/assertQtyInputs.test.ts index a74d1027..1b51265b 100644 --- a/src/tests/receiving/assertQtyInputs.test.ts +++ b/src/tests/receiving/assertQtyInputs.test.ts @@ -1,3 +1,4 @@ +import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; @@ -41,24 +42,58 @@ test.describe('Assert if quantity inputs remain when split lines', () => { } ); - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - const isRollbackLastReceiptButtonVisible = - await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); - const isRollbackButtonVisible = - await stockMovementShowPage.rollbackButton.isVisible(); + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + mainLocationService, + page, + locationListPage, + createLocationPage, + }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + const isRollbackLastReceiptButtonVisible = + await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); + const isRollbackButtonVisible = + await stockMovementShowPage.rollbackButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button - if (isRollbackLastReceiptButtonVisible) { - await stockMovementShowPage.rollbackLastReceiptButton.click(); - } + // due to failed test, shipment might not be received which will not show the button + if (isRollbackLastReceiptButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } - if (isRollbackButtonVisible) { - await stockMovementShowPage.rollbackButton.click(); - } + if (isRollbackButtonVisible) { + await stockMovementShowPage.rollbackButton.click(); + } - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - }); + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + await test.step('Deactivate receiving bin', async () => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); + } + ); test('Assert quantity input after split line', async ({ stockMovementShowPage, diff --git a/src/tests/receiving/assertRecipientField.test.ts b/src/tests/receiving/assertRecipientField.test.ts index 083c32e1..84cdd134 100644 --- a/src/tests/receiving/assertRecipientField.test.ts +++ b/src/tests/receiving/assertRecipientField.test.ts @@ -1,3 +1,4 @@ +import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; @@ -43,24 +44,58 @@ test.describe('Assert recipient field when receive', () => { } ); - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - const isRollbackLastReceiptButtonVisible = - await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); - const isRollbackButtonVisible = - await stockMovementShowPage.rollbackButton.isVisible(); - - // due to failed test, shipment might not be received which will not show the button - if (isRollbackLastReceiptButtonVisible) { - await stockMovementShowPage.rollbackLastReceiptButton.click(); - } - - if (isRollbackButtonVisible) { - await stockMovementShowPage.rollbackButton.click(); + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + mainLocationService, + page, + locationListPage, + createLocationPage, + }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + const isRollbackLastReceiptButtonVisible = + await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); + const isRollbackButtonVisible = + await stockMovementShowPage.rollbackButton.isVisible(); + + // due to failed test, shipment might not be received which will not show the button + if (isRollbackLastReceiptButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } + + if (isRollbackButtonVisible) { + await stockMovementShowPage.rollbackButton.click(); + } + + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + await test.step('Deactivate receiving bin', async () => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); } - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - }); + ); test('Assert recipient field filled and disabled', async ({ stockMovementShowPage, diff --git a/src/tests/receiving/cancelRemainingQty.test.ts b/src/tests/receiving/cancelRemainingQty.test.ts index 827b8761..80e29825 100644 --- a/src/tests/receiving/cancelRemainingQty.test.ts +++ b/src/tests/receiving/cancelRemainingQty.test.ts @@ -1,3 +1,4 @@ +import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; @@ -37,24 +38,58 @@ test.describe('Cancel qty in the middle of receipt', () => { } ); - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - const isRollbackLastReceiptButtonVisible = - await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); - const isRollbackButtonVisible = - await stockMovementShowPage.rollbackButton.isVisible(); - - // due to failed test, shipment might not be received which will not show the button - if (isRollbackLastReceiptButtonVisible) { - await stockMovementShowPage.rollbackLastReceiptButton.click(); - } - - if (isRollbackButtonVisible) { - await stockMovementShowPage.rollbackButton.click(); + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + mainLocationService, + page, + locationListPage, + createLocationPage, + }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + const isRollbackLastReceiptButtonVisible = + await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); + const isRollbackButtonVisible = + await stockMovementShowPage.rollbackButton.isVisible(); + + // due to failed test, shipment might not be received which will not show the button + if (isRollbackLastReceiptButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } + + if (isRollbackButtonVisible) { + await stockMovementShowPage.rollbackButton.click(); + } + + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + await test.step('Deactivate receiving bin', async () => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); } - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - }); + ); test('Cancel remaining qty when receive item partially', async ({ stockMovementShowPage, diff --git a/src/tests/receiving/editBinLocationWhenReceive.test.ts b/src/tests/receiving/editBinLocationWhenReceive.test.ts index 086c2fd2..c535ca68 100644 --- a/src/tests/receiving/editBinLocationWhenReceive.test.ts +++ b/src/tests/receiving/editBinLocationWhenReceive.test.ts @@ -1,3 +1,4 @@ +import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; @@ -72,13 +73,15 @@ test.describe('Edit Bin Location when receive inbound stock movement', () => { mainLocationService, createLocationPage, }) => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.rollbackLastReceiptButton.click(); await stockMovementShowPage.rollbackButton.click(); await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); await test.step('Deactivate created bin location', async () => { - const mainLocation = await mainLocationService.getLocation(); await page.goto('./location/list'); await locationListPage.searchByLocationNameField.fill( mainLocation.name @@ -102,6 +105,22 @@ test.describe('Edit Bin Location when receive inbound stock movement', () => { await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); await createLocationPage.locationConfigurationTabSection.saveButton.click(); }); + + await test.step('Deactivate receiving bin', async () => { + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); } ); @@ -255,13 +274,15 @@ test.describe('Edit Bin Location to bin with zone when receive inbound stock mov mainLocationService, createLocationPage, }) => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.rollbackLastReceiptButton.click(); await stockMovementShowPage.rollbackButton.click(); await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); await test.step('Deactivate created bin location', async () => { - const mainLocation = await mainLocationService.getLocation(); await page.goto('./location/list'); await locationListPage.searchByLocationNameField.fill( mainLocation.name @@ -301,6 +322,22 @@ test.describe('Edit Bin Location to bin with zone when receive inbound stock mov await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); await createLocationPage.locationConfigurationTabSection.saveButton.click(); }); + + await test.step('Deactivate receiving bin', async () => { + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); } ); @@ -439,13 +476,15 @@ test.describe('Edit Bin Location when receive for all lines', () => { mainLocationService, createLocationPage, }) => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.rollbackLastReceiptButton.click(); await stockMovementShowPage.rollbackButton.click(); await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); await test.step('Deactivate created bin location', async () => { - const mainLocation = await mainLocationService.getLocation(); await page.goto('./location/list'); await locationListPage.searchByLocationNameField.fill( mainLocation.name @@ -469,6 +508,22 @@ test.describe('Edit Bin Location when receive for all lines', () => { await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); await createLocationPage.locationConfigurationTabSection.saveButton.click(); }); + + await test.step('Deactivate receiving bin', async () => { + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); } ); diff --git a/src/tests/receiving/editOriginalLineQtyTo0.test.ts b/src/tests/receiving/editOriginalLineQtyTo0.test.ts index 801b95c4..baa3c316 100644 --- a/src/tests/receiving/editOriginalLineQtyTo0.test.ts +++ b/src/tests/receiving/editOriginalLineQtyTo0.test.ts @@ -1,3 +1,4 @@ +import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; @@ -56,24 +57,58 @@ test.describe('Edit qty of original line to 0', () => { } ); - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - const isRollbackLastReceiptButtonVisible = - await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); - const isRollbackButtonVisible = - await stockMovementShowPage.rollbackButton.isVisible(); - - // due to failed test, shipment might not be received which will not show the button - if (isRollbackLastReceiptButtonVisible) { - await stockMovementShowPage.rollbackLastReceiptButton.click(); - } - - if (isRollbackButtonVisible) { - await stockMovementShowPage.rollbackButton.click(); + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + mainLocationService, + page, + locationListPage, + createLocationPage, + }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + const isRollbackLastReceiptButtonVisible = + await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); + const isRollbackButtonVisible = + await stockMovementShowPage.rollbackButton.isVisible(); + + // due to failed test, shipment might not be received which will not show the button + if (isRollbackLastReceiptButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } + + if (isRollbackButtonVisible) { + await stockMovementShowPage.rollbackButton.click(); + } + + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + await test.step('Deactivate receiving bin', async () => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); } - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - }); + ); test('Edit qty of original line to 0', async ({ stockMovementShowPage, @@ -239,24 +274,57 @@ test.describe('Edit original line to other product in the middle of receipt', () } ); - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - const isRollbackLastReceiptButtonVisible = - await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); - const isRollbackButtonVisible = - await stockMovementShowPage.rollbackButton.isVisible(); - - // due to failed test, shipment might not be received which will not show the button - if (isRollbackLastReceiptButtonVisible) { - await stockMovementShowPage.rollbackLastReceiptButton.click(); - } - - if (isRollbackButtonVisible) { - await stockMovementShowPage.rollbackButton.click(); + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + mainLocationService, + page, + locationListPage, + createLocationPage, + }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + const isRollbackLastReceiptButtonVisible = + await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); + const isRollbackButtonVisible = + await stockMovementShowPage.rollbackButton.isVisible(); + + // due to failed test, shipment might not be received which will not show the button + if (isRollbackLastReceiptButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } + + if (isRollbackButtonVisible) { + await stockMovementShowPage.rollbackButton.click(); + } + + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + await test.step('Deactivate receiving bin', async () => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); } - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - }); + ); test('Edit qty of original line to 0 and edit product to other', async ({ stockMovementShowPage, diff --git a/src/tests/receiving/editsInReceiving.test.ts b/src/tests/receiving/editsInReceiving.test.ts index 2deeb461..26e67cab 100644 --- a/src/tests/receiving/editsInReceiving.test.ts +++ b/src/tests/receiving/editsInReceiving.test.ts @@ -1,3 +1,4 @@ +import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; @@ -46,24 +47,58 @@ test.describe('Edit items in the middle of receipt', () => { } ); - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - const isRollbackLastReceiptButtonVisible = - await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); - const isRollbackButtonVisible = - await stockMovementShowPage.rollbackButton.isVisible(); - - // due to failed test, shipment might not be received which will not show the button - if (isRollbackLastReceiptButtonVisible) { - await stockMovementShowPage.rollbackLastReceiptButton.click(); - } - - if (isRollbackButtonVisible) { - await stockMovementShowPage.rollbackButton.click(); + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + mainLocationService, + page, + locationListPage, + createLocationPage, + }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + const isRollbackLastReceiptButtonVisible = + await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); + const isRollbackButtonVisible = + await stockMovementShowPage.rollbackButton.isVisible(); + + // due to failed test, shipment might not be received which will not show the button + if (isRollbackLastReceiptButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } + + if (isRollbackButtonVisible) { + await stockMovementShowPage.rollbackButton.click(); + } + + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + await test.step('Deactivate receiving bin', async () => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); } - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - }); + ); test('Edit item qty on receiving page', async ({ stockMovementShowPage, diff --git a/src/tests/receiving/exportReceivingTemplate.test.ts b/src/tests/receiving/exportReceivingTemplate.test.ts index 54414a6e..f218a3f0 100644 --- a/src/tests/receiving/exportReceivingTemplate.test.ts +++ b/src/tests/receiving/exportReceivingTemplate.test.ts @@ -51,23 +51,57 @@ test.describe('Export receiving template', () => { } ); - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.rollbackLastReceiptButton.click(); - await stockMovementShowPage.rollbackButton.click(); - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - - for (const workbook of workbooks) { - workbook.delete(); + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + mainLocationService, + page, + locationListPage, + createLocationPage, + }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await stockMovementShowPage.rollbackLastReceiptButton.click(); + await stockMovementShowPage.rollbackButton.click(); + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + for (const workbook of workbooks) { + workbook.delete(); + } + + await test.step('Deactivate receiving bin', async () => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); } - }); + ); test('Export receiving template', async ({ stockMovementShowPage, receivingPage, mainProductService, otherProductService, - thirdProductService + thirdProductService, }) => { let filePath: string; let downloadedExportTemplateFile: WorkbookUtils; diff --git a/src/tests/receiving/importReceivingTemplate.test.ts b/src/tests/receiving/importReceivingTemplate.test.ts index 9a765bca..172bff67 100644 --- a/src/tests/receiving/importReceivingTemplate.test.ts +++ b/src/tests/receiving/importReceivingTemplate.test.ts @@ -48,24 +48,58 @@ test.describe('Import receiving template', () => { } ); - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - const isButtonVisible = - await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); - - // due to failed test, shipment might not be received which will not show the button - if (isButtonVisible) { - await stockMovementShowPage.rollbackLastReceiptButton.click(); - } - - await stockMovementShowPage.rollbackButton.click(); - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - - for (const workbook of workbooks) { - workbook.delete(); + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + mainLocationService, + page, + locationListPage, + createLocationPage, + }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + const isButtonVisible = + await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); + + // due to failed test, shipment might not be received which will not show the button + if (isButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } + + await stockMovementShowPage.rollbackButton.click(); + + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + for (const workbook of workbooks) { + workbook.delete(); + } + + await test.step('Deactivate receiving bin', async () => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); } - }); + ); test('Receive shipment using import receiving template', async ({ stockMovementShowPage, @@ -110,7 +144,8 @@ test.describe('Import receiving template', () => { await test.step('Input receiving now qty into template', async () => { const documentRow = parsedDocumentData[1]; const row = [...documentRow]; - (row[RECEIVING_NOW_COLUMN_IDX] = '20'), (row[COMMENT_COLUMN_IDX] = 'e2e-comment'); + (row[RECEIVING_NOW_COLUMN_IDX] = '20'), + (row[COMMENT_COLUMN_IDX] = 'e2e-comment'); data.push(row); }); @@ -192,7 +227,9 @@ test.describe('Import receiving template', () => { await test.step('Input receiving now qty into template', async () => { const documentRow = parsedDocumentData[1]; const row = [...documentRow]; - (row[LOT_COLUMN_IDX] = 'editlot'), (row[RECEIVING_NOW_COLUMN_IDX] = '20'), (row[COMMENT_COLUMN_IDX] = 'comment'); + (row[LOT_COLUMN_IDX] = 'editlot'), + (row[RECEIVING_NOW_COLUMN_IDX] = '20'), + (row[COMMENT_COLUMN_IDX] = 'comment'); data.push(row); }); diff --git a/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts b/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts index 97ed740a..8eaed9ea 100644 --- a/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts +++ b/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts @@ -1,3 +1,4 @@ +import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; @@ -7,33 +8,69 @@ import UniqueIdentifier from '@/utils/UniqueIdentifier'; test.describe('Lot number system expiry date modification on receiving workflow', () => { const STOCK_MOVEMENTS: StockMovementResponse[] = []; - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - // TODO: Improve this one, it is prone to getting stuck if there are not deleted SMs in the tested location - while (STOCK_MOVEMENTS.length > 0) { - const STOCK_MOVEMENT = STOCK_MOVEMENTS.pop() as StockMovementResponse; + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + mainLocationService, + page, + locationListPage, + createLocationPage, + }) => { + // TODO: Improve this one, it is prone to getting stuck if there are not deleted SMs in the tested location + while (STOCK_MOVEMENTS.length > 0) { + const STOCK_MOVEMENT = STOCK_MOVEMENTS.pop() as StockMovementResponse; - await test.step(`Go to stock movement "${STOCK_MOVEMENT.id}" show page`, async () => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.waitForUrl(); - await stockMovementShowPage.isLoaded(); - }); + await test.step(`Go to stock movement "${STOCK_MOVEMENT.id}" show page`, async () => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await stockMovementShowPage.waitForUrl(); + await stockMovementShowPage.isLoaded(); + }); - const isButtonVisible = - await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button - if (isButtonVisible) { - await stockMovementShowPage.rollbackLastReceiptButton.click(); - } + const isButtonVisible = + await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); + // due to failed test, shipment might not be received which will not show the button + if (isButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } - await test.step('Rollback shipment', async () => { - await stockMovementShowPage.rollbackButton.click(); - }); + await test.step('Rollback shipment', async () => { + await stockMovementShowPage.rollbackButton.click(); + }); - await test.step(`Delete stock movement "${STOCK_MOVEMENT.id}"`, async () => { - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - }); + await test.step(`Delete stock movement "${STOCK_MOVEMENT.id}"`, async () => { + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + }); + + await test.step('Deactivate receiving bin', async () => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await locationListPage + .getLocationEditButton(mainLocation.name) + .click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); + } } - }); + ); test('Edit lot expiration date on a new lot does not render a confirmation modal', async ({ stockMovementShowPage, diff --git a/src/tests/receiving/receiveInbound.test.ts b/src/tests/receiving/receiveInbound.test.ts index f1176075..cc544c5e 100644 --- a/src/tests/receiving/receiveInbound.test.ts +++ b/src/tests/receiving/receiveInbound.test.ts @@ -41,20 +41,54 @@ test.describe('Receive inbound stock movement', () => { } ); - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - const isButtonVisible = - await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); - - // due to failed test, shipment might not be received which will not show the button - if (isButtonVisible) { - await stockMovementShowPage.rollbackLastReceiptButton.click(); - } + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + mainLocationService, + page, + locationListPage, + createLocationPage, + }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + const isButtonVisible = + await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); - await stockMovementShowPage.rollbackButton.click(); + // due to failed test, shipment might not be received which will not show the button + if (isButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - }); + await stockMovementShowPage.rollbackButton.click(); + + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + await test.step('Deactivate receiving bin', async () => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); + } + ); test('Receive inbound stock movement', async ({ stockMovementShowPage, @@ -359,51 +393,91 @@ test.describe('Receive inbound stock movement', () => { ).toHaveValue('10'); }); }); +}); - test.describe('Receive from different locations', () => { - test.afterEach(async ({ authService }) => { - await authService.changeLocation(AppConfig.instance.locations.main.id); - }); +test.describe('Receive from different locations', () => { + let STOCK_MOVEMENT: StockMovementResponse; + const description = 'some description'; + const dateRequested = getToday(); - test('Receiving should not be available from other location than which is specfied as destination location', async ({ - stockMovementShowPage, - depotLocationService, - navbar, - locationChooser, + test.beforeEach( + async ({ + supplierLocationService, + stockMovementService, + mainProductService, + otherProductService, }) => { - const OTHER_LOCATION = await depotLocationService.getLocation(); - - await test.step('Go to stock movement show page', async () => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.isLoaded(); + const supplierLocation = await supplierLocationService.getLocation(); + STOCK_MOVEMENT = await stockMovementService.createInbound({ + originId: supplierLocation.id, + description, + dateRequested, }); - await test.step('Switch locations', async () => { - await navbar.locationChooserButton.click(); - await locationChooser - .getOrganization(OTHER_LOCATION.organization?.name as string) - .click(); - await locationChooser.getLocation(OTHER_LOCATION.name).click(); - }); + const product = await mainProductService.getProduct(); + const product2 = await otherProductService.getProduct(); - await test.step('Assert location in location chooser button should be updated', async () => { - await expect(navbar.locationChooserButton).toContainText( - OTHER_LOCATION.name - ); - await stockMovementShowPage.isLoaded(); - }); + await stockMovementService.addItemsToInboundStockMovement( + STOCK_MOVEMENT.id, + [ + { productId: product.id, quantity: 10 }, + { productId: product2.id, quantity: 10 }, + ] + ); - await test.step('Start receving process', async () => { - await stockMovementShowPage.receiveButton.click(); + await stockMovementService.sendInboundStockMovement(STOCK_MOVEMENT.id, { + shipmentType: ShipmentType.AIR, }); + } + ); - await test.step('Assert error on stock movement show page', async () => { - await stockMovementShowPage.isLoaded(); - await expect(stockMovementShowPage.errorMessage).toBeVisible(); - await expect(stockMovementShowPage.errorMessage).toContainText( - 'To receive this Stock Movement, please log in to the destination location' - ); - }); + test.afterEach( + async ({ authService, stockMovementShowPage, stockMovementService }) => { + await authService.changeLocation(AppConfig.instance.locations.main.id); + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await stockMovementShowPage.rollbackButton.click(); + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + } + ); + + test('Receiving should not be available from other location than which is specfied as destination location', async ({ + stockMovementShowPage, + depotLocationService, + navbar, + locationChooser, + }) => { + const OTHER_LOCATION = await depotLocationService.getLocation(); + + await test.step('Go to stock movement show page', async () => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await stockMovementShowPage.isLoaded(); + }); + + await test.step('Switch locations', async () => { + await navbar.locationChooserButton.click(); + await locationChooser + .getOrganization(OTHER_LOCATION.organization?.name as string) + .click(); + await locationChooser.getLocation(OTHER_LOCATION.name).click(); + }); + + await test.step('Assert location in location chooser button should be updated', async () => { + await expect(navbar.locationChooserButton).toContainText( + OTHER_LOCATION.name + ); + await stockMovementShowPage.isLoaded(); + }); + + await test.step('Start receving process', async () => { + await stockMovementShowPage.receiveButton.click(); + }); + + await test.step('Assert error on stock movement show page', async () => { + await stockMovementShowPage.isLoaded(); + await expect(stockMovementShowPage.errorMessage).toBeVisible(); + await expect(stockMovementShowPage.errorMessage).toContainText( + 'To receive this Stock Movement, please log in to the destination location' + ); }); }); }); diff --git a/src/tests/receiving/receiveToHoldBin.test.ts b/src/tests/receiving/receiveToHoldBin.test.ts index 805d3732..0ddc6604 100644 --- a/src/tests/receiving/receiveToHoldBin.test.ts +++ b/src/tests/receiving/receiveToHoldBin.test.ts @@ -1,3 +1,4 @@ +import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; @@ -89,13 +90,15 @@ test.describe('Receive item into hold bin', () => { mainLocationService, createLocationPage, }) => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.rollbackLastReceiptButton.click(); await stockMovementShowPage.rollbackButton.click(); await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); await test.step('Deatitave created bin location', async () => { - const mainLocation = await mainLocationService.getLocation(); await page.goto('./location/list'); await locationListPage.searchByLocationNameField.fill( mainLocation.name @@ -119,6 +122,22 @@ test.describe('Receive item into hold bin', () => { await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); await createLocationPage.locationConfigurationTabSection.saveButton.click(); }); + + await test.step('Deactivate receiving bin', async () => { + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); } ); diff --git a/src/tests/receiving/receivingStatusChanges.test.ts b/src/tests/receiving/receivingStatusChanges.test.ts index 90e9c47d..c61694b1 100644 --- a/src/tests/receiving/receivingStatusChanges.test.ts +++ b/src/tests/receiving/receivingStatusChanges.test.ts @@ -1,3 +1,4 @@ +import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import InboundListPage from '@/pages/inbound/list/InboundListPage'; @@ -41,24 +42,57 @@ test.describe('Status changes on sm view page when receive shipment', () => { } ); - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - const isRollbackLastReceiptButtonVisible = - await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); - const isRollbackButtonVisible = - await stockMovementShowPage.rollbackButton.isVisible(); - - // due to failed test, shipment might not be received which will not show the button - if (isRollbackLastReceiptButtonVisible) { - await stockMovementShowPage.rollbackLastReceiptButton.click(); - } - - if (isRollbackButtonVisible) { - await stockMovementShowPage.rollbackButton.click(); + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + mainLocationService, + page, + locationListPage, + createLocationPage, + }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + const isRollbackLastReceiptButtonVisible = + await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); + const isRollbackButtonVisible = + await stockMovementShowPage.rollbackButton.isVisible(); + + // due to failed test, shipment might not be received which will not show the button + if (isRollbackLastReceiptButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } + + if (isRollbackButtonVisible) { + await stockMovementShowPage.rollbackButton.click(); + } + + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + await test.step('Deactivate receiving bin', async () => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); } - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - }); + ); test('Assert status changes on view page and receipt tab when receive 1 item partially', async ({ stockMovementShowPage, diff --git a/src/tests/receiving/rollbackStatusChanges.test.ts b/src/tests/receiving/rollbackStatusChanges.test.ts index 0bf1c0fb..3f35b4f3 100644 --- a/src/tests/receiving/rollbackStatusChanges.test.ts +++ b/src/tests/receiving/rollbackStatusChanges.test.ts @@ -1,3 +1,4 @@ +import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import InboundListPage from '@/pages/inbound/list/InboundListPage'; @@ -41,11 +42,45 @@ test.describe('Status changes on sm view page when rollback receipts', () => { } ); - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.rollbackButton.click(); - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - }); + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + mainLocationService, + page, + locationListPage, + createLocationPage, + }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await stockMovementShowPage.rollbackButton.click(); + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + await test.step('Deactivate receiving bin', async () => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); + } + ); test('Assert status changes on view page and receipt tab when rollback partial receipt of 1 item', async ({ stockMovementShowPage, diff --git a/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts b/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts index 3bc8364b..77b37c46 100644 --- a/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts +++ b/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts @@ -1,3 +1,4 @@ +import AppConfig from '@/config/AppConfig'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; import { getDateByOffset, getToday } from '@/utils/DateUtils'; @@ -33,24 +34,58 @@ test.describe('Apply sorting by alphabetical order and remain inputs', () => { } ); - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - const isRollbackLastReceiptButtonVisible = - await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); - const isRollbackButtonVisible = - await stockMovementShowPage.rollbackButton.isVisible(); - - // due to failed test, shipment might not be received which will not show the button - if (isRollbackLastReceiptButtonVisible) { - await stockMovementShowPage.rollbackLastReceiptButton.click(); - } - - if (isRollbackButtonVisible) { - await stockMovementShowPage.rollbackButton.click(); + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + mainLocationService, + page, + locationListPage, + createLocationPage, + }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + const isRollbackLastReceiptButtonVisible = + await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); + const isRollbackButtonVisible = + await stockMovementShowPage.rollbackButton.isVisible(); + + // due to failed test, shipment might not be received which will not show the button + if (isRollbackLastReceiptButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } + + if (isRollbackButtonVisible) { + await stockMovementShowPage.rollbackButton.click(); + } + + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + await test.step('Deactivate receiving bin', async () => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); } - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - }); + ); test('Apply sorting by alphabetical order and remain inputs', async ({ stockMovementShowPage, diff --git a/src/tests/receiving/tableShortcutsInReceiving.test.ts b/src/tests/receiving/tableShortcutsInReceiving.test.ts index 065220dc..e79c9997 100644 --- a/src/tests/receiving/tableShortcutsInReceiving.test.ts +++ b/src/tests/receiving/tableShortcutsInReceiving.test.ts @@ -1,3 +1,4 @@ +import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; @@ -57,24 +58,58 @@ test.describe('Use table shortcuts on receiving page', () => { } ); - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - const isRollbackLastReceiptButtonVisible = - await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); - const isRollbackButtonVisible = - await stockMovementShowPage.rollbackButton.isVisible(); + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + mainLocationService, + page, + locationListPage, + createLocationPage, + }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + const isRollbackLastReceiptButtonVisible = + await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); + const isRollbackButtonVisible = + await stockMovementShowPage.rollbackButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button - if (isRollbackLastReceiptButtonVisible) { - await stockMovementShowPage.rollbackLastReceiptButton.click(); - } + // due to failed test, shipment might not be received which will not show the button + if (isRollbackLastReceiptButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } - if (isRollbackButtonVisible) { - await stockMovementShowPage.rollbackButton.click(); - } + if (isRollbackButtonVisible) { + await stockMovementShowPage.rollbackButton.click(); + } - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - }); + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + await test.step('Deactivate receiving bin', async () => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); + } + ); test('Use Ctrl+ArrowDown to copy cell shortcut on receiving now and comment fields', async ({ stockMovementShowPage, @@ -95,7 +130,9 @@ test.describe('Use table shortcuts on receiving page', () => { await receivingPage.receivingStep.table .row(1) .receivingNowField.textbox.fill('10'); - await receivingPage.receivingStep.table.row(1).receivingNowField.textbox.focus(); + await receivingPage.receivingStep.table + .row(1) + .receivingNowField.textbox.focus(); await page.keyboard.press('Control+ArrowDown'); await page.keyboard.press('Control+ArrowDown'); await page.keyboard.press('Control+ArrowDown'); @@ -117,7 +154,9 @@ test.describe('Use table shortcuts on receiving page', () => { await receivingPage.receivingStep.table .row(1) .commentField.textbox.fill(comment1); - await receivingPage.receivingStep.table.row(1).commentField.textbox.focus(); + await receivingPage.receivingStep.table + .row(1) + .commentField.textbox.focus(); await page.keyboard.press('Control+ArrowDown'); await page.keyboard.press('Control+ArrowDown'); await page.keyboard.press('Control+ArrowDown'); @@ -139,7 +178,9 @@ test.describe('Use table shortcuts on receiving page', () => { await receivingPage.receivingStep.table .row(5) .receivingNowField.textbox.fill('5'); - await receivingPage.receivingStep.table.row(5).receivingNowField.textbox.focus(); + await receivingPage.receivingStep.table + .row(5) + .receivingNowField.textbox.focus(); await page.keyboard.press('Control+ArrowDown'); await expect( receivingPage.receivingStep.table.row(6).receivingNowField.textbox @@ -147,7 +188,9 @@ test.describe('Use table shortcuts on receiving page', () => { await receivingPage.receivingStep.table .row(5) .commentField.textbox.fill(comment2); - await receivingPage.receivingStep.table.row(5).commentField.textbox.focus(); + await receivingPage.receivingStep.table + .row(5) + .commentField.textbox.focus(); await page.keyboard.press('Control+ArrowDown'); await expect( receivingPage.receivingStep.table.row(6).commentField.textbox diff --git a/src/tests/receiving/validationsOnDeliverOnDate.test.ts b/src/tests/receiving/validationsOnDeliverOnDate.test.ts index 1f31e211..d88d2fd8 100644 --- a/src/tests/receiving/validationsOnDeliverOnDate.test.ts +++ b/src/tests/receiving/validationsOnDeliverOnDate.test.ts @@ -1,3 +1,4 @@ +import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; @@ -30,11 +31,45 @@ test.describe('Validations on edit Deliver On Date when receiving shipment', () } ); - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.rollbackButton.click(); - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - }); + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + mainLocationService, + page, + locationListPage, + createLocationPage, + }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await stockMovementShowPage.rollbackButton.click(); + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + await test.step('Deactivate receiving bin', async () => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); + } + ); test('Assert validation on try to edit Delivered on Date to future date', async ({ stockMovementShowPage, diff --git a/src/tests/receiving/validationsOnEditAndReceive.test.ts b/src/tests/receiving/validationsOnEditAndReceive.test.ts index 1c510cc2..813c338f 100644 --- a/src/tests/receiving/validationsOnEditAndReceive.test.ts +++ b/src/tests/receiving/validationsOnEditAndReceive.test.ts @@ -1,9 +1,10 @@ +import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; import { getToday } from '@/utils/DateUtils'; -test.describe('Validations on edit and receive inbound stock movement', () => { +test.describe('Assert validation on try to receive not yet shipped inbound', () => { let STOCK_MOVEMENT: StockMovementResponse; const description = 'some description'; const dateRequested = getToday(); @@ -36,20 +37,6 @@ test.describe('Validations on edit and receive inbound stock movement', () => { test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - const isRollbackLastReceiptButtonVisible = - await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); - const isRollbackButtonVisible = - await stockMovementShowPage.rollbackButton.isVisible(); - - // due to failed test, shipment might not be received which will not show the button - if (isRollbackLastReceiptButtonVisible) { - await stockMovementShowPage.rollbackLastReceiptButton.click(); - } - - if (isRollbackButtonVisible) { - await stockMovementShowPage.rollbackButton.click(); - } - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); }); @@ -74,6 +61,91 @@ test.describe('Validations on edit and receive inbound stock movement', () => { ); }); }); +}); + +test.describe('Validations on edit and receive inbound stock movement', () => { + let STOCK_MOVEMENT: StockMovementResponse; + const description = 'some description'; + const dateRequested = getToday(); + + test.beforeEach( + async ({ + supplierLocationService, + stockMovementService, + mainProductService, + }) => { + const supplierLocation = await supplierLocationService.getLocation(); + STOCK_MOVEMENT = await stockMovementService.createInbound({ + originId: supplierLocation.id, + description, + dateRequested, + }); + + const product = await mainProductService.getProduct(); + + await stockMovementService.addItemsToInboundStockMovement( + STOCK_MOVEMENT.id, + [{ productId: product.id, quantity: 10 }] + ); + + await stockMovementService.sendInboundStockMovement(STOCK_MOVEMENT.id, { + shipmentType: ShipmentType.AIR, + }); + } + ); + + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + mainLocationService, + page, + locationListPage, + createLocationPage, + }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + const isRollbackLastReceiptButtonVisible = + await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); + const isRollbackButtonVisible = + await stockMovementShowPage.rollbackButton.isVisible(); + + // due to failed test, shipment might not be received which will not show the button + if (isRollbackLastReceiptButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } + + if (isRollbackButtonVisible) { + await stockMovementShowPage.rollbackButton.click(); + } + + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + await test.step('Deactivate receiving bin', async () => { + const mainLocation = await mainLocationService.getLocation(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); + } + ); test('Assert access to Edit page for partially received and received inbounds', async ({ stockMovementShowPage, From 1361c196f4ce2b19d101492f3284bbf28b217f01 Mon Sep 17 00:00:00 2001 From: Katarzyna Date: Wed, 26 Nov 2025 10:21:46 +0100 Subject: [PATCH 2/4] improvements after review --- .../inbound/createInbound/exportItems.test.ts | 1 - .../receiving/assertBinLocationField.test.ts | 34 +++------- .../assertCreationOfGoodsReceiptNote.test.ts | 33 +++------- .../assertCreationOfReceivingBin.test.ts | 32 +++------ src/tests/receiving/assertQtyInputs.test.ts | 33 +++------- .../receiving/assertRecipientField.test.ts | 33 +++------- .../receiving/cancelRemainingQty.test.ts | 34 +++------- .../editBinLocationWhenReceive.test.ts | 61 ++++++----------- .../receiving/editOriginalLineQtyTo0.test.ts | 65 +++++-------------- src/tests/receiving/editsInReceiving.test.ts | 33 +++------- .../receiving/exportReceivingTemplate.test.ts | 32 +++------ .../receiving/importReceivingTemplate.test.ts | 33 +++------- .../lotExpirySystemUpdateOnReceiving.test.ts | 35 +++------- src/tests/receiving/receiveInbound.test.ts | 33 +++------- ...eiveInboundWithoutPartialReceiving.test.ts | 1 - src/tests/receiving/receiveToHoldBin.test.ts | 23 +++---- .../receiving/receivingStatusChanges.test.ts | 33 +++------- ...atusChangesWithoutPartialReceiving.test.ts | 1 - .../receiving/rollbackStatusChanges.test.ts | 32 +++------ ...ByAlphabeticalOrderAndRemainInputs.test.ts | 33 +++------- .../tableShortcutsInReceiving.test.ts | 33 +++------- .../validationsOnDeliverOnDate.test.ts | 32 +++------ .../validationsOnEditAndReceive.test.ts | 33 +++------- src/utils/BinLocationUtils.ts | 45 +++++++++++++ 24 files changed, 242 insertions(+), 516 deletions(-) create mode 100644 src/utils/BinLocationUtils.ts diff --git a/src/tests/inbound/createInbound/exportItems.test.ts b/src/tests/inbound/createInbound/exportItems.test.ts index f6c6cce0..47eb45d9 100644 --- a/src/tests/inbound/createInbound/exportItems.test.ts +++ b/src/tests/inbound/createInbound/exportItems.test.ts @@ -152,7 +152,6 @@ test.describe('Export all incoming items', () => { const isRollbackButtonVisible = await stockMovementShowPage.rollbackButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button if (isRollbackLastReceiptButtonVisible) { await stockMovementShowPage.rollbackLastReceiptButton.click(); } diff --git a/src/tests/receiving/assertBinLocationField.test.ts b/src/tests/receiving/assertBinLocationField.test.ts index 8a80abcf..91e8ec43 100644 --- a/src/tests/receiving/assertBinLocationField.test.ts +++ b/src/tests/receiving/assertBinLocationField.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; test.describe('Assert bin location not clearable', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -50,7 +51,6 @@ test.describe('Assert bin location not clearable', () => { const isRollbackButtonVisible = await stockMovementShowPage.rollbackButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button if (isRollbackLastReceiptButtonVisible) { await stockMovementShowPage.rollbackLastReceiptButton.click(); } @@ -60,30 +60,14 @@ test.describe('Assert bin location not clearable', () => { } await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - - await test.step('Deactivate receiving bin', async () => { - const mainLocation = await mainLocationService.getLocation(); - const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - await page.goto('./location/list'); - await locationListPage.searchByLocationNameField.fill( - mainLocation.name - ); - await locationListPage.findButton.click(); - await locationListPage.getLocationEditButton(mainLocation.name).click(); - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); diff --git a/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts b/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts index d1676ca2..6b8f6658 100644 --- a/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts +++ b/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; test.describe('Assert Goods Receipt Note is created and opened', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -48,30 +49,14 @@ test.describe('Assert Goods Receipt Note is created and opened', () => { await stockMovementShowPage.rollbackLastReceiptButton.click(); await stockMovementShowPage.rollbackButton.click(); await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - - await test.step('Deactivate receiving bin', async () => { - const mainLocation = await mainLocationService.getLocation(); - const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - await page.goto('./location/list'); - await locationListPage.searchByLocationNameField.fill( - mainLocation.name - ); - await locationListPage.findButton.click(); - await locationListPage.getLocationEditButton(mainLocation.name).click(); - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); diff --git a/src/tests/receiving/assertCreationOfReceivingBin.test.ts b/src/tests/receiving/assertCreationOfReceivingBin.test.ts index 155f954c..90418f45 100644 --- a/src/tests/receiving/assertCreationOfReceivingBin.test.ts +++ b/src/tests/receiving/assertCreationOfReceivingBin.test.ts @@ -4,6 +4,7 @@ import { expect, test } from '@/fixtures/fixtures'; import CreateLocationPage from '@/pages/location/createLocation/CreateLocationPage'; import LocationListPage from '@/pages/location/LocationListPage'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; test.describe('Assert creation of receiving bin', () => { test.describe.configure({ timeout: 60000 }); @@ -55,29 +56,14 @@ test.describe('Assert creation of receiving bin', () => { await stockMovementShowPage.rollbackButton.click(); await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - await test.step('Deactivate receiving bin', async () => { - const mainLocation = await mainLocationService.getLocation(); - const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - await page.goto('./location/list'); - await locationListPage.searchByLocationNameField.fill( - mainLocation.name - ); - await locationListPage.findButton.click(); - await locationListPage.getLocationEditButton(mainLocation.name).click(); - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); diff --git a/src/tests/receiving/assertQtyInputs.test.ts b/src/tests/receiving/assertQtyInputs.test.ts index 1b51265b..042d295b 100644 --- a/src/tests/receiving/assertQtyInputs.test.ts +++ b/src/tests/receiving/assertQtyInputs.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; import { formatDate, getDateByOffset } from '@/utils/DateUtils'; test.describe('Assert if quantity inputs remain when split lines', () => { @@ -57,7 +58,6 @@ test.describe('Assert if quantity inputs remain when split lines', () => { const isRollbackButtonVisible = await stockMovementShowPage.rollbackButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button if (isRollbackLastReceiptButtonVisible) { await stockMovementShowPage.rollbackLastReceiptButton.click(); } @@ -68,29 +68,14 @@ test.describe('Assert if quantity inputs remain when split lines', () => { await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - await test.step('Deactivate receiving bin', async () => { - const mainLocation = await mainLocationService.getLocation(); - const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - await page.goto('./location/list'); - await locationListPage.searchByLocationNameField.fill( - mainLocation.name - ); - await locationListPage.findButton.click(); - await locationListPage.getLocationEditButton(mainLocation.name).click(); - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); diff --git a/src/tests/receiving/assertRecipientField.test.ts b/src/tests/receiving/assertRecipientField.test.ts index 84cdd134..e9f8153e 100644 --- a/src/tests/receiving/assertRecipientField.test.ts +++ b/src/tests/receiving/assertRecipientField.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; test.describe('Assert recipient field when receive', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -59,7 +60,6 @@ test.describe('Assert recipient field when receive', () => { const isRollbackButtonVisible = await stockMovementShowPage.rollbackButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button if (isRollbackLastReceiptButtonVisible) { await stockMovementShowPage.rollbackLastReceiptButton.click(); } @@ -70,29 +70,14 @@ test.describe('Assert recipient field when receive', () => { await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - await test.step('Deactivate receiving bin', async () => { - const mainLocation = await mainLocationService.getLocation(); - const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - await page.goto('./location/list'); - await locationListPage.searchByLocationNameField.fill( - mainLocation.name - ); - await locationListPage.findButton.click(); - await locationListPage.getLocationEditButton(mainLocation.name).click(); - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); diff --git a/src/tests/receiving/cancelRemainingQty.test.ts b/src/tests/receiving/cancelRemainingQty.test.ts index 80e29825..8c1933b1 100644 --- a/src/tests/receiving/cancelRemainingQty.test.ts +++ b/src/tests/receiving/cancelRemainingQty.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; test.describe('Cancel qty in the middle of receipt', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -53,7 +54,6 @@ test.describe('Cancel qty in the middle of receipt', () => { const isRollbackButtonVisible = await stockMovementShowPage.rollbackButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button if (isRollbackLastReceiptButtonVisible) { await stockMovementShowPage.rollbackLastReceiptButton.click(); } @@ -63,30 +63,14 @@ test.describe('Cancel qty in the middle of receipt', () => { } await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - - await test.step('Deactivate receiving bin', async () => { - const mainLocation = await mainLocationService.getLocation(); - const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - await page.goto('./location/list'); - await locationListPage.searchByLocationNameField.fill( - mainLocation.name - ); - await locationListPage.findButton.click(); - await locationListPage.getLocationEditButton(mainLocation.name).click(); - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); diff --git a/src/tests/receiving/editBinLocationWhenReceive.test.ts b/src/tests/receiving/editBinLocationWhenReceive.test.ts index c535ca68..815ca194 100644 --- a/src/tests/receiving/editBinLocationWhenReceive.test.ts +++ b/src/tests/receiving/editBinLocationWhenReceive.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; import UniqueIdentifier from '@/utils/UniqueIdentifier'; test.describe('Edit Bin Location when receive inbound stock movement', () => { @@ -106,20 +107,12 @@ test.describe('Edit Bin Location when receive inbound stock movement', () => { await createLocationPage.locationConfigurationTabSection.saveButton.click(); }); - await test.step('Deactivate receiving bin', async () => { - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); @@ -323,20 +316,12 @@ test.describe('Edit Bin Location to bin with zone when receive inbound stock mov await createLocationPage.locationConfigurationTabSection.saveButton.click(); }); - await test.step('Deactivate receiving bin', async () => { - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); @@ -509,20 +494,12 @@ test.describe('Edit Bin Location when receive for all lines', () => { await createLocationPage.locationConfigurationTabSection.saveButton.click(); }); - await test.step('Deactivate receiving bin', async () => { - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); diff --git a/src/tests/receiving/editOriginalLineQtyTo0.test.ts b/src/tests/receiving/editOriginalLineQtyTo0.test.ts index baa3c316..5d0506f1 100644 --- a/src/tests/receiving/editOriginalLineQtyTo0.test.ts +++ b/src/tests/receiving/editOriginalLineQtyTo0.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; import { getDateByOffset } from '@/utils/DateUtils'; import UniqueIdentifier from '@/utils/UniqueIdentifier'; @@ -72,7 +73,6 @@ test.describe('Edit qty of original line to 0', () => { const isRollbackButtonVisible = await stockMovementShowPage.rollbackButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button if (isRollbackLastReceiptButtonVisible) { await stockMovementShowPage.rollbackLastReceiptButton.click(); } @@ -83,29 +83,14 @@ test.describe('Edit qty of original line to 0', () => { await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - await test.step('Deactivate receiving bin', async () => { - const mainLocation = await mainLocationService.getLocation(); - const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - await page.goto('./location/list'); - await locationListPage.searchByLocationNameField.fill( - mainLocation.name - ); - await locationListPage.findButton.click(); - await locationListPage.getLocationEditButton(mainLocation.name).click(); - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); @@ -289,7 +274,6 @@ test.describe('Edit original line to other product in the middle of receipt', () const isRollbackButtonVisible = await stockMovementShowPage.rollbackButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button if (isRollbackLastReceiptButtonVisible) { await stockMovementShowPage.rollbackLastReceiptButton.click(); } @@ -299,29 +283,14 @@ test.describe('Edit original line to other product in the middle of receipt', () } await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - await test.step('Deactivate receiving bin', async () => { - const mainLocation = await mainLocationService.getLocation(); - const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - await page.goto('./location/list'); - await locationListPage.searchByLocationNameField.fill( - mainLocation.name - ); - await locationListPage.findButton.click(); - await locationListPage.getLocationEditButton(mainLocation.name).click(); - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); diff --git a/src/tests/receiving/editsInReceiving.test.ts b/src/tests/receiving/editsInReceiving.test.ts index 26e67cab..80402a01 100644 --- a/src/tests/receiving/editsInReceiving.test.ts +++ b/src/tests/receiving/editsInReceiving.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; import { formatDate, getDateByOffset, getToday } from '@/utils/DateUtils'; import UniqueIdentifier from '@/utils/UniqueIdentifier'; @@ -62,7 +63,6 @@ test.describe('Edit items in the middle of receipt', () => { const isRollbackButtonVisible = await stockMovementShowPage.rollbackButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button if (isRollbackLastReceiptButtonVisible) { await stockMovementShowPage.rollbackLastReceiptButton.click(); } @@ -73,29 +73,14 @@ test.describe('Edit items in the middle of receipt', () => { await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - await test.step('Deactivate receiving bin', async () => { - const mainLocation = await mainLocationService.getLocation(); - const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - await page.goto('./location/list'); - await locationListPage.searchByLocationNameField.fill( - mainLocation.name - ); - await locationListPage.findButton.click(); - await locationListPage.getLocationEditButton(mainLocation.name).click(); - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); diff --git a/src/tests/receiving/exportReceivingTemplate.test.ts b/src/tests/receiving/exportReceivingTemplate.test.ts index f218a3f0..5a54bbf7 100644 --- a/src/tests/receiving/exportReceivingTemplate.test.ts +++ b/src/tests/receiving/exportReceivingTemplate.test.ts @@ -4,6 +4,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; import { formatDate, getDateByOffset } from '@/utils/DateUtils'; import UniqueIdentifier from '@/utils/UniqueIdentifier'; import { WorkbookUtils } from '@/utils/WorkbookUtils'; @@ -69,29 +70,14 @@ test.describe('Export receiving template', () => { workbook.delete(); } - await test.step('Deactivate receiving bin', async () => { - const mainLocation = await mainLocationService.getLocation(); - const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - await page.goto('./location/list'); - await locationListPage.searchByLocationNameField.fill( - mainLocation.name - ); - await locationListPage.findButton.click(); - await locationListPage.getLocationEditButton(mainLocation.name).click(); - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); diff --git a/src/tests/receiving/importReceivingTemplate.test.ts b/src/tests/receiving/importReceivingTemplate.test.ts index 172bff67..8cd7854c 100644 --- a/src/tests/receiving/importReceivingTemplate.test.ts +++ b/src/tests/receiving/importReceivingTemplate.test.ts @@ -4,6 +4,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; import { getDateByOffset } from '@/utils/DateUtils'; import UniqueIdentifier from '@/utils/UniqueIdentifier'; import { WorkbookUtils } from '@/utils/WorkbookUtils'; @@ -61,7 +62,6 @@ test.describe('Import receiving template', () => { const isButtonVisible = await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button if (isButtonVisible) { await stockMovementShowPage.rollbackLastReceiptButton.click(); } @@ -74,29 +74,14 @@ test.describe('Import receiving template', () => { workbook.delete(); } - await test.step('Deactivate receiving bin', async () => { - const mainLocation = await mainLocationService.getLocation(); - const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - await page.goto('./location/list'); - await locationListPage.searchByLocationNameField.fill( - mainLocation.name - ); - await locationListPage.findButton.click(); - await locationListPage.getLocationEditButton(mainLocation.name).click(); - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); diff --git a/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts b/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts index 8eaed9ea..6c4d65a9 100644 --- a/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts +++ b/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; import { formatDate, getDateByOffset, getToday } from '@/utils/DateUtils'; import UniqueIdentifier from '@/utils/UniqueIdentifier'; @@ -29,7 +30,6 @@ test.describe('Lot number system expiry date modification on receiving workflow' const isButtonVisible = await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button if (isButtonVisible) { await stockMovementShowPage.rollbackLastReceiptButton.click(); } @@ -42,31 +42,14 @@ test.describe('Lot number system expiry date modification on receiving workflow' await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); }); - await test.step('Deactivate receiving bin', async () => { - const mainLocation = await mainLocationService.getLocation(); - const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - await page.goto('./location/list'); - await locationListPage.searchByLocationNameField.fill( - mainLocation.name - ); - await locationListPage.findButton.click(); - await locationListPage - .getLocationEditButton(mainLocation.name) - .click(); - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } } diff --git a/src/tests/receiving/receiveInbound.test.ts b/src/tests/receiving/receiveInbound.test.ts index cc544c5e..8ea40176 100644 --- a/src/tests/receiving/receiveInbound.test.ts +++ b/src/tests/receiving/receiveInbound.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; import { formatDate, getToday } from '@/utils/DateUtils'; test.describe('Receive inbound stock movement', () => { @@ -54,7 +55,6 @@ test.describe('Receive inbound stock movement', () => { const isButtonVisible = await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button if (isButtonVisible) { await stockMovementShowPage.rollbackLastReceiptButton.click(); } @@ -63,29 +63,14 @@ test.describe('Receive inbound stock movement', () => { await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - await test.step('Deactivate receiving bin', async () => { - const mainLocation = await mainLocationService.getLocation(); - const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - await page.goto('./location/list'); - await locationListPage.searchByLocationNameField.fill( - mainLocation.name - ); - await locationListPage.findButton.click(); - await locationListPage.getLocationEditButton(mainLocation.name).click(); - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); diff --git a/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts b/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts index a99f753f..344545eb 100644 --- a/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts +++ b/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts @@ -50,7 +50,6 @@ test.describe('Receive inbound stock movement in location without partial receiv const isRollbackButtonVisible = await stockMovementShowPage.rollbackButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button if (isRollbackLastReceiptButtonVisible) { await stockMovementShowPage.rollbackLastReceiptButton.click(); } diff --git a/src/tests/receiving/receiveToHoldBin.test.ts b/src/tests/receiving/receiveToHoldBin.test.ts index 0ddc6604..82b7fe9d 100644 --- a/src/tests/receiving/receiveToHoldBin.test.ts +++ b/src/tests/receiving/receiveToHoldBin.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; import UniqueIdentifier from '@/utils/UniqueIdentifier'; test.describe('Receive item into hold bin', () => { @@ -98,7 +99,7 @@ test.describe('Receive item into hold bin', () => { await stockMovementShowPage.rollbackButton.click(); await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - await test.step('Deatitave created bin location', async () => { + await test.step('Deactitave created bin location', async () => { await page.goto('./location/list'); await locationListPage.searchByLocationNameField.fill( mainLocation.name @@ -123,20 +124,12 @@ test.describe('Receive item into hold bin', () => { await createLocationPage.locationConfigurationTabSection.saveButton.click(); }); - await test.step('Deactivate receiving bin', async () => { - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); diff --git a/src/tests/receiving/receivingStatusChanges.test.ts b/src/tests/receiving/receivingStatusChanges.test.ts index c61694b1..da11fc32 100644 --- a/src/tests/receiving/receivingStatusChanges.test.ts +++ b/src/tests/receiving/receivingStatusChanges.test.ts @@ -4,6 +4,7 @@ import { expect, test } from '@/fixtures/fixtures'; import InboundListPage from '@/pages/inbound/list/InboundListPage'; import StockMovementShowPage from '@/pages/stockMovementShow/StockMovementShowPage'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; import { getToday } from '@/utils/DateUtils'; test.describe('Status changes on sm view page when receive shipment', () => { @@ -57,7 +58,6 @@ test.describe('Status changes on sm view page when receive shipment', () => { const isRollbackButtonVisible = await stockMovementShowPage.rollbackButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button if (isRollbackLastReceiptButtonVisible) { await stockMovementShowPage.rollbackLastReceiptButton.click(); } @@ -67,29 +67,14 @@ test.describe('Status changes on sm view page when receive shipment', () => { } await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - await test.step('Deactivate receiving bin', async () => { - const mainLocation = await mainLocationService.getLocation(); - const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - await page.goto('./location/list'); - await locationListPage.searchByLocationNameField.fill( - mainLocation.name - ); - await locationListPage.findButton.click(); - await locationListPage.getLocationEditButton(mainLocation.name).click(); - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); diff --git a/src/tests/receiving/receivingStatusChangesWithoutPartialReceiving.test.ts b/src/tests/receiving/receivingStatusChangesWithoutPartialReceiving.test.ts index 81f7c7a1..1a563705 100644 --- a/src/tests/receiving/receivingStatusChangesWithoutPartialReceiving.test.ts +++ b/src/tests/receiving/receivingStatusChangesWithoutPartialReceiving.test.ts @@ -52,7 +52,6 @@ test.describe('Status changes on sm view page when receive shipment in location const isRollbackButtonVisible = await stockMovementShowPage.rollbackButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button if (isRollbackLastReceiptButtonVisible) { await stockMovementShowPage.rollbackLastReceiptButton.click(); } diff --git a/src/tests/receiving/rollbackStatusChanges.test.ts b/src/tests/receiving/rollbackStatusChanges.test.ts index 3f35b4f3..621139de 100644 --- a/src/tests/receiving/rollbackStatusChanges.test.ts +++ b/src/tests/receiving/rollbackStatusChanges.test.ts @@ -4,6 +4,7 @@ import { expect, test } from '@/fixtures/fixtures'; import InboundListPage from '@/pages/inbound/list/InboundListPage'; import StockMovementShowPage from '@/pages/stockMovementShow/StockMovementShowPage'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; import { getToday } from '@/utils/DateUtils'; test.describe('Status changes on sm view page when rollback receipts', () => { @@ -55,29 +56,14 @@ test.describe('Status changes on sm view page when rollback receipts', () => { await stockMovementShowPage.rollbackButton.click(); await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - await test.step('Deactivate receiving bin', async () => { - const mainLocation = await mainLocationService.getLocation(); - const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - await page.goto('./location/list'); - await locationListPage.searchByLocationNameField.fill( - mainLocation.name - ); - await locationListPage.findButton.click(); - await locationListPage.getLocationEditButton(mainLocation.name).click(); - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); diff --git a/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts b/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts index 77b37c46..64f9d371 100644 --- a/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts +++ b/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts @@ -1,6 +1,7 @@ import AppConfig from '@/config/AppConfig'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; import { getDateByOffset, getToday } from '@/utils/DateUtils'; test.describe('Apply sorting by alphabetical order and remain inputs', () => { @@ -49,7 +50,6 @@ test.describe('Apply sorting by alphabetical order and remain inputs', () => { const isRollbackButtonVisible = await stockMovementShowPage.rollbackButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button if (isRollbackLastReceiptButtonVisible) { await stockMovementShowPage.rollbackLastReceiptButton.click(); } @@ -60,29 +60,14 @@ test.describe('Apply sorting by alphabetical order and remain inputs', () => { await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - await test.step('Deactivate receiving bin', async () => { - const mainLocation = await mainLocationService.getLocation(); - const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - await page.goto('./location/list'); - await locationListPage.searchByLocationNameField.fill( - mainLocation.name - ); - await locationListPage.findButton.click(); - await locationListPage.getLocationEditButton(mainLocation.name).click(); - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); diff --git a/src/tests/receiving/tableShortcutsInReceiving.test.ts b/src/tests/receiving/tableShortcutsInReceiving.test.ts index e79c9997..313e9b38 100644 --- a/src/tests/receiving/tableShortcutsInReceiving.test.ts +++ b/src/tests/receiving/tableShortcutsInReceiving.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; test.describe('Use table shortcuts on receiving page', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -73,7 +74,6 @@ test.describe('Use table shortcuts on receiving page', () => { const isRollbackButtonVisible = await stockMovementShowPage.rollbackButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button if (isRollbackLastReceiptButtonVisible) { await stockMovementShowPage.rollbackLastReceiptButton.click(); } @@ -84,29 +84,14 @@ test.describe('Use table shortcuts on receiving page', () => { await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - await test.step('Deactivate receiving bin', async () => { - const mainLocation = await mainLocationService.getLocation(); - const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - await page.goto('./location/list'); - await locationListPage.searchByLocationNameField.fill( - mainLocation.name - ); - await locationListPage.findButton.click(); - await locationListPage.getLocationEditButton(mainLocation.name).click(); - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); diff --git a/src/tests/receiving/validationsOnDeliverOnDate.test.ts b/src/tests/receiving/validationsOnDeliverOnDate.test.ts index d88d2fd8..0d870227 100644 --- a/src/tests/receiving/validationsOnDeliverOnDate.test.ts +++ b/src/tests/receiving/validationsOnDeliverOnDate.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; import { getDateByOffset } from '@/utils/DateUtils'; test.describe('Validations on edit Deliver On Date when receiving shipment', () => { @@ -44,29 +45,14 @@ test.describe('Validations on edit Deliver On Date when receiving shipment', () await stockMovementShowPage.rollbackButton.click(); await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - await test.step('Deactivate receiving bin', async () => { - const mainLocation = await mainLocationService.getLocation(); - const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - await page.goto('./location/list'); - await locationListPage.searchByLocationNameField.fill( - mainLocation.name - ); - await locationListPage.findButton.click(); - await locationListPage.getLocationEditButton(mainLocation.name).click(); - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); diff --git a/src/tests/receiving/validationsOnEditAndReceive.test.ts b/src/tests/receiving/validationsOnEditAndReceive.test.ts index 813c338f..80cfd592 100644 --- a/src/tests/receiving/validationsOnEditAndReceive.test.ts +++ b/src/tests/receiving/validationsOnEditAndReceive.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import BinLocationUtils from '@/utils/BinLocationUtils'; import { getToday } from '@/utils/DateUtils'; test.describe('Assert validation on try to receive not yet shipped inbound', () => { @@ -109,7 +110,6 @@ test.describe('Validations on edit and receive inbound stock movement', () => { const isRollbackButtonVisible = await stockMovementShowPage.rollbackButton.isVisible(); - // due to failed test, shipment might not be received which will not show the button if (isRollbackLastReceiptButtonVisible) { await stockMovementShowPage.rollbackLastReceiptButton.click(); } @@ -120,29 +120,14 @@ test.describe('Validations on edit and receive inbound stock movement', () => { await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - await test.step('Deactivate receiving bin', async () => { - const mainLocation = await mainLocationService.getLocation(); - const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - await page.goto('./location/list'); - await locationListPage.searchByLocationNameField.fill( - mainLocation.name - ); - await locationListPage.findButton.click(); - await locationListPage.getLocationEditButton(mainLocation.name).click(); - await createLocationPage.binLocationTab.click(); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.searchField.fill( - receivingBin - ); - await createLocationPage.binLocationTabSection.searchField.press( - 'Enter' - ); - await createLocationPage.binLocationTabSection.isLoaded(); - await createLocationPage.binLocationTabSection.editBinButton.click(); - await createLocationPage.locationConfigurationTab.click(); - await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); - await createLocationPage.locationConfigurationTabSection.saveButton.click(); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, }); } ); diff --git a/src/utils/BinLocationUtils.ts b/src/utils/BinLocationUtils.ts new file mode 100644 index 00000000..3ad70788 --- /dev/null +++ b/src/utils/BinLocationUtils.ts @@ -0,0 +1,45 @@ +import { Page } from '@playwright/test'; + +import BasePageModel from '@/pages/BasePageModel'; +import CreateLocationPage from '@/pages/location/createLocation/CreateLocationPage'; +import LocationListPage from '@/pages/location/LocationListPage'; +import LocationData from '@/utils/LocationData'; + +class BinLocationUtils extends BasePageModel { + constructor(page: Page) { + super(page); + } + + static async deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }: { + mainLocationService: LocationData; + locationListPage: LocationListPage; + createLocationPage: CreateLocationPage; + page: Page; + receivingBin: string; + }) { + const mainLocation = await mainLocationService.getLocation(); + await page.goto('./location/list'); + await locationListPage.searchByLocationNameField.fill(mainLocation.name); + await locationListPage.findButton.click(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + receivingBin + ); + await createLocationPage.binLocationTabSection.searchField.press('Enter'); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + } +} + +export default BinLocationUtils; From 07ef2a66bd979ff3a4d17d71951b98f6288dd3c4 Mon Sep 17 00:00:00 2001 From: Alan Nadolny <83239466+alannadolny@users.noreply.github.com> Date: Wed, 26 Nov 2025 11:22:09 +0100 Subject: [PATCH 3/4] Update src/utils/BinLocationUtils.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/utils/BinLocationUtils.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/utils/BinLocationUtils.ts b/src/utils/BinLocationUtils.ts index 3ad70788..b7b9b73f 100644 --- a/src/utils/BinLocationUtils.ts +++ b/src/utils/BinLocationUtils.ts @@ -5,11 +5,7 @@ import CreateLocationPage from '@/pages/location/createLocation/CreateLocationPa import LocationListPage from '@/pages/location/LocationListPage'; import LocationData from '@/utils/LocationData'; -class BinLocationUtils extends BasePageModel { - constructor(page: Page) { - super(page); - } - +class BinLocationUtils { static async deactivateReceivingBin({ mainLocationService, locationListPage, From 93b0885213cb2c3058780acf17edaea73bcd0ebe Mon Sep 17 00:00:00 2001 From: Alan Nadolny <83239466+alannadolny@users.noreply.github.com> Date: Wed, 26 Nov 2025 11:24:12 +0100 Subject: [PATCH 4/4] Update src/utils/BinLocationUtils.ts --- src/utils/BinLocationUtils.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils/BinLocationUtils.ts b/src/utils/BinLocationUtils.ts index b7b9b73f..e41c53f6 100644 --- a/src/utils/BinLocationUtils.ts +++ b/src/utils/BinLocationUtils.ts @@ -1,6 +1,5 @@ import { Page } from '@playwright/test'; -import BasePageModel from '@/pages/BasePageModel'; import CreateLocationPage from '@/pages/location/createLocation/CreateLocationPage'; import LocationListPage from '@/pages/location/LocationListPage'; import LocationData from '@/utils/LocationData';