diff --git a/src/pages/putaway/components/CompletePutawayTable.ts b/src/pages/putaway/components/CompletePutawayTable.ts index 260baea..a8c5f2c 100644 --- a/src/pages/putaway/components/CompletePutawayTable.ts +++ b/src/pages/putaway/components/CompletePutawayTable.ts @@ -31,6 +31,10 @@ class Row extends BasePageModel { get putawayBin() { return this.row.getByTestId('table-cell').nth(10); } + + get quantity() { + return this.row.getByTestId('table-cell').nth(7); + } } export default CompletePutawayTable; diff --git a/src/pages/putaway/steps/CompleteStep.ts b/src/pages/putaway/steps/CompleteStep.ts index 64dd33f..e4a838e 100644 --- a/src/pages/putaway/steps/CompleteStep.ts +++ b/src/pages/putaway/steps/CompleteStep.ts @@ -37,6 +37,10 @@ class CompleteStep extends BasePageModel { exact: true, }); } + + get editButton() { + return this.page.getByTestId('edit-button').first(); + } } export default CompleteStep; diff --git a/src/tests/putaway/assertAttemptToEditCompletedPutaway.test.ts b/src/tests/putaway/assertAttemptToEditCompletedPutaway.test.ts index ba41acf..a69ef59 100644 --- a/src/tests/putaway/assertAttemptToEditCompletedPutaway.test.ts +++ b/src/tests/putaway/assertAttemptToEditCompletedPutaway.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import RefreshCachesUtils from '@/utils/RefreshCaches'; import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; test.describe('Assert attempt to edit completed putaway', () => { @@ -90,8 +91,10 @@ test.describe('Assert attempt to edit completed putaway', () => { await test.step('Go to create putaway page', async () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); - await navbar.profileButton.click(); - await navbar.refreshCachesButton.click(); + await RefreshCachesUtils.refreshCaches({ + navbar, + page, + }); await navbar.inbound.click(); await navbar.createPutaway.click(); await createPutawayPage.isLoaded(); diff --git a/src/tests/putaway/assertPutawayDetailsPage.test.ts b/src/tests/putaway/assertPutawayDetailsPage.test.ts index c697967..7fe6dc7 100644 --- a/src/tests/putaway/assertPutawayDetailsPage.test.ts +++ b/src/tests/putaway/assertPutawayDetailsPage.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import RefreshCachesUtils from '@/utils/RefreshCaches'; import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; test.describe('Assert putaway details page', () => { @@ -97,8 +98,10 @@ test.describe('Assert putaway details page', () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); await expect(stockMovementShowPage.statusTag).toHaveText('Received'); - await navbar.profileButton.click(); - await navbar.refreshCachesButton.click(); + await RefreshCachesUtils.refreshCaches({ + navbar, + page, + }); }); await test.step('Go to create putaway page', async () => { @@ -140,7 +143,7 @@ test.describe('Assert putaway details page', () => { }); await test.step('Go to putaway view page and assert page elements', async () => { - const row = putawayListPage.table.row(1) + const row = putawayListPage.table.row(1); await row.actionsButton.click(); await row.viewOrderDetails.click(); await putawayDetailsPage.isLoaded(); diff --git a/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts b/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts index a18d764..7f00a72 100644 --- a/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts +++ b/src/tests/putaway/changeLocationOnCreatePutawayPage.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import RefreshCachesUtils from '@/utils/RefreshCaches'; import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; test.describe('Change location on putaway create page and list pages', () => { @@ -76,6 +77,7 @@ test.describe('Change location on putaway create page and list pages', () => { test('Change location on putaway create page and list page', async ({ stockMovementShowPage, navbar, + page, createPutawayPage, locationChooser, productService, @@ -95,8 +97,10 @@ test.describe('Change location on putaway create page and list pages', () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); await expect(stockMovementShowPage.statusTag).toHaveText('Received'); - await navbar.profileButton.click(); - await navbar.refreshCachesButton.click(); + await RefreshCachesUtils.refreshCaches({ + navbar, + page, + }); }); await test.step('Go to create putaway page and assert its content', async () => { @@ -120,8 +124,10 @@ test.describe('Change location on putaway create page and list pages', () => { .getOrganization(depotLocation.organization?.name as string) .click(); await locationChooser.getLocation(depotLocation.name).click(); - await navbar.profileButton.click(); - await navbar.refreshCachesButton.click(); + await RefreshCachesUtils.refreshCaches({ + navbar, + page, + }); await createPutawayPage.goToPage(); await expect(createPutawayPage.emptyCreatePageInformation).toBeVisible(); await expect( diff --git a/src/tests/putaway/createMoreThan1PutawayForTheSameItem.test.ts b/src/tests/putaway/createMoreThan1PutawayForTheSameItem.test.ts index 5cb28af..3b98ca6 100644 --- a/src/tests/putaway/createMoreThan1PutawayForTheSameItem.test.ts +++ b/src/tests/putaway/createMoreThan1PutawayForTheSameItem.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import RefreshCachesUtils from '@/utils/RefreshCaches'; import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; test.describe('Create more than 1 putaway from the same item', () => { @@ -81,6 +82,7 @@ test.describe('Create more than 1 putaway from the same item', () => { test('Create more than 1 putaway from the same item', async ({ stockMovementShowPage, navbar, + page, createPutawayPage, internalLocationService, productShowPage, @@ -143,7 +145,7 @@ test.describe('Create more than 1 putaway from the same item', () => { await createPutawayPage.completeStep.isLoaded(); }); - await test.step('Accept dialog and and complete putaway', async () => { + await test.step('Accept dialog and complete putaway', async () => { await createPutawayPage.completeStep.isLoaded(); await createPutawayPage.completeStep.completePutawayButton.click(); await expect( @@ -170,8 +172,10 @@ test.describe('Create more than 1 putaway from the same item', () => { await expect( productShowPage.inStockTabSection.row(1).quantityOnHand ).toHaveText('5'); - await navbar.profileButton.click(); - await navbar.refreshCachesButton.click(); + await RefreshCachesUtils.refreshCaches({ + navbar, + page, + }); }); await test.step('Go to create putaway page and assert receiving bin', async () => { diff --git a/src/tests/putaway/createPutaway.test.ts b/src/tests/putaway/createPutaway.test.ts index 8bd64bd..655a8b8 100644 --- a/src/tests/putaway/createPutaway.test.ts +++ b/src/tests/putaway/createPutaway.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import RefreshCachesUtils from '@/utils/RefreshCaches'; import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; test.describe('Putaway received inbound shipment', () => { @@ -81,6 +82,7 @@ test.describe('Putaway received inbound shipment', () => { test('Create putaway from inbound stock movement', async ({ stockMovementShowPage, navbar, + page, createPutawayPage, internalLocationService, productShowPage, @@ -91,8 +93,10 @@ test.describe('Putaway received inbound shipment', () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); await expect(stockMovementShowPage.statusTag).toHaveText('Received'); - await navbar.profileButton.click(); - await navbar.refreshCachesButton.click(); + await RefreshCachesUtils.refreshCaches({ + navbar, + page, + }); }); await test.step('Go to create putaway page', async () => { @@ -131,7 +135,7 @@ test.describe('Putaway received inbound shipment', () => { await putawayDetailsPage.summaryTab.click(); productService.setProduct('5'); const product = await productService.getProduct(); - await productShowPage.goToPage(product.id) + await productShowPage.goToPage(product.id); await productShowPage.inStockTab.click(); await productShowPage.inStockTabSection.isLoaded(); const internalLocation = await internalLocationService.getLocation(); diff --git a/src/tests/putaway/performPutawayAsManagerUser.test.ts b/src/tests/putaway/performPutawayAsManagerUser.test.ts new file mode 100644 index 0000000..2b98fcb --- /dev/null +++ b/src/tests/putaway/performPutawayAsManagerUser.test.ts @@ -0,0 +1,227 @@ +import Navbar from '@/components/Navbar'; +import AppConfig from '@/config/AppConfig'; +import { ShipmentType } from '@/constants/ShipmentType'; +import { expect, test } from '@/fixtures/fixtures'; +import CreatePutawayPage from '@/pages/putaway/CreatePutawayPage'; +import PutawayDetailsPage from '@/pages/putaway/putawayDetails/PutawayDetailsPage'; +import StockMovementShowPage from '@/pages/stockMovementShow/StockMovementShowPage'; +import { StockMovementResponse } from '@/types'; +import RefreshCachesUtils from '@/utils/RefreshCaches'; +import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; + +test.describe('Perform putaway as manager user', () => { + let STOCK_MOVEMENT: StockMovementResponse; + + test.beforeEach( + async ({ + supplierLocationService, + stockMovementService, + productService, + receivingService, + }) => { + const supplierLocation = await supplierLocationService.getLocation(); + STOCK_MOVEMENT = await stockMovementService.createInbound({ + originId: supplierLocation.id, + }); + + productService.setProduct('3'); + const product = await productService.getProduct(); + productService.setProduct('4'); + const product2 = await productService.getProduct(); + + await stockMovementService.addItemsToInboundStockMovement( + STOCK_MOVEMENT.id, + [ + { productId: product.id, quantity: 10 }, + { productId: product2.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, + }, + { + shipmentItemId: getShipmentItemId(receipt, 0, 1), + quantityReceiving: 10, + binLocationName: receivingBin, + }, + ]); + await receivingService.completeReceipt(shipmentId); + } + ); + + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + navbar, + transactionListPage, + oldViewShipmentPage, + }) => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await navbar.configurationButton.click(); + await navbar.transactions.click(); + await transactionListPage.deleteTransaction(1); + await transactionListPage.deleteTransaction(1); + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); + await oldViewShipmentPage.undoStatusChangeButton.click(); + await stockMovementShowPage.isLoaded(); + await stockMovementShowPage.rollbackButton.click(); + + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); + } + ); + + test('Perform putaway as manager user', async ({ + managerUserContext, + internalLocationService, + productService, + page, + }) => { + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + productService.setProduct('3'); + const product = await productService.getProduct(); + productService.setProduct('4'); + const product2 = await productService.getProduct(); + const internalLocation = await internalLocationService.getLocation(); + + const managerUserPage = await managerUserContext.newPage(); + const navbar = new Navbar(managerUserPage); + const stockMovementShowPage = new StockMovementShowPage(managerUserPage); + const createPutawayPage = new CreatePutawayPage(managerUserPage); + const putawayDetailsPage = new PutawayDetailsPage(managerUserPage); + + await test.step('Go to create putaway page', async () => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await stockMovementShowPage.isLoaded(); + await RefreshCachesUtils.refreshCaches({ + navbar, + page, + }); + await navbar.inbound.click(); + await navbar.createPutaway.click(); + await createPutawayPage.isLoaded(); + }); + + await test.step('Start putaway', async () => { + await createPutawayPage.table + .row(0) + .getExpandBinLocation(receivingBin) + .click(); + await expect( + createPutawayPage.table.row(1).getProductName(product2.name) + ).toBeVisible(); + await expect( + createPutawayPage.table.row(2).getProductName(product.name) + ).toBeVisible(); + await createPutawayPage.table.row(1).checkbox.click(); + await createPutawayPage.table.row(2).checkbox.click(); + await createPutawayPage.startPutawayButton.click(); + await createPutawayPage.startStep.isLoaded(); + }); + + await test.step('Select bins to putaway', async () => { + await createPutawayPage.startStep.table.row(1).putawayBinSelect.click(); + await createPutawayPage.startStep.table + .row(1) + .getPutawayBin(internalLocation.name) + .click(); + await createPutawayPage.startStep.table.row(2).putawayBinSelect.click(); + await createPutawayPage.startStep.table + .row(2) + .getPutawayBin(internalLocation.name) + .click(); + }); + + await test.step('Use edit button as manager user on both lines', async () => { + await createPutawayPage.startStep.table.row(1).editButton.click(); + await createPutawayPage.startStep.table.row(1).quantityInput.fill('5'); + await createPutawayPage.startStep.table.row(2).editButton.click(); + await createPutawayPage.startStep.table.row(2).quantityInput.fill('5'); + }); + + await test.step('Go to complete step and assert qty after edit', async () => { + await createPutawayPage.startStep.nextButton.click(); + await createPutawayPage.completeStep.isLoaded(); + await expect( + createPutawayPage.completeStep.table.row(2).quantity + ).toContainText('5'); + await expect( + createPutawayPage.completeStep.table.row(3).quantity + ).toContainText('5'); + await expect(createPutawayPage.completeStep.table.rows).toHaveCount(4); + }); + + await test.step('Go backward and use delete button as manager user', async () => { + await createPutawayPage.completeStep.editButton.click(); + await createPutawayPage.startStep.isLoaded(); + await expect(createPutawayPage.startStep.table.rows).toHaveCount(3); + await createPutawayPage.startStep.table.row(2).deleteButton.click(); + await expect(createPutawayPage.startStep.table.rows).toHaveCount(2); + }); + + await test.step('Go to next page and assert displayed rows', async () => { + await createPutawayPage.startStep.nextButton.click(); + await createPutawayPage.completeStep.isLoaded(); + await expect(createPutawayPage.completeStep.table.rows).toHaveCount(3); + }); + + await test.step('Complete putaway', async () => { + await createPutawayPage.completeStep.completePutawayButton.click(); + await expect( + createPutawayPage.completeStep.confirmPutawayDialog + ).toBeVisible(); + await expect( + createPutawayPage.completeStep.confirmPutawayDialog + ).toContainText( + /Qty5 of item .* is still in the receiving bin\. Do you want to continue\?/ + ); + await expect( + createPutawayPage.completeStep.confirmPutawayDialog + ).toBeVisible(); + await createPutawayPage.completeStep.yesButtonOnConfirmPutawayDialog + .last() + .click(); + }); + + await test.step('Assert completing putaway', async () => { + await putawayDetailsPage.isLoaded(); + await expect(putawayDetailsPage.statusTag).toHaveText('Completed'); + }); + + await test.step('Assert qty still available to putaway on create putaway page', async () => { + await navbar.profileButton.click(); + await navbar.refreshCachesButton.click(); + await createPutawayPage.goToPage(); + await createPutawayPage.table + .row(0) + .getExpandBinLocation(receivingBin) + .click(); + await expect( + createPutawayPage.table.row(1).getProductName(product2.name) + ).toBeVisible(); + await expect( + createPutawayPage.table.row(2).getProductName(product.name) + ).toBeVisible(); + await managerUserPage.close(); + }); + }); +}); diff --git a/src/tests/putaway/putawayMoreThan1Item.test.ts b/src/tests/putaway/putawayMoreThan1Item.test.ts index 488fd02..5287646 100644 --- a/src/tests/putaway/putawayMoreThan1Item.test.ts +++ b/src/tests/putaway/putawayMoreThan1Item.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import RefreshCachesUtils from '@/utils/RefreshCaches'; import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; test.describe('Create putaway for more than 1 item, separate putaways', () => { @@ -87,6 +88,7 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { test('Create putaway from inbound stock movement for 2 items, 2 separate putaways', async ({ stockMovementShowPage, navbar, + page, createPutawayPage, internalLocationService, productShowPage, @@ -105,8 +107,10 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { await test.step('Go to create putaway page', async () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); - await navbar.profileButton.click(); - await navbar.refreshCachesButton.click(); + await RefreshCachesUtils.refreshCaches({ + navbar, + page, + }); await navbar.inbound.click(); await navbar.createPutaway.click(); await createPutawayPage.isLoaded(); @@ -164,7 +168,7 @@ 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.row(1); await row.actionsButton.click(); await row.viewOrderDetails.click(); await putawayDetailsPage.isLoaded(); @@ -187,8 +191,10 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { }); await test.step('Go to create putaway page and start putaway for 2nd item', async () => { - await navbar.profileButton.click(); - await navbar.refreshCachesButton.click(); + await RefreshCachesUtils.refreshCaches({ + navbar, + page, + }); await createPutawayPage.goToPage(); await createPutawayPage.table .row(0) @@ -231,8 +237,10 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { }); await test.step('Assert empty create putaway page', async () => { - await navbar.profileButton.click(); - await navbar.refreshCachesButton.click(); + await RefreshCachesUtils.refreshCaches({ + navbar, + page, + }); await createPutawayPage.goToPage(); await expect(createPutawayPage.emptyCreatePageInformation).toBeVisible(); }); @@ -321,6 +329,7 @@ test.describe('Putaway 2 items in the same putaway', () => { test('Create putaway from inbound stock movement for 2 items', async ({ stockMovementShowPage, navbar, + page, createPutawayPage, internalLocationService, productShowPage, @@ -338,8 +347,10 @@ test.describe('Putaway 2 items in the same putaway', () => { await test.step('Go to create putaway page', async () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); - await navbar.profileButton.click(); - await navbar.refreshCachesButton.click(); + await RefreshCachesUtils.refreshCaches({ + navbar, + page, + }); await navbar.inbound.click(); await navbar.createPutaway.click(); await createPutawayPage.isLoaded(); @@ -408,8 +419,10 @@ test.describe('Putaway 2 items in the same putaway', () => { }); await test.step('Assert empty create putaway page', async () => { - await navbar.profileButton.click(); - await navbar.refreshCachesButton.click(); + await RefreshCachesUtils.refreshCaches({ + navbar, + page, + }); await createPutawayPage.goToPage(); await expect(createPutawayPage.emptyCreatePageInformation).toBeVisible(); }); diff --git a/src/tests/putaway/putawayToPreferredBin.test.ts b/src/tests/putaway/putawayToPreferredBin.test.ts index 0e74090..8a8106b 100644 --- a/src/tests/putaway/putawayToPreferredBin.test.ts +++ b/src/tests/putaway/putawayToPreferredBin.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import RefreshCachesUtils from '@/utils/RefreshCaches'; import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; test.describe('Putaway to preferred bin and default bin', () => { @@ -116,6 +117,7 @@ test.describe('Putaway to preferred bin and default bin', () => { test('Create putaway for product with preferred bin assigned and without it', async ({ stockMovementShowPage, navbar, + page, createPutawayPage, internalLocationService, productShowPage, @@ -133,8 +135,10 @@ test.describe('Putaway to preferred bin and default bin', () => { await test.step('Go to create putaway page', async () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); - await navbar.profileButton.click(); - await navbar.refreshCachesButton.click(); + await RefreshCachesUtils.refreshCaches({ + navbar, + page, + }); await navbar.inbound.click(); await navbar.createPutaway.click(); await createPutawayPage.isLoaded(); @@ -214,6 +218,7 @@ test.describe('Putaway to preferred bin and default bin', () => { test('Edit putaway bin when preferred bin assigned automatically', async ({ stockMovementShowPage, navbar, + page, createPutawayPage, internalLocationService, internalLocation2Service, @@ -231,8 +236,10 @@ test.describe('Putaway to preferred bin and default bin', () => { await test.step('Go to create putaway page', async () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); - await navbar.profileButton.click(); - await navbar.refreshCachesButton.click(); + await RefreshCachesUtils.refreshCaches({ + navbar, + page, + }); await navbar.inbound.click(); await navbar.createPutaway.click(); await createPutawayPage.isLoaded(); diff --git a/src/tests/putaway/qtyValidationsInPutaways.test.ts b/src/tests/putaway/qtyValidationsInPutaways.test.ts index d786ead..5672871 100644 --- a/src/tests/putaway/qtyValidationsInPutaways.test.ts +++ b/src/tests/putaway/qtyValidationsInPutaways.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import RefreshCachesUtils from '@/utils/RefreshCaches'; import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; test.describe('Assert qty validations in putaways', () => { @@ -76,6 +77,7 @@ test.describe('Assert qty validations in putaways', () => { test('Assert qty validations in putaways', async ({ stockMovementShowPage, navbar, + page, createPutawayPage, internalLocationService, }) => { @@ -84,8 +86,10 @@ test.describe('Assert qty validations in putaways', () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); await expect(stockMovementShowPage.statusTag).toHaveText('Received'); - await navbar.profileButton.click(); - await navbar.refreshCachesButton.click(); + await RefreshCachesUtils.refreshCaches({ + navbar, + page, + }); }); await test.step('Go to create putaway page', async () => { diff --git a/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts b/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts index c577e09..fd10e0f 100644 --- a/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts +++ b/src/tests/putaway/rollbackLastReceiptWhenPutawayCreated.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import RefreshCachesUtils from '@/utils/RefreshCaches'; import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; test.describe('Rollback last receipt behavior when putaway created', () => { @@ -79,6 +80,7 @@ test.describe('Rollback last receipt behavior when putaway created', () => { test('Rollback last receipt behavior when putaway created', async ({ stockMovementShowPage, navbar, + page, createPutawayPage, internalLocationService, receivingPage, @@ -89,8 +91,10 @@ test.describe('Rollback last receipt behavior when putaway created', () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); await expect(stockMovementShowPage.statusTag).toHaveText('Received'); - await navbar.profileButton.click(); - await navbar.refreshCachesButton.click(); + await RefreshCachesUtils.refreshCaches({ + navbar, + page, + }); }); await test.step('Go to create putaway page', async () => { @@ -152,7 +156,7 @@ 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.row(1); await row.actionsButton.click(); await row.viewOrderDetails.click(); await putawayDetailsPage.isLoaded(); diff --git a/src/tests/putaway/splitLineInPutaway.test.ts b/src/tests/putaway/splitLineInPutaway.test.ts index c81ab51..49b8141 100644 --- a/src/tests/putaway/splitLineInPutaway.test.ts +++ b/src/tests/putaway/splitLineInPutaway.test.ts @@ -2,6 +2,7 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { StockMovementResponse } from '@/types'; +import RefreshCachesUtils from '@/utils/RefreshCaches'; import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; test.describe('Split line in Putaway', () => { @@ -84,6 +85,7 @@ test.describe('Split line in Putaway', () => { test('Assert split line in Putaway', async ({ stockMovementShowPage, navbar, + page, createPutawayPage, internalLocationService, internalLocation2Service, @@ -98,8 +100,10 @@ test.describe('Split line in Putaway', () => { await test.step('Go to create putaway page', async () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); - await navbar.profileButton.click(); - await navbar.refreshCachesButton.click(); + await RefreshCachesUtils.refreshCaches({ + navbar, + page, + }); await navbar.inbound.click(); await navbar.createPutaway.click(); await createPutawayPage.isLoaded(); @@ -194,6 +198,7 @@ test.describe('Split line in Putaway', () => { test('Assert behavior when split into more than 1 line', async ({ stockMovementShowPage, navbar, + page, createPutawayPage, internalLocationService, internalLocation2Service, @@ -204,8 +209,10 @@ test.describe('Split line in Putaway', () => { await test.step('Go to create putaway page', async () => { await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); await stockMovementShowPage.isLoaded(); - await navbar.profileButton.click(); - await navbar.refreshCachesButton.click(); + await RefreshCachesUtils.refreshCaches({ + navbar, + page, + }); await navbar.inbound.click(); await navbar.createPutaway.click(); await createPutawayPage.isLoaded(); diff --git a/src/utils/RefreshCaches.ts b/src/utils/RefreshCaches.ts new file mode 100644 index 0000000..565a65f --- /dev/null +++ b/src/utils/RefreshCaches.ts @@ -0,0 +1,12 @@ +import { Page } from '@playwright/test'; + +import Navbar from '@/components/Navbar'; + +class RefreshCachesUtils { + static async refreshCaches({ navbar }: { navbar: Navbar; page: Page }) { + await navbar.profileButton.click(); + await navbar.refreshCachesButton.click(); + } +} + +export default RefreshCachesUtils;