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