From c19dff6a025dc4b3dd1c6d30b8bcf24b3dd80309 Mon Sep 17 00:00:00 2001 From: Katarzyna Date: Mon, 29 Jun 2026 10:16:33 +0200 Subject: [PATCH 01/10] fix typo in buttons name --- src/pages/product/productShow/ProductShowPage.ts | 2 +- src/tests/putaway/assertZonesInPutaways.test.ts | 4 ++-- src/tests/putaway/putawayToPreferredBin.test.ts | 4 ++-- .../sortPutawayByCurrentPreferredAndOriginalOrder.test.ts | 2 +- src/utils/productUtils.ts | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pages/product/productShow/ProductShowPage.ts b/src/pages/product/productShow/ProductShowPage.ts index ad0f2d8..ca6927a 100644 --- a/src/pages/product/productShow/ProductShowPage.ts +++ b/src/pages/product/productShow/ProductShowPage.ts @@ -36,7 +36,7 @@ class ProductShowPage extends BasePageModel { return this.page.getByRole('link', { name: 'Stock History' }); } - get editProductkButton() { + get editProductButton() { return this.page.getByRole('link', { name: 'Edit Product' }); } } diff --git a/src/tests/putaway/assertZonesInPutaways.test.ts b/src/tests/putaway/assertZonesInPutaways.test.ts index e16464b..1e9a49b 100644 --- a/src/tests/putaway/assertZonesInPutaways.test.ts +++ b/src/tests/putaway/assertZonesInPutaways.test.ts @@ -125,7 +125,7 @@ test.describe('Assert zones on putaway pages', () => { await test.step('Assign bin with zone as preferred bin', async () => { await productShowPage.goToPage(productB.id); - await productShowPage.editProductkButton.click(); + await productShowPage.editProductButton.click(); await productEditPage.inventoryLevelsTab.click(); await productEditPage.inventoryLevelsTabSection.createStockLevelButton.click(); await productEditPage.inventoryLevelsTabSection.createStockLevelModal.receivingTab.click(); @@ -170,7 +170,7 @@ test.describe('Assert zones on putaway pages', () => { await test.step('Delete inventory level', async () => { await productShowPage.goToPage(product.id); - await productShowPage.editProductkButton.click(); + await productShowPage.editProductButton.click(); await productEditPage.inventoryLevelsTab.click(); await productEditPage.inventoryLevelsTabSection .row(1) diff --git a/src/tests/putaway/putawayToPreferredBin.test.ts b/src/tests/putaway/putawayToPreferredBin.test.ts index b979b0b..557c8bb 100644 --- a/src/tests/putaway/putawayToPreferredBin.test.ts +++ b/src/tests/putaway/putawayToPreferredBin.test.ts @@ -72,7 +72,7 @@ test.describe('Putaway to preferred bin and default bin', () => { await receivingService.completeReceipt(shipmentId); await productShowPage.goToPage(product2.id); - await productShowPage.editProductkButton.click(); + await productShowPage.editProductButton.click(); await productEditPage.inventoryLevelsTab.click(); await productEditPage.inventoryLevelsTabSection.createStockLevelButton.click(); await productEditPage.inventoryLevelsTabSection.createStockLevelModal.receivingTab.click(); @@ -108,7 +108,7 @@ test.describe('Putaway to preferred bin and default bin', () => { }); const product2 = await productService.getProduct(Product.FOUR); await productShowPage.goToPage(product2.id); - await productShowPage.editProductkButton.click(); + await productShowPage.editProductButton.click(); await productEditPage.inventoryLevelsTab.click(); await productEditPage.inventoryLevelsTabSection .row(1) diff --git a/src/tests/putaway/sortPutawayByCurrentPreferredAndOriginalOrder.test.ts b/src/tests/putaway/sortPutawayByCurrentPreferredAndOriginalOrder.test.ts index 09f4d13..01b8fa2 100644 --- a/src/tests/putaway/sortPutawayByCurrentPreferredAndOriginalOrder.test.ts +++ b/src/tests/putaway/sortPutawayByCurrentPreferredAndOriginalOrder.test.ts @@ -122,7 +122,7 @@ test.describe('Sort putaway by current bin, preferred bin and original order', ( // Remove preferred bins for A and B. for (const product of [productA, productB]) { await productShowPage.goToPage(product.id); - await productShowPage.editProductkButton.click(); + await productShowPage.editProductButton.click(); await productEditPage.inventoryLevelsTab.click(); await productEditPage.inventoryLevelsTabSection .row(1) diff --git a/src/utils/productUtils.ts b/src/utils/productUtils.ts index 5edcc8d..d612c24 100644 --- a/src/utils/productUtils.ts +++ b/src/utils/productUtils.ts @@ -14,7 +14,7 @@ export async function assignPreferredBin( bin: LocationResponse ) { await productShowPage.goToPage(product.id); - await productShowPage.editProductkButton.click(); + await productShowPage.editProductButton.click(); await productEditPage.inventoryLevelsTab.click(); await productEditPage.inventoryLevelsTabSection.createStockLevelButton.click(); await productEditPage.inventoryLevelsTabSection.createStockLevelModal.receivingTab.click(); From 36ab8dbd48ff02b603a9e5f3ff40a23e99074fe6 Mon Sep 17 00:00:00 2001 From: Katarzyna Date: Wed, 1 Jul 2026 12:26:50 +0200 Subject: [PATCH 02/10] update fixtures with new pages --- src/fixtures/fixtures.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/fixtures/fixtures.ts b/src/fixtures/fixtures.ts index 9956175..8adb1d6 100644 --- a/src/fixtures/fixtures.ts +++ b/src/fixtures/fixtures.ts @@ -30,6 +30,7 @@ import ProductEditPage from '@/pages/product/productEdit/ProductEditPage'; import ProductShowPage from '@/pages/product/productShow/ProductShowPage'; import CreatePutawayPage from '@/pages/putaway/CreatePutawayPage'; import PutawayListPage from '@/pages/putaway/list/PutawayListPage'; +import AddCommentToPutawayPage from '@/pages/putaway/putawayDetails/AddCommentToPutawayPage'; import PutawayDetailsPage from '@/pages/putaway/putawayDetails/PutawayDetailsPage'; import ReceivingPage from '@/pages/receiving/ReceivingPage'; import OldViewShipmentPage from '@/pages/stockMovementShow/OldViewShipmentPage'; @@ -74,6 +75,7 @@ type Fixtures = { putawayListPage: PutawayListPage; productEditPage: ProductEditPage; editTransactionPage: EditTransactionPage; + addCommentToPutawayPage: AddCommentToPutawayPage; // COMPONENTS navbar: Navbar; locationChooser: LocationChooser; @@ -153,6 +155,8 @@ export const test = baseTest.extend({ productEditPage: async ({ page }, use) => use(new ProductEditPage(page)), editTransactionPage: async ({ page }, use) => use(new EditTransactionPage(page)), + addCommentToPutawayPage: async ({ page }, use) => + use(new AddCommentToPutawayPage(page)), // COMPONENTS navbar: async ({ page }, use) => use(new Navbar(page)), locationChooser: async ({ page }, use) => use(new LocationChooser(page)), From 2d41d6cc9741fbd785b43d1b933cd14815b50b62 Mon Sep 17 00:00:00 2001 From: Katarzyna Date: Wed, 1 Jul 2026 12:27:46 +0200 Subject: [PATCH 03/10] add new pages and elements --- .../putawayDetails/AddCommentToPutawayPage.ts | 42 +++++++++++ .../putawayDetails/PutawayDetailsPage.ts | 7 ++ .../components/CommentsTable.ts | 72 +++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 src/pages/putaway/putawayDetails/AddCommentToPutawayPage.ts create mode 100644 src/pages/putaway/putawayDetails/components/CommentsTable.ts diff --git a/src/pages/putaway/putawayDetails/AddCommentToPutawayPage.ts b/src/pages/putaway/putawayDetails/AddCommentToPutawayPage.ts new file mode 100644 index 0000000..c2eee55 --- /dev/null +++ b/src/pages/putaway/putawayDetails/AddCommentToPutawayPage.ts @@ -0,0 +1,42 @@ +import { expect } from '@playwright/test'; + +import BasePageModel from '@/pages/BasePageModel'; + +class AddCommentToPutawayPage extends BasePageModel { + async isLoaded() { + await expect( + this.page.getByRole('heading', { name: 'Add Comment' }) + ).toBeVisible(); + } + + get commentField() { + return this.page.locator('#comment'); + } + + get saveButton() { + return this.page.getByRole('button', { name: 'Save' }); + } + + get recipientDropdown() { + return this.page.locator('#recipient_id_chosen .chosen-single'); + } + + get recipientOptions() { + return this.page.locator('#recipient_id_chosen .chosen-results li'); + } + + async selectRecipient(name: string) { + await this.recipientDropdown.click(); + + await this.recipientOptions.filter({ hasText: name }).click(); + } + + get senderName() { + return this.page + .locator('tr.prop') + .filter({ hasText: 'From' }) + .locator('td.value'); + } +} + +export default AddCommentToPutawayPage; diff --git a/src/pages/putaway/putawayDetails/PutawayDetailsPage.ts b/src/pages/putaway/putawayDetails/PutawayDetailsPage.ts index ef281a5..ff5fd9f 100644 --- a/src/pages/putaway/putawayDetails/PutawayDetailsPage.ts +++ b/src/pages/putaway/putawayDetails/PutawayDetailsPage.ts @@ -4,6 +4,7 @@ import FileHandler from '@/components/FileHandler'; import BasePageModel from '@/pages/BasePageModel'; import AuditingTable from './components/AuditingTable'; +import CommentsTable from './components/CommentsTable'; import ItemDetailsTable from './components/ItemDetailsTable'; import ItemStatusTable from './components/ItemStatusTable'; import OrderHeaderTable from './components/OrderHeaderTable'; @@ -16,6 +17,7 @@ class PutawayDetailsPage extends BasePageModel { itemDetailsTable: ItemDetailsTable; auditingTable: AuditingTable; fileHandler: FileHandler; + commentsTable: CommentsTable; constructor(page: Page) { super(page); @@ -25,6 +27,7 @@ class PutawayDetailsPage extends BasePageModel { this.itemDetailsTable = new ItemDetailsTable(page); this.auditingTable = new AuditingTable(page); this.fileHandler = new FileHandler(page); + this.commentsTable = new CommentsTable(page); } async isLoaded() { @@ -127,6 +130,10 @@ class PutawayDetailsPage extends BasePageModel { this.page.once('dialog', (dialog) => dialog.accept()); await this.actionsDeleteButton.click(); } + + get badgeCount() { + return this.page.locator('li.tab-badge'); + } } export default PutawayDetailsPage; diff --git a/src/pages/putaway/putawayDetails/components/CommentsTable.ts b/src/pages/putaway/putawayDetails/components/CommentsTable.ts new file mode 100644 index 0000000..7a7dcac --- /dev/null +++ b/src/pages/putaway/putawayDetails/components/CommentsTable.ts @@ -0,0 +1,72 @@ +import { expect, Locator, Page } from '@playwright/test'; + +import BasePageModel from '@/pages/BasePageModel'; + +class CommentsTable extends BasePageModel { + constructor(page: Page) { + super(page); + } + + async isLoaded() { + await expect( + this.page.getByRole('heading').getByText('Comments') + ).toBeVisible(); + } + + get table() { + return this.page.getByRole('table').filter({ + hasText: 'Comment', + }); + } + + get rows() { + return this.table.getByRole('row'); + } + + row(index: number) { + return new Row(this.page, this.rows.nth(index)); + } + + getColumnHeader(columnName: string) { + return this.table.getByRole('row').getByText(columnName, { exact: true }); + } + + async clickDeleteCommentButton(index: number) { + this.page.once('dialog', (dialog) => dialog.accept()); + await this.row(index).deleteButton.click(); + } + + get emptyCommentTable() { + return this.page.locator('.fade.center.empty').getByText('No comments'); + } +} + +class Row extends BasePageModel { + row: Locator; + constructor(page: Page, row: Locator) { + super(page); + this.row = row; + } + + get commentContent() { + return this.row.getByRole('cell').nth(2); + } + + get recipientContent() { + return this.row.getByRole('cell').nth(0); + } + + get senderContent() { + return this.row.getByRole('cell').nth(1); + } + + get editButton() { + return this.row.getByRole('link', { name: 'Edit', exact: true }); + } + + get deleteButton() { + return this.row.getByRole('link', { name: 'Delete', exact: true }); + } +} + +export default CommentsTable; From 637ae9081566419f6641f9b086727e8cd01f927f Mon Sep 17 00:00:00 2001 From: Katarzyna Date: Wed, 1 Jul 2026 12:28:19 +0200 Subject: [PATCH 04/10] add comments to putaway test --- src/tests/putaway/addCommentToPutaway.test.ts | 315 ++++++++++++++++++ 1 file changed, 315 insertions(+) create mode 100644 src/tests/putaway/addCommentToPutaway.test.ts diff --git a/src/tests/putaway/addCommentToPutaway.test.ts b/src/tests/putaway/addCommentToPutaway.test.ts new file mode 100644 index 0000000..e6a2d9f --- /dev/null +++ b/src/tests/putaway/addCommentToPutaway.test.ts @@ -0,0 +1,315 @@ +import AppConfig from '@/config/AppConfig'; +import { ShipmentType } from '@/constants/ShipmentType'; +import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; +import { StockMovementResponse } from '@/types'; +import RefreshCachesUtils from '@/utils/RefreshCaches'; +import { + deleteReceivedShipment, + getShipmentId, + getShipmentItemId, +} from '@/utils/shipmentUtils'; + +test.describe('Add comment to Putaway', () => { + let STOCK_MOVEMENT: StockMovementResponse; + + test.beforeEach( + async ({ + supplierLocationService, + stockMovementService, + productService, + receivingService, + }) => { + const supplierLocation = await supplierLocationService.getLocation(); + STOCK_MOVEMENT = await stockMovementService.createInbound({ + originId: supplierLocation.id, + }); + + const product = await productService.getProduct(Product.FIVE); + + await stockMovementService.addItemsToInboundStockMovement( + STOCK_MOVEMENT.id, + [{ productId: product.id, quantity: 10 }] + ); + + 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); + } + ); + + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + navbar, + transactionListPage, + oldViewShipmentPage, + }) => { + await navbar.configurationButton.click(); + await navbar.transactions.click(); + await transactionListPage.table.row(1).actionsButton.click(); + await transactionListPage.table.deleteButton.click(); + await expect(transactionListPage.successMessage).toBeVisible(); + await transactionListPage.table.row(1).actionsButton.click(); + await transactionListPage.table.deleteButton.click(); + await expect(transactionListPage.successMessage).toBeVisible(); + + await deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT, + }); + } + ); + + test('Add comment to putaway', async ({ + stockMovementShowPage, + navbar, + createPutawayPage, + internalLocationService, + putawayDetailsPage, + putawayListPage, + mainUserService, + addCommentToPutawayPage, + managerUserService, + }) => { + const internalLocation = await internalLocationService.getLocation(); + + const mainUser = await mainUserService.getUser(); + const managerUser = await managerUserService.getUser(); + + await test.step('Go to stock movement show page and assert received status', async () => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await stockMovementShowPage.isLoaded(); + await expect(stockMovementShowPage.statusTag).toHaveText('Received'); + await RefreshCachesUtils.refreshCaches({ + navbar, + }); + }); + + await test.step('Go to create putaway page', async () => { + await navbar.inbound.click(); + await navbar.createPutaway.click(); + await createPutawayPage.isLoaded(); + }); + + await test.step('Start putaway', async () => { + await createPutawayPage.table.row(0).checkbox.click(); + await createPutawayPage.startPutawayButton.click(); + await createPutawayPage.startStep.isLoaded(); + }); + + await test.step('Select bin to putaway', async () => { + await createPutawayPage.startStep.table.row(0).putawayBinSelect.click(); + await createPutawayPage.startStep.table + .row(0) + .getPutawayBin(internalLocation.name) + .click(); + await createPutawayPage.startStep.saveButton.click(); + }); + + await test.step('Go to putaway list page', async () => { + await putawayListPage.goToPage(); + await putawayListPage.isLoaded(); + await expect(putawayListPage.table.row(1).statusTag).toHaveText( + 'Pending' + ); + }); + + await test.step('Go to putaway view page', async () => { + const row = putawayListPage.table.row(1); + await row.actionsButton.click(); + await row.viewOrderDetails.click(); + await putawayDetailsPage.isLoaded(); + }); + + await test.step('Add comment to pending putaway', async () => { + await expect(putawayDetailsPage.addCommentButton).toBeVisible(); + await putawayDetailsPage.addCommentButton.click(); + await addCommentToPutawayPage.isLoaded(); + await addCommentToPutawayPage.commentField.fill('add comment'); + await addCommentToPutawayPage.saveButton.click(); + }); + + await test.step('Assert comment is indicated on putaway details page', async () => { + await putawayDetailsPage.isLoaded(); + await putawayDetailsPage.commentsTab.click(); + await expect(putawayDetailsPage.badgeCount).toBeVisible(); + await expect(putawayDetailsPage.badgeCount).toHaveAttribute( + 'data-count', + '1' + ); + }); + + await test.step('Assert content of comments tab', async () => { + await expect( + putawayDetailsPage.commentsTable.getColumnHeader('to') + ).toBeVisible(); + await expect( + putawayDetailsPage.commentsTable.getColumnHeader('from') + ).toBeVisible(); + await expect( + putawayDetailsPage.commentsTable.getColumnHeader('Comment') + ).toBeVisible(); + await expect( + putawayDetailsPage.commentsTable.getColumnHeader('Date') + ).toBeVisible(); + await expect( + putawayDetailsPage.commentsTable.getColumnHeader('Actions') + ).toBeVisible(); + }); + + await test.step('Assert content of added comment', async () => { + await expect( + putawayDetailsPage.commentsTable.row(2).commentContent + ).toHaveText('add comment'); + }); + + await test.step('Edit added comment', async () => { + await putawayDetailsPage.commentsTable.row(2).editButton.click(); + await addCommentToPutawayPage.isLoaded(); + await expect(addCommentToPutawayPage.commentField).toHaveText( + 'add comment' + ); + await addCommentToPutawayPage.commentField.fill('edit added comment'); + await addCommentToPutawayPage.saveButton.click(); + }); + + await test.step('Assert comment is indicated on putaway details page', async () => { + await putawayDetailsPage.isLoaded(); + await putawayDetailsPage.commentsTab.click(); + await expect(putawayDetailsPage.badgeCount).toBeVisible(); + await expect(putawayDetailsPage.badgeCount).toHaveAttribute( + 'data-count', + '1' + ); + }); + + await test.step('Assert content of added comment', async () => { + await expect(putawayDetailsPage.commentsTable.rows).toHaveCount(1); + await expect( + putawayDetailsPage.commentsTable.row(2).commentContent + ).toHaveText('edit added comment'); + }); + + await test.step('Add another comment to pending putaway', async () => { + await expect(putawayDetailsPage.addCommentButton).toBeVisible(); + await putawayDetailsPage.addCommentButton.click(); + await addCommentToPutawayPage.isLoaded(); + await addCommentToPutawayPage.commentField.fill('add another comment'); + await addCommentToPutawayPage.saveButton.click(); + }); + + await test.step('Assert comment is indicated on putaway details page', async () => { + await putawayDetailsPage.isLoaded(); + await putawayDetailsPage.commentsTab.click(); + await expect(putawayDetailsPage.badgeCount).toBeVisible(); + await expect(putawayDetailsPage.badgeCount).toHaveAttribute( + 'data-count', + '2' + ); + await putawayDetailsPage.commentsTable.isLoaded(); + await expect(putawayDetailsPage.commentsTable.rows).toHaveCount(4); + }); + + await test.step('Delete added comment', async () => { + await putawayDetailsPage.commentsTable.clickDeleteCommentButton(2); + await putawayDetailsPage.isLoaded(); + }); + + await test.step('Assert delete comment is indicated on putaway details page', async () => { + await putawayDetailsPage.isLoaded(); + await putawayDetailsPage.commentsTab.click(); + await expect(putawayDetailsPage.badgeCount).toBeVisible(); + await expect(putawayDetailsPage.badgeCount).toHaveAttribute( + 'data-count', + '1' + ); + await expect(putawayDetailsPage.commentsTable.rows).toHaveCount(3); + }); + + await test.step('Assert delete added comments', async () => { + await putawayDetailsPage.commentsTable.clickDeleteCommentButton(2); + await putawayDetailsPage.isLoaded(); + await putawayDetailsPage.commentsTab.click(); + await expect( + putawayDetailsPage.commentsTable.emptyCommentTable + ).toBeVisible(); + await expect(putawayDetailsPage.badgeCount).toBeHidden(); + }); + + await test.step('Return to putaway and complete it', async () => { + await putawayDetailsPage.editButton.click(); + 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 expect( + putawayDetailsPage.orderHeaderTable.statusRowValue + ).toContainText('Completed'); + await putawayDetailsPage.isLoaded(); + }); + + await test.step('Add comment to compleded putaway', async () => { + await putawayDetailsPage.isLoaded(); + await expect(putawayDetailsPage.addCommentButton).toBeVisible(); + await putawayDetailsPage.addCommentButton.click(); + await addCommentToPutawayPage.isLoaded(); + await addCommentToPutawayPage.selectRecipient(managerUser.name); + await expect(addCommentToPutawayPage.senderName).toContainText( + mainUser.name + ); + await addCommentToPutawayPage.commentField.fill( + 'add comment to completed putaway' + ); + await addCommentToPutawayPage.saveButton.click(); + }); + + await test.step('Assert comment is indicated on putaway details page', async () => { + await putawayDetailsPage.isLoaded(); + await putawayDetailsPage.commentsTab.click(); + await expect(putawayDetailsPage.badgeCount).toBeVisible(); + await expect(putawayDetailsPage.badgeCount).toHaveAttribute( + 'data-count', + '1' + ); + }); + + await test.step('Assert content of added comment', async () => { + await expect(putawayDetailsPage.commentsTable.rows).toHaveCount(3); + await expect( + putawayDetailsPage.commentsTable.row(2).recipientContent + ).toContainText(managerUser.name); + await expect( + putawayDetailsPage.commentsTable.row(2).senderContent + ).toContainText(mainUser.name); + await expect( + putawayDetailsPage.commentsTable.row(2).commentContent + ).toHaveText('add comment to completed putaway'); + }); + }); +}); From de73c4172b96c3a79595ad6a07e69855a048ec8a Mon Sep 17 00:00:00 2001 From: Katarzyna Date: Wed, 1 Jul 2026 15:04:03 +0200 Subject: [PATCH 05/10] improve wait for loading tab --- .../putaway/putawayDetails/PutawayDetailsPage.ts | 10 ++++++++++ src/tests/putaway/addCommentToPutaway.test.ts | 14 +++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/pages/putaway/putawayDetails/PutawayDetailsPage.ts b/src/pages/putaway/putawayDetails/PutawayDetailsPage.ts index ff5fd9f..0fd56a8 100644 --- a/src/pages/putaway/putawayDetails/PutawayDetailsPage.ts +++ b/src/pages/putaway/putawayDetails/PutawayDetailsPage.ts @@ -134,6 +134,16 @@ class PutawayDetailsPage extends BasePageModel { get badgeCount() { return this.page.locator('li.tab-badge'); } + + get spinner() { + return this.page.locator('.loading'); + } + + async waitUntilSpinnerHides() { + await this.spinner.waitFor({ + state: 'hidden', + }); + } } export default PutawayDetailsPage; diff --git a/src/tests/putaway/addCommentToPutaway.test.ts b/src/tests/putaway/addCommentToPutaway.test.ts index e6a2d9f..9839cd3 100644 --- a/src/tests/putaway/addCommentToPutaway.test.ts +++ b/src/tests/putaway/addCommentToPutaway.test.ts @@ -154,6 +154,8 @@ test.describe('Add comment to Putaway', () => { await test.step('Assert comment is indicated on putaway details page', async () => { await putawayDetailsPage.isLoaded(); await putawayDetailsPage.commentsTab.click(); + await putawayDetailsPage.waitUntilSpinnerHides(); + await putawayDetailsPage.commentsTable.isLoaded(); await expect(putawayDetailsPage.badgeCount).toBeVisible(); await expect(putawayDetailsPage.badgeCount).toHaveAttribute( 'data-count', @@ -198,6 +200,8 @@ test.describe('Add comment to Putaway', () => { await test.step('Assert comment is indicated on putaway details page', async () => { await putawayDetailsPage.isLoaded(); await putawayDetailsPage.commentsTab.click(); + await putawayDetailsPage.waitUntilSpinnerHides(); + await putawayDetailsPage.commentsTable.isLoaded(); await expect(putawayDetailsPage.badgeCount).toBeVisible(); await expect(putawayDetailsPage.badgeCount).toHaveAttribute( 'data-count', @@ -206,7 +210,7 @@ test.describe('Add comment to Putaway', () => { }); await test.step('Assert content of added comment', async () => { - await expect(putawayDetailsPage.commentsTable.rows).toHaveCount(1); + await expect(putawayDetailsPage.commentsTable.rows).toHaveCount(3); await expect( putawayDetailsPage.commentsTable.row(2).commentContent ).toHaveText('edit added comment'); @@ -223,6 +227,8 @@ test.describe('Add comment to Putaway', () => { await test.step('Assert comment is indicated on putaway details page', async () => { await putawayDetailsPage.isLoaded(); await putawayDetailsPage.commentsTab.click(); + await putawayDetailsPage.waitUntilSpinnerHides(); + await putawayDetailsPage.commentsTable.isLoaded(); await expect(putawayDetailsPage.badgeCount).toBeVisible(); await expect(putawayDetailsPage.badgeCount).toHaveAttribute( 'data-count', @@ -240,6 +246,8 @@ test.describe('Add comment to Putaway', () => { await test.step('Assert delete comment is indicated on putaway details page', async () => { await putawayDetailsPage.isLoaded(); await putawayDetailsPage.commentsTab.click(); + await putawayDetailsPage.waitUntilSpinnerHides(); + await putawayDetailsPage.commentsTable.isLoaded(); await expect(putawayDetailsPage.badgeCount).toBeVisible(); await expect(putawayDetailsPage.badgeCount).toHaveAttribute( 'data-count', @@ -252,6 +260,8 @@ test.describe('Add comment to Putaway', () => { await putawayDetailsPage.commentsTable.clickDeleteCommentButton(2); await putawayDetailsPage.isLoaded(); await putawayDetailsPage.commentsTab.click(); + await putawayDetailsPage.waitUntilSpinnerHides(); + await putawayDetailsPage.commentsTable.isLoaded(); await expect( putawayDetailsPage.commentsTable.emptyCommentTable ).toBeVisible(); @@ -292,6 +302,8 @@ test.describe('Add comment to Putaway', () => { await test.step('Assert comment is indicated on putaway details page', async () => { await putawayDetailsPage.isLoaded(); await putawayDetailsPage.commentsTab.click(); + await putawayDetailsPage.waitUntilSpinnerHides(); + await putawayDetailsPage.commentsTable.isLoaded(); await expect(putawayDetailsPage.badgeCount).toBeVisible(); await expect(putawayDetailsPage.badgeCount).toHaveAttribute( 'data-count', From 7f575434c0bc067100ed5422f67a875b1b2e78c7 Mon Sep 17 00:00:00 2001 From: Katarzyna Date: Thu, 2 Jul 2026 15:41:12 +0200 Subject: [PATCH 06/10] improve navigation on rows on putaway list --- src/pages/putaway/list/PutawayListTable.ts | 9 +++ src/pages/putaway/steps/StartStep.ts | 6 ++ src/tests/putaway/addCommentToPutaway.test.ts | 15 +++- .../putaway/assertPutawayDetailsPage.test.ts | 30 ++++--- .../changeLocationOnCreatePutawayPage.test.ts | 26 ++++-- .../putaway/deleteItemsFromPutaway.test.ts | 53 +++++++++--- .../putaway/deletePendingPutaway.test.ts | 80 +++++++++++++++++-- .../performPutawayAsManagerUser.test.ts | 54 ++++++++----- .../putaway/putawayMoreThan1Item.test.ts | 10 ++- .../putaway/qtyValidationsInPutaways.test.ts | 11 ++- ...lbackLastReceiptWhenPutawayCreated.test.ts | 7 +- ...ByCurrentPreferredAndOriginalOrder.test.ts | 13 ++- ...dationOnQtyRemovedFromReceivingBin.test.ts | 10 ++- 13 files changed, 254 insertions(+), 70 deletions(-) diff --git a/src/pages/putaway/list/PutawayListTable.ts b/src/pages/putaway/list/PutawayListTable.ts index 095f666..b5f6075 100644 --- a/src/pages/putaway/list/PutawayListTable.ts +++ b/src/pages/putaway/list/PutawayListTable.ts @@ -15,6 +15,15 @@ class PutawayListTable extends BasePageModel { return new Row(this.page, this.rows.nth(index)); } + rowByOrderNumber(orderNumber: string) { + return new Row( + this.page, + this.rows.filter({ + has: this.page.getByTestId('order-number').getByText(orderNumber), + }) + ); + } + async clickDeleteOrderButton(index: number) { this.page.once('dialog', (dialog) => dialog.accept()); await this.row(index).deleteOrder.click(); diff --git a/src/pages/putaway/steps/StartStep.ts b/src/pages/putaway/steps/StartStep.ts index b2993da..ff1f3f9 100644 --- a/src/pages/putaway/steps/StartStep.ts +++ b/src/pages/putaway/steps/StartStep.ts @@ -55,6 +55,12 @@ class StartStep extends BasePageModel { async closeDisplayedError() { return this.page.locator('.alert-close-icon').first().click(); } + + get orderNumberValue() { + return this.page.locator( + '[data-testid=\'wizardTitle\'] > div > span:nth-of-type(2)' + ); + } } export default StartStep; diff --git a/src/tests/putaway/addCommentToPutaway.test.ts b/src/tests/putaway/addCommentToPutaway.test.ts index 9839cd3..b056267 100644 --- a/src/tests/putaway/addCommentToPutaway.test.ts +++ b/src/tests/putaway/addCommentToPutaway.test.ts @@ -119,6 +119,9 @@ test.describe('Add comment to Putaway', () => { await createPutawayPage.startStep.isLoaded(); }); + const putawayOrderIdentifier = + await createPutawayPage.startStep.orderNumberValue.textContent(); + await test.step('Select bin to putaway', async () => { await createPutawayPage.startStep.table.row(0).putawayBinSelect.click(); await createPutawayPage.startStep.table @@ -131,13 +134,17 @@ test.describe('Add comment to Putaway', () => { await test.step('Go to putaway list page', async () => { await putawayListPage.goToPage(); await putawayListPage.isLoaded(); - await expect(putawayListPage.table.row(1).statusTag).toHaveText( - 'Pending' - ); + await expect( + putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ).statusTag + ).toHaveText('Pending'); }); await test.step('Go to putaway view page', async () => { - const row = putawayListPage.table.row(1); + const row = putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ); await row.actionsButton.click(); await row.viewOrderDetails.click(); await putawayDetailsPage.isLoaded(); diff --git a/src/tests/putaway/assertPutawayDetailsPage.test.ts b/src/tests/putaway/assertPutawayDetailsPage.test.ts index 4188f4e..a706503 100644 --- a/src/tests/putaway/assertPutawayDetailsPage.test.ts +++ b/src/tests/putaway/assertPutawayDetailsPage.test.ts @@ -132,6 +132,9 @@ test.describe('Assert putaway details page', () => { await createPutawayPage.startStep.isLoaded(); }); + const putawayOrderIdentifier = + await createPutawayPage.startStep.orderNumberValue.textContent(); + await test.step('Select bin to putaway', async () => { await createPutawayPage.startStep.table.row(0).putawayBinSelect.click(); await createPutawayPage.startStep.table @@ -150,16 +153,20 @@ test.describe('Assert putaway details page', () => { await expect(putawayListPage.orderTypeFilter).toBeDisabled(); await expect(putawayListPage.statusFilter).toContainText('Pending'); await expect(putawayListPage.statusFilter).toBeEnabled(); - await expect(putawayListPage.table.row(1).statusTag).toHaveText( - 'Pending' - ); + await expect( + putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ).statusTag + ).toHaveText('Pending'); await expect(putawayListPage.destinationFilter).toContainText( currentLocation.name ); }); await test.step('Go to putaway view page and assert page elements', async () => { - const row = putawayListPage.table.row(1); + const row = putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ); await row.actionsButton.click(); await row.viewOrderDetails.click(); await putawayDetailsPage.isLoaded(); @@ -266,9 +273,6 @@ test.describe('Assert putaway details page', () => { await putawayDetailsPage.summaryActionsButton.click(); }); - const putawayOrderIdentifier = - await putawayDetailsPage.orderHeaderTable.orderNumberValue.textContent(); - const detailsPagePdfFileName = 'Putaway ' + `${putawayOrderIdentifier}`.toString().trim() + '.pdf'; @@ -370,15 +374,19 @@ test.describe('Assert putaway details page', () => { `${putawayOrderIdentifier}`.toString().trim() ); await putawayListPage.searchButton.click(); - await expect(putawayListPage.table.row(1).statusTag).toHaveText( - 'Completed' - ); + await expect( + putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ).statusTag + ).toHaveText('Completed'); }); await test.step('Download putaway pdf from putaway list', async () => { const generatePutawayPdfFileName = 'Putaway ' + `${putawayOrderIdentifier}`.toString().trim() + '.pdf'; - const row = putawayListPage.table.row(1); + const row = putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ); await row.actionsButton.click(); await row.generatePdf.click(); await putawayDetailsPage.fileHandler.onDownload(); diff --git a/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts b/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts index 76d127b..d201229 100644 --- a/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts +++ b/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts @@ -12,6 +12,7 @@ import { test.describe('Change location on putaway create page and list pages', () => { let STOCK_MOVEMENT: StockMovementResponse; + let putawayOrderIdentifier: string | undefined; test.beforeEach( async ({ @@ -20,6 +21,7 @@ test.describe('Change location on putaway create page and list pages', () => { productService, receivingService, }) => { + putawayOrderIdentifier = undefined; const supplierLocation = await supplierLocationService.getLocation(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -63,8 +65,11 @@ test.describe('Change location on putaway create page and list pages', () => { putawayListPage, oldViewShipmentPage, }) => { + if (!putawayOrderIdentifier) return; await putawayListPage.goToPage(); - await putawayListPage.table.row(1).actionsButton.click(); + await putawayListPage.table + .rowByOrderNumber(`${putawayOrderIdentifier}`.toString().trim()) + .actionsButton.click(); await putawayListPage.table.clickDeleteOrderButton(1); await putawayListPage.emptyPutawayList.isVisible(); @@ -150,21 +155,26 @@ test.describe('Change location on putaway create page and list pages', () => { await createPutawayPage.table.row(1).checkbox.click(); await createPutawayPage.startPutawayButton.click(); await createPutawayPage.startStep.isLoaded(); + }); + + putawayOrderIdentifier = + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + (await createPutawayPage.startStep.orderNumberValue.textContent())!; + + await test.step('Save pending putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); await test.step('Go to list page and assert putaway is created', async () => { await putawayListPage.goToPage(); await putawayListPage.isLoaded(); - await expect(putawayListPage.table.row(1).statusTag).toHaveText( - 'Pending' - ); + await expect( + putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ).statusTag + ).toHaveText('Pending'); }); - const putawayOrderIdentifier = await putawayListPage.table - .row(1) - .orderNumber.textContent(); - await test.step('Change location to another depot', async () => { await navbar.locationChooserButton.click(); await locationChooser diff --git a/src/tests/putaway/deleteItemsFromPutaway.test.ts b/src/tests/putaway/deleteItemsFromPutaway.test.ts index 012bb39..b960a79 100644 --- a/src/tests/putaway/deleteItemsFromPutaway.test.ts +++ b/src/tests/putaway/deleteItemsFromPutaway.test.ts @@ -130,14 +130,26 @@ test.describe('Delete items from putaway', () => { await createPutawayPage.table.row(2).checkbox.click(); await createPutawayPage.startPutawayButton.click(); await createPutawayPage.startStep.isLoaded(); + }); + + const putawayOrderIdentifier = + await createPutawayPage.startStep.orderNumberValue.textContent(); + + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); await test.step('Go to putaway list page and assert number of lines', async () => { await putawayListPage.goToPage(); await putawayListPage.isLoaded(); - await expect(putawayListPage.table.row(1).lineItems).toContainText('2'); - const row = putawayListPage.table.row(1); + await expect( + putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ).lineItems + ).toContainText('2'); + const row = putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ); await row.actionsButton.click(); await row.viewOrderDetails.click(); await putawayDetailsPage.isLoaded(); @@ -186,8 +198,14 @@ test.describe('Delete items from putaway', () => { await test.step('Go to putaway list page and assert number of lines', async () => { await putawayListPage.goToPage(); await putawayListPage.isLoaded(); - await expect(putawayListPage.table.row(1).lineItems).toContainText('1'); - const row = putawayListPage.table.row(1); + await expect( + putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ).lineItems + ).toContainText('1'); + const row = putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ); await row.actionsButton.click(); await row.viewOrderDetails.click(); await putawayDetailsPage.isLoaded(); @@ -267,8 +285,14 @@ test.describe('Delete items from putaway', () => { await test.step('Go to putaway list page and assert number of lines', async () => { await putawayListPage.goToPage(); await putawayListPage.isLoaded(); - await expect(putawayListPage.table.row(1).lineItems).toContainText('2'); - const row = putawayListPage.table.row(1); + await expect( + putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ).lineItems + ).toContainText('2'); + const row = putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ); await row.actionsButton.click(); await row.viewOrderDetails.click(); await putawayDetailsPage.isLoaded(); @@ -351,9 +375,6 @@ test.describe('Delete items from putaway', () => { ).toHaveCount(2); }); - const putawayOrderIdentifier = - await putawayDetailsPage.orderHeaderTable.orderNumberValue.textContent(); - await test.step('Assert completed putaway on list putaway and assert number of lines', async () => { await putawayListPage.goToPage(); await putawayListPage.clearFilteringButton.click(); @@ -361,10 +382,16 @@ test.describe('Delete items from putaway', () => { `${putawayOrderIdentifier}`.toString().trim() ); await putawayListPage.searchButton.click(); - await expect(putawayListPage.table.row(1).statusTag).toHaveText( - 'Completed' - ); - await expect(putawayListPage.table.row(1).lineItems).toContainText('2'); + await expect( + putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ).statusTag + ).toHaveText('Completed'); + await expect( + putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ).lineItems + ).toContainText('2'); }); }); }); diff --git a/src/tests/putaway/deletePendingPutaway.test.ts b/src/tests/putaway/deletePendingPutaway.test.ts index 5f89ee3..29fcf32 100644 --- a/src/tests/putaway/deletePendingPutaway.test.ts +++ b/src/tests/putaway/deletePendingPutaway.test.ts @@ -110,6 +110,12 @@ test.describe('Delete pending putaways', () => { await createPutawayPage.table.row(1).checkbox.click(); await createPutawayPage.startPutawayButton.click(); await createPutawayPage.startStep.isLoaded(); + }); + + const putawayOrderIdentifier = + await createPutawayPage.startStep.orderNumberValue.textContent(); + + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -119,7 +125,9 @@ test.describe('Delete pending putaways', () => { await expect( putawayListPage.table.rows.filter({ has: page.locator('td') }) ).toHaveCount(1); - const row = putawayListPage.table.row(1); + const row = putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ); await row.actionsButton.click(); await putawayListPage.table.clickDeleteOrderButton(1); await putawayListPage.emptyPutawayList.isVisible(); @@ -161,6 +169,12 @@ test.describe('Delete pending putaways', () => { await createPutawayPage.table.row(1).checkbox.click(); await createPutawayPage.startPutawayButton.click(); await createPutawayPage.startStep.isLoaded(); + }); + + const putawayOrderIdentifier = + await createPutawayPage.startStep.orderNumberValue.textContent(); + + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -170,7 +184,9 @@ test.describe('Delete pending putaways', () => { await expect( putawayListPage.table.rows.filter({ has: page.locator('td') }) ).toHaveCount(1); - const row = putawayListPage.table.row(1); + const row = putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ); await row.actionsButton.click(); await row.viewOrderDetails.click(); }); @@ -220,6 +236,12 @@ test.describe('Delete pending putaways', () => { await createPutawayPage.table.row(1).checkbox.click(); await createPutawayPage.startPutawayButton.click(); await createPutawayPage.startStep.isLoaded(); + }); + + const putawayOrderIdentifier = + await createPutawayPage.startStep.orderNumberValue.textContent(); + + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -231,7 +253,9 @@ test.describe('Delete pending putaways', () => { has: managerUserPage.locator('td'), }) ).toHaveCount(1); - const row = putawayListPage.table.row(1); + const row = putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ); await row.actionsButton.click(); await putawayListPage.table.clickDeleteOrderButton(1); await putawayListPage.emptyPutawayList.isVisible(); @@ -276,6 +300,12 @@ test.describe('Delete pending putaways', () => { await createPutawayPage.table.row(1).checkbox.click(); await createPutawayPage.startPutawayButton.click(); await createPutawayPage.startStep.isLoaded(); + }); + + const putawayOrderIdentifier = + await createPutawayPage.startStep.orderNumberValue.textContent(); + + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -287,7 +317,9 @@ test.describe('Delete pending putaways', () => { has: managerUserPage.locator('td'), }) ).toHaveCount(1); - const row = putawayListPage.table.row(1); + const row = putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ); await row.actionsButton.click(); await row.viewOrderDetails.click(); }); @@ -338,6 +370,12 @@ test.describe('Delete pending putaways', () => { await createPutawayPage.table.row(1).checkbox.click(); await createPutawayPage.startPutawayButton.click(); await createPutawayPage.startStep.isLoaded(); + }); + + const putawayOrderIdentifier = + await createPutawayPage.startStep.orderNumberValue.textContent(); + + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -349,7 +387,9 @@ test.describe('Delete pending putaways', () => { has: adminUserPage.locator('td'), }) ).toHaveCount(1); - const row = putawayListPage.table.row(1); + const row = putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ); await row.actionsButton.click(); await putawayListPage.table.clickDeleteOrderButton(1); await putawayListPage.emptyPutawayList.isVisible(); @@ -394,6 +434,12 @@ test.describe('Delete pending putaways', () => { await createPutawayPage.table.row(1).checkbox.click(); await createPutawayPage.startPutawayButton.click(); await createPutawayPage.startStep.isLoaded(); + }); + + const putawayOrderIdentifier = + await createPutawayPage.startStep.orderNumberValue.textContent(); + + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -405,7 +451,9 @@ test.describe('Delete pending putaways', () => { has: adminUserPage.locator('td'), }) ).toHaveCount(1); - const row = putawayListPage.table.row(1); + const row = putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ); await row.actionsButton.click(); await row.viewOrderDetails.click(); }); @@ -456,6 +504,12 @@ test.describe('Delete pending putaways', () => { await createPutawayPage.table.row(1).checkbox.click(); await createPutawayPage.startPutawayButton.click(); await createPutawayPage.startStep.isLoaded(); + }); + + const putawayOrderIdentifier = + await createPutawayPage.startStep.orderNumberValue.textContent(); + + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -467,7 +521,9 @@ test.describe('Delete pending putaways', () => { has: assistantUserPage.locator('td'), }) ).toHaveCount(1); - const row = putawayListPage.table.row(1); + const row = putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ); await row.actionsButton.click(); await putawayListPage.table.clickDeleteOrderButton(1); await putawayListPage.emptyPutawayList.isVisible(); @@ -512,6 +568,12 @@ test.describe('Delete pending putaways', () => { await createPutawayPage.table.row(1).checkbox.click(); await createPutawayPage.startPutawayButton.click(); await createPutawayPage.startStep.isLoaded(); + }); + + const putawayOrderIdentifier = + await createPutawayPage.startStep.orderNumberValue.textContent(); + + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -523,7 +585,9 @@ test.describe('Delete pending putaways', () => { has: assistantUserPage.locator('td'), }) ).toHaveCount(1); - const row = putawayListPage.table.row(1); + const row = putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ); await row.actionsButton.click(); await row.viewOrderDetails.click(); }); diff --git a/src/tests/putaway/performPutawayAsManagerUser.test.ts b/src/tests/putaway/performPutawayAsManagerUser.test.ts index 725670a..e0dc37d 100644 --- a/src/tests/putaway/performPutawayAsManagerUser.test.ts +++ b/src/tests/putaway/performPutawayAsManagerUser.test.ts @@ -101,7 +101,7 @@ test.describe('Perform putaway as manager user', () => { internalLocationService, }) => { const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;; + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; const internalLocation = await internalLocationService.getLocation(); const managerUserPage = await managerUserContext.newPage(); @@ -274,6 +274,12 @@ test.describe('Perform putaway as manager user', () => { .row(2) .getPutawayBin(internalLocation.name) .click(); + }); + + const putawayOrderIdentifier = + await createPutawayPageManagerUser.startStep.orderNumberValue.textContent(); + + await test.step('Save putaway', async () => { await createPutawayPageManagerUser.startStep.saveButton.click(); await managerUserPage.close(); }); @@ -281,12 +287,11 @@ test.describe('Perform putaway as manager user', () => { await test.step('Go to list putaway page as main user and use filters', async () => { await putawayListPage.goToPage(); await putawayListPage.isLoaded(); - await expect(putawayListPage.table.row(1).statusTag).toHaveText( - 'Pending' - ); - const putawayOrderIdentifier = await putawayListPage.table - .row(1) - .orderNumber.textContent(); + await expect( + putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ).statusTag + ).toHaveText('Pending'); await putawayListPage.searchField.fill( `${putawayOrderIdentifier}`.toString().trim() ); @@ -294,15 +299,14 @@ test.describe('Perform putaway as manager user', () => { await putawayListPage.orderedByTextInput.fill(managerUser.name); await putawayListPage.getOrderedBy(managerUser.name); await putawayListPage.searchButton.click(); - await expect(putawayListPage.table.row(1).orderedBy).toContainText( - managerUser.name - ); + await expect( + putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ).orderedBy + ).toContainText(managerUser.name); }); await test.step('Clear applied filters and filter by created by ans status', async () => { - const putawayOrderIdentifier = await putawayListPage.table - .row(1) - .orderNumber.textContent(); await putawayListPage.isLoaded(); await putawayListPage.clearFilteringButton.click(); await putawayListPage.statusFilter.click(); @@ -312,17 +316,25 @@ test.describe('Perform putaway as manager user', () => { await putawayListPage.createdByTextInput.fill(managerUser.name); await putawayListPage.getCreatedBy(managerUser.name); await putawayListPage.searchButton.click(); - await expect(putawayListPage.table.row(1).orderNumber).toContainText( - `${putawayOrderIdentifier}` - ); - await expect(putawayListPage.table.row(1).statusTag).toHaveText( - 'Pending' - ); + await expect( + putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ).orderNumber + ).toContainText(`${putawayOrderIdentifier}`); + await expect( + putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ).statusTag + ).toHaveText('Pending'); }); await test.step('Go to putaway details page', async () => { - await putawayListPage.table.row(1).actionsButton.click(); - await putawayListPage.table.row(1).viewOrderDetails.click(); + await putawayListPage.table + .rowByOrderNumber(`${putawayOrderIdentifier}`.toString().trim()) + .actionsButton.click(); + await putawayListPage.table + .rowByOrderNumber(`${putawayOrderIdentifier}`.toString().trim()) + .viewOrderDetails.click(); await putawayDetailsPage.isLoaded(); }); diff --git a/src/tests/putaway/putawayMoreThan1Item.test.ts b/src/tests/putaway/putawayMoreThan1Item.test.ts index 512892d..1e44df2 100644 --- a/src/tests/putaway/putawayMoreThan1Item.test.ts +++ b/src/tests/putaway/putawayMoreThan1Item.test.ts @@ -145,6 +145,12 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { .row(1) .getPutawayBin(internalLocation.name) .click(); + }); + + const putawayOrderIdentifier = + await createPutawayPage.startStep.orderNumberValue.textContent(); + + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -168,7 +174,9 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { await test.step('Go to putaway list page and edit created pending putaway', async () => { await putawayListPage.goToPage(); await putawayListPage.isLoaded(); - const row = putawayListPage.table.row(1); + const row = putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ); await row.actionsButton.click(); await row.viewOrderDetails.click(); await putawayDetailsPage.isLoaded(); diff --git a/src/tests/putaway/qtyValidationsInPutaways.test.ts b/src/tests/putaway/qtyValidationsInPutaways.test.ts index 916a4ad..c9853e7 100644 --- a/src/tests/putaway/qtyValidationsInPutaways.test.ts +++ b/src/tests/putaway/qtyValidationsInPutaways.test.ts @@ -12,6 +12,7 @@ import { test.describe('Assert qty validations in putaways', () => { let STOCK_MOVEMENT: StockMovementResponse; + let putawayOrderIdentifier: string | undefined; test.beforeEach( async ({ @@ -20,6 +21,7 @@ test.describe('Assert qty validations in putaways', () => { productService, receivingService, }) => { + putawayOrderIdentifier = undefined; const supplierLocation = await supplierLocationService.getLocation(); STOCK_MOVEMENT = await stockMovementService.createInbound({ originId: supplierLocation.id, @@ -63,8 +65,11 @@ test.describe('Assert qty validations in putaways', () => { stockMovementService, oldViewShipmentPage, }) => { + if (!putawayOrderIdentifier) return; await putawayListPage.goToPage(); - await putawayListPage.table.row(1).actionsButton.click(); + await putawayListPage.table + .rowByOrderNumber(`${putawayOrderIdentifier}`.toString().trim()) + .actionsButton.click(); await putawayListPage.table.clickDeleteOrderButton(1); await putawayListPage.emptyPutawayList.isVisible(); @@ -105,6 +110,10 @@ test.describe('Assert qty validations in putaways', () => { await createPutawayPage.startStep.isLoaded(); }); + putawayOrderIdentifier = + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + (await createPutawayPage.startStep.orderNumberValue.textContent())!; + await test.step('Try to edit qty to higher and assert validations', async () => { await createPutawayPage.startStep.table.row(0).editButton.click(); await createPutawayPage.startStep.table.row(0).quantityInput.fill('20'); diff --git a/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts b/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts index d6b205d..61ae8e3 100644 --- a/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts +++ b/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts @@ -111,6 +111,9 @@ test.describe('Rollback last receipt behavior when putaway created', () => { await createPutawayPage.startStep.isLoaded(); }); + const putawayOrderIdentifier = + await createPutawayPage.startStep.orderNumberValue.textContent(); + await test.step('Select bin to putaway', async () => { const internalLocation = await internalLocationService.getLocation(); await createPutawayPage.startStep.table.row(0).putawayBinSelect.click(); @@ -158,7 +161,9 @@ test.describe('Rollback last receipt behavior when putaway created', () => { }); await test.step('Open putaway details page', async () => { - const row = putawayListPage.table.row(1); + const row = putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ); await row.actionsButton.click(); await row.viewOrderDetails.click(); await putawayDetailsPage.isLoaded(); diff --git a/src/tests/putaway/sortPutawayByCurrentPreferredAndOriginalOrder.test.ts b/src/tests/putaway/sortPutawayByCurrentPreferredAndOriginalOrder.test.ts index 01b8fa2..4ef27df 100644 --- a/src/tests/putaway/sortPutawayByCurrentPreferredAndOriginalOrder.test.ts +++ b/src/tests/putaway/sortPutawayByCurrentPreferredAndOriginalOrder.test.ts @@ -31,6 +31,8 @@ test.describe('Sort putaway by current bin, preferred bin and original order', ( let binOne: LocationResponse; let binTwo: LocationResponse; + let putawayOrderIdentifier: string | undefined; + test.beforeEach( async ({ supplierLocationService, @@ -42,6 +44,7 @@ test.describe('Sort putaway by current bin, preferred bin and original order', ( productShowPage, productEditPage, }) => { + putawayOrderIdentifier = undefined; [productA, productB, productC] = [ await productService.getProduct(Product.ONE), await productService.getProduct(Product.TWO), @@ -96,7 +99,11 @@ test.describe('Sort putaway by current bin, preferred bin and original order', ( // Remove the pending 2nd putaway await putawayListPage.goToPage(); await putawayListPage.isLoaded(); - await putawayListPage.table.row(1).actionsButton.click(); + if (!putawayOrderIdentifier) return; + await putawayListPage.goToPage(); + await putawayListPage.table + .rowByOrderNumber(`${putawayOrderIdentifier}`.toString().trim()) + .actionsButton.click(); await putawayListPage.table.clickDeleteOrderButton(1); // Delete the 3 created transactions @@ -216,6 +223,10 @@ test.describe('Sort putaway by current bin, preferred bin and original order', ( await createPutawayPage.startStep.isLoaded(); }); + putawayOrderIdentifier = + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + (await createPutawayPage.startStep.orderNumberValue.textContent())!; + await test.step('assert original order of items', async () => { await expect(createPutawayPage.startStep.sortButton).toContainText( 'Sort by current bins' diff --git a/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts b/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts index 47897ba..f67ddc9 100644 --- a/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts +++ b/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts @@ -214,6 +214,12 @@ test.describe('Assert validation on qty removed from receiving bin', () => { await expect(createPutawayPage.startStep.table.rows).toHaveCount(2); await expect(createPutawayPage.startStep.saveButton).toBeEnabled(); await expect(createPutawayPage.startStep.nextButton).toBeEnabled(); + }); + + const putawayOrderIdentifier = + await createPutawayPage.startStep.orderNumberValue.textContent(); + + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -233,7 +239,9 @@ test.describe('Assert validation on qty removed from receiving bin', () => { await test.step('Go to putaway list page and edit created pending putaway', async () => { await putawayListPage.goToPage(); await putawayListPage.isLoaded(); - const row = putawayListPage.table.row(1); + const row = putawayListPage.table.rowByOrderNumber( + `${putawayOrderIdentifier}`.toString().trim() + ); await row.actionsButton.click(); await row.viewOrderDetails.click(); await putawayDetailsPage.isLoaded(); From 3c8e0f87d612a1a9f6f32baca8d31f7fc91aa233 Mon Sep 17 00:00:00 2001 From: Katarzyna Date: Mon, 6 Jul 2026 12:37:29 +0200 Subject: [PATCH 07/10] improvements after review --- .../components/CommentsTable.ts | 6 +-- src/pages/putaway/steps/StartStep.ts | 4 +- src/tests/putaway/addCommentToPutaway.test.ts | 33 +++++++------ .../putaway/assertPutawayDetailsPage.test.ts | 22 ++++----- .../changeLocationOnCreatePutawayPage.test.ts | 17 ++++--- .../putaway/deleteItemsFromPutaway.test.ts | 39 +++++++-------- .../putaway/deletePendingPutaway.test.ts | 48 +++++++++++++++---- .../performPutawayAsManagerUser.test.ts | 32 ++++++------- .../putaway/putawayMoreThan1Item.test.ts | 6 ++- ...lbackLastReceiptWhenPutawayCreated.test.ts | 6 ++- ...dationOnQtyRemovedFromReceivingBin.test.ts | 6 ++- 11 files changed, 129 insertions(+), 90 deletions(-) diff --git a/src/pages/putaway/putawayDetails/components/CommentsTable.ts b/src/pages/putaway/putawayDetails/components/CommentsTable.ts index 7a7dcac..ffca7ad 100644 --- a/src/pages/putaway/putawayDetails/components/CommentsTable.ts +++ b/src/pages/putaway/putawayDetails/components/CommentsTable.ts @@ -48,15 +48,15 @@ class Row extends BasePageModel { this.row = row; } - get commentContent() { + get comment() { return this.row.getByRole('cell').nth(2); } - get recipientContent() { + get recipient() { return this.row.getByRole('cell').nth(0); } - get senderContent() { + get sender() { return this.row.getByRole('cell').nth(1); } diff --git a/src/pages/putaway/steps/StartStep.ts b/src/pages/putaway/steps/StartStep.ts index ff1f3f9..f626e65 100644 --- a/src/pages/putaway/steps/StartStep.ts +++ b/src/pages/putaway/steps/StartStep.ts @@ -57,9 +57,7 @@ class StartStep extends BasePageModel { } get orderNumberValue() { - return this.page.locator( - '[data-testid=\'wizardTitle\'] > div > span:nth-of-type(2)' - ); + return this.page.getByTestId('wizardTitle').locator('> div > span').nth(1); } } diff --git a/src/tests/putaway/addCommentToPutaway.test.ts b/src/tests/putaway/addCommentToPutaway.test.ts index b056267..a1270b8 100644 --- a/src/tests/putaway/addCommentToPutaway.test.ts +++ b/src/tests/putaway/addCommentToPutaway.test.ts @@ -122,6 +122,10 @@ test.describe('Add comment to Putaway', () => { const putawayOrderIdentifier = await createPutawayPage.startStep.orderNumberValue.textContent(); + const putawayOrderIdentifierContent = `${putawayOrderIdentifier}` + .toString() + .trim(); + await test.step('Select bin to putaway', async () => { await createPutawayPage.startStep.table.row(0).putawayBinSelect.click(); await createPutawayPage.startStep.table @@ -135,15 +139,14 @@ test.describe('Add comment to Putaway', () => { await putawayListPage.goToPage(); await putawayListPage.isLoaded(); await expect( - putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() - ).statusTag + putawayListPage.table.rowByOrderNumber(putawayOrderIdentifierContent) + .statusTag ).toHaveText('Pending'); }); await test.step('Go to putaway view page', async () => { const row = putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() + putawayOrderIdentifierContent ); await row.actionsButton.click(); await row.viewOrderDetails.click(); @@ -189,9 +192,9 @@ test.describe('Add comment to Putaway', () => { }); await test.step('Assert content of added comment', async () => { - await expect( - putawayDetailsPage.commentsTable.row(2).commentContent - ).toHaveText('add comment'); + await expect(putawayDetailsPage.commentsTable.row(2).comment).toHaveText( + 'add comment' + ); }); await test.step('Edit added comment', async () => { @@ -218,9 +221,9 @@ test.describe('Add comment to Putaway', () => { await test.step('Assert content of added comment', async () => { await expect(putawayDetailsPage.commentsTable.rows).toHaveCount(3); - await expect( - putawayDetailsPage.commentsTable.row(2).commentContent - ).toHaveText('edit added comment'); + await expect(putawayDetailsPage.commentsTable.row(2).comment).toHaveText( + 'edit added comment' + ); }); await test.step('Add another comment to pending putaway', async () => { @@ -321,14 +324,14 @@ test.describe('Add comment to Putaway', () => { await test.step('Assert content of added comment', async () => { await expect(putawayDetailsPage.commentsTable.rows).toHaveCount(3); await expect( - putawayDetailsPage.commentsTable.row(2).recipientContent + putawayDetailsPage.commentsTable.row(2).recipient ).toContainText(managerUser.name); await expect( - putawayDetailsPage.commentsTable.row(2).senderContent + putawayDetailsPage.commentsTable.row(2).sender ).toContainText(mainUser.name); - await expect( - putawayDetailsPage.commentsTable.row(2).commentContent - ).toHaveText('add comment to completed putaway'); + await expect(putawayDetailsPage.commentsTable.row(2).comment).toHaveText( + 'add comment to completed putaway' + ); }); }); }); diff --git a/src/tests/putaway/assertPutawayDetailsPage.test.ts b/src/tests/putaway/assertPutawayDetailsPage.test.ts index a706503..839776f 100644 --- a/src/tests/putaway/assertPutawayDetailsPage.test.ts +++ b/src/tests/putaway/assertPutawayDetailsPage.test.ts @@ -135,6 +135,10 @@ test.describe('Assert putaway details page', () => { const putawayOrderIdentifier = await createPutawayPage.startStep.orderNumberValue.textContent(); + const putawayOrderIdentifierContent = `${putawayOrderIdentifier}` + .toString() + .trim(); + await test.step('Select bin to putaway', async () => { await createPutawayPage.startStep.table.row(0).putawayBinSelect.click(); await createPutawayPage.startStep.table @@ -154,9 +158,8 @@ test.describe('Assert putaway details page', () => { await expect(putawayListPage.statusFilter).toContainText('Pending'); await expect(putawayListPage.statusFilter).toBeEnabled(); await expect( - putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() - ).statusTag + putawayListPage.table.rowByOrderNumber(putawayOrderIdentifierContent) + .statusTag ).toHaveText('Pending'); await expect(putawayListPage.destinationFilter).toContainText( currentLocation.name @@ -165,7 +168,7 @@ test.describe('Assert putaway details page', () => { await test.step('Go to putaway view page and assert page elements', async () => { const row = putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() + putawayOrderIdentifierContent ); await row.actionsButton.click(); await row.viewOrderDetails.click(); @@ -370,14 +373,11 @@ test.describe('Assert putaway details page', () => { await expect(putawayListPage.destinationFilter).toContainText( currentLocation.name ); - await putawayListPage.searchField.fill( - `${putawayOrderIdentifier}`.toString().trim() - ); + await putawayListPage.searchField.fill(putawayOrderIdentifierContent); await putawayListPage.searchButton.click(); await expect( - putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() - ).statusTag + putawayListPage.table.rowByOrderNumber(putawayOrderIdentifierContent) + .statusTag ).toHaveText('Completed'); }); @@ -385,7 +385,7 @@ test.describe('Assert putaway details page', () => { const generatePutawayPdfFileName = 'Putaway ' + `${putawayOrderIdentifier}`.toString().trim() + '.pdf'; const row = putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() + putawayOrderIdentifierContent ); await row.actionsButton.click(); await row.generatePdf.click(); diff --git a/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts b/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts index d201229..cec518a 100644 --- a/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts +++ b/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts @@ -161,6 +161,10 @@ test.describe('Change location on putaway create page and list pages', () => { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion (await createPutawayPage.startStep.orderNumberValue.textContent())!; + const putawayOrderIdentifierContent = `${putawayOrderIdentifier}` + .toString() + .trim(); + await test.step('Save pending putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -169,9 +173,8 @@ test.describe('Change location on putaway create page and list pages', () => { await putawayListPage.goToPage(); await putawayListPage.isLoaded(); await expect( - putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() - ).statusTag + putawayListPage.table.rowByOrderNumber(putawayOrderIdentifierContent) + .statusTag ).toHaveText('Pending'); }); @@ -182,9 +185,7 @@ test.describe('Change location on putaway create page and list pages', () => { .click(); await locationChooser.getLocation(depotLocation.name).click(); await putawayListPage.goToPage(); - await putawayListPage.searchField.fill( - `${putawayOrderIdentifier}`.toString().trim() - ); + await putawayListPage.searchField.fill(putawayOrderIdentifierContent); await putawayListPage.searchButton.click(); await putawayListPage.emptyPutawayList.isVisible(); }); @@ -194,9 +195,7 @@ test.describe('Change location on putaway create page and list pages', () => { await expect(putawayListPage.destinationFilter).toContainText( depotLocation.name ); - await putawayListPage.searchField.fill( - `${putawayOrderIdentifier}`.toString().trim() - ); + await putawayListPage.searchField.fill(putawayOrderIdentifierContent); await putawayListPage.searchButton.click(); await putawayListPage.emptyPutawayList.isVisible(); }); diff --git a/src/tests/putaway/deleteItemsFromPutaway.test.ts b/src/tests/putaway/deleteItemsFromPutaway.test.ts index b960a79..3fa7165 100644 --- a/src/tests/putaway/deleteItemsFromPutaway.test.ts +++ b/src/tests/putaway/deleteItemsFromPutaway.test.ts @@ -135,6 +135,10 @@ test.describe('Delete items from putaway', () => { const putawayOrderIdentifier = await createPutawayPage.startStep.orderNumberValue.textContent(); + const putawayOrderIdentifierContent = `${putawayOrderIdentifier}` + .toString() + .trim(); + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -143,12 +147,11 @@ test.describe('Delete items from putaway', () => { await putawayListPage.goToPage(); await putawayListPage.isLoaded(); await expect( - putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() - ).lineItems + putawayListPage.table.rowByOrderNumber(putawayOrderIdentifierContent) + .lineItems ).toContainText('2'); const row = putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() + putawayOrderIdentifierContent ); await row.actionsButton.click(); await row.viewOrderDetails.click(); @@ -199,12 +202,11 @@ test.describe('Delete items from putaway', () => { await putawayListPage.goToPage(); await putawayListPage.isLoaded(); await expect( - putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() - ).lineItems + putawayListPage.table.rowByOrderNumber(putawayOrderIdentifierContent) + .lineItems ).toContainText('1'); const row = putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() + putawayOrderIdentifierContent ); await row.actionsButton.click(); await row.viewOrderDetails.click(); @@ -286,12 +288,11 @@ test.describe('Delete items from putaway', () => { await putawayListPage.goToPage(); await putawayListPage.isLoaded(); await expect( - putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() - ).lineItems + putawayListPage.table.rowByOrderNumber(putawayOrderIdentifierContent) + .lineItems ).toContainText('2'); const row = putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() + putawayOrderIdentifierContent ); await row.actionsButton.click(); await row.viewOrderDetails.click(); @@ -378,19 +379,15 @@ test.describe('Delete items from putaway', () => { await test.step('Assert completed putaway on list putaway and assert number of lines', async () => { await putawayListPage.goToPage(); await putawayListPage.clearFilteringButton.click(); - await putawayListPage.searchField.fill( - `${putawayOrderIdentifier}`.toString().trim() - ); + await putawayListPage.searchField.fill(putawayOrderIdentifierContent); await putawayListPage.searchButton.click(); await expect( - putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() - ).statusTag + putawayListPage.table.rowByOrderNumber(putawayOrderIdentifierContent) + .statusTag ).toHaveText('Completed'); await expect( - putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() - ).lineItems + putawayListPage.table.rowByOrderNumber(putawayOrderIdentifierContent) + .lineItems ).toContainText('2'); }); }); diff --git a/src/tests/putaway/deletePendingPutaway.test.ts b/src/tests/putaway/deletePendingPutaway.test.ts index 29fcf32..4004ac4 100644 --- a/src/tests/putaway/deletePendingPutaway.test.ts +++ b/src/tests/putaway/deletePendingPutaway.test.ts @@ -115,6 +115,10 @@ test.describe('Delete pending putaways', () => { const putawayOrderIdentifier = await createPutawayPage.startStep.orderNumberValue.textContent(); + const putawayOrderIdentifierContent = `${putawayOrderIdentifier}` + .toString() + .trim(); + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -126,7 +130,7 @@ test.describe('Delete pending putaways', () => { putawayListPage.table.rows.filter({ has: page.locator('td') }) ).toHaveCount(1); const row = putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() + putawayOrderIdentifierContent ); await row.actionsButton.click(); await putawayListPage.table.clickDeleteOrderButton(1); @@ -174,6 +178,10 @@ test.describe('Delete pending putaways', () => { const putawayOrderIdentifier = await createPutawayPage.startStep.orderNumberValue.textContent(); + const putawayOrderIdentifierContent = `${putawayOrderIdentifier}` + .toString() + .trim(); + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -185,7 +193,7 @@ test.describe('Delete pending putaways', () => { putawayListPage.table.rows.filter({ has: page.locator('td') }) ).toHaveCount(1); const row = putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() + putawayOrderIdentifierContent ); await row.actionsButton.click(); await row.viewOrderDetails.click(); @@ -241,6 +249,10 @@ test.describe('Delete pending putaways', () => { const putawayOrderIdentifier = await createPutawayPage.startStep.orderNumberValue.textContent(); + const putawayOrderIdentifierContent = `${putawayOrderIdentifier}` + .toString() + .trim(); + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -254,7 +266,7 @@ test.describe('Delete pending putaways', () => { }) ).toHaveCount(1); const row = putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() + putawayOrderIdentifierContent ); await row.actionsButton.click(); await putawayListPage.table.clickDeleteOrderButton(1); @@ -305,6 +317,10 @@ test.describe('Delete pending putaways', () => { const putawayOrderIdentifier = await createPutawayPage.startStep.orderNumberValue.textContent(); + const putawayOrderIdentifierContent = `${putawayOrderIdentifier}` + .toString() + .trim(); + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -318,7 +334,7 @@ test.describe('Delete pending putaways', () => { }) ).toHaveCount(1); const row = putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() + putawayOrderIdentifierContent ); await row.actionsButton.click(); await row.viewOrderDetails.click(); @@ -375,6 +391,10 @@ test.describe('Delete pending putaways', () => { const putawayOrderIdentifier = await createPutawayPage.startStep.orderNumberValue.textContent(); + const putawayOrderIdentifierContent = `${putawayOrderIdentifier}` + .toString() + .trim(); + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -388,7 +408,7 @@ test.describe('Delete pending putaways', () => { }) ).toHaveCount(1); const row = putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() + putawayOrderIdentifierContent ); await row.actionsButton.click(); await putawayListPage.table.clickDeleteOrderButton(1); @@ -439,6 +459,10 @@ test.describe('Delete pending putaways', () => { const putawayOrderIdentifier = await createPutawayPage.startStep.orderNumberValue.textContent(); + const putawayOrderIdentifierContent = `${putawayOrderIdentifier}` + .toString() + .trim(); + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -452,7 +476,7 @@ test.describe('Delete pending putaways', () => { }) ).toHaveCount(1); const row = putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() + putawayOrderIdentifierContent ); await row.actionsButton.click(); await row.viewOrderDetails.click(); @@ -509,6 +533,10 @@ test.describe('Delete pending putaways', () => { const putawayOrderIdentifier = await createPutawayPage.startStep.orderNumberValue.textContent(); + const putawayOrderIdentifierContent = `${putawayOrderIdentifier}` + .toString() + .trim(); + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -522,7 +550,7 @@ test.describe('Delete pending putaways', () => { }) ).toHaveCount(1); const row = putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() + putawayOrderIdentifierContent ); await row.actionsButton.click(); await putawayListPage.table.clickDeleteOrderButton(1); @@ -573,6 +601,10 @@ test.describe('Delete pending putaways', () => { const putawayOrderIdentifier = await createPutawayPage.startStep.orderNumberValue.textContent(); + const putawayOrderIdentifierContent = `${putawayOrderIdentifier}` + .toString() + .trim(); + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -586,7 +618,7 @@ test.describe('Delete pending putaways', () => { }) ).toHaveCount(1); const row = putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() + putawayOrderIdentifierContent ); await row.actionsButton.click(); await row.viewOrderDetails.click(); diff --git a/src/tests/putaway/performPutawayAsManagerUser.test.ts b/src/tests/putaway/performPutawayAsManagerUser.test.ts index e0dc37d..ddf5901 100644 --- a/src/tests/putaway/performPutawayAsManagerUser.test.ts +++ b/src/tests/putaway/performPutawayAsManagerUser.test.ts @@ -279,6 +279,10 @@ test.describe('Perform putaway as manager user', () => { const putawayOrderIdentifier = await createPutawayPageManagerUser.startStep.orderNumberValue.textContent(); + const putawayOrderIdentifierContent = `${putawayOrderIdentifier}` + .toString() + .trim(); + await test.step('Save putaway', async () => { await createPutawayPageManagerUser.startStep.saveButton.click(); await managerUserPage.close(); @@ -288,21 +292,17 @@ test.describe('Perform putaway as manager user', () => { await putawayListPage.goToPage(); await putawayListPage.isLoaded(); await expect( - putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() - ).statusTag + putawayListPage.table.rowByOrderNumber(putawayOrderIdentifierContent) + .statusTag ).toHaveText('Pending'); - await putawayListPage.searchField.fill( - `${putawayOrderIdentifier}`.toString().trim() - ); + await putawayListPage.searchField.fill(putawayOrderIdentifierContent); await putawayListPage.orderedByFilter.click(); await putawayListPage.orderedByTextInput.fill(managerUser.name); await putawayListPage.getOrderedBy(managerUser.name); await putawayListPage.searchButton.click(); await expect( - putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() - ).orderedBy + putawayListPage.table.rowByOrderNumber(putawayOrderIdentifierContent) + .orderedBy ).toContainText(managerUser.name); }); @@ -317,23 +317,21 @@ test.describe('Perform putaway as manager user', () => { await putawayListPage.getCreatedBy(managerUser.name); await putawayListPage.searchButton.click(); await expect( - putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() - ).orderNumber + putawayListPage.table.rowByOrderNumber(putawayOrderIdentifierContent) + .orderNumber ).toContainText(`${putawayOrderIdentifier}`); await expect( - putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() - ).statusTag + putawayListPage.table.rowByOrderNumber(putawayOrderIdentifierContent) + .statusTag ).toHaveText('Pending'); }); await test.step('Go to putaway details page', async () => { await putawayListPage.table - .rowByOrderNumber(`${putawayOrderIdentifier}`.toString().trim()) + .rowByOrderNumber(putawayOrderIdentifierContent) .actionsButton.click(); await putawayListPage.table - .rowByOrderNumber(`${putawayOrderIdentifier}`.toString().trim()) + .rowByOrderNumber(putawayOrderIdentifierContent) .viewOrderDetails.click(); await putawayDetailsPage.isLoaded(); }); diff --git a/src/tests/putaway/putawayMoreThan1Item.test.ts b/src/tests/putaway/putawayMoreThan1Item.test.ts index 1e44df2..e885246 100644 --- a/src/tests/putaway/putawayMoreThan1Item.test.ts +++ b/src/tests/putaway/putawayMoreThan1Item.test.ts @@ -150,6 +150,10 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { const putawayOrderIdentifier = await createPutawayPage.startStep.orderNumberValue.textContent(); + const putawayOrderIdentifierContent = `${putawayOrderIdentifier}` + .toString() + .trim(); + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -175,7 +179,7 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { await putawayListPage.goToPage(); await putawayListPage.isLoaded(); const row = putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() + putawayOrderIdentifierContent ); await row.actionsButton.click(); await row.viewOrderDetails.click(); diff --git a/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts b/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts index 61ae8e3..c117515 100644 --- a/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts +++ b/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts @@ -114,6 +114,10 @@ test.describe('Rollback last receipt behavior when putaway created', () => { const putawayOrderIdentifier = await createPutawayPage.startStep.orderNumberValue.textContent(); + const putawayOrderIdentifierContent = `${putawayOrderIdentifier}` + .toString() + .trim(); + await test.step('Select bin to putaway', async () => { const internalLocation = await internalLocationService.getLocation(); await createPutawayPage.startStep.table.row(0).putawayBinSelect.click(); @@ -162,7 +166,7 @@ test.describe('Rollback last receipt behavior when putaway created', () => { await test.step('Open putaway details page', async () => { const row = putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() + putawayOrderIdentifierContent ); await row.actionsButton.click(); await row.viewOrderDetails.click(); diff --git a/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts b/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts index f67ddc9..daa263c 100644 --- a/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts +++ b/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts @@ -219,6 +219,10 @@ test.describe('Assert validation on qty removed from receiving bin', () => { const putawayOrderIdentifier = await createPutawayPage.startStep.orderNumberValue.textContent(); + const putawayOrderIdentifierContent = `${putawayOrderIdentifier}` + .toString() + .trim(); + await test.step('Save putaway', async () => { await createPutawayPage.startStep.saveButton.click(); }); @@ -240,7 +244,7 @@ test.describe('Assert validation on qty removed from receiving bin', () => { await putawayListPage.goToPage(); await putawayListPage.isLoaded(); const row = putawayListPage.table.rowByOrderNumber( - `${putawayOrderIdentifier}`.toString().trim() + putawayOrderIdentifierContent ); await row.actionsButton.click(); await row.viewOrderDetails.click(); From aedfaaf7a075030f1f5431a9f32164592b0d84c9 Mon Sep 17 00:00:00 2001 From: Katarzyna Date: Tue, 7 Jul 2026 13:17:26 +0200 Subject: [PATCH 08/10] improve flaky receiving tests --- .../StockMovementShowPage.ts | 14 +++++++++ .../assertCreationOfGoodsReceiptNote.test.ts | 9 ++---- .../receiving/cancelRemainingQty.test.ts | 15 ++++------ .../receiving/editOriginalLineQtyTo0.test.ts | 3 +- .../receiving/receivingStatusChanges.test.ts | 30 +++++++------------ ...atusChangesWithoutPartialReceiving.test.ts | 27 ++++++----------- .../receiving/rollbackStatusChanges.test.ts | 21 +++++-------- ...ByAlphabeticalOrderAndRemainInputs.test.ts | 6 ++++ 8 files changed, 55 insertions(+), 70 deletions(-) diff --git a/src/pages/stockMovementShow/StockMovementShowPage.ts b/src/pages/stockMovementShow/StockMovementShowPage.ts index 2b49dac..6c687b7 100644 --- a/src/pages/stockMovementShow/StockMovementShowPage.ts +++ b/src/pages/stockMovementShow/StockMovementShowPage.ts @@ -111,6 +111,20 @@ class StockMovementShowPage extends BasePageModel { this.page.once('dialog', (dialog) => dialog.accept()); await this.deleteButton.click(); } + + async openReceiptsTab() { + await expect(async () => { + await this.receiptTab.click(); + await this.receiptListTable.isLoaded(); + }).toPass({ timeout: 20000, intervals: [500, 1000, 2000] }); + } + + async openDocumentsTab() { + await expect(async () => { + await this.documentTab.click(); + await this.documentsListTable.isLoaded(); + }).toPass({ timeout: 20000, intervals: [500, 1000, 2000] }); + } } export default StockMovementShowPage; diff --git a/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts b/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts index 37793c4..ef63956 100644 --- a/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts +++ b/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts @@ -82,8 +82,7 @@ test.describe('Assert Goods Receipt Note is created and opened', () => { }); await test.step('Go to Documnents tab and assert Goods receipt note is not visible', async () => { - await stockMovementShowPage.documentTab.click(); - await stockMovementShowPage.documentsListTable.isLoaded(); + await stockMovementShowPage.openDocumentsTab(); await expect( stockMovementShowPage.documentsListTable .row(7) @@ -122,8 +121,7 @@ test.describe('Assert Goods Receipt Note is created and opened', () => { }); await test.step('Assert Goods receipt note is created and opened for partially received shipment', async () => { - await stockMovementShowPage.documentTab.click(); - await stockMovementShowPage.documentsListTable.isLoaded(); + await stockMovementShowPage.openDocumentsTab(); await expect( stockMovementShowPage.documentsListTable .row(7) @@ -160,8 +158,7 @@ test.describe('Assert Goods Receipt Note is created and opened', () => { }); await test.step('Assert Goods receipt note is created and opened for received shipment', async () => { - await stockMovementShowPage.documentTab.click(); - await stockMovementShowPage.documentsListTable.isLoaded(); + await stockMovementShowPage.openDocumentsTab(); await expect( stockMovementShowPage.documentsListTable .row(7) diff --git a/src/tests/receiving/cancelRemainingQty.test.ts b/src/tests/receiving/cancelRemainingQty.test.ts index 421a925..dc4581e 100644 --- a/src/tests/receiving/cancelRemainingQty.test.ts +++ b/src/tests/receiving/cancelRemainingQty.test.ts @@ -124,8 +124,7 @@ test.describe('Cancel qty in the middle of receipt', () => { await test.step('Assert canceled qty on stock movement show page', async () => { await expect(stockMovementShowPage.statusTag).toHaveText('Received'); - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await expect( stockMovementShowPage.receiptListTable.row(1).quantityCanceled ).toHaveText('50'); @@ -177,8 +176,7 @@ test.describe('Cancel qty in the middle of receipt', () => { await test.step('Assert canceled qty on stock movement show page', async () => { await expect(stockMovementShowPage.statusTag).toHaveText('Receiving'); - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await expect( stockMovementShowPage.receiptListTable.row(1).quantityReceived ).toHaveText('50'); @@ -235,8 +233,7 @@ test.describe('Cancel qty in the middle of receipt', () => { await test.step('Assert canceled qty on stock movement show page', async () => { await expect(stockMovementShowPage.statusTag).toHaveText('Received'); - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await expect( stockMovementShowPage.receiptListTable.row(2).quantityCanceled ).toHaveText('10'); @@ -305,8 +302,7 @@ test.describe('Cancel qty in the middle of receipt', () => { await test.step('Assert canceled and received qty on stock movement show page', async () => { await expect(stockMovementShowPage.statusTag).toHaveText('Received'); - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await expect( stockMovementShowPage.receiptListTable.row(1).quantityCanceled ).toHaveText('0'); @@ -377,8 +373,7 @@ test.describe('Cancel qty in the middle of receipt', () => { await test.step('Assert canceled qty on stock movement show page', async () => { await expect(stockMovementShowPage.statusTag).toHaveText('Received'); - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await expect( stockMovementShowPage.receiptListTable.row(1).quantityCanceled ).toHaveText('50'); diff --git a/src/tests/receiving/editOriginalLineQtyTo0.test.ts b/src/tests/receiving/editOriginalLineQtyTo0.test.ts index b9038aa..9cb02b6 100644 --- a/src/tests/receiving/editOriginalLineQtyTo0.test.ts +++ b/src/tests/receiving/editOriginalLineQtyTo0.test.ts @@ -380,8 +380,7 @@ test.describe('Edit original line to other product in the middle of receipt', () await expect( stockMovementShowPage.packingListTable.row(1).product ).toHaveText(PRODUCT_FOUR.name); - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await expect( stockMovementShowPage.receiptListTable.row(1).product ).toHaveText(PRODUCT_FIVE.name); diff --git a/src/tests/receiving/receivingStatusChanges.test.ts b/src/tests/receiving/receivingStatusChanges.test.ts index 9efc174..78ff309 100644 --- a/src/tests/receiving/receivingStatusChanges.test.ts +++ b/src/tests/receiving/receivingStatusChanges.test.ts @@ -88,8 +88,7 @@ test.describe('Status changes on sm view page when receive shipment', () => { }); await test.step('Assert empty receipt tab', async () => { - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect(stockMovementShowPage.emptyReceiptTab).toBeVisible(); }); @@ -117,8 +116,7 @@ test.describe('Status changes on sm view page when receive shipment', () => { await newStockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await newStockMovementShowPage.isLoaded(); await expect(newStockMovementShowPage.statusTag).toHaveText('Shipped'); - await newStockMovementShowPage.receiptTab.click(); - await newStockMovementShowPage.receiptListTable.isLoaded(); + await newStockMovementShowPage.openReceiptsTab(); await newStockMovementShowPage.receiptTab.isVisible(); await expect( newStockMovementShowPage.receiptListTable.row(1).receiptStatus @@ -140,8 +138,7 @@ test.describe('Status changes on sm view page when receive shipment', () => { await test.step('Assert statuses on stock movmenent show page after receiving item partially', async () => { await expect(stockMovementShowPage.statusTag).toHaveText('Receiving'); - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect( stockMovementShowPage.receiptListTable.row(1).receiptStatus @@ -170,8 +167,7 @@ test.describe('Status changes on sm view page when receive shipment', () => { }); await test.step('Assert empty receipt tab', async () => { - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect(stockMovementShowPage.emptyReceiptTab).toBeVisible(); }); @@ -199,8 +195,7 @@ test.describe('Status changes on sm view page when receive shipment', () => { await newStockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await newStockMovementShowPage.isLoaded(); await expect(newStockMovementShowPage.statusTag).toHaveText('Shipped'); - await newStockMovementShowPage.receiptTab.click(); - await newStockMovementShowPage.receiptListTable.isLoaded(); + await newStockMovementShowPage.openReceiptsTab(); await newStockMovementShowPage.receiptTab.isVisible(); await expect( newStockMovementShowPage.receiptListTable.row(1).receiptStatus @@ -222,8 +217,7 @@ test.describe('Status changes on sm view page when receive shipment', () => { await test.step('Assert statuses on stock movmenent show page after receiving fully 1 of items', async () => { await expect(stockMovementShowPage.statusTag).toHaveText('Receiving'); - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect( stockMovementShowPage.receiptListTable.row(1).receiptStatus @@ -252,8 +246,7 @@ test.describe('Status changes on sm view page when receive shipment', () => { }); await test.step('Assert empty receipt tab', async () => { - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect(stockMovementShowPage.emptyReceiptTab).toBeVisible(); }); @@ -284,8 +277,7 @@ test.describe('Status changes on sm view page when receive shipment', () => { await newStockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await newStockMovementShowPage.isLoaded(); await expect(newStockMovementShowPage.statusTag).toHaveText('Shipped'); - await newStockMovementShowPage.receiptTab.click(); - await newStockMovementShowPage.receiptListTable.isLoaded(); + await newStockMovementShowPage.openReceiptsTab(); await newStockMovementShowPage.receiptTab.isVisible(); await expect( newStockMovementShowPage.receiptListTable.row(1).receiptStatus @@ -316,8 +308,7 @@ test.describe('Status changes on sm view page when receive shipment', () => { await test.step('Assert statuses on stock movmenent show page after receiving items', async () => { await expect(stockMovementShowPage.statusTag).toHaveText('Receiving'); - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect( stockMovementShowPage.receiptListTable.row(1).receiptStatus @@ -360,8 +351,7 @@ test.describe('Status changes on sm view page when receive shipment', () => { await test.step('Assert statuses on stock movmenent show page after receiving items', async () => { await expect(stockMovementShowPage.statusTag).toHaveText('Received'); - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect( stockMovementShowPage.receiptListTable.row(3).receiptStatus diff --git a/src/tests/receiving/receivingStatusChangesWithoutPartialReceiving.test.ts b/src/tests/receiving/receivingStatusChangesWithoutPartialReceiving.test.ts index b7d0275..9dfea48 100644 --- a/src/tests/receiving/receivingStatusChangesWithoutPartialReceiving.test.ts +++ b/src/tests/receiving/receivingStatusChangesWithoutPartialReceiving.test.ts @@ -81,8 +81,7 @@ test.describe('Status changes on sm view page when receive shipment in location }); await test.step('Assert empty receipt tab', async () => { - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect(stockMovementShowPage.emptyReceiptTab).toBeVisible(); }); @@ -115,8 +114,7 @@ test.describe('Status changes on sm view page when receive shipment in location }); await test.step('Assert Qty and statuses on receipt tab after receiving item partially and cancel not received qty', async () => { - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect( stockMovementShowPage.receiptListTable.row(1).receiptStatus @@ -161,8 +159,7 @@ test.describe('Status changes on sm view page when receive shipment in location }); await test.step('Assert empty receipt tab', async () => { - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect(stockMovementShowPage.emptyReceiptTab).toBeVisible(); }); @@ -195,8 +192,7 @@ test.describe('Status changes on sm view page when receive shipment in location }); await test.step('Assert Qty and statuses on receipt tab after receiving item partially and cancel not received qty', async () => { - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect( stockMovementShowPage.receiptListTable.row(1).receiptStatus @@ -241,8 +237,7 @@ test.describe('Status changes on sm view page when receive shipment in location }); await test.step('Assert empty receipt tab', async () => { - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect(stockMovementShowPage.emptyReceiptTab).toBeVisible(); }); @@ -274,8 +269,7 @@ test.describe('Status changes on sm view page when receive shipment in location }); await test.step('Assert Qty and statuses on receipt tab after receiving items and cancel not received qty', async () => { - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect( stockMovementShowPage.receiptListTable.row(1).receiptStatus @@ -320,8 +314,7 @@ test.describe('Status changes on sm view page when receive shipment in location }); await test.step('Assert empty receipt tab', async () => { - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect(stockMovementShowPage.emptyReceiptTab).toBeVisible(); }); @@ -353,8 +346,7 @@ test.describe('Status changes on sm view page when receive shipment in location }); await test.step('Assert Qty and statuses on receipt tab after receiving items and cancel not received qty', async () => { - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect( stockMovementShowPage.receiptListTable.row(1).receiptStatus @@ -392,8 +384,7 @@ test.describe('Status changes on sm view page when receive shipment in location }); await test.step('Assert empty receipt tab after rollback receipt', async () => { - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect(stockMovementShowPage.emptyReceiptTab).toBeVisible(); }); diff --git a/src/tests/receiving/rollbackStatusChanges.test.ts b/src/tests/receiving/rollbackStatusChanges.test.ts index 19b359e..262d159 100644 --- a/src/tests/receiving/rollbackStatusChanges.test.ts +++ b/src/tests/receiving/rollbackStatusChanges.test.ts @@ -105,8 +105,7 @@ test.describe('Status changes on sm view page when rollback receipts', () => { await test.step('Assert statuses on stock movmenent show page after receiving item partially', async () => { await expect(stockMovementShowPage.statusTag).toHaveText('Receiving'); - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect( stockMovementShowPage.receiptListTable.row(1).receiptStatus @@ -128,8 +127,7 @@ test.describe('Status changes on sm view page when rollback receipts', () => { }); await test.step('Assert empty receipt tab after rollback last receipt', async () => { - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect(stockMovementShowPage.emptyReceiptTab).toBeVisible(); }); @@ -166,8 +164,7 @@ test.describe('Status changes on sm view page when rollback receipts', () => { await test.step('Assert statuses on stock movmenent show page after receiving fully 1 of items', async () => { await expect(stockMovementShowPage.statusTag).toHaveText('Receiving'); - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect( stockMovementShowPage.receiptListTable.row(1).receiptStatus @@ -189,8 +186,7 @@ test.describe('Status changes on sm view page when rollback receipts', () => { }); await test.step('Assert empty receipt tab after rollback last receipt', async () => { - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect(stockMovementShowPage.emptyReceiptTab).toBeVisible(); }); @@ -249,8 +245,7 @@ test.describe('Status changes on sm view page when rollback receipts', () => { await test.step('Assert statuses on stock movmenent show page after receiving items', async () => { await expect(stockMovementShowPage.statusTag).toHaveText('Received'); - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect( stockMovementShowPage.receiptListTable.row(3).receiptStatus @@ -270,8 +265,7 @@ test.describe('Status changes on sm view page when rollback receipts', () => { await test.step('Assert statuses on stock movmenent show page after receiving items', async () => { await expect(stockMovementShowPage.statusTag).toHaveText('Receiving'); - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect( stockMovementShowPage.receiptListTable.row(1).receiptStatus @@ -303,8 +297,7 @@ test.describe('Status changes on sm view page when rollback receipts', () => { }); await test.step('Assert empty receipt tab after rollback both receipts', async () => { - await stockMovementShowPage.receiptTab.click(); - await stockMovementShowPage.receiptListTable.isLoaded(); + await stockMovementShowPage.openReceiptsTab(); await stockMovementShowPage.receiptTab.isVisible(); await expect(stockMovementShowPage.emptyReceiptTab).toBeVisible(); }); diff --git a/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts b/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts index 5b2b2db..d6f3005 100644 --- a/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts +++ b/src/tests/receiving/sortByAlphabeticalOrderAndRemainInputs.test.ts @@ -104,6 +104,11 @@ test.describe('Apply sorting by alphabetical order and remain inputs', () => { await test.step('Send shipment', async () => { await createInboundPage.nextButton.click(); await createInboundPage.sendStep.isLoaded(); + // wait until the last added item shows up in the table, otherwise the send step + // is still re-rendering after data fetch and the click below can get lost + await expect( + createInboundPage.sendStep.table.row(2).productCode.field + ).toBeVisible(); await expect(createInboundPage.sendStep.sendShipmentButton).toBeVisible(); await expect(createInboundPage.sendStep.sendShipmentButton).toBeEnabled(); await Promise.all([ @@ -111,6 +116,7 @@ test.describe('Apply sorting by alphabetical order and remain inputs', () => { createInboundPage.sendStep.sendShipmentButton.click(), ]); await stockMovementShowPage.isLoaded(); + await expect(stockMovementShowPage.statusTag).toHaveText('Shipped'); }); await test.step('Go to shipment receiving page', async () => { From 5380ae8fc3fd0200a31076449da9f48be125d386 Mon Sep 17 00:00:00 2001 From: Katarzyna Date: Wed, 8 Jul 2026 11:20:20 +0200 Subject: [PATCH 09/10] improve data cleanups in putaway tests --- src/api/BaseServiceModel.ts | 4 ++ src/setup/validateCleanState.setup.ts | 4 +- .../changeLocationOnCreatePutawayPage.test.ts | 17 ++++--- .../putaway/qtyValidationsInPutaways.test.ts | 17 ++++--- ...ByCurrentPreferredAndOriginalOrder.test.ts | 50 +++++++++++-------- src/types.d.ts | 13 +++-- src/utils/shipmentUtils.ts | 42 ++++++++++++++++ 7 files changed, 105 insertions(+), 42 deletions(-) diff --git a/src/api/BaseServiceModel.ts b/src/api/BaseServiceModel.ts index 0e0fa57..99da297 100644 --- a/src/api/BaseServiceModel.ts +++ b/src/api/BaseServiceModel.ts @@ -6,6 +6,10 @@ class BaseServiceModel { constructor(request: APIRequestContext) { this.request = request; } + + getRequestContext() { + return this.request; + } } export default BaseServiceModel; diff --git a/src/setup/validateCleanState.setup.ts b/src/setup/validateCleanState.setup.ts index 8f149f7..cb40ea6 100644 --- a/src/setup/validateCleanState.setup.ts +++ b/src/setup/validateCleanState.setup.ts @@ -25,8 +25,8 @@ function assertNoPutawayCandidates( const details = candidates .map( (candidate) => - `${candidate.product?.productCode ?? '?'} ${candidate.product?.name ?? ''} ` + - `(bin: ${candidate.currentLocation?.name ?? '?'}, qty: ${candidate.quantity ?? '?'}, ` + + `${candidate['product.productCode'] ?? '?'} ${candidate['product.name'] ?? ''} ` + + `(bin: ${candidate['currentLocation.name'] ?? '?'}, qty: ${candidate.quantity ?? '?'}, ` + `status: ${candidate.putawayStatus ?? '?'})` ) .join('; '); diff --git a/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts b/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts index cec518a..485deae 100644 --- a/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts +++ b/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts @@ -65,13 +65,16 @@ test.describe('Change location on putaway create page and list pages', () => { putawayListPage, oldViewShipmentPage, }) => { - if (!putawayOrderIdentifier) return; - await putawayListPage.goToPage(); - await putawayListPage.table - .rowByOrderNumber(`${putawayOrderIdentifier}`.toString().trim()) - .actionsButton.click(); - await putawayListPage.table.clickDeleteOrderButton(1); - await putawayListPage.emptyPutawayList.isVisible(); + // the received shipment must be cleaned up even when the test fails + // before the putaway is created + if (putawayOrderIdentifier) { + await putawayListPage.goToPage(); + await putawayListPage.table + .rowByOrderNumber(`${putawayOrderIdentifier}`.toString().trim()) + .actionsButton.click(); + await putawayListPage.table.clickDeleteOrderButton(1); + await putawayListPage.emptyPutawayList.isVisible(); + } await deleteReceivedShipment({ stockMovementShowPage, diff --git a/src/tests/putaway/qtyValidationsInPutaways.test.ts b/src/tests/putaway/qtyValidationsInPutaways.test.ts index c9853e7..f1230dc 100644 --- a/src/tests/putaway/qtyValidationsInPutaways.test.ts +++ b/src/tests/putaway/qtyValidationsInPutaways.test.ts @@ -65,13 +65,16 @@ test.describe('Assert qty validations in putaways', () => { stockMovementService, oldViewShipmentPage, }) => { - if (!putawayOrderIdentifier) return; - await putawayListPage.goToPage(); - await putawayListPage.table - .rowByOrderNumber(`${putawayOrderIdentifier}`.toString().trim()) - .actionsButton.click(); - await putawayListPage.table.clickDeleteOrderButton(1); - await putawayListPage.emptyPutawayList.isVisible(); + // the received shipment must be cleaned up even when the test fails + // before the putaway is started + if (putawayOrderIdentifier) { + await putawayListPage.goToPage(); + await putawayListPage.table + .rowByOrderNumber(`${putawayOrderIdentifier}`.toString().trim()) + .actionsButton.click(); + await putawayListPage.table.clickDeleteOrderButton(1); + await putawayListPage.emptyPutawayList.isVisible(); + } await deleteReceivedShipment({ stockMovementShowPage, diff --git a/src/tests/putaway/sortPutawayByCurrentPreferredAndOriginalOrder.test.ts b/src/tests/putaway/sortPutawayByCurrentPreferredAndOriginalOrder.test.ts index 4ef27df..398e903 100644 --- a/src/tests/putaway/sortPutawayByCurrentPreferredAndOriginalOrder.test.ts +++ b/src/tests/putaway/sortPutawayByCurrentPreferredAndOriginalOrder.test.ts @@ -22,7 +22,7 @@ import { byNameAsc } from '@/utils/sortUtils'; */ test.describe('Sort putaway by current bin, preferred bin and original order', () => { let inboundOne: StockMovementResponse; - let inboundTwo: StockMovementResponse; + let inboundTwo: StockMovementResponse | undefined; let productA: ProductResponse; let productB: ProductResponse; @@ -45,6 +45,7 @@ test.describe('Sort putaway by current bin, preferred bin and original order', ( productEditPage, }) => { putawayOrderIdentifier = undefined; + inboundTwo = undefined; [productA, productB, productC] = [ await productService.getProduct(Product.ONE), await productService.getProduct(Product.TWO), @@ -96,29 +97,33 @@ test.describe('Sort putaway by current bin, preferred bin and original order', ( productShowPage, productEditPage, }) => { - // Remove the pending 2nd putaway - await putawayListPage.goToPage(); - await putawayListPage.isLoaded(); - if (!putawayOrderIdentifier) return; - await putawayListPage.goToPage(); - await putawayListPage.table - .rowByOrderNumber(`${putawayOrderIdentifier}`.toString().trim()) - .actionsButton.click(); - await putawayListPage.table.clickDeleteOrderButton(1); + // Remove the pending 2nd putaway and the 3 transactions created along + // the way; they exist only once the 2nd putaway has been started, but + // the shipments and preferred bins must be cleaned up regardless of + // how far the test got + if (putawayOrderIdentifier) { + await putawayListPage.goToPage(); + await putawayListPage.isLoaded(); + await putawayListPage.table + .rowByOrderNumber(`${putawayOrderIdentifier}`.toString().trim()) + .actionsButton.click(); + await putawayListPage.table.clickDeleteOrderButton(1); - // Delete the 3 created transactions - await navbar.configurationButton.click(); - await navbar.transactions.click(); - for (let i = 0; i < 3; i++) { - await transactionListPage.deleteTransaction(1); + await navbar.configurationButton.click(); + await navbar.transactions.click(); + for (let i = 0; i < 3; i++) { + await transactionListPage.deleteTransaction(1); + } } - await deleteReceivedShipment({ - stockMovementShowPage, - oldViewShipmentPage, - stockMovementService, - STOCK_MOVEMENT: inboundTwo, - }); + if (inboundTwo) { + await deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT: inboundTwo, + }); + } await deleteReceivedShipment({ stockMovementShowPage, oldViewShipmentPage, @@ -201,7 +206,8 @@ test.describe('Sort putaway by current bin, preferred bin and original order', ( const allProducts = [productA.name, productB.name, productC.name]; await test.step('go to create putaway page and start putaway for all items', async () => { - await stockMovementShowPage.goToPage(inboundTwo.id); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + await stockMovementShowPage.goToPage(inboundTwo!.id); await stockMovementShowPage.isLoaded(); await RefreshCachesUtils.refreshCaches({ navbar }); await navbar.inbound.click(); diff --git a/src/types.d.ts b/src/types.d.ts index ecccf96..9265f48 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -34,11 +34,16 @@ type StockMovementListResponse = { totalCount: number; }; +// GET /api/putaways returns rows flattened into dotted keys +// (e.g. "product.name"), not nested objects type PutawayCandidate = { - product?: { name?: string; productCode?: string }; - currentLocation?: { name?: string }; - quantity?: number; - putawayStatus?: string; + 'stockMovement.id'?: string | null; + 'stockMovement.name'?: string | null; + 'product.productCode'?: string | null; + 'product.name'?: string | null; + 'currentLocation.name'?: string | null; + quantity?: number | null; + putawayStatus?: string | null; }; type LocationResponse = { diff --git a/src/utils/shipmentUtils.ts b/src/utils/shipmentUtils.ts index abdd873..2c3f14a 100644 --- a/src/utils/shipmentUtils.ts +++ b/src/utils/shipmentUtils.ts @@ -1,3 +1,6 @@ +import { expect } from '@playwright/test'; + +import PutawayService from '@/api/PutawayService'; import ReceivingService from '@/api/ReceivingService'; import StockMovementService from '@/api/StockMovementService'; import AppConfig from '@/config/AppConfig'; @@ -76,4 +79,43 @@ export async function deleteReceivedShipment({ await stockMovementShowPage.isLoaded(); await stockMovementShowPage.rollbackButton.click(); await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + + // The server clears receiving-bin stock asynchronously after the stock + // movement is deleted, so a putaway candidate from this shipment can stay + // visible for a while; wait until it is gone so the next test (or the + // clean-state validation) does not see a phantom row. + const putawayService = new PutawayService( + stockMovementService.getRequestContext() + ); + const destinationId = + STOCK_MOVEMENT.destination?.id ?? + AppConfig.instance.locations.main.readId(); + await expect + .poll( + async () => { + const { data: candidates } = + await putawayService.getPutawayCandidates(destinationId); + // candidate references contain the receiving bin name + // (e.g. "R-") rather than the bare stock movement + // identifier, and decay to null mid-deletion, so match loosely + return candidates.filter((candidate) => { + const references = [ + candidate['stockMovement.id'], + candidate['stockMovement.name'], + candidate['currentLocation.name'], + ]; + return ( + references.every((reference) => !reference) || + references.some((reference) => + reference?.includes(STOCK_MOVEMENT.identifier) + ) + ); + }).length; + }, + { + message: `Putaway candidates from ${STOCK_MOVEMENT.identifier} are still present after deleting the stock movement`, + timeout: 30_000, + } + ) + .toBe(0); } From bc5fef1d54f22db18d008160344b8061ad4b404f Mon Sep 17 00:00:00 2001 From: Katarzyna Date: Wed, 8 Jul 2026 14:16:36 +0200 Subject: [PATCH 10/10] add improvements to receiving tests --- src/api/StockMovementService.ts | 11 +++++---- .../StockMovementShowPage.ts | 7 ++++++ .../receiving/exportReceivingTemplate.test.ts | 4 ++++ ...eiveInboundWithoutPartialReceiving.test.ts | 22 +++++++++++------- ...eInboundWithoutPickAndPutawayStock.test.ts | 23 +++++++++++-------- .../validationsOnDeliverOnDate.test.ts | 14 +++++++++-- .../validationsOnEditAndReceive.test.ts | 19 +++++++++++---- 7 files changed, 72 insertions(+), 28 deletions(-) diff --git a/src/api/StockMovementService.ts b/src/api/StockMovementService.ts index 1cd6cf6..3df67eb 100644 --- a/src/api/StockMovementService.ts +++ b/src/api/StockMovementService.ts @@ -68,10 +68,13 @@ class StockMovementService extends BaseServiceModel { } async deleteStockMovement(id: string) { - try { - await this.request.delete(STOCK_MOVEMENT_BY_ID(id)); - } catch (error) { - throw new Error('Problem deleting stock movement'); + // request.delete does not throw on HTTP error statuses, and a swallowed + // failed delete leaves the stock movement behind for the next tests + const apiResponse = await this.request.delete(STOCK_MOVEMENT_BY_ID(id)); + if (!apiResponse.ok()) { + throw new Error( + `Problem deleting stock movement ${id}: ${apiResponse.status()}` + ); } } diff --git a/src/pages/stockMovementShow/StockMovementShowPage.ts b/src/pages/stockMovementShow/StockMovementShowPage.ts index 6c687b7..a624464 100644 --- a/src/pages/stockMovementShow/StockMovementShowPage.ts +++ b/src/pages/stockMovementShow/StockMovementShowPage.ts @@ -113,7 +113,14 @@ class StockMovementShowPage extends BasePageModel { } async openReceiptsTab() { + // tab content is fetched once per page load, so when it fails to render, + // re-clicking the tab never refetches it — only a reload does + let reloadOnRetry = false; await expect(async () => { + if (reloadOnRetry) { + await this.page.reload(); + } + reloadOnRetry = true; await this.receiptTab.click(); await this.receiptListTable.isLoaded(); }).toPass({ timeout: 20000, intervals: [500, 1000, 2000] }); diff --git a/src/tests/receiving/exportReceivingTemplate.test.ts b/src/tests/receiving/exportReceivingTemplate.test.ts index bf65294..adea116 100644 --- a/src/tests/receiving/exportReceivingTemplate.test.ts +++ b/src/tests/receiving/exportReceivingTemplate.test.ts @@ -257,7 +257,11 @@ test.describe('Export receiving template', () => { await receivingPage.receivingStep.table .row(3) .commentField.textbox.fill('e2e_comment'); + // the exported template is generated server-side, so the save request + // must complete before downloading it + const dataSaved = receivingPage.receivingStep.waitForData(); await receivingPage.receivingStep.saveButton.click(); + await dataSaved; }); await test.step('Download export template after input data', async () => { diff --git a/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts b/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts index cab44a6..96bb5a0 100644 --- a/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts +++ b/src/tests/receiving/receiveInboundWithoutPartialReceiving.test.ts @@ -51,14 +51,20 @@ test.describe('Receive inbound stock movement in location without partial receiv oldViewShipmentPage, stockMovementService, }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await deleteReceivedShipment({ - stockMovementShowPage, - oldViewShipmentPage, - stockMovementService, - STOCK_MOVEMENT, - }); - await authService.changeLocation(AppConfig.instance.locations.main.id); + // the shipment must be deleted while the session is still at the depot, + // but the location has to be restored even when the cleanup fails, + // otherwise the next test file runs against the wrong location + try { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT, + }); + } finally { + await authService.changeLocation(AppConfig.instance.locations.main.id); + } } ); diff --git a/src/tests/receiving/receiveInboundWithoutPickAndPutawayStock.test.ts b/src/tests/receiving/receiveInboundWithoutPickAndPutawayStock.test.ts index 448d424..871c10b 100644 --- a/src/tests/receiving/receiveInboundWithoutPickAndPutawayStock.test.ts +++ b/src/tests/receiving/receiveInboundWithoutPickAndPutawayStock.test.ts @@ -48,15 +48,20 @@ test.describe('Receive inbound stock movement in location without pick and putaw oldViewShipmentPage, stockMovementService, }) => { - await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); - await deleteReceivedShipment({ - stockMovementShowPage, - oldViewShipmentPage, - stockMovementService, - STOCK_MOVEMENT, - }); - - await authService.changeLocation(AppConfig.instance.locations.main.id); + // the shipment must be deleted while the session is still at the depot, + // but the location has to be restored even when the cleanup fails, + // otherwise the next test file runs against the wrong location + try { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT, + }); + } finally { + await authService.changeLocation(AppConfig.instance.locations.main.id); + } } ); diff --git a/src/tests/receiving/validationsOnDeliverOnDate.test.ts b/src/tests/receiving/validationsOnDeliverOnDate.test.ts index 0408cfa..d40e911 100644 --- a/src/tests/receiving/validationsOnDeliverOnDate.test.ts +++ b/src/tests/receiving/validationsOnDeliverOnDate.test.ts @@ -4,7 +4,7 @@ import { expect, test } from '@/fixtures/fixtures'; import { Product } from '@/generated/ProductCodes.generated'; import { StockMovementResponse } from '@/types'; import BinLocationUtils from '@/utils/BinLocationUtils'; -import { getDateByOffset } from '@/utils/DateUtils'; +import { formatDate, getDateByOffset } from '@/utils/DateUtils'; import { deleteReceivedShipment } from '@/utils/shipmentUtils'; test.describe('Validations on edit Deliver On Date when receiving shipment', () => { @@ -115,11 +115,21 @@ test.describe('Validations on edit Deliver On Date when receiving shipment', () }); await test.step('Edit Delivered on Date on check page to past date', async () => { + const pastDate = getDateByOffset(new Date(), -1); + // the date picker re-renders the committed value with seconds zeroed, + // so fill with :00 to make the value comparable after the commit + pastDate.setSeconds(0, 0); await receivingPage.checkStep.isLoaded(); await receivingPage.checkStep.deliveredOnDateField.fillWithFormat( - getDateByOffset(new Date(), -1), + pastDate, 'MM/DD/YYYY HH:mm:ss Z' ); + // when the receive request fires before the date picker commits the + // value, the shipment gets received with the original valid date and + // the expected validation never appears + await expect( + receivingPage.checkStep.deliveredOnDateField.textbox + ).toHaveValue(formatDate(pastDate, 'MM/DD/YYYY HH:mm:ss Z')); await receivingPage.checkStep.isLoaded(); await receivingPage.checkStep.receiveShipmentButton.click(); await expect( diff --git a/src/tests/receiving/validationsOnEditAndReceive.test.ts b/src/tests/receiving/validationsOnEditAndReceive.test.ts index 3192ee5..fa59354 100644 --- a/src/tests/receiving/validationsOnEditAndReceive.test.ts +++ b/src/tests/receiving/validationsOnEditAndReceive.test.ts @@ -248,14 +248,23 @@ test.describe('Validations on edit and receive inbound stock movement', () => { await receivingPage.checkStep.isLoaded(); await receivingPage.checkStep.receiveShipmentButton.click(); await stockMovementShowPage.isLoaded(); + // the receipt is committed asynchronously; clicking Receive again + // before the status settles opens the wizard instead of the error + await expect(stockMovementShowPage.statusTag).toHaveText('Received'); }); await test.step('Validation on receive already received inbound', async () => { - await stockMovementShowPage.isLoaded(); - await stockMovementShowPage.receiveButton.click(); - await expect(stockMovementShowPage.errorMessage).toBeVisible({ - timeout: 10000, - }); + // the server-side already-received guard can lag behind the visible + // status, in which case the click opens the wizard instead of showing + // the error; retry the whole navigation until the guard kicks in + await expect(async () => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await stockMovementShowPage.isLoaded(); + await stockMovementShowPage.receiveButton.click(); + await expect(stockMovementShowPage.errorMessage).toBeVisible({ + timeout: 5000, + }); + }).toPass({ timeout: 30000, intervals: [1000, 2000] }); await expect(stockMovementShowPage.errorMessage).toContainText( 'Stock movement ' + STOCK_MOVEMENT.identifier +