Skip to content

Commit f02e006

Browse files
committed
add test to assert unable to edit completed putaways
1 parent d41c8f2 commit f02e006

File tree

1 file changed

+202
-0
lines changed

1 file changed

+202
-0
lines changed
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
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('Assert attempt to edit completed 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+
70+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
71+
await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click();
72+
await oldViewShipmentPage.undoStatusChangeButton.click();
73+
await stockMovementShowPage.isLoaded();
74+
await stockMovementShowPage.rollbackButton.click();
75+
76+
await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id);
77+
}
78+
);
79+
80+
test('Assert attempt to edit completed putaway', async ({
81+
stockMovementShowPage,
82+
navbar,
83+
createPutawayPage,
84+
internalLocationService,
85+
putawayDetailsPage,
86+
putawayListPage,
87+
page,
88+
}) => {
89+
await test.step('Go to create putaway page', async () => {
90+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
91+
await stockMovementShowPage.isLoaded();
92+
await navbar.profileButton.click();
93+
await navbar.refreshCachesButton.click();
94+
await navbar.inbound.click();
95+
await navbar.createPutaway.click();
96+
await createPutawayPage.isLoaded();
97+
});
98+
99+
await test.step('Start putaway', async () => {
100+
await createPutawayPage.table.row(0).checkbox.click();
101+
await createPutawayPage.startPutawayButton.click();
102+
await createPutawayPage.startStep.isLoaded();
103+
});
104+
105+
await test.step('Select bin to putaway', async () => {
106+
const internalLocation = await internalLocationService.getLocation();
107+
await createPutawayPage.startStep.table.row(0).putawayBinSelect.click();
108+
await createPutawayPage.startStep.table
109+
.row(0)
110+
.getPutawayBin(internalLocation.name)
111+
.click();
112+
await createPutawayPage.startStep.nextButton.click();
113+
});
114+
115+
await test.step('Go to next page and complete putaway', async () => {
116+
await createPutawayPage.completeStep.isLoaded();
117+
await createPutawayPage.completeStep.completePutawayButton.click();
118+
});
119+
120+
await test.step('Assert completing putaway', async () => {
121+
await putawayDetailsPage.isLoaded();
122+
await expect(putawayDetailsPage.statusTag).toHaveText('Completed');
123+
});
124+
125+
await test.step('Assert try to edit completed putaway', async () => {
126+
await putawayDetailsPage.assertClickOnEditButtonWhenPutawayCompleted();
127+
});
128+
129+
await test.step('Assert delete button is not visible for completed putaway', async () => {
130+
await putawayDetailsPage.summaryActionsButton.click();
131+
await expect(putawayDetailsPage.actionsDeleteButton).toBeHidden();
132+
});
133+
134+
await test.step('Go backward in browser', async () => {
135+
await page.goBack();
136+
await createPutawayPage.startStep.isLoaded();
137+
});
138+
139+
await test.step('Assert attemps to edit in completed putaway', async () => {
140+
await createPutawayPage.startStep.saveButton.click();
141+
await expect(
142+
createPutawayPage.startStep.validationOnEditCompletedPutaway
143+
).toBeVisible();
144+
await createPutawayPage.startStep.closeDisplayedError();
145+
await createPutawayPage.startStep.nextButton.click();
146+
await expect(
147+
createPutawayPage.startStep.validationOnEditCompletedPutaway
148+
).toBeVisible();
149+
await createPutawayPage.startStep.closeDisplayedError();
150+
await createPutawayPage.startStep.generatePutawayListButton.click();
151+
await expect(
152+
createPutawayPage.startStep.validationOnEditCompletedPutaway
153+
).toBeVisible();
154+
await createPutawayPage.startStep.closeDisplayedError();
155+
await createPutawayPage.startStep.sortByCurrentBinButton.click();
156+
await expect(
157+
createPutawayPage.startStep.validationOnEditCompletedPutaway
158+
).toBeVisible();
159+
await createPutawayPage.startStep.closeDisplayedError();
160+
});
161+
162+
await test.step('Assert attemps to edit item in completed putaway', async () => {
163+
await createPutawayPage.startStep.isLoaded();
164+
await createPutawayPage.startStep.table.row(0).deleteButton.click();
165+
await expect(
166+
createPutawayPage.startStep.validationOnDeleteItemFromCompletedPutaway
167+
).toBeVisible();
168+
await createPutawayPage.startStep.closeDisplayedError();
169+
await createPutawayPage.startStep.table.row(0).splitLineButton.click();
170+
await createPutawayPage.startStep.splitModal.isLoaded();
171+
await createPutawayPage.startStep.splitModal.addLineButton.click();
172+
const internalLocation = await internalLocationService.getLocation();
173+
await createPutawayPage.startStep.splitModal.table
174+
.row(1)
175+
.getPutawayBin(internalLocation.name);
176+
await createPutawayPage.startStep.splitModal.table
177+
.row(1)
178+
.quantityField.fill('5');
179+
await createPutawayPage.startStep.splitModal.table
180+
.row(2)
181+
.getPutawayBin(internalLocation.name);
182+
await createPutawayPage.startStep.splitModal.table
183+
.row(2)
184+
.quantityField.fill('5');
185+
await createPutawayPage.startStep.splitModal.saveButton.click();
186+
await expect(
187+
createPutawayPage.startStep.validationOnEditCompletedPutaway
188+
).toBeVisible();
189+
await createPutawayPage.startStep.closeDisplayedError();
190+
await createPutawayPage.startStep.table.row(0).editButton.click();
191+
await createPutawayPage.startStep.table.row(0).quantityField.fill('20');
192+
await expect(createPutawayPage.startStep.nextButton).toBeDisabled();
193+
await expect(createPutawayPage.startStep.saveButton).toBeDisabled();
194+
});
195+
196+
await test.step('Go putaway list page and assert pending putaway is not created', async () => {
197+
await putawayListPage.goToPage();
198+
await putawayListPage.isLoaded();
199+
await putawayListPage.emptyPutawayList.isVisible();
200+
});
201+
});
202+
});

0 commit comments

Comments
 (0)