Skip to content

Commit 614f177

Browse files
committed
add test to assert split line in putaway
1 parent 76a7504 commit 614f177

1 file changed

Lines changed: 346 additions & 0 deletions

File tree

Lines changed: 346 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,346 @@
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('Split line in Putaway', () => {
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 transactionListPage.table.row(1).actionsButton.click();
70+
await transactionListPage.table.deleteButton.click();
71+
await expect(transactionListPage.successMessage).toBeVisible();
72+
73+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
74+
await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click();
75+
await oldViewShipmentPage.undoStatusChangeButton.click();
76+
await stockMovementShowPage.isLoaded();
77+
await stockMovementShowPage.rollbackButton.click();
78+
79+
await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id);
80+
}
81+
);
82+
83+
test('Assert split line in Putaway', async ({
84+
stockMovementShowPage,
85+
navbar,
86+
createPutawayPage,
87+
internalLocationService,
88+
internalLocation2Service,
89+
putawayDetailsPage,
90+
productShowPage,
91+
fifthProductService,
92+
}) => {
93+
const internalLocation = await internalLocationService.getLocation();
94+
const internalLocation2 = await internalLocation2Service.getLocation();
95+
const receivingBin =
96+
AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;
97+
await test.step('Go to create putaway page', async () => {
98+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
99+
await stockMovementShowPage.isLoaded();
100+
await navbar.profileButton.click();
101+
await navbar.refreshCachesButton.click();
102+
await navbar.inbound.click();
103+
await navbar.createPutaway.click();
104+
await createPutawayPage.isLoaded();
105+
});
106+
107+
await test.step('Start putaway', async () => {
108+
await createPutawayPage.table.row(0).checkbox.click();
109+
await createPutawayPage.startPutawayButton.click();
110+
await createPutawayPage.startStep.isLoaded();
111+
});
112+
113+
await test.step('Split line in putaway', async () => {
114+
await createPutawayPage.startStep.table.row(0).splitLineButton.click();
115+
await createPutawayPage.startStep.splitModal.isLoaded();
116+
await createPutawayPage.startStep.splitModal.addLineButton.click();
117+
await createPutawayPage.startStep.splitModal.table
118+
.row(1)
119+
.getPutawayBin(internalLocation.name);
120+
await createPutawayPage.startStep.splitModal.table
121+
.row(1)
122+
.quantityField.fill('5');
123+
await createPutawayPage.startStep.splitModal.table
124+
.row(2)
125+
.getPutawayBin(internalLocation2.name);
126+
await createPutawayPage.startStep.splitModal.table
127+
.row(2)
128+
.quantityField.fill('5');
129+
await createPutawayPage.startStep.splitModal.saveButton.click();
130+
});
131+
132+
await test.step('Assert split line on start step', async () => {
133+
await expect(
134+
createPutawayPage.startStep.table.row(0).splitLineinPutawayBin
135+
).toHaveText('Split line');
136+
});
137+
138+
await test.step('Go to next page and assert split line on complete step', async () => {
139+
await createPutawayPage.startStep.nextButton.click();
140+
await createPutawayPage.completeStep.isLoaded();
141+
await expect(
142+
createPutawayPage.completeStep.table.row(2).getputawayBin(0)
143+
).toContainText(internalLocation.name);
144+
await expect(
145+
createPutawayPage.completeStep.table.row(3).getputawayBin(1)
146+
).toContainText(internalLocation.name);
147+
});
148+
149+
await test.step('Complete and assert completing putaway', async () => {
150+
await createPutawayPage.completeStep.completePutawayButton.click();
151+
await putawayDetailsPage.isLoaded();
152+
await expect(putawayDetailsPage.statusTag).toHaveText('Completed');
153+
});
154+
155+
await test.step('Assert content of items status table', async () => {
156+
await putawayDetailsPage.itemStatusTab.click();
157+
await expect(
158+
putawayDetailsPage.itemStatusTable.row(1).itemStatus
159+
).toHaveText('COMPLETED');
160+
await expect(
161+
putawayDetailsPage.itemStatusTable.row(1).originBin
162+
).toHaveText(receivingBin);
163+
await expect(
164+
putawayDetailsPage.itemStatusTable.row(1).destinationBin
165+
).toContainText(internalLocation.name);
166+
await expect(
167+
putawayDetailsPage.itemStatusTable.row(2).itemStatus
168+
).toHaveText('COMPLETED');
169+
await expect(
170+
putawayDetailsPage.itemStatusTable.row(2).originBin
171+
).toHaveText(receivingBin);
172+
await expect(
173+
putawayDetailsPage.itemStatusTable.row(2).destinationBin
174+
).toContainText(internalLocation.name);
175+
});
176+
177+
await test.step('Assert putaway bin on stock card', async () => {
178+
await putawayDetailsPage.summaryTab.click();
179+
const product = await fifthProductService.getProduct();
180+
await productShowPage.goToPage(product.id);
181+
await productShowPage.inStockTab.click();
182+
await productShowPage.inStockTabSection.isLoaded();
183+
await expect(
184+
productShowPage.inStockTabSection.row(1).binLocation
185+
).toHaveText(internalLocation.name);
186+
await expect(
187+
productShowPage.inStockTabSection.row(2).binLocation
188+
).toHaveText(internalLocation2.name);
189+
});
190+
});
191+
192+
test('Assert behavior when split into more than 1 line', async ({
193+
stockMovementShowPage,
194+
navbar,
195+
createPutawayPage,
196+
internalLocationService,
197+
internalLocation2Service,
198+
putawayDetailsPage,
199+
}) => {
200+
const internalLocation = await internalLocationService.getLocation();
201+
const internalLocation2 = await internalLocation2Service.getLocation();
202+
await test.step('Go to create putaway page', async () => {
203+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
204+
await stockMovementShowPage.isLoaded();
205+
await navbar.profileButton.click();
206+
await navbar.refreshCachesButton.click();
207+
await navbar.inbound.click();
208+
await navbar.createPutaway.click();
209+
await createPutawayPage.isLoaded();
210+
});
211+
212+
await test.step('Start putaway', async () => {
213+
await createPutawayPage.table.row(0).checkbox.click();
214+
await createPutawayPage.startPutawayButton.click();
215+
await createPutawayPage.startStep.isLoaded();
216+
});
217+
218+
await test.step('Split line in putaway', async () => {
219+
await createPutawayPage.startStep.table.row(0).splitLineButton.click();
220+
await createPutawayPage.startStep.splitModal.isLoaded();
221+
await createPutawayPage.startStep.splitModal.addLineButton.click();
222+
await createPutawayPage.startStep.splitModal.table
223+
.row(1)
224+
.getPutawayBin(internalLocation.name);
225+
await createPutawayPage.startStep.splitModal.table
226+
.row(1)
227+
.quantityField.fill('5');
228+
await createPutawayPage.startStep.splitModal.table
229+
.row(2)
230+
.getPutawayBin(internalLocation2.name);
231+
await createPutawayPage.startStep.splitModal.table
232+
.row(2)
233+
.quantityField.fill('5');
234+
await createPutawayPage.startStep.splitModal.saveButton.click();
235+
});
236+
237+
await test.step('Open split modal again and assert validation on empty bin', async () => {
238+
await createPutawayPage.startStep.table.row(0).splitLineButton.click();
239+
await createPutawayPage.startStep.splitModal.isLoaded();
240+
await createPutawayPage.startStep.splitModal.table
241+
.row(1)
242+
.clearBinSelect.click();
243+
await createPutawayPage.startStep.splitModal.isLoaded();
244+
await createPutawayPage.startStep.splitModal.table
245+
.row(1)
246+
.putawayBinField.blur();
247+
await expect(
248+
createPutawayPage.startStep.splitModal.table
249+
.row(1)
250+
.putawayBinField.first()
251+
.locator('xpath=ancestor::td')
252+
).toHaveClass(/has-error/);
253+
await expect(
254+
createPutawayPage.startStep.splitModal.saveButton
255+
).toBeDisabled();
256+
});
257+
258+
await test.step('Edit putaway bin on split line modal', async () => {
259+
await createPutawayPage.startStep.splitModal.table
260+
.row(1)
261+
.getPutawayBin(internalLocation2.name);
262+
await expect(
263+
createPutawayPage.startStep.splitModal.saveButton
264+
).toBeEnabled();
265+
await createPutawayPage.startStep.splitModal.saveButton.click();
266+
});
267+
268+
await test.step('Assert split line on start step', async () => {
269+
await expect(
270+
createPutawayPage.startStep.table.row(0).splitLineinPutawayBin
271+
).toHaveText('Split line');
272+
});
273+
274+
await test.step('Delete splitted line and add new line', async () => {
275+
await createPutawayPage.startStep.table.row(0).splitLineButton.click();
276+
await createPutawayPage.startStep.splitModal.isLoaded();
277+
await createPutawayPage.startStep.splitModal.table
278+
.row(1)
279+
.deleteButton.click();
280+
await createPutawayPage.startStep.splitModal.addLineButton.click();
281+
await createPutawayPage.startStep.splitModal.table
282+
.row(1)
283+
.quantityField.fill('3');
284+
await createPutawayPage.startStep.splitModal.table
285+
.row(2)
286+
.getPutawayBin(internalLocation2.name);
287+
await createPutawayPage.startStep.splitModal.table
288+
.row(2)
289+
.quantityField.fill('5');
290+
await createPutawayPage.startStep.splitModal.addLineButton.click();
291+
await createPutawayPage.startStep.splitModal.table
292+
.row(3)
293+
.quantityField.fill('2');
294+
await createPutawayPage.startStep.splitModal.table
295+
.row(3)
296+
.getPutawayBin(internalLocation2.name);
297+
298+
await createPutawayPage.startStep.splitModal.saveButton.click();
299+
await expect(
300+
createPutawayPage.startStep.table.row(0).splitLineinPutawayBin
301+
).toHaveText('Split line');
302+
});
303+
304+
await test.step('Go to next page and assert split line on complete step', async () => {
305+
await createPutawayPage.startStep.nextButton.click();
306+
await createPutawayPage.completeStep.isLoaded();
307+
await expect(
308+
createPutawayPage.completeStep.table.row(2).getputawayBin(0)
309+
).toContainText(internalLocation.name);
310+
await expect(
311+
createPutawayPage.completeStep.table.row(3).getputawayBin(1)
312+
).toContainText(internalLocation.name);
313+
await expect(
314+
createPutawayPage.completeStep.table.row(4).getputawayBin(2)
315+
).toContainText(internalLocation.name);
316+
});
317+
318+
await test.step('Complete and assert completing putaway', async () => {
319+
await createPutawayPage.completeStep.completePutawayButton.click();
320+
await putawayDetailsPage.isLoaded();
321+
await expect(putawayDetailsPage.statusTag).toHaveText('Completed');
322+
});
323+
324+
await test.step('Assert content of items status table', async () => {
325+
await putawayDetailsPage.itemStatusTab.click();
326+
await expect(
327+
putawayDetailsPage.itemStatusTable.row(1).itemStatus
328+
).toHaveText('COMPLETED');
329+
await expect(
330+
putawayDetailsPage.itemStatusTable.row(1).destinationBin
331+
).toContainText(internalLocation2.name);
332+
await expect(
333+
putawayDetailsPage.itemStatusTable.row(2).itemStatus
334+
).toHaveText('COMPLETED');
335+
await expect(
336+
putawayDetailsPage.itemStatusTable.row(2).destinationBin
337+
).toContainText(internalLocation2.name);
338+
await expect(
339+
putawayDetailsPage.itemStatusTable.row(3).itemStatus
340+
).toHaveText('COMPLETED');
341+
await expect(
342+
putawayDetailsPage.itemStatusTable.row(3).destinationBin
343+
).toContainText(internalLocation2.name);
344+
});
345+
});
346+
});

0 commit comments

Comments
 (0)