diff --git a/src/pages/location/createLocation/tabs/LocationDetailsTabSection.ts b/src/pages/location/createLocation/tabs/LocationDetailsTabSection.ts index b5338a7..8b72e19 100644 --- a/src/pages/location/createLocation/tabs/LocationDetailsTabSection.ts +++ b/src/pages/location/createLocation/tabs/LocationDetailsTabSection.ts @@ -51,6 +51,10 @@ class LocationDetailsTabSection extends BasePageModel { getZoneLocation(name: string) { return this.page.getByRole('listitem').getByText(name, { exact: true }); } + + get clearZoneLocation() { + return this.zoneLocationSelect.locator('.search-choice-close'); + } } export default LocationDetailsTabSection; diff --git a/src/pages/putaway/components/CompletePutawayTable.ts b/src/pages/putaway/components/CompletePutawayTable.ts index a8c5f2c..c796485 100644 --- a/src/pages/putaway/components/CompletePutawayTable.ts +++ b/src/pages/putaway/components/CompletePutawayTable.ts @@ -35,6 +35,14 @@ class Row extends BasePageModel { get quantity() { return this.row.getByTestId('table-cell').nth(7); } + + get preferredBin() { + return this.row.getByTestId('table-cell').nth(8); + } + + get currentBin() { + return this.row.getByTestId('table-cell').nth(9); + } } export default CompletePutawayTable; diff --git a/src/pages/putaway/components/SplitModalTable.ts b/src/pages/putaway/components/SplitModalTable.ts index 9c8c59f..3045f4f 100644 --- a/src/pages/putaway/components/SplitModalTable.ts +++ b/src/pages/putaway/components/SplitModalTable.ts @@ -63,6 +63,17 @@ class Row extends BasePageModel { get putawayBinField() { return this.row.getByTestId('bin-select').getByRole('textbox'); } + + get expandPutawayBinSelect() { + return this.row.locator('[class*="react-select__dropdown-indicator"]'); + } + + getZoneLocation(zoneLocation: string) { + return this.page + .getByTestId('custom-select-dropdown-menu') + .locator('.css-5ih5ya-group react-select__group-heading') + .getByText(zoneLocation, { exact: true }); + } } export default SplitModalTable; diff --git a/src/pages/putaway/components/StartPutawayTable.ts b/src/pages/putaway/components/StartPutawayTable.ts index 3357603..70acacf 100644 --- a/src/pages/putaway/components/StartPutawayTable.ts +++ b/src/pages/putaway/components/StartPutawayTable.ts @@ -73,6 +73,10 @@ class Row extends BasePageModel { return this.row.getByTestId('select-bin'); } + get expandPutawayBinSelect() { + return this.putawayBinSelect.locator('.react-select__dropdown-indicator'); + } + getPutawayBin(putawayBin: string) { return this.page .getByTestId('custom-select-dropdown-menu') @@ -88,6 +92,10 @@ class Row extends BasePageModel { return this.row.getByTestId('table-cell').nth(8); } + get currentdBin() { + return this.row.getByTestId('table-cell').nth(9); + } + get quantityField() { return this.row.getByTestId('table-cell').nth(7); } @@ -107,6 +115,13 @@ class Row extends BasePageModel { get expiryDateField() { return this.row.getByTestId('table-cell').nth(5); } + + getZoneLocation(zoneLocation: string) { + return this.page + .getByTestId('custom-select-dropdown-menu') + .locator('.css-5ih5ya-group react-select__group-heading') + .getByText(zoneLocation, { exact: true }); + } } export default StartPutawayTable; diff --git a/src/tests/putaway/assertZonesInPutaways.test.ts b/src/tests/putaway/assertZonesInPutaways.test.ts new file mode 100644 index 0000000..1b6e85e --- /dev/null +++ b/src/tests/putaway/assertZonesInPutaways.test.ts @@ -0,0 +1,456 @@ +import AppConfig from '@/config/AppConfig'; +import { LOCATION_URL } from '@/constants/applicationUrls'; +import { ShipmentType } from '@/constants/ShipmentType'; +import { expect, test } from '@/fixtures/fixtures'; +import { Product } from '@/generated/ProductCodes.generated'; +import { ProductResponse, StockMovementResponse } from '@/types'; +import RefreshCachesUtils from '@/utils/RefreshCaches'; +import { + deleteReceivedShipment, + getShipmentId, + getShipmentItemId, +} from '@/utils/shipmentUtils'; +import { byNameAsc } from '@/utils/sortUtils'; +import UniqueIdentifier from '@/utils/UniqueIdentifier'; + +test.describe('Assert zones on putaway pages', () => { + let STOCK_MOVEMENT: StockMovementResponse; + let productA: ProductResponse; + let productB: ProductResponse; + const uniqueIdentifier = new UniqueIdentifier(); + const zoneLocationName = uniqueIdentifier.generateUniqueString('zone'); + + test.beforeEach( + async ({ + supplierLocationService, + mainLocationService, + stockMovementService, + productService, + receivingService, + productShowPage, + productEditPage, + internalLocationService, + page, + locationListPage, + createLocationPage, + }) => { + const supplierLocation = await supplierLocationService.getLocation(); + const mainLocation = await mainLocationService.getLocation(); + const internalLocation = await internalLocationService.getLocation(); + STOCK_MOVEMENT = await stockMovementService.createInbound({ + originId: supplierLocation.id, + }); + + [productA, productB] = [ + await productService.getProduct(Product.FIVE), + await productService.getProduct(Product.FOUR), + ].sort(byNameAsc); + + await test.step('Create and receive stock movement', async () => { + await stockMovementService.addItemsToInboundStockMovement( + STOCK_MOVEMENT.id, + [ + { productId: productA.id, quantity: 10 }, + { productId: productB.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); + }); + + await test.step('Create zone for location', async () => { + await page.goto(LOCATION_URL.list()); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await expect( + locationListPage.getLocationEditButton(mainLocation.name) + ).toBeVisible(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.zoneLocationTab.click(); + await createLocationPage.zoneLocationTabSection.isLoaded(); + await createLocationPage.zoneLocationTabSection.addZoneLocationButton.click(); + await createLocationPage.zoneLocationTabSection.addZoneLocationDialog.zoneLocationNameField.fill( + zoneLocationName + ); + await createLocationPage.zoneLocationTabSection.addZoneLocationDialog.saveButton.click(); + await createLocationPage.zoneLocationTabSection.isLoaded(); + }); + + await test.step('Assign created zone to bin location', async () => { + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + internalLocation.name + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton + .first() + .click(); + await createLocationPage.locationDetailsTabSection.zoneLocationSelect.click(); + await createLocationPage.locationDetailsTabSection + .getZoneLocation(zoneLocationName) + .click(); + await createLocationPage.locationDetailsTabSection.saveButton.click(); + }); + + await test.step('Assign bin with zone as preferred bin', async () => { + await productShowPage.goToPage(productB.id); + await productShowPage.editProductkButton.click(); + await productEditPage.inventoryLevelsTab.click(); + await productEditPage.inventoryLevelsTabSection.createStockLevelButton.click(); + await productEditPage.inventoryLevelsTabSection.createStockLevelModal.receivingTab.click(); + const internalLocation = await internalLocationService.getLocation(); + await productEditPage.inventoryLevelsTabSection.createStockLevelModal.defaultPutawayLocation.click(); + await productEditPage.inventoryLevelsTabSection.createStockLevelModal + .getDefaultPutawayLocation(internalLocation.name) + .click(); + await productEditPage.inventoryLevelsTabSection.createStockLevelModal.createButton.click(); + }); + } + ); + + test.afterEach( + async ({ + stockMovementShowPage, + stockMovementService, + navbar, + transactionListPage, + oldViewShipmentPage, + productService, + productShowPage, + productEditPage, + page, + locationListPage, + mainLocationService, + createLocationPage, + internalLocationService, + }) => { + await navbar.configurationButton.click(); + await navbar.transactions.click(); + for (let n = 1; n < 3; n++) { + await transactionListPage.deleteTransaction(1); + } + await deleteReceivedShipment({ + stockMovementShowPage, + oldViewShipmentPage, + stockMovementService, + STOCK_MOVEMENT, + }); + const product = await productService.getProduct(Product.FOUR); + + await test.step('Delete inventory level', async () => { + await productShowPage.goToPage(product.id); + await productShowPage.editProductkButton.click(); + await productEditPage.inventoryLevelsTab.click(); + await productEditPage.inventoryLevelsTabSection + .row(1) + .editInventoryLevelButton.click(); + await expect( + productEditPage.inventoryLevelsTabSection.table + ).toBeVisible(); + await productEditPage.inventoryLevelsTabSection.createStockLevelModal.clickDeleteInventoryLevel(); + }); + + await test.step('Remove zone from bin location', async () => { + const mainLocation = await mainLocationService.getLocation(); + const internalLocation = await internalLocationService.getLocation(); + await page.goto(LOCATION_URL.list()); + await locationListPage.searchByLocationNameField.fill( + mainLocation.name + ); + await locationListPage.findButton.click(); + await expect( + locationListPage.getLocationEditButton(mainLocation.name) + ).toBeVisible(); + await locationListPage.getLocationEditButton(mainLocation.name).click(); + await createLocationPage.binLocationTab.click(); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.searchField.fill( + internalLocation.name + ); + await createLocationPage.binLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.binLocationTabSection.isLoaded(); + await createLocationPage.binLocationTabSection.editBinButton + .first() + .click(); + await createLocationPage.locationDetailsTabSection.clearZoneLocation.click(); + await createLocationPage.locationDetailsTabSection.saveButton.click(); + }); + + await test.step('Deactivate created zone location', async () => { + await createLocationPage.zoneLocationTab.click(); + await createLocationPage.zoneLocationTabSection.isLoaded(); + await createLocationPage.zoneLocationTabSection.searchField.fill( + zoneLocationName + ); + await createLocationPage.zoneLocationTabSection.searchField.press( + 'Enter' + ); + await createLocationPage.zoneLocationTabSection.isLoaded(); + await createLocationPage.zoneLocationTabSection.editZoneButton.click(); + await createLocationPage.locationConfigurationTab.click(); + await createLocationPage.locationConfigurationTabSection.activeCheckbox.uncheck(); + await createLocationPage.locationConfigurationTabSection.saveButton.click(); + }); + } + ); + + test('Create putaway and assert zones on putaway pages', async ({ + stockMovementShowPage, + navbar, + createPutawayPage, + internalLocationService, + putawayDetailsPage, + }) => { + const receivingBin = + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; + const internalLocation = await internalLocationService.getLocation(); + + await test.step('Go to create putaway page', async () => { + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); + await stockMovementShowPage.isLoaded(); + await RefreshCachesUtils.refreshCaches({ + navbar, + }); + await navbar.inbound.click(); + await navbar.createPutaway.click(); + await createPutawayPage.isLoaded(); + }); + + await test.step('Start 1st putaway', async () => { + await createPutawayPage.table + .row(0) + .getExpandBinLocation(receivingBin) + .click(); + await createPutawayPage.table.row(1).checkbox.click(); + await createPutawayPage.startPutawayButton.click(); + await createPutawayPage.startStep.isLoaded(); + await createPutawayPage.startStep.table.row(0).editButton.click(); + await createPutawayPage.startStep.table.row(0).quantityInput.fill('5'); + }); + + await test.step('Assert zones on start putaway page', async () => { + await createPutawayPage.startStep.table + .row(1) + .expandPutawayBinSelect.waitFor({ state: 'visible' }); + await createPutawayPage.startStep.table + .row(1) + .expandPutawayBinSelect.click(); + await createPutawayPage.startStep.table + .row(1) + .getZoneLocation(zoneLocationName) + .isVisible(); + await createPutawayPage.startStep.table + .row(1) + .getPutawayBin(internalLocation.name) + .click(); + await createPutawayPage.startStep.nextButton.click(); + }); + + await test.step('Assert zones on confirm page', async () => { + await createPutawayPage.completeStep.isLoaded(); + await expect( + createPutawayPage.completeStep.table.row(2).putawayBin + ).toContainText(`${zoneLocationName}: ${internalLocation.name}`); + }); + + await test.step('Complete putaway', async () => { + await createPutawayPage.completeStep.completePutawayButton.click(); + await expect( + createPutawayPage.completeStep.confirmPutawayDialog + ).toBeVisible(); + await createPutawayPage.completeStep.yesButtonOnConfirmPutawayDialog.click(); + await putawayDetailsPage.isLoaded(); + await expect(putawayDetailsPage.statusTag).toHaveText('Completed'); + }); + + 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 2nd putaway', async () => { + await createPutawayPage.table + .row(0) + .getExpandBinLocation(receivingBin) + .click(); + 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('Assert zones on start putaway page', async () => { + await expect( + createPutawayPage.startStep.table.row(1).currentdBin + ).toContainText(`${zoneLocationName}: ${internalLocation.name}`); + await createPutawayPage.startStep.table + .row(1) + .expandPutawayBinSelect.waitFor({ state: 'visible' }); + await createPutawayPage.startStep.table + .row(1) + .expandPutawayBinSelect.click(); + await createPutawayPage.startStep.table + .row(1) + .getZoneLocation(zoneLocationName) + .isVisible(); + await createPutawayPage.startStep.table + .row(1) + .getPutawayBin(internalLocation.name) + .click(); + await expect( + createPutawayPage.startStep.table.row(2).preferredBin + ).toContainText(`${zoneLocationName}: ${internalLocation.name}`); + await expect( + createPutawayPage.startStep.table.row(2).putawayBinSelect + ).toContainText(internalLocation.name); + await createPutawayPage.startStep.table + .row(2) + .expandPutawayBinSelect.waitFor({ state: 'visible' }); + await createPutawayPage.startStep.table + .row(2) + .expandPutawayBinSelect.click(); + await createPutawayPage.startStep.table + .row(2) + .getZoneLocation(zoneLocationName) + .isVisible(); + await createPutawayPage.startStep.table + .row(2) + .getPutawayBin(internalLocation.name) + .click(); + }); + + await test.step('Apply ordering by current bin', async () => { + await createPutawayPage.startStep.sortButton.click(); + await expect(createPutawayPage.startStep.sortButton).toContainText( + 'Sort by current bins' + ); + await expect( + createPutawayPage.startStep.table.row(1).currentdBin + ).toContainText(`${zoneLocationName}: ${internalLocation.name}`); + await expect( + createPutawayPage.startStep.table.row(2).preferredBin + ).toContainText(`${zoneLocationName}: ${internalLocation.name}`); + }); + + await test.step('Apply ordering by preferred bin', async () => { + await createPutawayPage.startStep.sortButton.click(); + await expect(createPutawayPage.startStep.sortButton).toContainText( + 'Sort by preferred bin' + ); + await expect( + createPutawayPage.startStep.table.row(2).currentdBin + ).toContainText(`${zoneLocationName}: ${internalLocation.name}`); + await expect( + createPutawayPage.startStep.table.row(1).preferredBin + ).toContainText(`${zoneLocationName}: ${internalLocation.name}`); + }); + + await test.step('Return to original order', async () => { + await createPutawayPage.startStep.sortButton.click(); + await expect(createPutawayPage.startStep.sortButton).toContainText( + 'Sort by current bins' + ); + await expect( + createPutawayPage.startStep.table.row(1).currentdBin + ).toContainText(`${zoneLocationName}: ${internalLocation.name}`); + await expect( + createPutawayPage.startStep.table.row(2).preferredBin + ).toContainText(`${zoneLocationName}: ${internalLocation.name}`); + }); + + await test.step('Assert zones on split line dialog', async () => { + await createPutawayPage.startStep.table + .row(0) + .splitLineButton.first() + .click(); + await createPutawayPage.startStep.splitModal.isLoaded(); + await createPutawayPage.startStep.splitModal.table + .row(1) + .expandPutawayBinSelect.click(); + await createPutawayPage.startStep.table + .row(1) + .getZoneLocation(zoneLocationName) + .isVisible(); + await createPutawayPage.startStep.splitModal.table + .row(1) + .getPutawayBin(internalLocation.name); + await createPutawayPage.startStep.splitModal.addLineButton.click(); + await createPutawayPage.startStep.splitModal.table + .row(2) + .expandPutawayBinSelect.click(); + await createPutawayPage.startStep.table + .row(2) + .getZoneLocation(zoneLocationName) + .isVisible(); + await createPutawayPage.startStep.splitModal.table + .row(2) + .getPutawayBin(internalLocation.name); + await createPutawayPage.startStep.splitModal.table + .row(2) + .quantityField.fill('5'); + await createPutawayPage.startStep.splitModal.cancelButton.click(); + await createPutawayPage.startStep.nextButton.click(); + }); + + await test.step('Assert zones on confirm page', async () => { + await createPutawayPage.completeStep.isLoaded(); + await expect( + createPutawayPage.completeStep.table.row(2).putawayBin + ).toContainText(`${zoneLocationName}: ${internalLocation.name}`); + await expect( + createPutawayPage.completeStep.table.row(2).currentBin + ).toContainText(`${zoneLocationName}: ${internalLocation.name}`); + await expect( + createPutawayPage.completeStep.table.row(3).putawayBin + ).toContainText(`${zoneLocationName}: ${internalLocation.name}`); + await expect( + createPutawayPage.completeStep.table.row(3).preferredBin + ).toContainText(`${zoneLocationName}: ${internalLocation.name}`); + }); + + await test.step('Complete putaway', async () => { + await createPutawayPage.completeStep.completePutawayButton.click(); + await putawayDetailsPage.isLoaded(); + await expect(putawayDetailsPage.statusTag).toHaveText('Completed'); + }); + }); +}); diff --git a/src/tests/putaway/deleteItemsFromPutaway.test.ts b/src/tests/putaway/deleteItemsFromPutaway.test.ts index 9f9fa23..66caff9 100644 --- a/src/tests/putaway/deleteItemsFromPutaway.test.ts +++ b/src/tests/putaway/deleteItemsFromPutaway.test.ts @@ -2,16 +2,19 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { Product } from '@/generated/ProductCodes.generated'; -import { StockMovementResponse } from '@/types'; +import { ProductResponse, StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; import { deleteReceivedShipment, getShipmentId, getShipmentItemId, } from '@/utils/shipmentUtils'; +import { byNameAsc } from '@/utils/sortUtils'; test.describe('Delete items from putaway', () => { let STOCK_MOVEMENT: StockMovementResponse; + let product: ProductResponse; + let product2: ProductResponse; test.beforeEach( async ({ @@ -25,8 +28,10 @@ test.describe('Delete items from putaway', () => { originId: supplierLocation.id, }); - const product = await productService.getProduct(Product.FIVE); - const product2 = await productService.getProduct(Product.FOUR); + [product, product2] = [ + await productService.getProduct(Product.FIVE), + await productService.getProduct(Product.FOUR), + ].sort(byNameAsc); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -93,13 +98,10 @@ test.describe('Delete items from putaway', () => { createPutawayPage, internalLocationService, putawayDetailsPage, - productService, putawayListPage, }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - const product = await productService.getProduct(Product.FIVE); - const product2 = await productService.getProduct(Product.FOUR); const internalLocation = await internalLocationService.getLocation(); await test.step('Go to create putaway page', async () => { diff --git a/src/tests/putaway/performPutawayAsManagerUser.test.ts b/src/tests/putaway/performPutawayAsManagerUser.test.ts index 35d0a6d..725670a 100644 --- a/src/tests/putaway/performPutawayAsManagerUser.test.ts +++ b/src/tests/putaway/performPutawayAsManagerUser.test.ts @@ -6,16 +6,19 @@ import { Product } from '@/generated/ProductCodes.generated'; import CreatePutawayPage from '@/pages/putaway/CreatePutawayPage'; import PutawayDetailsPage from '@/pages/putaway/putawayDetails/PutawayDetailsPage'; import StockMovementShowPage from '@/pages/stockMovementShow/StockMovementShowPage'; -import { StockMovementResponse } from '@/types'; +import { ProductResponse, StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; import { deleteReceivedShipment, getShipmentId, getShipmentItemId, } from '@/utils/shipmentUtils'; +import { byNameAsc } from '@/utils/sortUtils'; test.describe('Perform putaway as manager user', () => { let STOCK_MOVEMENT: StockMovementResponse; + let product: ProductResponse; + let product2: ProductResponse; test.beforeEach( async ({ @@ -29,8 +32,10 @@ test.describe('Perform putaway as manager user', () => { originId: supplierLocation.id, }); - const product = await productService.getProduct(Product.THREE); - const product2 = await productService.getProduct(Product.FOUR); + [product, product2] = [ + await productService.getProduct(Product.THREE), + await productService.getProduct(Product.FOUR), + ].sort(byNameAsc); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -94,12 +99,9 @@ test.describe('Perform putaway as manager user', () => { test('Perform putaway as manager user', async ({ managerUserContext, internalLocationService, - productService, }) => { const receivingBin = - AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - const product = await productService.getProduct(Product.THREE); - const product2 = await productService.getProduct(Product.FOUR); + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;; const internalLocation = await internalLocationService.getLocation(); const managerUserPage = await managerUserContext.newPage(); @@ -125,10 +127,10 @@ test.describe('Perform putaway as manager user', () => { .getExpandBinLocation(receivingBin) .click(); await expect( - createPutawayPage.table.row(1).getProductName(product2.name) + createPutawayPage.table.row(2).getProductName(product2.name) ).toBeVisible(); await expect( - createPutawayPage.table.row(2).getProductName(product.name) + createPutawayPage.table.row(1).getProductName(product.name) ).toBeVisible(); await createPutawayPage.table.row(1).checkbox.click(); await createPutawayPage.table.row(2).checkbox.click(); @@ -214,10 +216,10 @@ test.describe('Perform putaway as manager user', () => { .getExpandBinLocation(receivingBin) .click(); await expect( - createPutawayPage.table.row(1).getProductName(product2.name) + createPutawayPage.table.row(2).getProductName(product2.name) ).toBeVisible(); await expect( - createPutawayPage.table.row(2).getProductName(product.name) + createPutawayPage.table.row(1).getProductName(product.name) ).toBeVisible(); await managerUserPage.close(); }); diff --git a/src/tests/putaway/putawayMoreThan1Item.test.ts b/src/tests/putaway/putawayMoreThan1Item.test.ts index eb79bee..512892d 100644 --- a/src/tests/putaway/putawayMoreThan1Item.test.ts +++ b/src/tests/putaway/putawayMoreThan1Item.test.ts @@ -2,16 +2,19 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { Product } from '@/generated/ProductCodes.generated'; -import { StockMovementResponse } from '@/types'; +import { ProductResponse, StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; import { deleteReceivedShipment, getShipmentId, getShipmentItemId, } from '@/utils/shipmentUtils'; +import { byNameAsc } from '@/utils/sortUtils'; test.describe('Create putaway for more than 1 item, separate putaways', () => { let STOCK_MOVEMENT: StockMovementResponse; + let product: ProductResponse; + let product2: ProductResponse; test.beforeEach( async ({ @@ -25,8 +28,10 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { originId: supplierLocation.id, }); - const product = await productService.getProduct(Product.FIVE); - const product2 = await productService.getProduct(Product.FOUR); + [product, product2] = [ + await productService.getProduct(Product.FIVE), + await productService.getProduct(Product.FOUR), + ].sort(byNameAsc); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -94,13 +99,10 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { internalLocationService, productShowPage, putawayDetailsPage, - productService, putawayListPage, }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - const product = await productService.getProduct(Product.FIVE); - const product2 = await productService.getProduct(Product.FOUR); const internalLocation = await internalLocationService.getLocation(); await test.step('Go to create putaway page', async () => { @@ -245,6 +247,8 @@ test.describe('Create putaway for more than 1 item, separate putaways', () => { test.describe('Putaway 2 items in the same putaway', () => { let STOCK_MOVEMENT: StockMovementResponse; + let product: ProductResponse; + let product2: ProductResponse; test.beforeEach( async ({ @@ -258,8 +262,10 @@ test.describe('Putaway 2 items in the same putaway', () => { originId: supplierLocation.id, }); - const product = await productService.getProduct(Product.FIVE); - const product2 = await productService.getProduct(Product.FOUR); + [product, product2] = [ + await productService.getProduct(Product.FIVE), + await productService.getProduct(Product.FOUR), + ].sort(byNameAsc); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, diff --git a/src/tests/putaway/putawayToPreferredBin.test.ts b/src/tests/putaway/putawayToPreferredBin.test.ts index 49429ec..b979b0b 100644 --- a/src/tests/putaway/putawayToPreferredBin.test.ts +++ b/src/tests/putaway/putawayToPreferredBin.test.ts @@ -2,16 +2,19 @@ import AppConfig from '@/config/AppConfig'; import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { Product } from '@/generated/ProductCodes.generated'; -import { StockMovementResponse } from '@/types'; +import { ProductResponse, StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; import { deleteReceivedShipment, getShipmentId, getShipmentItemId, } from '@/utils/shipmentUtils'; +import { byNameAsc } from '@/utils/sortUtils'; test.describe('Putaway to preferred bin and default bin', () => { let STOCK_MOVEMENT: StockMovementResponse; + let product: ProductResponse; + let product2: ProductResponse; test.beforeEach( async ({ @@ -28,8 +31,10 @@ test.describe('Putaway to preferred bin and default bin', () => { originId: supplierLocation.id, }); - const product = await productService.getProduct(Product.FIVE); - const product2 = await productService.getProduct(Product.FOUR); + [product, product2] = [ + await productService.getProduct(Product.FIVE), + await productService.getProduct(Product.FOUR), + ].sort(byNameAsc); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -122,12 +127,9 @@ test.describe('Putaway to preferred bin and default bin', () => { internalLocationService, productShowPage, putawayDetailsPage, - productService, }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - const product = await productService.getProduct(Product.FIVE); - const product2 = await productService.getProduct(Product.FOUR); const internalLocation = await internalLocationService.getLocation(); await test.step('Go to create putaway page', async () => { @@ -220,11 +222,10 @@ test.describe('Putaway to preferred bin and default bin', () => { internalLocation2Service, productShowPage, putawayDetailsPage, - productService, }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - const product2 = await productService.getProduct(Product.FOUR); + const internalLocation = await internalLocationService.getLocation(); const internalLocation2 = await internalLocation2Service.getLocation(); diff --git a/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts b/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts index 329334f..56efccc 100644 --- a/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts +++ b/src/tests/putaway/validationOnQtyRemovedFromReceivingBin.test.ts @@ -5,16 +5,19 @@ import { ShipmentType } from '@/constants/ShipmentType'; import { expect, test } from '@/fixtures/fixtures'; import { Product } from '@/generated/ProductCodes.generated'; import ProductShowPage from '@/pages/product/productShow/ProductShowPage'; -import { StockMovementResponse } from '@/types'; +import { ProductResponse, StockMovementResponse } from '@/types'; import RefreshCachesUtils from '@/utils/RefreshCaches'; import { deleteReceivedShipment, getShipmentId, getShipmentItemId, } from '@/utils/shipmentUtils'; +import { byNameAsc } from '@/utils/sortUtils'; test.describe('Assert validation on qty removed from receiving bin', () => { let STOCK_MOVEMENT: StockMovementResponse; + let product: ProductResponse; + let product2: ProductResponse; test.beforeEach( async ({ @@ -28,8 +31,10 @@ test.describe('Assert validation on qty removed from receiving bin', () => { originId: supplierLocation.id, }); - const product = await productService.getProduct(Product.FIVE); - const product2 = await productService.getProduct(Product.FOUR); + [product, product2] = [ + await productService.getProduct(Product.FIVE), + await productService.getProduct(Product.FOUR), + ].sort(byNameAsc); await stockMovementService.addItemsToInboundStockMovement( STOCK_MOVEMENT.id, @@ -99,15 +104,12 @@ test.describe('Assert validation on qty removed from receiving bin', () => { internalLocationService, productShowPage, putawayDetailsPage, - productService, putawayListPage, browser, navbar, }) => { const receivingBin = AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; - const product = await productService.getProduct(Product.FIVE); - const product2 = await productService.getProduct(Product.FOUR); const internalLocation = await internalLocationService.getLocation(); await test.step('Edit transaction date of transfer in', async () => { diff --git a/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts b/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts index 83c1614..9d49973 100644 --- a/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts +++ b/src/tests/receiving/assertCreationOfGoodsReceiptNote.test.ts @@ -122,6 +122,8 @@ test.describe('Assert Goods Receipt Note is created and opened', () => { await test.step('Assert Goods receipt note is created and opened for partially received shipment', async () => { await stockMovementShowPage.documentTab.click(); + // eslint-disable-next-line playwright/no-networkidle + await page.waitForLoadState('networkidle'); await expect( stockMovementShowPage.documentsListTable .row(7)