Skip to content

Commit 13484d4

Browse files
committed
add test for perform putaway as manager user
1 parent b506235 commit 13484d4

1 file changed

Lines changed: 236 additions & 0 deletions

File tree

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
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 CreatePutawayPage from '@/pages/putaway/CreatePutawayPage';
7+
import PutawayDetailsPage from '@/pages/putaway/putawayDetails/PutawayDetailsPage';
8+
import StockMovementShowPage from '@/pages/stockMovementShow/StockMovementShowPage';
9+
import { StockMovementResponse } from '@/types';
10+
import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils';
11+
12+
test.describe('Perform putaway as manager user', () => {
13+
let STOCK_MOVEMENT: StockMovementResponse;
14+
15+
test.beforeEach(
16+
async ({
17+
supplierLocationService,
18+
stockMovementService,
19+
productService,
20+
receivingService,
21+
}) => {
22+
const supplierLocation = await supplierLocationService.getLocation();
23+
STOCK_MOVEMENT = await stockMovementService.createInbound({
24+
originId: supplierLocation.id,
25+
});
26+
27+
productService.setProduct('3');
28+
const product = await productService.getProduct();
29+
productService.setProduct('4');
30+
const product2 = await productService.getProduct();
31+
32+
await stockMovementService.addItemsToInboundStockMovement(
33+
STOCK_MOVEMENT.id,
34+
[
35+
{ productId: product.id, quantity: 10 },
36+
{ productId: product2.id, quantity: 10 },
37+
]
38+
);
39+
40+
await stockMovementService.sendInboundStockMovement(STOCK_MOVEMENT.id, {
41+
shipmentType: ShipmentType.AIR,
42+
});
43+
44+
const { data: stockMovement } =
45+
await stockMovementService.getStockMovement(STOCK_MOVEMENT.id);
46+
const shipmentId = getShipmentId(stockMovement);
47+
const { data: receipt } = await receivingService.getReceipt(shipmentId);
48+
const receivingBin =
49+
AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;
50+
51+
await receivingService.createReceivingBin(shipmentId, receipt);
52+
53+
await receivingService.updateReceivingItems(shipmentId, [
54+
{
55+
shipmentItemId: getShipmentItemId(receipt, 0, 0),
56+
quantityReceiving: 10,
57+
binLocationName: receivingBin,
58+
},
59+
{
60+
shipmentItemId: getShipmentItemId(receipt, 0, 1),
61+
quantityReceiving: 10,
62+
binLocationName: receivingBin,
63+
},
64+
]);
65+
await receivingService.completeReceipt(shipmentId);
66+
}
67+
);
68+
69+
test.afterEach(
70+
async ({
71+
stockMovementShowPage,
72+
stockMovementService,
73+
navbar,
74+
transactionListPage,
75+
oldViewShipmentPage,
76+
}) => {
77+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
78+
await navbar.configurationButton.click();
79+
await navbar.transactions.click();
80+
await transactionListPage.deleteTransaction(1);
81+
await transactionListPage.deleteTransaction(1);
82+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
83+
await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click();
84+
await oldViewShipmentPage.undoStatusChangeButton.click();
85+
await stockMovementShowPage.isLoaded();
86+
await stockMovementShowPage.rollbackButton.click();
87+
88+
await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id);
89+
}
90+
);
91+
92+
test('Perform putaway as manager user', async ({
93+
managerUserContext,
94+
internalLocationService,
95+
productService,
96+
}) => {
97+
const receivingBin =
98+
AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;
99+
productService.setProduct('3');
100+
const product = await productService.getProduct();
101+
productService.setProduct('4');
102+
const product2 = await productService.getProduct();
103+
const internalLocation = await internalLocationService.getLocation();
104+
105+
const managerUserPage = await managerUserContext.newPage();
106+
const stockMovementShowPage = new StockMovementShowPage(managerUserPage);
107+
const navbar = new Navbar(managerUserPage);
108+
const createPutawayPage = new CreatePutawayPage(managerUserPage);
109+
const putawayDetailsPage = new PutawayDetailsPage(managerUserPage);
110+
const productShowPage = new ProductShowPage(managerUserPage);
111+
112+
await test.step('Go to create putaway page', async () => {
113+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
114+
await stockMovementShowPage.isLoaded();
115+
await navbar.profileButton.click();
116+
await navbar.refreshCachesButton.click();
117+
await navbar.inbound.click();
118+
await navbar.createPutaway.click();
119+
await createPutawayPage.isLoaded();
120+
});
121+
122+
await test.step('Start putaway', async () => {
123+
await createPutawayPage.table
124+
.row(0)
125+
.getExpandBinLocation(receivingBin)
126+
.click();
127+
await expect(
128+
createPutawayPage.table.row(1).getProductName(product2.name)
129+
).toBeVisible();
130+
await expect(
131+
createPutawayPage.table.row(2).getProductName(product.name)
132+
).toBeVisible();
133+
await createPutawayPage.table.row(1).checkbox.click();
134+
await createPutawayPage.table.row(2).checkbox.click();
135+
await createPutawayPage.startPutawayButton.click();
136+
await createPutawayPage.startStep.isLoaded();
137+
});
138+
139+
await test.step('Select bins to putaway', async () => {
140+
await createPutawayPage.startStep.table.row(1).putawayBinSelect.click();
141+
await createPutawayPage.startStep.table
142+
.row(1)
143+
.getPutawayBin(internalLocation.name)
144+
.click();
145+
await createPutawayPage.startStep.table.row(2).putawayBinSelect.click();
146+
await createPutawayPage.startStep.table
147+
.row(2)
148+
.getPutawayBin(internalLocation.name)
149+
.click();
150+
});
151+
152+
await test.step('Use edit button as manager user on both lines', async () => {
153+
await createPutawayPage.startStep.table.row(1).editButton.click();
154+
await createPutawayPage.startStep.table.row(1).quantityInput.fill('5');
155+
await createPutawayPage.startStep.table.row(2).editButton.click();
156+
await createPutawayPage.startStep.table.row(2).quantityInput.fill('5');
157+
});
158+
159+
await test.step('Go to complete step and assert qty after edit', async () => {
160+
await createPutawayPage.startStep.nextButton.click();
161+
await createPutawayPage.completeStep.isLoaded();
162+
await expect(
163+
createPutawayPage.completeStep.table.row(2).qtyField
164+
).toContainText('5');
165+
await expect(
166+
createPutawayPage.completeStep.table.row(3).qtyField
167+
).toContainText('5');
168+
});
169+
170+
await test.step('Go backward and use delete button as manager user', async () => {
171+
await createPutawayPage.completeStep.editButton.click();
172+
await createPutawayPage.startStep.isLoaded();
173+
await createPutawayPage.startStep.table.row(2).deleteButton.click();
174+
await createPutawayPage.startStep.table.row(2).row.isHidden();
175+
});
176+
177+
await test.step('Go to next page and assert displayed rows', async () => {
178+
await createPutawayPage.startStep.nextButton.click();
179+
await createPutawayPage.completeStep.isLoaded();
180+
await createPutawayPage.completeStep.table.row(2).row.isVisible();
181+
await createPutawayPage.completeStep.table.row(2).row.isHidden();
182+
});
183+
184+
await test.step('Complete putaway', async () => {
185+
await createPutawayPage.completeStep.completePutawayButton.click();
186+
await expect(
187+
createPutawayPage.completeStep.confirmPutawayDialog
188+
).toBeVisible();
189+
await expect(
190+
createPutawayPage.completeStep.confirmPutawayDialog
191+
).toContainText(
192+
`Qty5 of item ${product.name} is still in the receiving bin. Do you want to continue?`
193+
);
194+
await expect(
195+
createPutawayPage.completeStep.confirmPutawayDialog
196+
).toBeVisible();
197+
await createPutawayPage.completeStep.yesButtonOnConfirmPutawayDialog
198+
.last()
199+
.click();
200+
});
201+
202+
await test.step('Assert completing putaway', async () => {
203+
await putawayDetailsPage.isLoaded();
204+
await expect(putawayDetailsPage.statusTag).toHaveText('Completed');
205+
});
206+
207+
await test.step('Assert putaway bin on stock card', async () => {
208+
await productShowPage.goToPage(product.id);
209+
await productShowPage.inStockTab.click();
210+
await productShowPage.inStockTabSection.isLoaded();
211+
await expect(
212+
productShowPage.inStockTabSection.row(2).binLocation
213+
).toHaveText(internalLocation.name);
214+
await expect(
215+
productShowPage.inStockTabSection.row(2).quantityOnHand
216+
).toHaveText('5');
217+
});
218+
219+
await test.step('Assert qty still available to putaway on create putaway page', async () => {
220+
await navbar.profileButton.click();
221+
await navbar.refreshCachesButton.click();
222+
await createPutawayPage.goToPage();
223+
await createPutawayPage.table
224+
.row(0)
225+
.getExpandBinLocation(receivingBin)
226+
.click();
227+
await expect(
228+
createPutawayPage.table.row(1).getProductName(product2.name)
229+
).toBeVisible();
230+
await expect(
231+
createPutawayPage.table.row(2).getProductName(product.name)
232+
).toBeVisible();
233+
await managerUserPage.close();
234+
});
235+
});
236+
});

0 commit comments

Comments
 (0)