-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperformPutawayAsManagerUser.test.ts
More file actions
225 lines (203 loc) · 8.47 KB
/
performPutawayAsManagerUser.test.ts
File metadata and controls
225 lines (203 loc) · 8.47 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
import Navbar from '@/components/Navbar';
import AppConfig from '@/config/AppConfig';
import { ShipmentType } from '@/constants/ShipmentType';
import { expect, test } from '@/fixtures/fixtures';
import CreatePutawayPage from '@/pages/putaway/CreatePutawayPage';
import PutawayDetailsPage from '@/pages/putaway/putawayDetails/PutawayDetailsPage';
import StockMovementShowPage from '@/pages/stockMovementShow/StockMovementShowPage';
import { StockMovementResponse } from '@/types';
import RefreshCachesUtils from '@/utils/RefreshCaches';
import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils';
test.describe('Perform putaway as manager user', () => {
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('3');
const product = await productService.getProduct();
productService.setProduct('4');
const product2 = await productService.getProduct();
await stockMovementService.addItemsToInboundStockMovement(
STOCK_MOVEMENT.id,
[
{ productId: product.id, quantity: 10 },
{ productId: product2.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,
},
{
shipmentItemId: getShipmentItemId(receipt, 0, 1),
quantityReceiving: 10,
binLocationName: receivingBin,
},
]);
await receivingService.completeReceipt(shipmentId);
}
);
test.afterEach(
async ({
stockMovementShowPage,
stockMovementService,
navbar,
transactionListPage,
oldViewShipmentPage,
}) => {
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
await navbar.configurationButton.click();
await navbar.transactions.click();
await transactionListPage.deleteTransaction(1);
await transactionListPage.deleteTransaction(1);
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('Perform putaway as manager user', async ({
managerUserContext,
internalLocationService,
productService,
}) => {
const receivingBin =
AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;
productService.setProduct('3');
const product = await productService.getProduct();
productService.setProduct('4');
const product2 = await productService.getProduct();
const internalLocation = await internalLocationService.getLocation();
const managerUserPage = await managerUserContext.newPage();
const navbar = new Navbar(managerUserPage);
const stockMovementShowPage = new StockMovementShowPage(managerUserPage);
const createPutawayPage = new CreatePutawayPage(managerUserPage);
const putawayDetailsPage = new PutawayDetailsPage(managerUserPage);
await test.step('Go to create putaway page', async () => {
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
await stockMovementShowPage.isLoaded();
await RefreshCachesUtils.refreshCaches({
navbar,
});
await navbar.inbound.click();
await navbar.createPutaway.click();
await createPutawayPage.isLoaded();
});
await test.step('Start putaway', async () => {
await createPutawayPage.table
.row(0)
.getExpandBinLocation(receivingBin)
.click();
await expect(
createPutawayPage.table.row(1).getProductName(product2.name)
).toBeVisible();
await expect(
createPutawayPage.table.row(2).getProductName(product.name)
).toBeVisible();
await createPutawayPage.table.row(1).checkbox.click();
await createPutawayPage.table.row(2).checkbox.click();
await createPutawayPage.startPutawayButton.click();
await createPutawayPage.startStep.isLoaded();
});
await test.step('Select bins to putaway', async () => {
await createPutawayPage.startStep.table.row(1).putawayBinSelect.click();
await createPutawayPage.startStep.table
.row(1)
.getPutawayBin(internalLocation.name)
.click();
await createPutawayPage.startStep.table.row(2).putawayBinSelect.click();
await createPutawayPage.startStep.table
.row(2)
.getPutawayBin(internalLocation.name)
.click();
});
await test.step('Use edit button as manager user on both lines', async () => {
await createPutawayPage.startStep.table.row(1).editButton.click();
await createPutawayPage.startStep.table.row(1).quantityInput.fill('5');
await createPutawayPage.startStep.table.row(2).editButton.click();
await createPutawayPage.startStep.table.row(2).quantityInput.fill('5');
});
await test.step('Go to complete step and assert qty after edit', async () => {
await createPutawayPage.startStep.nextButton.click();
await createPutawayPage.completeStep.isLoaded();
await expect(
createPutawayPage.completeStep.table.row(2).quantity
).toContainText('5');
await expect(
createPutawayPage.completeStep.table.row(3).quantity
).toContainText('5');
await expect(createPutawayPage.completeStep.table.rows).toHaveCount(4);
});
await test.step('Go backward and use delete button as manager user', async () => {
await createPutawayPage.completeStep.editButton.click();
await createPutawayPage.startStep.isLoaded();
await expect(createPutawayPage.startStep.table.rows).toHaveCount(3);
await createPutawayPage.startStep.table.row(2).deleteButton.click();
await expect(createPutawayPage.startStep.table.rows).toHaveCount(2);
});
await test.step('Go to next page and assert displayed rows', async () => {
await createPutawayPage.startStep.nextButton.click();
await createPutawayPage.completeStep.isLoaded();
await expect(createPutawayPage.completeStep.table.rows).toHaveCount(3);
});
await test.step('Complete putaway', async () => {
await createPutawayPage.completeStep.completePutawayButton.click();
await expect(
createPutawayPage.completeStep.confirmPutawayDialog
).toBeVisible();
await expect(
createPutawayPage.completeStep.confirmPutawayDialog
).toContainText(
/Qty5 of item .* is still in the receiving bin\. Do you want to continue\?/
);
await expect(
createPutawayPage.completeStep.confirmPutawayDialog
).toBeVisible();
await createPutawayPage.completeStep.yesButtonOnConfirmPutawayDialog
.last()
.click();
});
await test.step('Assert completing putaway', async () => {
await putawayDetailsPage.isLoaded();
await expect(putawayDetailsPage.statusTag).toHaveText('Completed');
});
await test.step('Assert qty still available to putaway on create putaway page', async () => {
await navbar.profileButton.click();
await navbar.refreshCachesButton.click();
await createPutawayPage.goToPage();
await createPutawayPage.table
.row(0)
.getExpandBinLocation(receivingBin)
.click();
await expect(
createPutawayPage.table.row(1).getProductName(product2.name)
).toBeVisible();
await expect(
createPutawayPage.table.row(2).getProductName(product.name)
).toBeVisible();
await managerUserPage.close();
});
});
});