Skip to content

Commit 845d525

Browse files
committed
add test for validate qty removed from receiving bin
1 parent e2b4f3a commit 845d525

1 file changed

Lines changed: 277 additions & 0 deletions

File tree

Lines changed: 277 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,277 @@
1+
import Navbar from '@/components/Navbar';
2+
import AppConfig from '@/config/AppConfig';
3+
import { ShipmentType } from '@/constants/ShipmentType';
4+
import { expect, test } from '@/fixtures/fixtures';
5+
import ProductShowPage from '@/pages/product/productShow/ProductShowPage';
6+
import { StockMovementResponse } from '@/types';
7+
import RefreshCachesUtils from '@/utils/RefreshCaches';
8+
import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils';
9+
10+
test.describe('Assert validation on qty removed from receiving bin', () => {
11+
let STOCK_MOVEMENT: StockMovementResponse;
12+
13+
test.beforeEach(
14+
async ({
15+
supplierLocationService,
16+
stockMovementService,
17+
productService,
18+
receivingService,
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+
);
66+
67+
test.afterEach(
68+
async ({
69+
stockMovementShowPage,
70+
stockMovementService,
71+
navbar,
72+
transactionListPage,
73+
oldViewShipmentPage,
74+
}) => {
75+
await navbar.configurationButton.click();
76+
await navbar.transactions.click();
77+
for (let n = 1; n < 4; n++) {
78+
await transactionListPage.deleteTransaction(1);
79+
}
80+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
81+
await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click();
82+
await oldViewShipmentPage.undoStatusChangeButton.click();
83+
await stockMovementShowPage.isLoaded();
84+
await stockMovementShowPage.rollbackButton.click();
85+
86+
await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id);
87+
}
88+
);
89+
90+
test('Assert validation on qty removed from receiving bin', async ({
91+
page,
92+
transactionListPage,
93+
editTransactionPage,
94+
stockMovementShowPage,
95+
createPutawayPage,
96+
internalLocationService,
97+
productShowPage,
98+
putawayDetailsPage,
99+
productService,
100+
putawayListPage,
101+
browser,
102+
navbar,
103+
}) => {
104+
const receivingBin =
105+
AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;
106+
productService.setProduct('5');
107+
const product = await productService.getProduct();
108+
productService.setProduct('4');
109+
const product2 = await productService.getProduct();
110+
const internalLocation = await internalLocationService.getLocation();
111+
112+
await test.step('Edit transaction date of transfer in', async () => {
113+
await page.goto('./dashboard');
114+
await navbar.configurationButton.click();
115+
await navbar.transactions.click();
116+
// eslint-disable-next-line playwright/no-networkidle
117+
await page.waitForLoadState('networkidle');
118+
await transactionListPage.table.row(1).actionsButton.click();
119+
await transactionListPage.table.editButton.click();
120+
await editTransactionPage.transactionDetailsHeaderTab
121+
.row(2)
122+
.transactionDateMinuteSelect.click();
123+
await editTransactionPage.transactionDetailsHeaderTab
124+
.row(2)
125+
.decreaseMinute();
126+
await editTransactionPage.saveButton.click();
127+
});
128+
129+
await test.step('Go to create putaway page', async () => {
130+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
131+
await stockMovementShowPage.isLoaded();
132+
await RefreshCachesUtils.refreshCaches({
133+
navbar,
134+
});
135+
await navbar.inbound.click();
136+
await navbar.createPutaway.click();
137+
await createPutawayPage.isLoaded();
138+
});
139+
140+
await test.step('Start putaway', async () => {
141+
await createPutawayPage.table
142+
.row(0)
143+
.getExpandBinLocation(receivingBin)
144+
.click();
145+
await expect(
146+
createPutawayPage.table.row(1).getProductName(product.name)
147+
).toBeVisible();
148+
await expect(
149+
createPutawayPage.table.row(2).getProductName(product2.name)
150+
).toBeVisible();
151+
await createPutawayPage.table.row(1).checkbox.click();
152+
await createPutawayPage.table.row(2).checkbox.click();
153+
await createPutawayPage.startPutawayButton.click();
154+
await createPutawayPage.startStep.isLoaded();
155+
});
156+
157+
await test.step('Select bin to putaway and go to next page', async () => {
158+
await createPutawayPage.startStep.table.row(1).putawayBinSelect.click();
159+
await createPutawayPage.startStep.table
160+
.row(1)
161+
.getPutawayBin(internalLocation.name)
162+
.click();
163+
await createPutawayPage.startStep.table.row(2).putawayBinSelect.click();
164+
await createPutawayPage.startStep.table
165+
.row(2)
166+
.getPutawayBin(internalLocation.name)
167+
.click();
168+
await createPutawayPage.startStep.nextButton.click();
169+
await createPutawayPage.completeStep.isLoaded();
170+
});
171+
172+
await test.step('Open new tab and edit qty to 0 in receiving bin on stock card', async () => {
173+
const newPage = await browser.newPage();
174+
const newProductShowPage = new ProductShowPage(newPage);
175+
const newNavbar = new Navbar(newPage);
176+
await newProductShowPage.goToPage(product.id);
177+
await newProductShowPage.recordStockButton.click();
178+
await newProductShowPage.recordStock.lineItemsTable
179+
.row(1)
180+
.newQuantity.getByRole('textbox')
181+
.fill('0');
182+
await newProductShowPage.recordStock.lineItemsTable.saveButton.click();
183+
await newNavbar.profileButton.click();
184+
await newNavbar.refreshCachesButton.click();
185+
await newPage.close();
186+
});
187+
188+
await test.step('Try to complete putaway and assert error message', async () => {
189+
await createPutawayPage.completeStep.isLoaded();
190+
await createPutawayPage.completeStep.completePutawayButton.click();
191+
await expect(
192+
createPutawayPage.completeStep.validationOnQtyInReceivingBin
193+
).toBeVisible();
194+
});
195+
196+
await test.step('Go backward and assert validatiion', async () => {
197+
await createPutawayPage.completeStep.editButton.click();
198+
await createPutawayPage.startStep.isLoaded();
199+
await expect(createPutawayPage.startStep.saveButton).toBeDisabled();
200+
await expect(createPutawayPage.startStep.nextButton).toBeDisabled();
201+
await createPutawayPage.startStep.table.row(1).editButton.click();
202+
await createPutawayPage.startStep.table.row(1).quantityInput.hover();
203+
await createPutawayPage.startStep.table.assertValidationOnQtyField(
204+
'Quantity cannot be greater than original putaway item quantity'
205+
);
206+
});
207+
208+
await test.step('Delete invalid line', async () => {
209+
await expect(createPutawayPage.startStep.table.rows).toHaveCount(3);
210+
await createPutawayPage.startStep.table.row(1).deleteButton.click();
211+
await expect(createPutawayPage.startStep.table.rows).toHaveCount(2);
212+
await expect(createPutawayPage.startStep.saveButton).toBeEnabled();
213+
await expect(createPutawayPage.startStep.nextButton).toBeEnabled();
214+
await createPutawayPage.startStep.saveButton.click();
215+
});
216+
217+
await test.step('Edit qty to lower in receiving bin when putaway started', async () => {
218+
await productShowPage.goToPage(product2.id);
219+
await productShowPage.recordStockButton.click();
220+
await productShowPage.recordStock.lineItemsTable
221+
.row(2)
222+
.newQuantity.getByRole('textbox')
223+
.fill('5');
224+
await productShowPage.recordStock.lineItemsTable.saveButton.click();
225+
await RefreshCachesUtils.refreshCaches({
226+
navbar,
227+
});
228+
});
229+
230+
await test.step('Go to putaway list page and edit created pending putaway', async () => {
231+
await putawayListPage.goToPage();
232+
await putawayListPage.isLoaded();
233+
const row = putawayListPage.table.row(1);
234+
await row.actionsButton.click();
235+
await row.viewOrderDetails.click();
236+
await putawayDetailsPage.isLoaded();
237+
});
238+
239+
await test.step('Edit pending putaway and assert validation on qty', async () => {
240+
await putawayDetailsPage.editButton.click();
241+
await createPutawayPage.startStep.isLoaded();
242+
await expect(createPutawayPage.startStep.saveButton).toBeDisabled();
243+
await expect(createPutawayPage.startStep.nextButton).toBeDisabled();
244+
await createPutawayPage.startStep.table.row(1).editButton.click();
245+
await createPutawayPage.startStep.table.row(1).quantityInput.hover();
246+
await createPutawayPage.startStep.table.assertValidationOnQtyField(
247+
'Quantity cannot be greater than original putaway item quantity'
248+
);
249+
});
250+
251+
await test.step('Edit qty in pending putaway', async () => {
252+
await createPutawayPage.startStep.table.row(1).quantityInput.fill('5');
253+
await expect(createPutawayPage.startStep.saveButton).toBeEnabled();
254+
await expect(createPutawayPage.startStep.nextButton).toBeEnabled();
255+
});
256+
257+
await test.step('Complete putaway', async () => {
258+
await createPutawayPage.startStep.nextButton.click();
259+
await createPutawayPage.completeStep.isLoaded();
260+
await createPutawayPage.completeStep.completePutawayButton.click();
261+
await putawayDetailsPage.isLoaded();
262+
await expect(putawayDetailsPage.statusTag).toHaveText('Completed');
263+
});
264+
265+
await test.step('Assert putaway bin and qty on stock card', async () => {
266+
await productShowPage.goToPage(product2.id);
267+
await productShowPage.inStockTab.click();
268+
await productShowPage.inStockTabSection.isLoaded();
269+
await expect(
270+
productShowPage.inStockTabSection.row(2).binLocation
271+
).toHaveText(internalLocation.name);
272+
await expect(
273+
productShowPage.inStockTabSection.row(2).quantityOnHand
274+
).toHaveText('5');
275+
});
276+
});
277+
});

0 commit comments

Comments
 (0)