Skip to content

Commit 57144be

Browse files
committed
add tests for putaway to preferred and default bins
1 parent ac52c7b commit 57144be

1 file changed

Lines changed: 304 additions & 0 deletions

File tree

Lines changed: 304 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,304 @@
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('Putaway to preferred bin and default bin', () => {
8+
let STOCK_MOVEMENT: StockMovementResponse;
9+
10+
test.beforeEach(
11+
async ({
12+
supplierLocationService,
13+
stockMovementService,
14+
productService,
15+
receivingService,
16+
productShowPage,
17+
productEditPage,
18+
internalLocationService,
19+
}) => {
20+
const supplierLocation = await supplierLocationService.getLocation();
21+
STOCK_MOVEMENT = await stockMovementService.createInbound({
22+
originId: supplierLocation.id,
23+
});
24+
25+
productService.setProduct('5');
26+
const product = await productService.getProduct();
27+
productService.setProduct('4');
28+
const product2 = await productService.getProduct();
29+
30+
await stockMovementService.addItemsToInboundStockMovement(
31+
STOCK_MOVEMENT.id,
32+
[
33+
{ productId: product.id, quantity: 10 },
34+
{ productId: product2.id, quantity: 10 },
35+
]
36+
);
37+
38+
await stockMovementService.sendInboundStockMovement(STOCK_MOVEMENT.id, {
39+
shipmentType: ShipmentType.AIR,
40+
});
41+
42+
const { data: stockMovement } =
43+
await stockMovementService.getStockMovement(STOCK_MOVEMENT.id);
44+
const shipmentId = getShipmentId(stockMovement);
45+
const { data: receipt } = await receivingService.getReceipt(shipmentId);
46+
const receivingBin =
47+
AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;
48+
49+
await receivingService.createReceivingBin(shipmentId, receipt);
50+
51+
await receivingService.updateReceivingItems(shipmentId, [
52+
{
53+
shipmentItemId: getShipmentItemId(receipt, 0, 0),
54+
quantityReceiving: 10,
55+
binLocationName: receivingBin,
56+
},
57+
{
58+
shipmentItemId: getShipmentItemId(receipt, 0, 1),
59+
quantityReceiving: 10,
60+
binLocationName: receivingBin,
61+
},
62+
]);
63+
await receivingService.completeReceipt(shipmentId);
64+
65+
await productShowPage.goToPage(product2.id);
66+
await productShowPage.editProductkButton.click();
67+
await productEditPage.inventoryLevelsTab.click();
68+
await productEditPage.inventoryLevelsTabSection.createStockLevelButton.click();
69+
await productEditPage.inventoryLevelsTabSection.createStockLevelModal.receivingTab.click();
70+
const internalLocation = await internalLocationService.getLocation();
71+
await productEditPage.inventoryLevelsTabSection.createStockLevelModal.defaultPutawayLocation.click();
72+
await productEditPage.inventoryLevelsTabSection.createStockLevelModal
73+
.getDefaultPutawayLocation(internalLocation.name)
74+
.click();
75+
await productEditPage.inventoryLevelsTabSection.createStockLevelModal.createButton.click();
76+
}
77+
);
78+
79+
test.afterEach(
80+
async ({
81+
stockMovementShowPage,
82+
stockMovementService,
83+
navbar,
84+
transactionListPage,
85+
oldViewShipmentPage,
86+
productService,
87+
productShowPage,
88+
productEditPage,
89+
}) => {
90+
await navbar.configurationButton.click();
91+
await navbar.transactions.click();
92+
await transactionListPage.deleteTransaction(1);
93+
await transactionListPage.deleteTransaction(1);
94+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
95+
await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click();
96+
await oldViewShipmentPage.undoStatusChangeButton.click();
97+
await stockMovementShowPage.isLoaded();
98+
await stockMovementShowPage.rollbackButton.click();
99+
100+
await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id);
101+
productService.setProduct('4');
102+
const product2 = await productService.getProduct();
103+
await productShowPage.goToPage(product2.id);
104+
await productShowPage.editProductkButton.click();
105+
await productEditPage.inventoryLevelsTab.click();
106+
await productEditPage.inventoryLevelsTabSection
107+
.row(1)
108+
.editInventoryLevelButton.click();
109+
await expect(
110+
productEditPage.inventoryLevelsTabSection.table
111+
).toBeVisible();
112+
await productEditPage.inventoryLevelsTabSection.createStockLevelModal.clickDeleteInventoryLevel();
113+
}
114+
);
115+
116+
test('Create putaway for product with preferred bin assigned and without it', async ({
117+
stockMovementShowPage,
118+
navbar,
119+
createPutawayPage,
120+
internalLocationService,
121+
productShowPage,
122+
putawayDetailsPage,
123+
productService,
124+
}) => {
125+
const receivingBin =
126+
AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;
127+
productService.setProduct('5');
128+
const product = await productService.getProduct();
129+
productService.setProduct('4');
130+
const product2 = await productService.getProduct();
131+
const internalLocation = await internalLocationService.getLocation();
132+
133+
await test.step('Go to create putaway page', async () => {
134+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
135+
await stockMovementShowPage.isLoaded();
136+
await navbar.profileButton.click();
137+
await navbar.refreshCachesButton.click();
138+
await navbar.inbound.click();
139+
await navbar.createPutaway.click();
140+
await createPutawayPage.isLoaded();
141+
});
142+
143+
await test.step('Start putaway', async () => {
144+
await createPutawayPage.table
145+
.row(0)
146+
.getExpandBinLocation(receivingBin)
147+
.click();
148+
await createPutawayPage.table.row(1).checkbox.click();
149+
await createPutawayPage.table.row(2).checkbox.click();
150+
await createPutawayPage.startPutawayButton.click();
151+
await createPutawayPage.startStep.isLoaded();
152+
});
153+
154+
await test.step('Assert assignment of preferred and putaway bins', async () => {
155+
await expect(
156+
createPutawayPage.startStep.table.row(1).getPreferredBin(0)
157+
).toHaveText('');
158+
await expect(
159+
createPutawayPage.startStep.table.row(2).getPreferredBin(1)
160+
).toContainText(internalLocation.name);
161+
await expect(
162+
createPutawayPage.startStep.table.row(1).putawayBinSelect
163+
).toBeEmpty();
164+
await expect(
165+
createPutawayPage.startStep.table.row(2).putawayBinSelect
166+
).toContainText(internalLocation.name);
167+
});
168+
169+
await test.step('Assert confirm complete putaway dialog when empty putaway bin', async () => {
170+
await createPutawayPage.startStep.nextButton.click();
171+
await createPutawayPage.completeStep.isLoaded();
172+
await createPutawayPage.completeStep.completePutawayButton.click();
173+
await expect(
174+
createPutawayPage.completeStep.confirmPutawayDialog
175+
).toBeVisible();
176+
await expect(
177+
createPutawayPage.completeStep.confirmPutawayDialog
178+
).toContainText(
179+
'Are you sure you want to putaway? There are some lines with empty bin locations.'
180+
);
181+
await createPutawayPage.completeStep.noButtonOnConfirmPutawayDialog.click();
182+
await createPutawayPage.completeStep.isLoaded();
183+
});
184+
185+
await test.step('Complete putaway', async () => {
186+
await createPutawayPage.completeStep.completePutawayButton.click();
187+
await expect(
188+
createPutawayPage.completeStep.confirmPutawayDialog
189+
).toBeVisible();
190+
await createPutawayPage.completeStep.yesButtonOnConfirmPutawayDialog.click();
191+
});
192+
193+
await test.step('Assert completing putaway', async () => {
194+
await putawayDetailsPage.isLoaded();
195+
await expect(putawayDetailsPage.statusTag).toHaveText('Completed');
196+
});
197+
198+
await test.step('Assert putaway bin on stock card', async () => {
199+
await productShowPage.goToPage(product2.id);
200+
await productShowPage.inStockTab.click();
201+
await productShowPage.inStockTabSection.isLoaded();
202+
await expect(
203+
productShowPage.inStockTabSection.row(2).binLocation
204+
).toHaveText(internalLocation.name);
205+
await productShowPage.goToPage(product.id);
206+
await productShowPage.inStockTab.click();
207+
await productShowPage.inStockTabSection.isLoaded();
208+
await expect(
209+
productShowPage.inStockTabSection.row(1).defaultBinLocation
210+
).toBeVisible();
211+
});
212+
});
213+
214+
test('Edit putaway bin when preferred bin assigned automatically', async ({
215+
stockMovementShowPage,
216+
navbar,
217+
createPutawayPage,
218+
internalLocationService,
219+
internalLocation2Service,
220+
productShowPage,
221+
putawayDetailsPage,
222+
productService,
223+
}) => {
224+
const receivingBin =
225+
AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;
226+
productService.setProduct('4');
227+
const product2 = await productService.getProduct();
228+
const internalLocation = await internalLocationService.getLocation();
229+
const internalLocation2 = await internalLocation2Service.getLocation();
230+
231+
await test.step('Go to create putaway page', async () => {
232+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
233+
await stockMovementShowPage.isLoaded();
234+
await navbar.profileButton.click();
235+
await navbar.refreshCachesButton.click();
236+
await navbar.inbound.click();
237+
await navbar.createPutaway.click();
238+
await createPutawayPage.isLoaded();
239+
});
240+
241+
await test.step('Start putaway', async () => {
242+
await createPutawayPage.table
243+
.row(0)
244+
.getExpandBinLocation(receivingBin)
245+
.click();
246+
await createPutawayPage.table.row(2).checkbox.click();
247+
await createPutawayPage.startPutawayButton.click();
248+
await createPutawayPage.startStep.isLoaded();
249+
});
250+
251+
await test.step('Assert assignment of preferred and putaway bins', async () => {
252+
await expect(
253+
createPutawayPage.startStep.table.row(1).getPreferredBin(0)
254+
).toContainText(internalLocation.name);
255+
await expect(
256+
createPutawayPage.startStep.table.row(1).putawayBinSelect
257+
).toContainText(internalLocation.name);
258+
});
259+
260+
await test.step('Edit putaway bin', async () => {
261+
await createPutawayPage.startStep.table.row(1).putawayBinSelect.click();
262+
await createPutawayPage.startStep.table
263+
.row(1)
264+
.getPutawayBin(internalLocation2.name)
265+
.click();
266+
});
267+
268+
await test.step('Go to next page and assert edited putaway bin', async () => {
269+
await createPutawayPage.startStep.nextButton.click();
270+
await createPutawayPage.completeStep.isLoaded();
271+
await expect(
272+
createPutawayPage.completeStep.table.row(2).getputawayBin(0)
273+
).toContainText(internalLocation2.name);
274+
});
275+
276+
await test.step('Complete putaway', async () => {
277+
await createPutawayPage.completeStep.completePutawayButton.click();
278+
await putawayDetailsPage.isLoaded();
279+
await expect(putawayDetailsPage.statusTag).toHaveText('Completed');
280+
});
281+
282+
await test.step('Assert content of items status table', async () => {
283+
await putawayDetailsPage.itemStatusTab.click();
284+
await expect(
285+
putawayDetailsPage.itemStatusTable.row(1).itemStatus
286+
).toHaveText('COMPLETED');
287+
await expect(
288+
putawayDetailsPage.itemStatusTable.row(1).originBin
289+
).toHaveText(receivingBin);
290+
await expect(
291+
putawayDetailsPage.itemStatusTable.row(1).destinationBin
292+
).toHaveText(internalLocation2.name);
293+
});
294+
295+
await test.step('Assert putaway bin on stock card', async () => {
296+
await productShowPage.goToPage(product2.id);
297+
await productShowPage.inStockTab.click();
298+
await productShowPage.inStockTabSection.isLoaded();
299+
await expect(
300+
productShowPage.inStockTabSection.row(2).binLocation
301+
).toHaveText(internalLocation2.name);
302+
});
303+
});
304+
});

0 commit comments

Comments
 (0)