|
| 1 | +import { ShipmentType } from '@/constants/ShipmentType'; |
| 2 | +import { expect, test } from '@/fixtures/fixtures'; |
| 3 | +import { StockMovementResponse } from '@/types'; |
| 4 | +import UniqueIdentifier from '@/utils/UniqueIdentifier'; |
| 5 | + |
| 6 | +test.describe('Receive item into hold bin', () => { |
| 7 | + test.describe.configure({ timeout: 60000 }); |
| 8 | + //timeout has been added for this test to make sure that the content on bin location tab will load as it can include a lot of data |
| 9 | + let STOCK_MOVEMENT: StockMovementResponse; |
| 10 | + const uniqueIdentifier = new UniqueIdentifier(); |
| 11 | + const binLocationName = uniqueIdentifier.generateUniqueString('holdbin'); |
| 12 | + |
| 13 | + test.beforeEach( |
| 14 | + async ({ |
| 15 | + supplierLocationService, |
| 16 | + mainLocationService, |
| 17 | + stockMovementService, |
| 18 | + mainProductService, |
| 19 | + page, |
| 20 | + locationListPage, |
| 21 | + createLocationPage, |
| 22 | + }) => { |
| 23 | + const supplierLocation = await supplierLocationService.getLocation(); |
| 24 | + const mainLocation = await mainLocationService.getLocation(); |
| 25 | + const PRODUCT_ONE = await mainProductService.getProduct(); |
| 26 | + |
| 27 | + STOCK_MOVEMENT = await stockMovementService.createInbound({ |
| 28 | + originId: supplierLocation.id, |
| 29 | + }); |
| 30 | + |
| 31 | + await stockMovementService.addItemsToInboundStockMovement( |
| 32 | + STOCK_MOVEMENT.id, |
| 33 | + [ |
| 34 | + { productId: PRODUCT_ONE.id, quantity: 20 }, |
| 35 | + ] |
| 36 | + ); |
| 37 | + |
| 38 | + await stockMovementService.sendInboundStockMovement(STOCK_MOVEMENT.id, { |
| 39 | + shipmentType: ShipmentType.AIR, |
| 40 | + }); |
| 41 | + |
| 42 | + await test.step('Create bin location with hold stock activity for location', async () => { |
| 43 | + await page.goto('./location/list'); |
| 44 | + await locationListPage.searchByLocationNameField.fill( |
| 45 | + mainLocation.name |
| 46 | + ); |
| 47 | + await locationListPage.findButton.click(); |
| 48 | + await expect( |
| 49 | + locationListPage.getLocationEditButton(mainLocation.name) |
| 50 | + ).toBeVisible(); |
| 51 | + await locationListPage.getLocationEditButton(mainLocation.name).click(); |
| 52 | + await createLocationPage.binLocationTab.click(); |
| 53 | + await createLocationPage.binLocationTabSection.isLoaded(); |
| 54 | + await createLocationPage.binLocationTabSection.addBinLocationButton.click(); |
| 55 | + await createLocationPage.binLocationTabSection.addBinLocationDialog.binLocationNameField.fill( |
| 56 | + binLocationName |
| 57 | + ); |
| 58 | + await createLocationPage.binLocationTabSection.addBinLocationDialog.saveButton.click(); |
| 59 | + await createLocationPage.binLocationTab.click(); |
| 60 | + await createLocationPage.binLocationTabSection.searchField.fill( |
| 61 | + binLocationName |
| 62 | + ); |
| 63 | + await createLocationPage.binLocationTabSection.searchField.press( |
| 64 | + 'Enter' |
| 65 | + ); |
| 66 | + await createLocationPage.binLocationTabSection.isLoaded(); |
| 67 | + await createLocationPage.binLocationTabSection.editBinButton.click(); |
| 68 | + await createLocationPage.locationConfigurationTab.click(); |
| 69 | + await createLocationPage.locationConfigurationTabSection.useDefaultSettingsCheckbox.uncheck(); |
| 70 | + await createLocationPage.locationConfigurationTabSection.removeSupportedActivitiesButton('Putaway stock').click(); |
| 71 | + await createLocationPage.locationConfigurationTabSection.removeSupportedActivitiesButton('Pick stock').click(); |
| 72 | + await createLocationPage.locationConfigurationTabSection.supportedActivitiesSelect.click(); |
| 73 | + await createLocationPage.locationConfigurationTabSection.getSupportedActivitiesOption('Hold stock').click(); |
| 74 | + await createLocationPage.locationConfigurationTabSection.saveButton.click(); |
| 75 | + }); |
| 76 | + } |
| 77 | + ); |
| 78 | + |
| 79 | + test.afterEach( |
| 80 | + async ({ |
| 81 | + stockMovementShowPage, |
| 82 | + stockMovementService, |
| 83 | + page, |
| 84 | + locationListPage, |
| 85 | + mainLocationService, |
| 86 | + createLocationPage, |
| 87 | + }) => { |
| 88 | + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); |
| 89 | + await stockMovementShowPage.rollbackLastReceiptButton.click(); |
| 90 | + await stockMovementShowPage.rollbackButton.click(); |
| 91 | + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); |
| 92 | + |
| 93 | + await test.step('Delete created bin location', async () => { |
| 94 | + const mainLocation = await mainLocationService.getLocation(); |
| 95 | + await page.goto('./location/list'); |
| 96 | + await locationListPage.searchByLocationNameField.fill( |
| 97 | + mainLocation.name |
| 98 | + ); |
| 99 | + await locationListPage.findButton.click(); |
| 100 | + await expect( |
| 101 | + locationListPage.getLocationEditButton(mainLocation.name) |
| 102 | + ).toBeVisible(); |
| 103 | + await locationListPage.getLocationEditButton(mainLocation.name).click(); |
| 104 | + await createLocationPage.binLocationTab.click(); |
| 105 | + await createLocationPage.binLocationTabSection.isLoaded(); |
| 106 | + await createLocationPage.binLocationTabSection.searchField.fill( |
| 107 | + binLocationName |
| 108 | + ); |
| 109 | + await createLocationPage.binLocationTabSection.searchField.press( |
| 110 | + 'Enter' |
| 111 | + ); |
| 112 | + await createLocationPage.binLocationTabSection.isLoaded(); |
| 113 | + await createLocationPage.binLocationTabSection.deleteBinButton.click(); |
| 114 | + await createLocationPage.binLocationTabSection.isLoaded(); |
| 115 | + }); |
| 116 | + } |
| 117 | + ); |
| 118 | + |
| 119 | + test('Receive to hold bin', async ({ |
| 120 | + stockMovementShowPage, |
| 121 | + receivingPage, |
| 122 | + productShowPage, |
| 123 | + }) => { |
| 124 | + await test.step('Go to stock movement show page', async () => { |
| 125 | + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); |
| 126 | + await stockMovementShowPage.isLoaded(); |
| 127 | + }); |
| 128 | + |
| 129 | + await test.step('Go to shipment receiving page', async () => { |
| 130 | + await stockMovementShowPage.receiveButton.click(); |
| 131 | + await receivingPage.receivingStep.isLoaded(); |
| 132 | + }); |
| 133 | + |
| 134 | + await test.step('Edit bin when receive item', async () => { |
| 135 | + await receivingPage.receivingStep.isLoaded(); |
| 136 | + await receivingPage.receivingStep.table.row(1).binLocationSelect.click(); |
| 137 | + await receivingPage.receivingStep.table |
| 138 | + .row(1) |
| 139 | + .getBinLocation(binLocationName) |
| 140 | + .click(); |
| 141 | + await receivingPage.receivingStep.table |
| 142 | + .row(1) |
| 143 | + .receivingNowField.textbox.fill('10'); |
| 144 | + }); |
| 145 | + |
| 146 | + await test.step('Go to check page', async () => { |
| 147 | + await receivingPage.nextButton.click(); |
| 148 | + await receivingPage.checkStep.isLoaded(); |
| 149 | + }); |
| 150 | + |
| 151 | + await test.step('Finish receipt of item', async () => { |
| 152 | + await receivingPage.checkStep.isLoaded(); |
| 153 | + await receivingPage.checkStep.receiveShipmentButton.click(); |
| 154 | + await stockMovementShowPage.isLoaded(); |
| 155 | + }); |
| 156 | + |
| 157 | + await test.step('Assert edited bin on Packing list', async () => { |
| 158 | + await expect( |
| 159 | + stockMovementShowPage.packingListTable.row(1).binLocation |
| 160 | + ).toHaveText(binLocationName); |
| 161 | + }); |
| 162 | + |
| 163 | + await test.step('Go to product page and assert bin location', async () => { |
| 164 | + await stockMovementShowPage.packingListTable.row(1).product.click(); |
| 165 | + await productShowPage.inStockTab.click(); |
| 166 | + await productShowPage.inStockTabSection.isLoaded(); |
| 167 | + await expect( |
| 168 | + productShowPage.inStockTabSection.row(2).binLocation |
| 169 | + ).toHaveText(binLocationName); |
| 170 | + await expect(productShowPage.inStockTabSection.row(2).row).toHaveAttribute('title', 'This bin has been restricted'); |
| 171 | + await expect(productShowPage.inStockTabSection.row(2).inventoryInformation).toHaveText('Hold'); |
| 172 | + }); |
| 173 | + }); |
| 174 | +}); |
0 commit comments