From c4d3af460c2dfb30eb1d44112d73aacc8f71867c Mon Sep 17 00:00:00 2001 From: Katarzyna Date: Thu, 16 Apr 2026 11:33:17 +0200 Subject: [PATCH 1/6] add elements to pages --- .../productShow/tabs/InStockTabSection.ts | 16 ++++++++++++++++ .../putaway/components/CreatePutawayTable.ts | 15 ++++++++++++--- .../putaway/components/StartPutawayTable.ts | 8 ++++++++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/pages/product/productShow/tabs/InStockTabSection.ts b/src/pages/product/productShow/tabs/InStockTabSection.ts index 5c3c852..12e4524 100644 --- a/src/pages/product/productShow/tabs/InStockTabSection.ts +++ b/src/pages/product/productShow/tabs/InStockTabSection.ts @@ -1,10 +1,14 @@ import { expect, Locator, Page } from '@playwright/test'; import BasePageModel from '@/pages/BasePageModel'; +import StockTransferDialog from '@/pages/product/productShow/sections/components/StockTransferDialog'; class InStockTabSection extends BasePageModel { + stockTransferDialog: StockTransferDialog; + constructor(page: Page) { super(page); + this.stockTransferDialog = new StockTransferDialog(page); } async isLoaded() { @@ -24,6 +28,10 @@ class InStockTabSection extends BasePageModel { row(index: number) { return new Row(this.page, this.rows.nth(index)); } + + get stockTransferButton() { + return this.page.getByRole('link', { name: 'Transfer Stock' }); + } } class Row extends BasePageModel { @@ -59,6 +67,14 @@ class Row extends BasePageModel { get quantityOnHand() { return this.row.locator('td').nth(4); } + + get lot() { + return this.row.locator('td').nth(2); + } + + get expires() { + return this.row.locator('td').nth(3); + } } export default InStockTabSection; diff --git a/src/pages/putaway/components/CreatePutawayTable.ts b/src/pages/putaway/components/CreatePutawayTable.ts index df479e5..e90442a 100644 --- a/src/pages/putaway/components/CreatePutawayTable.ts +++ b/src/pages/putaway/components/CreatePutawayTable.ts @@ -1,6 +1,7 @@ import { Locator, Page } from '@playwright/test'; import BasePageModel from '@/pages/BasePageModel'; +import { formatDate } from '@/utils/DateUtils'; class CreatePutawayTable extends BasePageModel { constructor(page: Page) { @@ -33,9 +34,7 @@ class Row extends BasePageModel { } getExpandBinLocation(binLocation: string) { - return this.row - .getByTestId('table-cell') - .getByText(binLocation); + return this.row.getByTestId('table-cell').getByText(binLocation); } get receivingBin() { @@ -45,6 +44,16 @@ class Row extends BasePageModel { getProductName(name: string) { return this.row.getByTestId('table-cell').getByText(name); } + + getLot(lot: string) { + return this.row.getByTestId('table-cell').getByText(lot); + } + + getExpDate(expDate: Date) { + return this.row + .getByTestId('table-cell') + .getByText(formatDate(expDate, 'MM/DD/YYYY').toString()); + } } export default CreatePutawayTable; diff --git a/src/pages/putaway/components/StartPutawayTable.ts b/src/pages/putaway/components/StartPutawayTable.ts index b716d61..fbd8305 100644 --- a/src/pages/putaway/components/StartPutawayTable.ts +++ b/src/pages/putaway/components/StartPutawayTable.ts @@ -82,6 +82,14 @@ class Row extends BasePageModel { get splitLineInPutawayBin() { return this.row.getByTestId('open-modal'); } + + get lotField() { + return this.row.getByTestId('table-cell').nth(4); + } + + get expiryDateField() { + return this.row.getByTestId('table-cell').nth(5); + } } export default StartPutawayTable; From ad8f9acd6cd069b71678a615adaabde559c52179 Mon Sep 17 00:00:00 2001 From: Katarzyna Date: Thu, 16 Apr 2026 11:33:50 +0200 Subject: [PATCH 2/6] add stock transfer dialog --- .../components/StockTransferDialog.ts | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/pages/product/productShow/sections/components/StockTransferDialog.ts diff --git a/src/pages/product/productShow/sections/components/StockTransferDialog.ts b/src/pages/product/productShow/sections/components/StockTransferDialog.ts new file mode 100644 index 0000000..b2443b5 --- /dev/null +++ b/src/pages/product/productShow/sections/components/StockTransferDialog.ts @@ -0,0 +1,38 @@ +import { expect } from '@playwright/test'; + +import BasePageModel from '@/pages/BasePageModel'; + +class StockTransferDialog extends BasePageModel { + + async isLoaded() { + await expect( + this.page.getByRole('dialog', { name: 'Transfer Stock' }) + ).toBeVisible(); + } + + get locationSelect() { + return this.page.getByRole('cell', { name: 'Choose where stock is being' }); + } + + async getLocation(locationName: string) { + const activeDropdown = this.page.locator( + '.chosen-container-active .chosen-results' + ); + + await activeDropdown.waitFor(); + + return activeDropdown.locator('li', { hasText: locationName }).click(); + } + + get binLocationSelect() { + return this.page.getByRole('cell', { name: 'Select an Option' }); + } + + get transferStockButton() { + return this.page + .getByRole('dialog', { name: 'Transfer Stock' }) + .getByRole('button', { name: 'Transfer Stock' }); + } +} + +export default StockTransferDialog; From 8b2739004e29be53ac6de36a878e4838ced45ee7 Mon Sep 17 00:00:00 2001 From: Katarzyna Date: Thu, 16 Apr 2026 11:34:30 +0200 Subject: [PATCH 3/6] add test for assertion of receiving bins on create putaway page --- ...rtReceivingBinsOnCreatePutawayPage.test.ts | 343 ++++++++++++++++++ 1 file changed, 343 insertions(+) create mode 100644 src/tests/putaway/assertReceivingBinsOnCreatePutawayPage.test.ts diff --git a/src/tests/putaway/assertReceivingBinsOnCreatePutawayPage.test.ts b/src/tests/putaway/assertReceivingBinsOnCreatePutawayPage.test.ts new file mode 100644 index 0000000..ddb6cd1 --- /dev/null +++ b/src/tests/putaway/assertReceivingBinsOnCreatePutawayPage.test.ts @@ -0,0 +1,343 @@ +import AppConfig from '@/config/AppConfig'; +import { ShipmentType } from '@/constants/ShipmentType'; +import { expect, test } from '@/fixtures/fixtures'; +import { StockMovementResponse } from '@/types'; +import { formatDate, getDateByOffset } from '@/utils/DateUtils'; +import RefreshCachesUtils from '@/utils/RefreshCaches'; +import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; +import UniqueIdentifier from '@/utils/UniqueIdentifier'; + +test.describe('Assert receiving bin on create putaway page', () => { + let STOCK_MOVEMENT: StockMovementResponse; + let STOCK_MOVEMENT_OTHER: StockMovementResponse; + const uniqueIdentifier = new UniqueIdentifier(); + const lot = uniqueIdentifier.generateUniqueString('lot'); + + test.beforeEach( + async ({ + stockMovementService, + supplierLocationService, + productService, + receivingService, + }) => { + const supplierLocation = await supplierLocationService.getLocation(); + + await test.step('Create 1st stock movement and receive it', async () => { + STOCK_MOVEMENT = await stockMovementService.createInbound({ + originId: supplierLocation.id, + }); + + productService.setProduct('5'); + const product = await productService.getProduct(); + + await stockMovementService.addItemsToInboundStockMovement( + STOCK_MOVEMENT.id, + [ + { + productId: product.id, + quantity: 10, + lotNumber: lot, + expirationDate: getDateByOffset(new Date(), 3), + }, + ] + ); + + await stockMovementService.sendInboundStockMovement(STOCK_MOVEMENT.id, { + shipmentType: ShipmentType.AIR, + }); + + const { data: stockMovement } = + await stockMovementService.getStockMovement(STOCK_MOVEMENT.id); + const shipmentId = getShipmentId(stockMovement); + const { data: receipt } = await receivingService.getReceipt(shipmentId); + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + + await receivingService.createReceivingBin(shipmentId, receipt); + + await receivingService.updateReceivingItems(shipmentId, [ + { + shipmentItemId: getShipmentItemId(receipt, 0, 0), + quantityReceiving: 10, + binLocationName: receivingBin, + }, + ]); + await receivingService.completeReceipt(shipmentId); + }); + + await test.step('Create 2nd stock movement and receive it', async () => { + STOCK_MOVEMENT_OTHER = await stockMovementService.createInbound({ + originId: supplierLocation.id, + }); + + productService.setProduct('5'); + const product = await productService.getProduct(); + + await stockMovementService.addItemsToInboundStockMovement( + STOCK_MOVEMENT_OTHER.id, + [{ productId: product.id, quantity: 10 }] + ); + + await stockMovementService.sendInboundStockMovement( + STOCK_MOVEMENT_OTHER.id, + { + shipmentType: ShipmentType.AIR, + } + ); + + const { data: stockMovement } = + await stockMovementService.getStockMovement(STOCK_MOVEMENT_OTHER.id); + const shipmentId = getShipmentId(stockMovement); + const { data: receipt } = await receivingService.getReceipt(shipmentId); + const receivingBin2 = + AppConfig.instance.receivingBinPrefix + + STOCK_MOVEMENT_OTHER.identifier; + + await receivingService.createReceivingBin(shipmentId, receipt); + + await receivingService.updateReceivingItems(shipmentId, [ + { + shipmentItemId: getShipmentItemId(receipt, 0, 0), + quantityReceiving: 10, + binLocationName: receivingBin2, + }, + ]); + await receivingService.completeReceipt(shipmentId); + }); + } + ); + + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + navbar, + transactionListPage, + oldViewShipmentPage, + }) => { + await navbar.configurationButton.click(); + await navbar.transactions.click(); + for (let n = 1; n < 4; n++) { + await transactionListPage.deleteTransaction(1); + } + + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await navbar.configurationButton.click(); + await navbar.transactions.click(); + await transactionListPage.deleteTransaction(1); + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); + await oldViewShipmentPage.undoStatusChangeButton.click(); + await stockMovementShowPage.isLoaded(); + await stockMovementShowPage.rollbackButton.click(); + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + await stockMovementShowPage.goToPage(STOCK_MOVEMENT_OTHER.id); + await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); + await oldViewShipmentPage.undoStatusChangeButton.click(); + await stockMovementShowPage.isLoaded(); + await stockMovementShowPage.rollbackButton.click(); + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT_OTHER.id); + } + ); + + test('Assert receiving bin on create putaway page', async ({ + stockMovementShowPage, + navbar, + createPutawayPage, + productService, + productShowPage, + mainLocationService, + internalLocationService, + putawayDetailsPage, + }) => { + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + const receivingBin2 = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT_OTHER.identifier; + productService.setProduct('5'); + const product = await productService.getProduct(); + const expDate = getDateByOffset(new Date(), 3); + const currentLocation = await mainLocationService.getLocation(); + const internalLocation = await internalLocationService.getLocation(); + + await test.step('Go to create putaway page', async () => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await stockMovementShowPage.isLoaded(); + await RefreshCachesUtils.refreshCaches({ + navbar, + }); + await navbar.inbound.click(); + await navbar.createPutaway.click(); + await createPutawayPage.isLoaded(); + }); + + await test.step('Assert content of create putawy page', async () => { + await expect(createPutawayPage.table.rows).toHaveCount(2); + await expect(createPutawayPage.table.row(0).receivingBin).toContainText( + receivingBin2 + ); + await createPutawayPage.table + .row(0) + .getExpandBinLocation(receivingBin2) + .click(); + await expect( + createPutawayPage.table.row(1).getProductName(product.name) + ).toBeVisible(); + await expect(createPutawayPage.table.row(2).receivingBin).toContainText( + receivingBin + ); + await createPutawayPage.table + .row(2) + .getExpandBinLocation(receivingBin) + .click(); + await expect( + createPutawayPage.table.row(3).getProductName(product.name) + ).toBeVisible(); + await expect(createPutawayPage.table.row(3).getLot(lot)).toBeVisible(); + await expect( + createPutawayPage.table.row(3).getExpDate(expDate) + ).toBeVisible(); + }); + + await test.step('Assert receiving bins and lot and exp on stockcard', async () => { + await productShowPage.goToPage(product.id); + await productShowPage.inStockTab.click(); + await productShowPage.inStockTabSection.isLoaded(); + await expect( + productShowPage.inStockTabSection.row(1).binLocation + ).toHaveText(receivingBin2); + await expect( + productShowPage.inStockTabSection.row(2).binLocation + ).toHaveText(receivingBin); + await expect(productShowPage.inStockTabSection.row(2).lot).toHaveText( + lot + ); + await expect(productShowPage.inStockTabSection.row(2).expires).toHaveText( + formatDate(expDate, 'MMM DD, YYYY') + ); + }); + + await test.step('Open transfer stock dialog for the 1st inventory', async () => { + await productShowPage.inStockTabSection.row(1).actionsButton.click(); + await productShowPage.inStockTabSection.stockTransferButton.click(); + await productShowPage.inStockTabSection.stockTransferDialog.isLoaded(); + }); + + await test.step('Perform Stock Transfer of 1 inventory to another receiving bin', async () => { + await productShowPage.inStockTabSection.stockTransferDialog.locationSelect.click(); + await productShowPage.inStockTabSection.stockTransferDialog.getLocation( + currentLocation.name + ); + await productShowPage.inStockTabSection.stockTransferDialog.binLocationSelect.click(); + await productShowPage.inStockTabSection.stockTransferDialog.getLocation( + receivingBin + ); + await productShowPage.inStockTabSection.stockTransferDialog.transferStockButton.click(); + }); + + await test.step('Assert receiving bins and lot and exp on stockcard after stock transfer', async () => { + await productShowPage.inStockTab.click(); + await productShowPage.inStockTabSection.isLoaded(); + await expect( + productShowPage.inStockTabSection.row(1).binLocation + ).toHaveText(receivingBin); + await expect( + productShowPage.inStockTabSection.row(2).binLocation + ).toHaveText(receivingBin); + await expect(productShowPage.inStockTabSection.row(2).lot).toHaveText( + lot + ); + await expect(productShowPage.inStockTabSection.row(2).expires).toHaveText( + formatDate(expDate, 'MMM DD, YYYY') + ); + }); + + await test.step('Go to create putaway page', async () => { + await productShowPage.inStockTabSection.isLoaded(); + await RefreshCachesUtils.refreshCaches({ + navbar, + }); + await navbar.inbound.click(); + await navbar.createPutaway.click(); + await createPutawayPage.isLoaded(); + }); + + await test.step('Assert create putaway page content after stock transfer', async () => { + await expect(createPutawayPage.table.rows).toHaveCount(1); + await expect(createPutawayPage.table.row(0).receivingBin).toContainText( + receivingBin + ); + await createPutawayPage.table + .row(0) + .getExpandBinLocation(receivingBin) + .click(); + await expect( + createPutawayPage.table.row(1).getProductName(product.name) + ).toBeVisible(); + await expect( + createPutawayPage.table.row(2).getProductName(product.name) + ).toBeVisible(); + await expect(createPutawayPage.table.row(2).getLot(lot)).toBeVisible(); + await expect( + createPutawayPage.table.row(2).getExpDate(expDate) + ).toBeVisible(); + await expect(createPutawayPage.table.rows).toHaveCount(3); + }); + + await test.step('Start putaway', async () => { + await createPutawayPage.table.row(1).checkbox.click(); + await createPutawayPage.table.row(2).checkbox.click(); + await createPutawayPage.startPutawayButton.click(); + await createPutawayPage.startStep.isLoaded(); + }); + + await test.step('Select bins to putaway', async () => { + await createPutawayPage.startStep.table.row(1).putawayBinSelect.click(); + await createPutawayPage.startStep.table + .row(1) + .getPutawayBin(internalLocation.name) + .click(); + await createPutawayPage.startStep.table.row(2).putawayBinSelect.click(); + await createPutawayPage.startStep.table + .row(2) + .getPutawayBin(internalLocation.name) + .click(); + await expect( + createPutawayPage.startStep.table.row(2).lotField + ).toHaveText(lot); + await expect( + createPutawayPage.startStep.table.row(2).expiryDateField + ).toHaveText(formatDate(expDate, 'MM/DD/YYYY')); + }); + + await test.step('Go to next page and complete putaway', async () => { + await createPutawayPage.startStep.nextButton.click(); + await createPutawayPage.completeStep.isLoaded(); + await createPutawayPage.completeStep.completePutawayButton.click(); + }); + + await test.step('Assert completing putaway', async () => { + await putawayDetailsPage.isLoaded(); + await expect(putawayDetailsPage.statusTag).toHaveText('Completed'); + }); + + await test.step('Assert bins and lot on stockcard after putaway', async () => { + await productShowPage.goToPage(product.id); + await productShowPage.inStockTab.click(); + await productShowPage.inStockTabSection.isLoaded(); + await expect( + productShowPage.inStockTabSection.row(1).binLocation + ).toHaveText(internalLocation.name); + await expect( + productShowPage.inStockTabSection.row(2).binLocation + ).toHaveText(internalLocation.name); + await expect(productShowPage.inStockTabSection.row(2).lot).toHaveText( + lot + ); + await expect(productShowPage.inStockTabSection.row(2).expires).toHaveText( + formatDate(expDate, 'MMM DD, YYYY') + ); + }); + }); +}); From c36d465bf47e413f83d5e8720fe29a775e3836c8 Mon Sep 17 00:00:00 2001 From: Katarzyna Date: Tue, 21 Apr 2026 10:25:34 +0200 Subject: [PATCH 4/6] add improvements after review --- .../components/StockTransferDialog.ts | 17 ++-- .../putaway/components/CreatePutawayTable.ts | 16 ++-- ...rtReceivingBinsOnCreatePutawayPage.test.ts | 89 +++++++++++-------- src/utils/shipmentUtils.ts | 22 +++++ 4 files changed, 92 insertions(+), 52 deletions(-) diff --git a/src/pages/product/productShow/sections/components/StockTransferDialog.ts b/src/pages/product/productShow/sections/components/StockTransferDialog.ts index b2443b5..4feb0c6 100644 --- a/src/pages/product/productShow/sections/components/StockTransferDialog.ts +++ b/src/pages/product/productShow/sections/components/StockTransferDialog.ts @@ -3,18 +3,19 @@ import { expect } from '@playwright/test'; import BasePageModel from '@/pages/BasePageModel'; class StockTransferDialog extends BasePageModel { - + get stockTransferDialog() { + return this.page.getByRole('dialog', { name: 'Transfer Stock' }); + } + async isLoaded() { - await expect( - this.page.getByRole('dialog', { name: 'Transfer Stock' }) - ).toBeVisible(); + await expect(this.stockTransferDialog).toBeVisible(); } get locationSelect() { return this.page.getByRole('cell', { name: 'Choose where stock is being' }); } - async getLocation(locationName: string) { + async selectLocation(locationName: string) { const activeDropdown = this.page.locator( '.chosen-container-active .chosen-results' ); @@ -29,9 +30,9 @@ class StockTransferDialog extends BasePageModel { } get transferStockButton() { - return this.page - .getByRole('dialog', { name: 'Transfer Stock' }) - .getByRole('button', { name: 'Transfer Stock' }); + return this.stockTransferDialog.getByRole('button', { + name: 'Transfer Stock', + }); } } diff --git a/src/pages/putaway/components/CreatePutawayTable.ts b/src/pages/putaway/components/CreatePutawayTable.ts index e90442a..95cd307 100644 --- a/src/pages/putaway/components/CreatePutawayTable.ts +++ b/src/pages/putaway/components/CreatePutawayTable.ts @@ -33,8 +33,12 @@ class Row extends BasePageModel { return this.row.getByRole('checkbox'); } + get tableCell() { + return this.row.getByTestId('table-cell'); + } + getExpandBinLocation(binLocation: string) { - return this.row.getByTestId('table-cell').getByText(binLocation); + return this.tableCell.getByText(binLocation); } get receivingBin() { @@ -42,17 +46,17 @@ class Row extends BasePageModel { } getProductName(name: string) { - return this.row.getByTestId('table-cell').getByText(name); + return this.tableCell.getByText(name); } getLot(lot: string) { - return this.row.getByTestId('table-cell').getByText(lot); + return this.tableCell.getByText(lot); } getExpDate(expDate: Date) { - return this.row - .getByTestId('table-cell') - .getByText(formatDate(expDate, 'MM/DD/YYYY').toString()); + return this.tableCell.getByText( + formatDate(expDate, 'MM/DD/YYYY').toString() + ); } } diff --git a/src/tests/putaway/assertReceivingBinsOnCreatePutawayPage.test.ts b/src/tests/putaway/assertReceivingBinsOnCreatePutawayPage.test.ts index ddb6cd1..d79ea4c 100644 --- a/src/tests/putaway/assertReceivingBinsOnCreatePutawayPage.test.ts +++ b/src/tests/putaway/assertReceivingBinsOnCreatePutawayPage.test.ts @@ -4,12 +4,16 @@ import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; import { formatDate, getDateByOffset } from '@/utils/DateUtils'; import RefreshCachesUtils from '@/utils/RefreshCaches'; -import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; +import { + deleteReceivedShipment, + getShipmentId, + getShipmentItemId, +} from '@/utils/shipmentUtils'; import UniqueIdentifier from '@/utils/UniqueIdentifier'; test.describe('Assert receiving bin on create putaway page', () => { - let STOCK_MOVEMENT: StockMovementResponse; - let STOCK_MOVEMENT_OTHER: StockMovementResponse; + let PRIMARY_STOCK_MOVEMENT: StockMovementResponse; + let SECONDARY_STOCK_MOVEMENT: StockMovementResponse; const uniqueIdentifier = new UniqueIdentifier(); const lot = uniqueIdentifier.generateUniqueString('lot'); @@ -22,8 +26,8 @@ test.describe('Assert receiving bin on create putaway page', () => { }) => { const supplierLocation = await supplierLocationService.getLocation(); - await test.step('Create 1st stock movement and receive it', async () => { - STOCK_MOVEMENT = await stockMovementService.createInbound({ + await test.step('Create 1st stock movement', async () => { + PRIMARY_STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, }); @@ -31,7 +35,7 @@ test.describe('Assert receiving bin on create putaway page', () => { const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( - STOCK_MOVEMENT.id, + PRIMARY_STOCK_MOVEMENT.id, [ { productId: product.id, @@ -42,16 +46,24 @@ test.describe('Assert receiving bin on create putaway page', () => { ] ); - await stockMovementService.sendInboundStockMovement(STOCK_MOVEMENT.id, { - shipmentType: ShipmentType.AIR, - }); + await stockMovementService.sendInboundStockMovement( + PRIMARY_STOCK_MOVEMENT.id, + { + shipmentType: ShipmentType.AIR, + } + ); + }); + await test.step('Receive 1st stock movement', async () => { const { data: stockMovement } = - await stockMovementService.getStockMovement(STOCK_MOVEMENT.id); + await stockMovementService.getStockMovement( + PRIMARY_STOCK_MOVEMENT.id + ); const shipmentId = getShipmentId(stockMovement); const { data: receipt } = await receivingService.getReceipt(shipmentId); const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + AppConfig.instance.receivingBinPrefix + + PRIMARY_STOCK_MOVEMENT.identifier; await receivingService.createReceivingBin(shipmentId, receipt); @@ -65,8 +77,8 @@ test.describe('Assert receiving bin on create putaway page', () => { await receivingService.completeReceipt(shipmentId); }); - await test.step('Create 2nd stock movement and receive it', async () => { - STOCK_MOVEMENT_OTHER = await stockMovementService.createInbound({ + await test.step('Create 2nd stock movement', async () => { + SECONDARY_STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, }); @@ -74,24 +86,28 @@ test.describe('Assert receiving bin on create putaway page', () => { const product = await productService.getProduct(); await stockMovementService.addItemsToInboundStockMovement( - STOCK_MOVEMENT_OTHER.id, + SECONDARY_STOCK_MOVEMENT.id, [{ productId: product.id, quantity: 10 }] ); await stockMovementService.sendInboundStockMovement( - STOCK_MOVEMENT_OTHER.id, + SECONDARY_STOCK_MOVEMENT.id, { shipmentType: ShipmentType.AIR, } ); + }); + await test.step('Receive 2nd stock movement', async () => { const { data: stockMovement } = - await stockMovementService.getStockMovement(STOCK_MOVEMENT_OTHER.id); + await stockMovementService.getStockMovement( + SECONDARY_STOCK_MOVEMENT.id + ); const shipmentId = getShipmentId(stockMovement); const { data: receipt } = await receivingService.getReceipt(shipmentId); const receivingBin2 = AppConfig.instance.receivingBinPrefix + - STOCK_MOVEMENT_OTHER.identifier; + SECONDARY_STOCK_MOVEMENT.identifier; await receivingService.createReceivingBin(shipmentId, receipt); @@ -121,23 +137,19 @@ test.describe('Assert receiving bin on create putaway page', () => { await transactionListPage.deleteTransaction(1); } - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await navbar.configurationButton.click(); - await navbar.transactions.click(); - await transactionListPage.deleteTransaction(1); - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); - await oldViewShipmentPage.undoStatusChangeButton.click(); - await stockMovementShowPage.isLoaded(); - await stockMovementShowPage.rollbackButton.click(); - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + await deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT: PRIMARY_STOCK_MOVEMENT, + }); - await stockMovementShowPage.goToPage(STOCK_MOVEMENT_OTHER.id); - await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); - await oldViewShipmentPage.undoStatusChangeButton.click(); - await stockMovementShowPage.isLoaded(); - await stockMovementShowPage.rollbackButton.click(); - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT_OTHER.id); + await deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT: SECONDARY_STOCK_MOVEMENT, + }); } ); @@ -152,9 +164,10 @@ test.describe('Assert receiving bin on create putaway page', () => { putawayDetailsPage, }) => { const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + AppConfig.instance.receivingBinPrefix + PRIMARY_STOCK_MOVEMENT.identifier; const receivingBin2 = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT_OTHER.identifier; + AppConfig.instance.receivingBinPrefix + + SECONDARY_STOCK_MOVEMENT.identifier; productService.setProduct('5'); const product = await productService.getProduct(); const expDate = getDateByOffset(new Date(), 3); @@ -162,7 +175,7 @@ test.describe('Assert receiving bin on create putaway page', () => { const internalLocation = await internalLocationService.getLocation(); await test.step('Go to create putaway page', async () => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await stockMovementShowPage.goToPage(PRIMARY_STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); await RefreshCachesUtils.refreshCaches({ navbar, @@ -226,11 +239,11 @@ test.describe('Assert receiving bin on create putaway page', () => { await test.step('Perform Stock Transfer of 1 inventory to another receiving bin', async () => { await productShowPage.inStockTabSection.stockTransferDialog.locationSelect.click(); - await productShowPage.inStockTabSection.stockTransferDialog.getLocation( + await productShowPage.inStockTabSection.stockTransferDialog.selectLocation( currentLocation.name ); await productShowPage.inStockTabSection.stockTransferDialog.binLocationSelect.click(); - await productShowPage.inStockTabSection.stockTransferDialog.getLocation( + await productShowPage.inStockTabSection.stockTransferDialog.selectLocation( receivingBin ); await productShowPage.inStockTabSection.stockTransferDialog.transferStockButton.click(); diff --git a/src/utils/shipmentUtils.ts b/src/utils/shipmentUtils.ts index 936c9ff..e33c8ea 100644 --- a/src/utils/shipmentUtils.ts +++ b/src/utils/shipmentUtils.ts @@ -1,3 +1,6 @@ +import StockMovementService from '@/api/StockMovementService'; +import OldViewShipmentPage from '@/pages/stockMovementShow/OldViewShipmentPage'; +import StockMovementShowPage from '@/pages/stockMovementShow/StockMovementShowPage'; import { ReceiptResponse, StockMovementResponse } from '@/types'; export const getShipmentId = (stockMovement: StockMovementResponse) => { @@ -12,3 +15,22 @@ export const getShipmentItemId = ( return receipt.containers[containerIndex].shipmentItems[shipmentItemIndex] .shipmentItemId; }; + +export async function deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT, +}: { + STOCK_MOVEMENT: StockMovementResponse; + stockMovementService: StockMovementService; + stockMovementShowPage: StockMovementShowPage; + oldViewShipmentPage: OldViewShipmentPage; +}) { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); + await oldViewShipmentPage.undoStatusChangeButton.click(); + await stockMovementShowPage.isLoaded(); + await stockMovementShowPage.rollbackButton.click(); + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); +} From 048def51abe35511efac81e2aa2bfe34b2da7e21 Mon Sep 17 00:00:00 2001 From: Katarzyna Date: Tue, 21 Apr 2026 11:39:34 +0200 Subject: [PATCH 5/6] refactor after each in other putaway tests --- ...ssertAttemptToEditCompletedPutaway.test.ts | 21 ++++++++------ .../putaway/assertPutawayDetailsPage.test.ts | 21 ++++++++------ .../changeLocationOnCreatePutawayPage.test.ts | 23 ++++++++------- ...eateMoreThan1PutawayForTheSameItem.test.ts | 21 ++++++++------ src/tests/putaway/createPutaway.test.ts | 21 ++++++++------ .../performPutawayAsManagerUser.test.ts | 19 +++++++----- .../putaway/putawayMoreThan1Item.test.ts | 29 ++++++++++--------- .../putaway/putawayToPreferredBin.test.ts | 23 ++++++++------- .../putaway/qtyValidationsInPutaways.test.ts | 21 ++++++++------ ...lbackLastReceiptWhenPutawayCreated.test.ts | 20 ++++++++----- src/tests/putaway/splitLineInPutaway.test.ts | 23 ++++++++------- ...dationOnQtyRemovedFromReceivingBin.test.ts | 19 +++++++----- 12 files changed, 149 insertions(+), 112 deletions(-) diff --git a/src/tests/putaway/assertAttemptToEditCompletedPutaway.test.ts b/src/tests/putaway/assertAttemptToEditCompletedPutaway.test.ts index 8dd24bf..ecd3e33 100644 --- a/src/tests/putaway/assertAttemptToEditCompletedPutaway.test.ts +++ b/src/tests/putaway/assertAttemptToEditCompletedPutaway.test.ts @@ -3,7 +3,11 @@ import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; -import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; +import { + deleteReceivedShipment, + getShipmentId, + getShipmentItemId, +} from '@/utils/shipmentUtils'; test.describe('Assert attempt to edit completed putaway', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -69,13 +73,12 @@ test.describe('Assert attempt to edit completed putaway', () => { await transactionListPage.table.deleteButton.click(); await expect(transactionListPage.successMessage).toBeVisible(); - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); - await oldViewShipmentPage.undoStatusChangeButton.click(); - await stockMovementShowPage.isLoaded(); - await stockMovementShowPage.rollbackButton.click(); - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + await deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT, + }); } ); @@ -92,7 +95,7 @@ test.describe('Assert attempt to edit completed putaway', () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); await RefreshCachesUtils.refreshCaches({ - navbar + navbar, }); await navbar.inbound.click(); await navbar.createPutaway.click(); diff --git a/src/tests/putaway/assertPutawayDetailsPage.test.ts b/src/tests/putaway/assertPutawayDetailsPage.test.ts index f1927b7..3381d45 100644 --- a/src/tests/putaway/assertPutawayDetailsPage.test.ts +++ b/src/tests/putaway/assertPutawayDetailsPage.test.ts @@ -3,7 +3,11 @@ import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; -import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; +import { + deleteReceivedShipment, + getShipmentId, + getShipmentItemId, +} from '@/utils/shipmentUtils'; test.describe('Assert putaway details page', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -69,13 +73,12 @@ test.describe('Assert putaway details page', () => { await transactionListPage.table.deleteButton.click(); await expect(transactionListPage.successMessage).toBeVisible(); - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); - await oldViewShipmentPage.undoStatusChangeButton.click(); - await stockMovementShowPage.isLoaded(); - await stockMovementShowPage.rollbackButton.click(); - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + await deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT, + }); } ); @@ -99,7 +102,7 @@ test.describe('Assert putaway details page', () => { await stockMovementShowPage.isLoaded(); await expect(stockMovementShowPage.statusTag).toHaveText('Received'); await RefreshCachesUtils.refreshCaches({ - navbar + navbar, }); }); diff --git a/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts b/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts index afc1948..0ba04a5 100644 --- a/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts +++ b/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts @@ -3,7 +3,11 @@ import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; -import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; +import { + deleteReceivedShipment, + getShipmentId, + getShipmentItemId, +} from '@/utils/shipmentUtils'; test.describe('Change location on putaway create page and list pages', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -64,13 +68,12 @@ test.describe('Change location on putaway create page and list pages', () => { await putawayListPage.table.clickDeleteOrderButton(1); await putawayListPage.emptyPutawayList.isVisible(); - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); - await oldViewShipmentPage.undoStatusChangeButton.click(); - await stockMovementShowPage.isLoaded(); - await stockMovementShowPage.rollbackButton.click(); - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + await deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT, + }); } ); @@ -97,7 +100,7 @@ test.describe('Change location on putaway create page and list pages', () => { await stockMovementShowPage.isLoaded(); await expect(stockMovementShowPage.statusTag).toHaveText('Received'); await RefreshCachesUtils.refreshCaches({ - navbar + navbar, }); }); @@ -123,7 +126,7 @@ test.describe('Change location on putaway create page and list pages', () => { .click(); await locationChooser.getLocation(depotLocation.name).click(); await RefreshCachesUtils.refreshCaches({ - navbar + navbar, }); await createPutawayPage.goToPage(); await expect(createPutawayPage.emptyCreatePageInformation).toBeVisible(); diff --git a/src/tests/putaway/createMoreThan1PutawayForTheSameItem.test.ts b/src/tests/putaway/createMoreThan1PutawayForTheSameItem.test.ts index ba8c15b..7ffe9bc 100644 --- a/src/tests/putaway/createMoreThan1PutawayForTheSameItem.test.ts +++ b/src/tests/putaway/createMoreThan1PutawayForTheSameItem.test.ts @@ -3,7 +3,11 @@ import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; -import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; +import { + deleteReceivedShipment, + getShipmentId, + getShipmentItemId, +} from '@/utils/shipmentUtils'; test.describe('Create more than 1 putaway from the same item', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -69,13 +73,12 @@ test.describe('Create more than 1 putaway from the same item', () => { await transactionListPage.table.deleteButton.click(); await expect(transactionListPage.successMessage).toBeVisible(); - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); - await oldViewShipmentPage.undoStatusChangeButton.click(); - await stockMovementShowPage.isLoaded(); - await stockMovementShowPage.rollbackButton.click(); - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + await deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT, + }); } ); @@ -172,7 +175,7 @@ test.describe('Create more than 1 putaway from the same item', () => { productShowPage.inStockTabSection.row(1).quantityOnHand ).toHaveText('5'); await RefreshCachesUtils.refreshCaches({ - navbar + navbar, }); }); diff --git a/src/tests/putaway/createPutaway.test.ts b/src/tests/putaway/createPutaway.test.ts index 64282ac..4314677 100644 --- a/src/tests/putaway/createPutaway.test.ts +++ b/src/tests/putaway/createPutaway.test.ts @@ -3,7 +3,11 @@ import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; -import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; +import { + deleteReceivedShipment, + getShipmentId, + getShipmentItemId, +} from '@/utils/shipmentUtils'; test.describe('Putaway received inbound shipment', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -69,13 +73,12 @@ test.describe('Putaway received inbound shipment', () => { await transactionListPage.table.deleteButton.click(); await expect(transactionListPage.successMessage).toBeVisible(); - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); - await oldViewShipmentPage.undoStatusChangeButton.click(); - await stockMovementShowPage.isLoaded(); - await stockMovementShowPage.rollbackButton.click(); - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + await deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT, + }); } ); @@ -93,7 +96,7 @@ test.describe('Putaway received inbound shipment', () => { await stockMovementShowPage.isLoaded(); await expect(stockMovementShowPage.statusTag).toHaveText('Received'); await RefreshCachesUtils.refreshCaches({ - navbar + navbar, }); }); diff --git a/src/tests/putaway/performPutawayAsManagerUser.test.ts b/src/tests/putaway/performPutawayAsManagerUser.test.ts index d4fde9e..793c94d 100644 --- a/src/tests/putaway/performPutawayAsManagerUser.test.ts +++ b/src/tests/putaway/performPutawayAsManagerUser.test.ts @@ -7,7 +7,11 @@ import PutawayDetailsPage from '@/pages/putaway/putawayDetails/PutawayDetailsPag import StockMovementShowPage from '@/pages/stockMovementShow/StockMovementShowPage'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; -import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; +import { + deleteReceivedShipment, + getShipmentId, + getShipmentItemId, +} from '@/utils/shipmentUtils'; test.describe('Perform putaway as manager user', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -79,13 +83,12 @@ test.describe('Perform putaway as manager user', () => { await navbar.transactions.click(); await transactionListPage.deleteTransaction(1); await transactionListPage.deleteTransaction(1); - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); - await oldViewShipmentPage.undoStatusChangeButton.click(); - await stockMovementShowPage.isLoaded(); - await stockMovementShowPage.rollbackButton.click(); - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + await deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT, + }); } ); diff --git a/src/tests/putaway/putawayMoreThan1Item.test.ts b/src/tests/putaway/putawayMoreThan1Item.test.ts index db344ba..67bf3cc 100644 --- a/src/tests/putaway/putawayMoreThan1Item.test.ts +++ b/src/tests/putaway/putawayMoreThan1Item.test.ts @@ -3,7 +3,11 @@ import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; -import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; +import { + deleteReceivedShipment, + getShipmentId, + getShipmentItemId, +} from '@/utils/shipmentUtils'; test.describe('Create putaway for more than 1 item, separate putaways', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -75,13 +79,12 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { for (let n = 1; n < 4; n++) { await transactionListPage.deleteTransaction(1); } - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); - await oldViewShipmentPage.undoStatusChangeButton.click(); - await stockMovementShowPage.isLoaded(); - await stockMovementShowPage.rollbackButton.click(); - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + await deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT, + }); } ); @@ -107,7 +110,7 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); await RefreshCachesUtils.refreshCaches({ - navbar + navbar, }); await navbar.inbound.click(); await navbar.createPutaway.click(); @@ -190,7 +193,7 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { await test.step('Go to create putaway page and start putaway for 2nd item', async () => { await RefreshCachesUtils.refreshCaches({ - navbar + navbar, }); await createPutawayPage.goToPage(); await createPutawayPage.table @@ -235,7 +238,7 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { await test.step('Assert empty create putaway page', async () => { await RefreshCachesUtils.refreshCaches({ - navbar + navbar, }); await createPutawayPage.goToPage(); await expect(createPutawayPage.emptyCreatePageInformation).toBeVisible(); @@ -343,7 +346,7 @@ test.describe('Putaway 2 items in the same putaway', () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); await RefreshCachesUtils.refreshCaches({ - navbar + navbar, }); await navbar.inbound.click(); await navbar.createPutaway.click(); @@ -414,7 +417,7 @@ test.describe('Putaway 2 items in the same putaway', () => { await test.step('Assert empty create putaway page', async () => { await RefreshCachesUtils.refreshCaches({ - navbar + navbar, }); await createPutawayPage.goToPage(); await expect(createPutawayPage.emptyCreatePageInformation).toBeVisible(); diff --git a/src/tests/putaway/putawayToPreferredBin.test.ts b/src/tests/putaway/putawayToPreferredBin.test.ts index 4537115..6d79054 100644 --- a/src/tests/putaway/putawayToPreferredBin.test.ts +++ b/src/tests/putaway/putawayToPreferredBin.test.ts @@ -3,7 +3,11 @@ import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; -import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; +import { + deleteReceivedShipment, + getShipmentId, + getShipmentItemId, +} from '@/utils/shipmentUtils'; test.describe('Putaway to preferred bin and default bin', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -92,13 +96,12 @@ test.describe('Putaway to preferred bin and default bin', () => { await navbar.transactions.click(); await transactionListPage.deleteTransaction(1); await transactionListPage.deleteTransaction(1); - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); - await oldViewShipmentPage.undoStatusChangeButton.click(); - await stockMovementShowPage.isLoaded(); - await stockMovementShowPage.rollbackButton.click(); - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + await deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT, + }); productService.setProduct('4'); const product2 = await productService.getProduct(); await productShowPage.goToPage(product2.id); @@ -135,7 +138,7 @@ test.describe('Putaway to preferred bin and default bin', () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); await RefreshCachesUtils.refreshCaches({ - navbar + navbar, }); await navbar.inbound.click(); await navbar.createPutaway.click(); @@ -234,7 +237,7 @@ test.describe('Putaway to preferred bin and default bin', () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); await RefreshCachesUtils.refreshCaches({ - navbar + navbar, }); await navbar.inbound.click(); await navbar.createPutaway.click(); diff --git a/src/tests/putaway/qtyValidationsInPutaways.test.ts b/src/tests/putaway/qtyValidationsInPutaways.test.ts index 9f6d38b..3818f56 100644 --- a/src/tests/putaway/qtyValidationsInPutaways.test.ts +++ b/src/tests/putaway/qtyValidationsInPutaways.test.ts @@ -3,7 +3,11 @@ import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; -import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; +import { + deleteReceivedShipment, + getShipmentId, + getShipmentItemId, +} from '@/utils/shipmentUtils'; test.describe('Assert qty validations in putaways', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -64,13 +68,12 @@ test.describe('Assert qty validations in putaways', () => { await putawayListPage.table.clickDeleteOrderButton(1); await putawayListPage.emptyPutawayList.isVisible(); - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); - await oldViewShipmentPage.undoStatusChangeButton.click(); - await stockMovementShowPage.isLoaded(); - await stockMovementShowPage.rollbackButton.click(); - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + await deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT, + }); } ); @@ -86,7 +89,7 @@ test.describe('Assert qty validations in putaways', () => { await stockMovementShowPage.isLoaded(); await expect(stockMovementShowPage.statusTag).toHaveText('Received'); await RefreshCachesUtils.refreshCaches({ - navbar + navbar, }); }); diff --git a/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts b/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts index 79e9c67..a0a1208 100644 --- a/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts +++ b/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts @@ -3,7 +3,11 @@ import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; -import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; +import { + deleteReceivedShipment, + getShipmentId, + getShipmentItemId, +} from '@/utils/shipmentUtils'; test.describe('Rollback last receipt behavior when putaway created', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -68,12 +72,12 @@ test.describe('Rollback last receipt behavior when putaway created', () => { await transactionListPage.table.row(1).actionsButton.click(); await transactionListPage.table.deleteButton.click(); await expect(transactionListPage.successMessage).toBeVisible(); - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); - await oldViewShipmentPage.undoStatusChangeButton.click(); - await stockMovementShowPage.isLoaded(); - await stockMovementShowPage.rollbackButton.click(); - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + await deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT, + }); } ); @@ -91,7 +95,7 @@ test.describe('Rollback last receipt behavior when putaway created', () => { await stockMovementShowPage.isLoaded(); await expect(stockMovementShowPage.statusTag).toHaveText('Received'); await RefreshCachesUtils.refreshCaches({ - navbar + navbar, }); }); diff --git a/src/tests/putaway/splitLineInPutaway.test.ts b/src/tests/putaway/splitLineInPutaway.test.ts index 5631f11..37d7ea5 100644 --- a/src/tests/putaway/splitLineInPutaway.test.ts +++ b/src/tests/putaway/splitLineInPutaway.test.ts @@ -3,7 +3,11 @@ import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; -import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; +import { + deleteReceivedShipment, + getShipmentId, + getShipmentItemId, +} from '@/utils/shipmentUtils'; test.describe('Split line in Putaway', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -72,13 +76,12 @@ test.describe('Split line in Putaway', () => { await transactionListPage.table.deleteButton.click(); await expect(transactionListPage.successMessage).toBeVisible(); - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); - await oldViewShipmentPage.undoStatusChangeButton.click(); - await stockMovementShowPage.isLoaded(); - await stockMovementShowPage.rollbackButton.click(); - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + await deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT, + }); } ); @@ -100,7 +103,7 @@ test.describe('Split line in Putaway', () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); await RefreshCachesUtils.refreshCaches({ - navbar + navbar, }); await navbar.inbound.click(); await navbar.createPutaway.click(); @@ -207,7 +210,7 @@ test.describe('Split line in Putaway', () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); await RefreshCachesUtils.refreshCaches({ - navbar + navbar, }); await navbar.inbound.click(); await navbar.createPutaway.click(); diff --git a/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts b/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts index 124703b..ab7660f 100644 --- a/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts +++ b/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts @@ -5,7 +5,11 @@ import { expect, test } from '@/fixtures/fixtures'; import ProductShowPage from '@/pages/product/productShow/ProductShowPage'; import { StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; -import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; +import { + deleteReceivedShipment, + getShipmentId, + getShipmentItemId, +} from '@/utils/shipmentUtils'; test.describe('Assert validation on qty removed from receiving bin', () => { let STOCK_MOVEMENT: StockMovementResponse; @@ -77,13 +81,12 @@ test.describe('Assert validation on qty removed from receiving bin', () => { for (let n = 1; n < 4; n++) { await transactionListPage.deleteTransaction(1); } - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); - await oldViewShipmentPage.undoStatusChangeButton.click(); - await stockMovementShowPage.isLoaded(); - await stockMovementShowPage.rollbackButton.click(); - - await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + await deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT, + }); } ); From 5b77695b4dc8c3d79248b63176b3e4cea2061cff Mon Sep 17 00:00:00 2001 From: Katarzyna Date: Tue, 21 Apr 2026 15:42:44 +0200 Subject: [PATCH 6/6] fix failing tests --- .../receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts b/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts index 52c11fe..719dfd3 100644 --- a/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts +++ b/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts @@ -110,6 +110,7 @@ test.describe('Apply sorting by alphabetical order and remain inputs', () => { await test.step('Send shipment', async () => { await createInboundPage.nextButton.click(); await createInboundPage.sendStep.isLoaded(); + await expect(createInboundPage.sendStep.sendShipmentButton).toBeVisible(); await createInboundPage.sendStep.sendShipmentButton.click(); await stockMovementShowPage.waitForUrl(); await stockMovementShowPage.isLoaded();