-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchangeLocationOnCreatePutawayPage.test.ts
More file actions
196 lines (175 loc) · 7 KB
/
changeLocationOnCreatePutawayPage.test.ts
File metadata and controls
196 lines (175 loc) · 7 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
import AppConfig from '@/config/AppConfig';
import { ShipmentType } from '@/constants/ShipmentType';
import { expect, test } from '@/fixtures/fixtures';
import { StockMovementResponse } from '@/types';
import RefreshCachesUtils from '@/utils/RefreshCaches';
import { getShipmentId, getShipmentItemId } from '@/utils/shipmentUtils';
test.describe('Change location on putaway create page and list pages', () => {
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 ({
stockMovementShowPage,
stockMovementService,
putawayListPage,
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('Change location on putaway create page and list page', async ({
stockMovementShowPage,
navbar,
createPutawayPage,
locationChooser,
productService,
depotLocationService,
mainLocationService,
putawayListPage,
authService,
}) => {
const receivingBin =
AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;
productService.setProduct('5');
const product = await productService.getProduct();
const mainLocation = await mainLocationService.getLocation();
const depotLocation = await depotLocationService.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 RefreshCachesUtils.refreshCaches({
navbar
});
});
await test.step('Go to create putaway page and assert its content', async () => {
await createPutawayPage.goToPage();
await createPutawayPage.isLoaded();
await expect(createPutawayPage.table.row(0).receivingBin).toContainText(
receivingBin
);
await createPutawayPage.table
.row(0)
.getExpandBinLocation(receivingBin)
.click();
await expect(
createPutawayPage.table.row(1).getProductName(product.name)
).toBeVisible();
});
await test.step('Change location to another depot', async () => {
await navbar.locationChooserButton.click();
await locationChooser
.getOrganization(depotLocation.organization?.name as string)
.click();
await locationChooser.getLocation(depotLocation.name).click();
await RefreshCachesUtils.refreshCaches({
navbar
});
await createPutawayPage.goToPage();
await expect(createPutawayPage.emptyCreatePageInformation).toBeVisible();
await expect(
createPutawayPage.table.row(0).getExpandBinLocation(receivingBin)
).toBeHidden();
});
await test.step('Return to main location and create pending putaway', async () => {
await navbar.locationChooserButton.click();
await locationChooser
.getOrganization(mainLocation.organization?.name as string)
.click();
await locationChooser.getLocation(mainLocation.name).click();
await navbar.profileButton.click();
await navbar.refreshCachesButton.click();
await createPutawayPage.goToPage();
await createPutawayPage.table
.row(0)
.getExpandBinLocation(receivingBin)
.click();
await createPutawayPage.table.row(1).checkbox.click();
await createPutawayPage.startPutawayButton.click();
await createPutawayPage.startStep.isLoaded();
await createPutawayPage.startStep.saveButton.click();
});
await test.step('Go to list page and assert putaway is created', async () => {
await putawayListPage.goToPage();
await putawayListPage.isLoaded();
await expect(putawayListPage.table.row(1).statusTag).toHaveText(
'Pending'
);
});
const putawayOrderIdentifier = await putawayListPage.table
.row(1)
.orderNumber.textContent();
await test.step('Change location to another depot', async () => {
await navbar.locationChooserButton.click();
await locationChooser
.getOrganization(depotLocation.organization?.name as string)
.click();
await locationChooser.getLocation(depotLocation.name).click();
await putawayListPage.goToPage();
await putawayListPage.searchField.fill(
`${putawayOrderIdentifier}`.toString().trim()
);
await putawayListPage.searchButton.click();
await putawayListPage.emptyPutawayList.isVisible();
});
await test.step('Go to putaway list page and assert pending putaway not visible in other location', async () => {
await putawayListPage.goToPage();
await expect(putawayListPage.destinationFilter).toContainText(
depotLocation.name
);
await putawayListPage.searchField.fill(
`${putawayOrderIdentifier}`.toString().trim()
);
await putawayListPage.searchButton.click();
await putawayListPage.emptyPutawayList.isVisible();
});
await test.step('Return to main location', async () => {
await authService.changeLocation(AppConfig.instance.locations.main.id);
});
});
});