Skip to content

Commit 7277dd5

Browse files
authored
OBPIH-7537 Putaway - qty validations (#76)
* fix file name in test * add elements to putaway pages * add test for qty validations in putaways * fix tooltip * remove unused lines
1 parent edb774f commit 7277dd5

4 files changed

Lines changed: 285 additions & 9 deletions

File tree

src/pages/putaway/components/SplitModalTable.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Locator, Page } from '@playwright/test';
1+
import { expect, Locator, Page } from '@playwright/test';
22

33
import BasePageModel from '@/pages/BasePageModel';
44

@@ -18,6 +18,14 @@ class SplitModalTable extends BasePageModel {
1818
row(index: number) {
1919
return new Row(this.page, this.rows.nth(index));
2020
}
21+
22+
get qtyValidationTooltip() {
23+
return this.page.getByRole('tooltip');
24+
}
25+
26+
assertValidationOnQtyField = async (errorContent: string) => {
27+
await expect(this.qtyValidationTooltip).toContainText(errorContent);
28+
};
2129
}
2230

2331
class Row extends BasePageModel {

src/pages/putaway/components/StartPutawayTable.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Locator, Page } from '@playwright/test';
1+
import { expect, Locator, Page } from '@playwright/test';
22

33
import BasePageModel from '@/pages/BasePageModel';
44

@@ -18,6 +18,14 @@ class StartPutawayTable extends BasePageModel {
1818
row(index: number) {
1919
return new Row(this.page, this.rows.nth(index));
2020
}
21+
22+
get qtyValidationTooltip() {
23+
return this.page.getByRole('tooltip');
24+
}
25+
26+
assertValidationOnQtyField = async (errorContent: string) => {
27+
await expect(this.qtyValidationTooltip).toContainText(errorContent);
28+
};
2129
}
2230

