|
| 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('Rollback last receipt behavior when putaway created', () => { |
| 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 | + navbar, |
| 58 | + transactionListPage, |
| 59 | + oldViewShipmentPage, |
| 60 | + }) => { |
| 61 | + await navbar.configurationButton.click(); |
| 62 | + await navbar.transactions.click(); |
| 63 | + await transactionListPage.table.row(1).actionsButton.click(); |
| 64 | + await transactionListPage.table.deleteButton.click(); |
| 65 | + await expect(transactionListPage.successMessage).toBeVisible(); |
| 66 | + await transactionListPage.table.row(1).actionsButton.click(); |
| 67 | + await transactionListPage.table.deleteButton.click(); |
| 68 | + await expect(transactionListPage.successMessage).toBeVisible(); |
| 69 | + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); |
| 70 | + await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click(); |
| 71 | + await oldViewShipmentPage.undoStatusChangeButton.click(); |
| 72 | + await stockMovementShowPage.isLoaded(); |
| 73 | + await stockMovementShowPage.rollbackButton.click(); |
| 74 | + await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id); |
| 75 | + } |
| 76 | + ); |
| 77 | + |
| 78 | + test('Rollback last receipt behavior when putaway created', async ({ |
| 79 | + stockMovementShowPage, |
| 80 | + navbar, |
| 81 | + createPutawayPage, |
| 82 | + internalLocationService, |
| 83 | + receivingPage, |
| 84 | + putawayListPage, |
| 85 | + putawayDetailsPage, |
| 86 | + }) => { |
| 87 | + await test.step('Go to stock movement show page and assert received status', async () => { |
| 88 | + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); |
| 89 | + await stockMovementShowPage.isLoaded(); |
| 90 | + await expect(stockMovementShowPage.statusTag).toHaveText('Received'); |
| 91 | + await navbar.profileButton.click(); |
| 92 | + await navbar.refreshCachesButton.click(); |
| 93 | + }); |
| 94 | + |
| 95 | + await test.step('Go to create putaway page', async () => { |
| 96 | + await navbar.inbound.click(); |
| 97 | + await navbar.createPutaway.click(); |
| 98 | + await createPutawayPage.isLoaded(); |
| 99 | + }); |
| 100 | + |
| 101 | + await test.step('Start putaway', async () => { |
| 102 | + await createPutawayPage.table.row(0).checkbox.click(); |
| 103 | + await createPutawayPage.startPutawayButton.click(); |
| 104 | + await createPutawayPage.startStep.isLoaded(); |
| 105 | + }); |
| 106 | + |
| 107 | + await test.step('Select bin to putaway', async () => { |
| 108 | + const internalLocation = await internalLocationService.getLocation(); |
| 109 | + await createPutawayPage.startStep.table.row(0).putawayBinSelect.click(); |
| 110 | + await createPutawayPage.startStep.table |
| 111 | + .row(0) |
| 112 | + .getPutawayBin(internalLocation.name) |
| 113 | + .click(); |
| 114 | + }); |
| 115 | + |
| 116 | + await test.step('Save progress on pending putaway', async () => { |
| 117 | + await createPutawayPage.startStep.saveButton.click(); |
| 118 | + }); |
| 119 | + |
| 120 | + await test.step('Go to stock movement show page and rollback last receipt when pending putaway created', async () => { |
| 121 | + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); |
| 122 | + await stockMovementShowPage.isLoaded(); |
| 123 | + await expect(stockMovementShowPage.statusTag).toHaveText('Received'); |
| 124 | + await stockMovementShowPage.rollbackLastReceiptButton.click(); |
| 125 | + await expect( |
| 126 | + stockMovementShowPage.rollbackReceiptInformationMessage |
| 127 | + ).toBeVisible(); |
| 128 | + await expect( |
| 129 | + stockMovementShowPage.rollbackReceiptInformationMessage |
| 130 | + ).toContainText( |
| 131 | + 'Successfully rolled back last receipt in stock movement ' |
| 132 | + ); |
| 133 | + await expect(stockMovementShowPage.statusTag).toHaveText('Shipped'); |
| 134 | + }); |
| 135 | + |
| 136 | + await test.step('Receive sm', async () => { |
| 137 | + await stockMovementShowPage.receiveButton.click(); |
| 138 | + await receivingPage.receivingStep.isLoaded(); |
| 139 | + await receivingPage.receivingStep.autofillQuantitiesButton.click(); |
| 140 | + await receivingPage.nextButton.click(); |
| 141 | + await receivingPage.checkStep.isLoaded(); |
| 142 | + await receivingPage.checkStep.receiveShipmentButton.click(); |
| 143 | + await stockMovementShowPage.isLoaded(); |
| 144 | + await expect(stockMovementShowPage.statusTag).toHaveText('Received'); |
| 145 | + }); |
| 146 | + |
| 147 | + await test.step('Go to putaway list page', async () => { |
| 148 | + await navbar.inbound.click(); |
| 149 | + await navbar.listPutaways.click(); |
| 150 | + await putawayListPage.isLoaded(); |
| 151 | + }); |
| 152 | + |
| 153 | + await test.step('Open putaway detials page', async () => { |
| 154 | + await putawayListPage.table.row(1).actionsButton.click(); |
| 155 | + await putawayListPage.table.viewOrderDetailsButton.click(); |
| 156 | + await putawayDetailsPage.isLoaded(); |
| 157 | + }); |
| 158 | + |
| 159 | + await test.step('Edit pending putaway', async () => { |
| 160 | + await putawayDetailsPage.editButton.click(); |
| 161 | + await createPutawayPage.startStep.isLoaded(); |
| 162 | + await createPutawayPage.startStep.nextButton.click(); |
| 163 | + }); |
| 164 | + |
| 165 | + await test.step('Go to next page and complete putaway', async () => { |
| 166 | + await createPutawayPage.completeStep.isLoaded(); |
| 167 | + await createPutawayPage.completeStep.completePutawayButton.click(); |
| 168 | + }); |
| 169 | + |
| 170 | + await test.step('Assert completing putaway', async () => { |
| 171 | + await putawayDetailsPage.isLoaded(); |
| 172 | + await expect(putawayDetailsPage.statusTag).toHaveText('Completed'); |
| 173 | + }); |
| 174 | + |
| 175 | + await test.step('Go to stock movement show page and rollback last receipt when completed putaway created', async () => { |
| 176 | + await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id); |
| 177 | + await stockMovementShowPage.isLoaded(); |
| 178 | + await expect(stockMovementShowPage.statusTag).toHaveText('Received'); |
| 179 | + await stockMovementShowPage.rollbackLastReceiptButton.click(); |
| 180 | + await expect( |
| 181 | + stockMovementShowPage.rollbackReceiptInformationMessage |
| 182 | + ).toBeVisible(); |
| 183 | + await expect( |
| 184 | + stockMovementShowPage.rollbackReceiptInformationMessage |
| 185 | + ).toContainText('Unable to rollback last receipt in stock movement'); |
| 186 | + await expect(stockMovementShowPage.statusTag).toHaveText('Received'); |
| 187 | + }); |
| 188 | + }); |
| 189 | +}); |
0 commit comments