|
| 1 | +import AppConfig from '@/config/AppConfig'; |
| 2 | +import { ShipmentType } from '@/constants/ShipmentType'; |
| 3 | +import { expect, test } from '@/fixtures/fixtures'; |
| 4 | +import { StockMovementResponse } from '@/types'; |
| 5 | +import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils'; |
| 6 | + |
| 7 | +test.describe('Change location on putaway create page and list pages', () => { |
| 8 | + let STOCK_MOVEMENT: StockMovementResponse; |
| 9 | + |
| 10 | + test.beforeEach( |
| 11 | + async ({ |
| 12 | + supplierLocationService, |
| 13 | + stockMovementService, |
| 14 | + fifthProductService, |
| 15 | + receivingService, |
| 16 | + }) => { |
| 17 | + const supplierLocation = await supplierLocationService.getLocation(); |
| 18 | + STOCK_MOVEMENT = await stockMovementService.createInbound({ |
| 19 | + originId: supplierLocation.id, |
| 20 | + }); |
| 21 | + |
| 22 | + const product = await fifthProductService.getProduct(); |
| 23 | + |
| 24 | + await stockMovementService.addItemsToInboundStockMovement( |
| 25 | + STOCK_MOVEMENT.id, |
| 26 | + [{ productId: product.id, quantity: 10 }] |
| 27 | + ); |
| 28 | + |
| 29 | + await stockMovementService.sendInboundStockMovement(STOCK_MOVEMENT.id, { |
| 30 | + shipmentType: ShipmentType.AIR, |
| 31 | + }); |
| 32 | + |
| 33 | + const { data: stockMovement } = |
| 34 | + await stockMovementService.getStockMovement(STOCK_MOVEMENT.id); |
| 35 | + const shipmentId = getShipmentId(stockMovement); |
| 36 | + const { data: receipt } = await receivingService.getReceipt(shipmentId); |
| 37 | + const receivingBin = |
| 38 | + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; |
| 39 | + |
| 40 | + await receivingService.createReceivingBin(shipmentId, receipt); |
| 41 | + |
| 42 | + await receivingService.updateReceivingItems(shipmentId, [ |
| 43 | + { |
| 44 | + shipmentItemId: getShipmentItemId(receipt, 0, 0), |
| 45 | + quantityReceiving: 10, |
| 46 | + binLocationName: receivingBin, |
| 47 | + }, |
| 48 | + ]); |
| 49 | + await receivingService.completeReceipt(shipmentId); |
| 50 | + } |
| 51 | + ); |
| 52 | + |
| 53 | + test.afterEach( |
| 54 | + async ({ |
| 55 | + stockMovementShowPage, |
| 56 | + stockMovementService, |
| 57 | + putawayListPage, |
| 58 | + oldViewShipmentPage, |
| 59 | + }) => { |
| 60 | + await putawayListPage.goToPage(); |
| 61 | + await putawayListPage.table.row(1).actionsButton.click(); |
| 62 | + await putawayListPage.table.clickDeleteOrderButton(); |
| 63 | + await putawayListPage.emptyPutawayList.isVisible(); |
| 64 | + |
| 65 | + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); |
| 66 | + await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); |
| 67 | + await oldViewShipmentPage.undoStatusChangeButton.click(); |
| 68 | + await stockMovementShowPage.isLoaded(); |
| 69 | + await stockMovementShowPage.rollbackButton.click(); |
| 70 | + |
| 71 | + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); |
| 72 | + } |
| 73 | + ); |
| 74 | + |
| 75 | + test('Change location on putaway create page and list page', async ({ |
| 76 | + stockMovementShowPage, |
| 77 | + navbar, |
| 78 | + createPutawayPage, |
| 79 | + locationChooser, |
| 80 | + fifthProductService, |
| 81 | + depotLocationService, |
| 82 | + mainLocationService, |
| 83 | + putawayListPage, |
| 84 | + authService, |
| 85 | + }) => { |
| 86 | + const receivingBin = |
| 87 | + AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier; |
| 88 | + const product = await fifthProductService.getProduct(); |
| 89 | + const mainLocation = await mainLocationService.getLocation(); |
| 90 | + const depotLocation = await depotLocationService.getLocation(); |
| 91 | + |
| 92 | + await test.step('Go to stock movement show page and assert received status', async () => { |
| 93 | + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); |
| 94 | + await stockMovementShowPage.isLoaded(); |
| 95 | + await expect(stockMovementShowPage.statusTag).toHaveText('Received'); |
| 96 | + await navbar.profileButton.click(); |
| 97 | + await navbar.refreshCachesButton.click(); |
| 98 | + }); |
| 99 | + |
| 100 | + await test.step('Go to create putaway page and assert its content', async () => { |
| 101 | + await createPutawayPage.goToPage(); |
| 102 | + await createPutawayPage.isLoaded(); |
| 103 | + await expect(createPutawayPage.table.row(0).receivingBin).toContainText( |
| 104 | + receivingBin |
| 105 | + ); |
| 106 | + await createPutawayPage.table |
| 107 | + .row(0) |
| 108 | + .getExpandBinLocation(receivingBin) |
| 109 | + .click(); |
| 110 | + await expect( |
| 111 | + createPutawayPage.table.row(1).getProductName(product.name) |
| 112 | + ).toBeVisible(); |
| 113 | + }); |
| 114 | + |
| 115 | + await test.step('Change location to another depot', async () => { |
| 116 | + await navbar.locationChooserButton.click(); |
| 117 | + await locationChooser |
| 118 | + .getOrganization(depotLocation.organization?.name as string) |
| 119 | + .click(); |
| 120 | + await locationChooser.getLocation(depotLocation.name).click(); |
| 121 | + await navbar.profileButton.click(); |
| 122 | + await navbar.refreshCachesButton.click(); |
| 123 | + await createPutawayPage.goToPage(); |
| 124 | + await expect(createPutawayPage.emptyCreatePageInformation).toBeVisible(); |
| 125 | + await expect( |
| 126 | + createPutawayPage.table.row(0).getExpandBinLocation(receivingBin) |
| 127 | + ).toBeHidden(); |
| 128 | + }); |
| 129 | + |
| 130 | + await test.step('Return to main location and create pending putaway', async () => { |
| 131 | + await navbar.locationChooserButton.click(); |
| 132 | + await locationChooser |
| 133 | + .getOrganization(mainLocation.organization?.name as string) |
| 134 | + .click(); |
| 135 | + await locationChooser.getLocation(mainLocation.name).click(); |
| 136 | + await navbar.profileButton.click(); |
| 137 | + await navbar.refreshCachesButton.click(); |
| 138 | + await createPutawayPage.goToPage(); |
| 139 | + await createPutawayPage.table |
| 140 | + .row(0) |
| 141 | + .getExpandBinLocation(receivingBin) |
| 142 | + .click(); |
| 143 | + await createPutawayPage.table.row(1).checkbox.click(); |
| 144 | + await createPutawayPage.startPutawayButton.click(); |
| 145 | + await createPutawayPage.startStep.isLoaded(); |
| 146 | + await createPutawayPage.startStep.saveButton.click(); |
| 147 | + }); |
| 148 | + |
| 149 | + await test.step('Go to list page and assert putaway is created', async () => { |
| 150 | + await putawayListPage.goToPage(); |
| 151 | + await putawayListPage.isLoaded(); |
| 152 | + await expect(putawayListPage.table.row(1).statusTag).toHaveText( |
| 153 | + 'Pending' |
| 154 | + ); |
| 155 | + }); |
| 156 | + |
| 157 | + const putawayOrderIdentifier = await putawayListPage.table |
| 158 | + .row(1) |
| 159 | + .orderNumber.textContent(); |
| 160 | + |
| 161 | + await test.step('Change location to another depot', async () => { |
| 162 | + await navbar.locationChooserButton.click(); |
| 163 | + await locationChooser |
| 164 | + .getOrganization(depotLocation.organization?.name as string) |
| 165 | + .click(); |
| 166 | + await locationChooser.getLocation(depotLocation.name).click(); |
| 167 | + await putawayListPage.goToPage(); |
| 168 | + await putawayListPage.searchField.fill( |
| 169 | + `${putawayOrderIdentifier}`.toString().trim() |
| 170 | + ); |
| 171 | + await putawayListPage.searchButton.click(); |
| 172 | + await putawayListPage.emptyPutawayList.isVisible(); |
| 173 | + }); |
| 174 | + |
| 175 | + await test.step('Go to putaway list page and assert pending putaway not visible in other location', async () => { |
| 176 | + await putawayListPage.goToPage(); |
| 177 | + await expect(putawayListPage.destinationFilter).toContainText( |
| 178 | + depotLocation.name |
| 179 | + ); |
| 180 | + await putawayListPage.searchField.fill( |
| 181 | + `${putawayOrderIdentifier}`.toString().trim() |
| 182 | + ); |
| 183 | + await putawayListPage.searchButton.click(); |
| 184 | + await putawayListPage.emptyPutawayList.isVisible(); |
| 185 | + }); |
| 186 | + |
| 187 | + await test.step('Return to main location', async () => { |
| 188 | + await authService.changeLocation(AppConfig.instance.locations.main.id); |
| 189 | + }); |
| 190 | + }); |
| 191 | +}); |
0 commit comments