Skip to content

Commit eeca984

Browse files
committed
add test for rollback last receipt behavior
1 parent e095de4 commit eeca984

1 file changed

Lines changed: 179 additions & 0 deletions

File tree

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
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(stockMovementShowPage.statusTag).toHaveText('Shipped');
126+
});
127+
128+
await test.step('Receive sm', async () => {
129+
await stockMovementShowPage.receiveButton.click();
130+
await receivingPage.receivingStep.isLoaded();
131+
await receivingPage.receivingStep.autofillQuantitiesButton.click();
132+
await receivingPage.nextButton.click();
133+
await receivingPage.checkStep.isLoaded();
134+
await receivingPage.checkStep.receiveShipmentButton.click();
135+
await stockMovementShowPage.isLoaded();
136+
await expect(stockMovementShowPage.statusTag).toHaveText('Received');
137+
});
138+
139+
await test.step('Go to putaway list page', async () => {
140+
await navbar.inbound.click();
141+
await navbar.listPutaways.click();
142+
await putawayListPage.isLoaded();
143+
});
144+
145+
await test.step('Open putaway detials page', async () => {
146+
await putawayListPage.table.row(1).actionsButton.click();
147+
await putawayListPage.table.viewOrderDetailsButton.click();
148+
await putawayDetailsPage.isLoaded();
149+
});
150+
151+
await test.step('Edit pending putaway', async () => {
152+
await putawayDetailsPage.editButton.click();
153+
await createPutawayPage.startStep.isLoaded();
154+
await createPutawayPage.startStep.nextButton.click();
155+
});
156+
157+
await test.step('Go to next page and complete putaway', async () => {
158+
await createPutawayPage.completeStep.isLoaded();
159+
await createPutawayPage.completeStep.completePutawayButton.click();
160+
});
161+
162+
await test.step('Assert completing putaway', async () => {
163+
await putawayDetailsPage.isLoaded();
164+
await expect(putawayDetailsPage.statusTag).toHaveText('Completed');
165+
});
166+
167+
await test.step('Go to stock movement show page and rollback last receipt when completed putaway created', async () => {
168+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
169+
await stockMovementShowPage.isLoaded();
170+
await expect(stockMovementShowPage.statusTag).toHaveText('Received');
171+
await stockMovementShowPage.rollbackLastReceiptButton.click();
172+
await expect(stockMovementShowPage.informationMessage).toBeVisible();
173+
await expect(stockMovementShowPage.informationMessage).toContainText(
174+
'Unable to rollback last receipt in stock movement'
175+
);
176+
await expect(stockMovementShowPage.statusTag).toHaveText('Received');
177+
});
178+
});
179+
});

0 commit comments

Comments
 (0)