diff --git a/src/tests/inbound/createInbound/exportItems.test.ts b/src/tests/inbound/createInbound/exportItems.test.ts index f6c6cce..47eb45d 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 7dcd40b..91e8ec4 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; @@ -35,24 +36,41 @@ 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(); - } + 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); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); + } + ); test('Assert bin location not clearable', async ({ stockMovementShowPage, @@ -69,7 +87,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 +107,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 05eead7..6b8f665 100644 --- a/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts +++ b/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts @@ -1,6 +1,8 @@ +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; @@ -34,12 +36,30 @@ 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); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); + } + ); 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 6245728..90418f4 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 }); @@ -42,11 +43,30 @@ 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); + + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); + } + ); 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 a74d102..042d295 100644 --- a/src/tests/receiving/assertQtyInputs.test.ts +++ b/src/tests/receiving/assertQtyInputs.test.ts @@ -1,6 +1,8 @@ +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', () => { @@ -41,24 +43,42 @@ 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(); - } + 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); + + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); + } + ); 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 083c32e..e9f8153 100644 --- a/src/tests/receiving/assertRecipientField.test.ts +++ b/src/tests/receiving/assertRecipientField.test.ts @@ -1,6 +1,8 @@ +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; @@ -43,24 +45,42 @@ 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(); + + if (isRollbackLastReceiptButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } + + if (isRollbackButtonVisible) { + await stockMovementShowPage.rollbackButton.click(); + } + + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); } - - 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 827b876..8c1933b 100644 --- a/src/tests/receiving/cancelRemainingQty.test.ts +++ b/src/tests/receiving/cancelRemainingQty.test.ts @@ -1,6 +1,8 @@ +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; @@ -37,24 +39,41 @@ 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(); + + if (isRollbackLastReceiptButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } + + if (isRollbackButtonVisible) { + await stockMovementShowPage.rollbackButton.click(); + } + + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); } - - 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 086c2fd..815ca19 100644 --- a/src/tests/receiving/editBinLocationWhenReceive.test.ts +++ b/src/tests/receiving/editBinLocationWhenReceive.test.ts @@ -1,6 +1,8 @@ +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', () => { @@ -72,13 +74,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 +106,14 @@ test.describe('Edit Bin Location when receive inbound stock movement', () => { await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); await createLocationPage.locationConfigurationTabSection.saveButton.click(); }); + + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); } ); @@ -255,13 +267,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 +315,14 @@ 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 BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); } ); @@ -439,13 +461,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 +493,14 @@ test.describe('Edit Bin Location when receive for all lines', () => { 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 801b95c..5d0506f 100644 --- a/src/tests/receiving/editOriginalLineQtyTo0.test.ts +++ b/src/tests/receiving/editOriginalLineQtyTo0.test.ts @@ -1,6 +1,8 @@ +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'; @@ -56,24 +58,42 @@ 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(); + + if (isRollbackLastReceiptButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } + + if (isRollbackButtonVisible) { + await stockMovementShowPage.rollbackButton.click(); + } + + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); } - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - }); + ); test('Edit qty of original line to 0', async ({ stockMovementShowPage, @@ -239,24 +259,41 @@ 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(); + + if (isRollbackLastReceiptButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } + + if (isRollbackButtonVisible) { + await stockMovementShowPage.rollbackButton.click(); + } + + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); } - - 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 2deeb46..80402a0 100644 --- a/src/tests/receiving/editsInReceiving.test.ts +++ b/src/tests/receiving/editsInReceiving.test.ts @@ -1,6 +1,8 @@ +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'; @@ -46,24 +48,42 @@ 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(); + + if (isRollbackLastReceiptButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } + + if (isRollbackButtonVisible) { + await stockMovementShowPage.rollbackButton.click(); + } + + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); } - - 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 54414a6..5a54bbf 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'; @@ -51,23 +52,42 @@ 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(); + } + + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); } - }); + ); 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 9a765bc..8cd7854 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'; @@ -48,24 +49,42 @@ test.describe('Import receiving template', () => { } ); - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - const isButtonVisible = - await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); + 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(); - } + if (isButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } - await stockMovementShowPage.rollbackButton.click(); + await stockMovementShowPage.rollbackButton.click(); - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - for (const workbook of workbooks) { - workbook.delete(); + for (const workbook of workbooks) { + workbook.delete(); + } + + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); } - }); + ); test('Receive shipment using import receiving template', async ({ stockMovementShowPage, @@ -110,7 +129,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 +212,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 97ed740..6c4d65a 100644 --- a/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts +++ b/src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts @@ -1,39 +1,59 @@ +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'; 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(); + 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); + }); + + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); + } } - }); + ); 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 f117607..8ea4017 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', () => { @@ -41,20 +42,38 @@ test.describe('Receive inbound stock movement', () => { } ); - test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - const isButtonVisible = - await stockMovementShowPage.rollbackLastReceiptButton.isVisible(); + 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(); - } + if (isButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } - await stockMovementShowPage.rollbackButton.click(); + await stockMovementShowPage.rollbackButton.click(); - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); - }); + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); + } + ); test('Receive inbound stock movement', async ({ stockMovementShowPage, @@ -359,51 +378,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/receiveInboundWithoutPartialReceiving.test.ts b/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts index a99f753..344545e 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 805d373..82b7fe9 100644 --- a/src/tests/receiving/receiveToHoldBin.test.ts +++ b/src/tests/receiving/receiveToHoldBin.test.ts @@ -1,6 +1,8 @@ +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', () => { @@ -89,13 +91,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 test.step('Deactitave created bin location', async () => { await page.goto('./location/list'); await locationListPage.searchByLocationNameField.fill( mainLocation.name @@ -119,6 +123,14 @@ test.describe('Receive item into hold bin', () => { 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 90e9c47..da11fc3 100644 --- a/src/tests/receiving/receivingStatusChanges.test.ts +++ b/src/tests/receiving/receivingStatusChanges.test.ts @@ -1,8 +1,10 @@ +import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; 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', () => { @@ -41,24 +43,41 @@ 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(); + + if (isRollbackLastReceiptButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } + + if (isRollbackButtonVisible) { + await stockMovementShowPage.rollbackButton.click(); + } + + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); } - - 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/receivingStatusChangesWithoutPartialReceiving.test.ts b/src/tests/receiving/receivingStatusChangesWithoutPartialReceiving.test.ts index 81f7c7a..1a56370 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 0bf1c0f..621139d 100644 --- a/src/tests/receiving/rollbackStatusChanges.test.ts +++ b/src/tests/receiving/rollbackStatusChanges.test.ts @@ -1,8 +1,10 @@ +import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; 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', () => { @@ -41,11 +43,30 @@ 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); + + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); + } + ); 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 3bc8364..64f9d37 100644 --- a/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts +++ b/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts @@ -1,5 +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', () => { @@ -33,24 +35,42 @@ 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(); + + if (isRollbackLastReceiptButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } + + if (isRollbackButtonVisible) { + await stockMovementShowPage.rollbackButton.click(); + } + + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); } - - 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 065220d..313e9b3 100644 --- a/src/tests/receiving/tableShortcutsInReceiving.test.ts +++ b/src/tests/receiving/tableShortcutsInReceiving.test.ts @@ -1,6 +1,8 @@ +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; @@ -57,24 +59,42 @@ 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(); - } + 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); + + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); + } + ); test('Use Ctrl+ArrowDown to copy cell shortcut on receiving now and comment fields', async ({ stockMovementShowPage, @@ -95,7 +115,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 +139,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 +163,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 +173,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 1f31e21..0d87022 100644 --- a/src/tests/receiving/validationsOnDeliverOnDate.test.ts +++ b/src/tests/receiving/validationsOnDeliverOnDate.test.ts @@ -1,6 +1,8 @@ +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', () => { @@ -30,11 +32,30 @@ 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); + + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); + } + ); 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 1c510cc..80cfd59 100644 --- a/src/tests/receiving/validationsOnEditAndReceive.test.ts +++ b/src/tests/receiving/validationsOnEditAndReceive.test.ts @@ -1,9 +1,11 @@ +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('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 +38,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 +62,75 @@ 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(); + + if (isRollbackLastReceiptButtonVisible) { + await stockMovementShowPage.rollbackLastReceiptButton.click(); + } + + if (isRollbackButtonVisible) { + await stockMovementShowPage.rollbackButton.click(); + } + + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + await BinLocationUtils.deactivateReceivingBin({ + mainLocationService, + locationListPage, + createLocationPage, + page, + receivingBin, + }); + } + ); test('Assert access to Edit page for partially received and received inbounds', async ({ stockMovementShowPage, diff --git a/src/utils/BinLocationUtils.ts b/src/utils/BinLocationUtils.ts new file mode 100644 index 0000000..e41c53f --- /dev/null +++ b/src/utils/BinLocationUtils.ts @@ -0,0 +1,40 @@ +import { Page } from '@playwright/test'; + +import CreateLocationPage from '@/pages/location/createLocation/CreateLocationPage'; +import LocationListPage from '@/pages/location/LocationListPage'; +import LocationData from '@/utils/LocationData'; + +class BinLocationUtils { + 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;