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..8dd24bf 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,9 @@ 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 + }); 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..f1927b7 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,9 @@ 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 + }); }); await test.step('Go to create putaway page', async () => { @@ -140,7 +142,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..afc1948 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', () => { @@ -95,8 +96,9 @@ 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 + }); }); await test.step('Go to create putaway page and assert its content', async () => { @@ -120,8 +122,9 @@ 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 + }); 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..ba8c15b 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', () => { @@ -143,7 +144,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 +171,9 @@ 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 + }); }); 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..64282ac 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', () => { @@ -91,8 +92,9 @@ 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 + }); }); await test.step('Go to create putaway page', async () => { @@ -131,7 +133,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..d4fde9e --- /dev/null +++ b/src/tests/putaway/performPutawayAsManagerUser.test.ts @@ -0,0 +1,225 @@ +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, + }) => { + 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, + }); + 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..db344ba 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', () => { @@ -105,8 +106,9 @@ 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 + }); await navbar.inbound.click(); await navbar.createPutaway.click(); await createPutawayPage.isLoaded(); @@ -164,7 +166,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 +189,9 @@ 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 + }); await createPutawayPage.goToPage(); await createPutawayPage.table .row(0) @@ -231,8 +234,9 @@ 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 + }); await createPutawayPage.goToPage(); await expect(createPutawayPage.emptyCreatePageInformation).toBeVisible(); }); @@ -338,8 +342,9 @@ 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 + }); await navbar.inbound.click(); await navbar.createPutaway.click(); await createPutawayPage.isLoaded(); @@ -408,8 +413,9 @@ 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 + }); 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..4537115 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', () => { @@ -133,8 +134,9 @@ 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 + }); await navbar.inbound.click(); await navbar.createPutaway.click(); await createPutawayPage.isLoaded(); @@ -231,8 +233,9 @@ 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 + }); 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..9f6d38b 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', () => { @@ -84,8 +85,9 @@ 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 + }); }); 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..79e9c67 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', () => { @@ -89,8 +90,9 @@ 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 + }); }); await test.step('Go to create putaway page', async () => { @@ -152,7 +154,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..5631f11 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', () => { @@ -98,8 +99,9 @@ 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 + }); await navbar.inbound.click(); await navbar.createPutaway.click(); await createPutawayPage.isLoaded(); @@ -204,8 +206,9 @@ 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 + }); 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..a050eb0 --- /dev/null +++ b/src/utils/RefreshCaches.ts @@ -0,0 +1,10 @@ +import Navbar from '@/components/Navbar'; + +class RefreshCachesUtils { + static async refreshCaches({ navbar }: { navbar: Navbar }) { + await navbar.profileButton.click(); + await navbar.refreshCachesButton.click(); + } +} + +export default RefreshCachesUtils;