2331
class Row extends BasePageModel {
@@ -68,7 +76,7 @@ class Row extends BasePageModel {
6876
}
6977

7078
get quantityInput() {
71-
return this.row.getByTestId('quantity-input')
79+
return this.row.getByTestId('quantity-input');
7280
}
7381

7482
get splitLineInPutawayBin() {

src/tests/inbound/createInbound/downloadDocsFromSendPage.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,7 @@ test.describe('Download documents from inbound send page', () => {
1515
const uniqueIdentifier = new UniqueIdentifier();
1616

1717
test.beforeEach(
18-
async ({
19-
productService,
20-
mainUserService,
21-
supplierLocationService,
22-
}) => {
18+
async ({ productService, mainUserService, supplierLocationService }) => {
2319
productService.setProduct('1');
2420
const PRODUCT_ONE = await productService.getProduct();
2521
USER = await mainUserService.getUser();
@@ -225,7 +221,7 @@ test.describe('Download documents from inbound send page', () => {
225221
]);
226222

227223
expect(download.suggestedFilename()).toMatch(
228-
/^Packing List - .*\.xls(x)?$/
224+
/^Packing List_.*\.xls(x)?$/
229225
);
230226
await popup.close();
231227
});
Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
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 qty validations in putaways', () => {
8+
let STOCK_MOVEMENT: StockMovementResponse;
9+
10+
test.beforeEach(
11+
async ({
12+
supplierLocationService,
13+
stockMovementService,
14+
productService,
15+
receivingService,
16+
}) => {
17+
const supplierLocation = await supplierLocationService.getLocation();
18+
STOCK_MOVEMENT = await stockMovementService.createInbound({
19+
originId: supplierLocation.id,
20+
});
21+
22+
productService.setProduct('5');
23+
const product = await productService.getProduct();
24+
25+
await stockMovementService.addItemsToInboundStockMovement(
26+
STOCK_MOVEMENT.id,
27+
[{ productId: product.id, quantity: 10 }]
28+
);
29+
30+
await stockMovementService.sendInboundStockMovement(STOCK_MOVEMENT.id, {
31+
shipmentType: ShipmentType.AIR,
32+
});
33+
34+
const { data: stockMovement } =
35+
await stockMovementService.getStockMovement(STOCK_MOVEMENT.id);
36+
const shipmentId = getShipmentId(stockMovement);
37+
const { data: receipt } = await receivingService.getReceipt(shipmentId);
38+
const receivingBin =
39+
AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;
40+
41+
await receivingService.createReceivingBin(shipmentId, receipt);
42+
43+
await receivingService.updateReceivingItems(shipmentId, [
44+
{
45+
shipmentItemId: getShipmentItemId(receipt, 0, 0),
46+
quantityReceiving: 10,
47+
binLocationName: receivingBin,
48+
},
49+
]);
50+
await receivingService.completeReceipt(shipmentId);
51+
}
52+
);
53+
54+
test.afterEach(
55+
async ({
56+
putawayListPage,
57+
stockMovementShowPage,
58+
stockMovementService,
59+
oldViewShipmentPage,
60+
}) => {
61+
await putawayListPage.goToPage();
62+
await putawayListPage.table.row(1).actionsButton.click();
63+
await putawayListPage.table.clickDeleteOrderButton(1);
64+
await putawayListPage.emptyPutawayList.isVisible();
65+
66+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
67+
await stockMovementShowPage.detailsListTable.oldViewShipmentPage.click();
68+
await oldViewShipmentPage.undoStatusChangeButton.click();
69+
await stockMovementShowPage.isLoaded();
70+
await stockMovementShowPage.rollbackButton.click();
71+
72+
await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id);
73+
}
74+
);
75+
76+
test('Assert qty validations in putaways', async ({
77+
stockMovementShowPage,
78+
navbar,
79+
createPutawayPage,
80+
internalLocationService,
81+
}) => {
82+
const internalLocation = await internalLocationService.getLocation();
83+
await test.step('Go to stock movement show page and assert received status', async () => {
84+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
85+
await stockMovementShowPage.isLoaded();
86+
await expect(stockMovementShowPage.statusTag).toHaveText('Received');
87+
await navbar.profileButton.click();
88+
await navbar.refreshCachesButton.click();
89+
});
90+
91+
await test.step('Go to create putaway page', async () => {
92+
await navbar.inbound.click();
93+
await navbar.createPutaway.click();
94+
await createPutawayPage.isLoaded();
95+
});
96+
97+
await test.step('Start putaway', async () => {
98+
await createPutawayPage.table.row(0).checkbox.click();
99+
await createPutawayPage.startPutawayButton.click();
100+
await createPutawayPage.startStep.isLoaded();
101+
});
102+
103+
await test.step('Try to edit qty to higher and assert validations', async () => {
104+
await createPutawayPage.startStep.table.row(0).editButton.click();
105+
await createPutawayPage.startStep.table.row(0).quantityInput.fill('20');
106+
await createPutawayPage.startStep.table.row(0).quantityInput.hover();
107+
await createPutawayPage.startStep.table.assertValidationOnQtyField(
108+
'Quantity cannot be greater than original putaway item quantity'
109+
);
110+
await expect(createPutawayPage.startStep.nextButton).toBeDisabled();
111+
await expect(createPutawayPage.startStep.saveButton).toBeDisabled();
112+
});
113+
114+
await test.step('Try to edit qty to 0 and assert validation', async () => {
115+
await createPutawayPage.startStep.table.row(0).editButton.click();
116+
await createPutawayPage.startStep.table.row(0).quantityInput.fill('0');
117+
await createPutawayPage.startStep.table.row(0).quantityInput.hover();
118+
await createPutawayPage.startStep.table.assertValidationOnQtyField(
119+
'Quantity cannot be less than 1'
120+
);
121+
await expect(createPutawayPage.startStep.nextButton).toBeDisabled();
122+
await expect(createPutawayPage.startStep.saveButton).toBeDisabled();
123+
});
124+
125+
await test.step('Try to edit qty to negative and assert validation', async () => {
126+
await createPutawayPage.startStep.table.row(0).editButton.click();
127+
await createPutawayPage.startStep.table.row(0).quantityInput.fill('-2');
128+
await createPutawayPage.startStep.table.row(0).quantityInput.hover();
129+
await createPutawayPage.startStep.table.assertValidationOnQtyField(
130+
'Quantity cannot be less than 1'
131+
);
132+
await expect(createPutawayPage.startStep.nextButton).toBeDisabled();
133+
await expect(createPutawayPage.startStep.saveButton).toBeDisabled();
134+
});
135+
136+
await test.step('Edit ptaway qty back to original value', async () => {
137+
await createPutawayPage.startStep.table.row(0).editButton.click();
138+
await createPutawayPage.startStep.table.row(0).quantityInput.fill('10');
139+
await expect(createPutawayPage.startStep.nextButton).toBeEnabled();
140+
await expect(createPutawayPage.startStep.saveButton).toBeEnabled();
141+
});
142+
143+
await test.step('Open split line modal', async () => {
144+
await createPutawayPage.startStep.table.row(0).splitLineButton.click();
145+
await createPutawayPage.startStep.splitModal.isLoaded();
146+
await createPutawayPage.startStep.splitModal.table
147+
.row(1)
148+
.getPutawayBin(internalLocation.name);
149+
});
150+
151+
await test.step('Try to edit qty to higher on split line modal', async () => {
152+
await createPutawayPage.startStep.splitModal.table
153+
.row(1)
154+
.quantityField.fill('20');
155+
await createPutawayPage.startStep.splitModal.table
156+
.row(1)
157+
.quantityField.hover();
158+
await createPutawayPage.startStep.splitModal.table.assertValidationOnQtyField(
159+
'Sum of all split items quantities cannot be higher than original putaway item quantity'
160+
);
161+
await expect(
162+
createPutawayPage.startStep.splitModal.saveButton
163+
).toBeDisabled();
164+
});
165+
166+
await test.step('Try to edit qty to 0 and assert validation on split line modal', async () => {
167+
await createPutawayPage.startStep.splitModal.table
168+
.row(1)
169+
.quantityField.fill('0');
170+
await createPutawayPage.startStep.splitModal.table
171+
.row(1)
172+
.quantityField.hover();
173+
await createPutawayPage.startStep.splitModal.table.assertValidationOnQtyField(
174+
'Items quantity cannot be less than 1'
175+
);
176+
await expect(
177+
createPutawayPage.startStep.splitModal.saveButton
178+
).toBeDisabled();
179+
});
180+
181+
await test.step('Try to edit qty to negative and assert validation on split line modal', async () => {
182+
await createPutawayPage.startStep.splitModal.table
183+
.row(1)
184+
.quantityField.fill('-1');
185+
await createPutawayPage.startStep.splitModal.table
186+
.row(1)
187+
.quantityField.hover();
188+
await createPutawayPage.startStep.splitModal.table.assertValidationOnQtyField(
189+
'Items quantity cannot be less than 1'
190+
);
191+
await expect(
192+
createPutawayPage.startStep.splitModal.saveButton
193+
).toBeDisabled();
194+
});
195+
196+
await test.step('Edit qty back to original value', async () => {
197+
await createPutawayPage.startStep.splitModal.table
198+
.row(1)
199+
.quantityField.fill('10');
200+
await expect(
201+
createPutawayPage.startStep.splitModal.saveButton
202+
).toBeEnabled();
203+
});
204+
205+
await test.step('Add new line on split line modal and assert empty qty on newly added line', async () => {
206+
await createPutawayPage.startStep.splitModal.addLineButton.click();
207+
await createPutawayPage.startStep.splitModal.table
208+
.row(2)
209+
.getPutawayBin(internalLocation.name);
210+
await createPutawayPage.startStep.splitModal.table
211+
.row(2)
212+
.quantityField.hover();
213+
await createPutawayPage.startStep.splitModal.table.assertValidationOnQtyField(
214+
'Items quantity cannot be less than 1'
215+
);
216+
});
217+
218+
await test.step('Try to input higher qty on newly added line', async () => {
219+
await createPutawayPage.startStep.splitModal.table
220+
.row(2)
221+
.quantityField.fill('5');
222+
await createPutawayPage.startStep.splitModal.table
223+
.row(1)
224+
.quantityField.hover();
225+
await createPutawayPage.startStep.splitModal.table.assertValidationOnQtyField(
226+
'Sum of all split items quantities cannot be higher than original putaway item quantity'
227+
);
228+
await createPutawayPage.startStep.splitModal.table
229+
.row(2)
230+
.quantityField.hover();
231+
await createPutawayPage.startStep.splitModal.table.assertValidationOnQtyField(
232+
'Sum of all split items quantities cannot be higher than original putaway item quantity'
233+
);
234+
});
235+
236+
await test.step('Try to input 0 on newly added line', async () => {
237+
await createPutawayPage.startStep.splitModal.table
238+
.row(2)
239+
.quantityField.fill('0');
240+
await createPutawayPage.startStep.splitModal.table
241+
.row(2)
242+
.quantityField.hover();
243+
await createPutawayPage.startStep.splitModal.table.assertValidationOnQtyField(
244+
'Items quantity cannot be less than 1'
245+
);
246+
});
247+
248+
await test.step('Try to input negative qty on newly added line', async () => {
249+
await createPutawayPage.startStep.splitModal.table
250+
.row(2)
251+
.quantityField.fill('-5');
252+
await createPutawayPage.startStep.splitModal.table
253+
.row(2)
254+
.quantityField.hover();
255+
await createPutawayPage.startStep.splitModal.table.assertValidationOnQtyField(
256+
'Items quantity cannot be less than 1'
257+
);
258+
});
259+
260+
await test.step('Leave split modal', async () => {
261+
await createPutawayPage.startStep.splitModal.cancelButton.click();
262+
});
263+
});
264+
});

0 commit comments

Comments
 (0)