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