Skip to content

Commit 3e8a73b

Browse files
authored
OBPIH-6705, OBPIH-6699, OBPIH-6694 Add receiving tests (#28)
* fix misspells in receiving tests * OBPIH-6705, OBPIH-6699, OBPIH-6694 add tests for validations on receive shipped inbound, edit received shipment and receive received inbound * add elements to inbound send page
1 parent 21b4082 commit 3e8a73b

File tree

3 files changed

+216
-5
lines changed

3 files changed

+216
-5
lines changed

src/pages/inbound/create/steps/SendStep.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ class SendStep extends BasePageModel {
4848
return this.page.getByRole('button', { name: 'Send shipment' });
4949
}
5050

51+
get saveAndExitButton() {
52+
return this.page.getByRole('button', { name: 'Save and Exit' });
53+
}
54+
5155
async isLoaded() {
5256
await expect(this.originField.textbox).toBeVisible();
5357
await expect(this.destinationSelect.selectField).toBeVisible();

src/tests/receiving/receiveInbound.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ test.describe('Receive inbound stock movement', () => {
207207
});
208208
});
209209

210-
test('Receving should be available from location that is specfied as destination location', async ({
210+
test('Receiving should be available from location that is specfied as destination location', async ({
211211
stockMovementShowPage,
212212
receivingPage,
213213
}) => {
@@ -220,7 +220,7 @@ test.describe('Receive inbound stock movement', () => {
220220
await stockMovementShowPage.receiveButton.click();
221221
});
222222

223-
await test.step('Assert that receing page is loaded', async () => {
223+
await test.step('Assert that receiving page is loaded', async () => {
224224
await receivingPage.receivingStep.isLoaded();
225225
});
226226

@@ -239,12 +239,12 @@ test.describe('Receive inbound stock movement', () => {
239239
});
240240
});
241241

242-
test.describe('Receive from differnt locations', () => {
242+
test.describe('Receive from different locations', () => {
243243
test.afterEach(async ({ authService }) => {
244244
await authService.changeLocation(AppConfig.instance.locations.main.id);
245245
});
246246

247-
test('Receving should not be available from other location than which is specfied as destination location', async ({
247+
test('Receiving should not be available from other location than which is specfied as destination location', async ({
248248
stockMovementShowPage,
249249
depotLocationService,
250250
navbar,
@@ -257,7 +257,7 @@ test.describe('Receive inbound stock movement', () => {
257257
await stockMovementShowPage.isLoaded();
258258
});
259259

260-
await test.step('switch locations', async () => {
260+
await test.step('Switch locations', async () => {
261261
await navbar.locationChooserButton.click();
262262
await locationChooser
263263
.getOrganization(OTHER_LOCATION.organization?.name as string)
Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
import { ShipmentType } from '@/constants/ShipmentType';
2+
import { expect, test } from '@/fixtures/fixtures';
3+
import { StockMovementResponse } from '@/types';
4+
import { getToday } from '@/utils/DateUtils';
5+
6+
test.describe('Validations on edit and receive inbound stock movement', () => {
7+
let STOCK_MOVEMENT: StockMovementResponse;
8+
const description = 'some description';
9+
const dateRequested = getToday();
10+
11+
test.beforeEach(
12+
async ({
13+
supplierLocationService,
14+
stockMovementService,
15+
mainProductService,
16+
}) => {
17+
const supplierLocation = await supplierLocationService.getLocation();
18+
STOCK_MOVEMENT = await stockMovementService.createInbound({
19+
originId: supplierLocation.id,
20+
description,
21+
dateRequested,
22+
});
23+
24+
const product = await mainProductService.getProduct();
25+
26+
await stockMovementService.addItemsToInboundStockMovement(
27+
STOCK_MOVEMENT.id,
28+
[{ productId: product.id, quantity: 10 }]
29+
);
30+
31+
await stockMovementService.sendInboundStockMovement(STOCK_MOVEMENT.id, {
32+
shipmentType: ShipmentType.AIR,
33+
});
34+
}
35+
);
36+
37+
test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => {
38+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
39+
const isRollbackLastReceiptButtonVisible =
40+
await stockMovementShowPage.rollbackLastReceiptButton.isVisible();
41+
const isRollbackButtonVisible =
42+
await stockMovementShowPage.rollbackButton.isVisible();
43+
44+
// due to failed test, shipment might not be received which will not show the button
45+
if (isRollbackLastReceiptButtonVisible) {
46+
await stockMovementShowPage.rollbackLastReceiptButton.click();
47+
}
48+
49+
if (isRollbackButtonVisible) {
50+
await stockMovementShowPage.rollbackButton.click();
51+
}
52+
53+
await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id);
54+
});
55+
56+
test('Assert validation on try to receive not yet shipped inbound', async ({
57+
stockMovementShowPage,
58+
}) => {
59+
await test.step('Go to stock movement show page', async () => {
60+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
61+
await stockMovementShowPage.isLoaded();
62+
});
63+
64+
await test.step('Rollback inbound shipment', async () => {
65+
await stockMovementShowPage.rollbackButton.click();
66+
await stockMovementShowPage.isLoaded();
67+
});
68+
69+
await test.step('Validation on unable to receive not yet shipped inbound', async () => {
70+
await stockMovementShowPage.receiveButton.click();
71+
await expect(stockMovementShowPage.errorMessage).toBeVisible();
72+
await expect(stockMovementShowPage.errorMessage).toContainText(
73+
'Stock movement ' + STOCK_MOVEMENT.identifier + ' has not been shipped'
74+
);
75+
});
76+
});
77+
78+
test('Assert access to Edit page for partially received and received inbounds', async ({
79+
stockMovementShowPage,
80+
createInboundPage,
81+
receivingPage,
82+
}) => {
83+
await test.step('Go to stock movement show page', async () => {
84+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
85+
await stockMovementShowPage.isLoaded();
86+
});
87+
88+
await test.step('Display send page for shipped inbound', async () => {
89+
await stockMovementShowPage.editButton.click();
90+
await createInboundPage.sendStep.isLoaded();
91+
await createInboundPage.sendStep.saveAndExitButton.click();
92+
await stockMovementShowPage.waitForUrl();
93+
await stockMovementShowPage.isLoaded();
94+
});
95+
96+
await test.step('Go to shipment receiving page', async () => {
97+
await stockMovementShowPage.receiveButton.click();
98+
await receivingPage.receivingStep.isLoaded();
99+
});
100+
101+
await test.step('Select all items to receive', async () => {
102+
await receivingPage.receivingStep.isLoaded();
103+
await receivingPage.receivingStep.table
104+
.row(1)
105+
.receivingNowField.textbox.fill('5');
106+
});
107+
108+
await test.step('Go to Check page', async () => {
109+
await receivingPage.nextButton.click();
110+
});
111+
112+
await test.step('Receive shipment', async () => {
113+
await receivingPage.checkStep.isLoaded();
114+
await receivingPage.checkStep.receiveShipmentButton.click();
115+
await stockMovementShowPage.isLoaded();
116+
});
117+
118+
await test.step('Validation on edit partially received inbound', async () => {
119+
await stockMovementShowPage.isLoaded();
120+
await expect(
121+
stockMovementShowPage.rollbackLastReceiptButton
122+
).toBeVisible();
123+
await stockMovementShowPage.editButton.click();
124+
await expect(stockMovementShowPage.errorMessage).toBeVisible();
125+
await expect(stockMovementShowPage.errorMessage).toContainText(
126+
'Cannot edit received shipment'
127+
);
128+
});
129+
130+
await test.step('Go to shipment receiving page', async () => {
131+
await stockMovementShowPage.receiveButton.click();
132+
await receivingPage.receivingStep.isLoaded();
133+
});
134+
135+
await test.step('Select all items to receive', async () => {
136+
await receivingPage.receivingStep.isLoaded();
137+
await receivingPage.receivingStep.table
138+
.row(1)
139+
.receivingNowField.textbox.fill('5');
140+
});
141+
142+
await test.step('Go to Check page', async () => {
143+
await receivingPage.nextButton.click();
144+
});
145+
146+
await test.step('Receive shipment', async () => {
147+
await receivingPage.checkStep.isLoaded();
148+
await receivingPage.checkStep.receiveShipmentButton.click();
149+
await stockMovementShowPage.isLoaded();
150+
});
151+
152+
await test.step('Validation on edit received inbound', async () => {
153+
await stockMovementShowPage.isLoaded();
154+
await expect(
155+
stockMovementShowPage.rollbackLastReceiptButton
156+
).toBeVisible();
157+
await stockMovementShowPage.editButton.click();
158+
await expect(stockMovementShowPage.errorMessage).toBeVisible();
159+
await expect(stockMovementShowPage.errorMessage).toContainText(
160+
'Cannot edit received shipment'
161+
);
162+
});
163+
});
164+
165+
test('Assert unable to receive already received inbounds', async ({
166+
stockMovementShowPage,
167+
receivingPage,
168+
}) => {
169+
await test.step('Go to stock movement show page', async () => {
170+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
171+
await stockMovementShowPage.isLoaded();
172+
});
173+
174+
await test.step('Go to shipment receiving page', async () => {
175+
await stockMovementShowPage.receiveButton.click();
176+
await receivingPage.receivingStep.isLoaded();
177+
});
178+
179+
await test.step('Select all items to receive', async () => {
180+
await receivingPage.receivingStep.isLoaded();
181+
await receivingPage.receivingStep.table
182+
.row(1)
183+
.receivingNowField.textbox.fill('10');
184+
});
185+
186+
await test.step('Go to Check page', async () => {
187+
await receivingPage.nextButton.click();
188+
});
189+
190+
await test.step('Receive shipment', async () => {
191+
await receivingPage.checkStep.isLoaded();
192+
await receivingPage.checkStep.receiveShipmentButton.click();
193+
await stockMovementShowPage.isLoaded();
194+
});
195+
196+
await test.step('Validation on receive already received inbound', async () => {
197+
await stockMovementShowPage.isLoaded();
198+
await stockMovementShowPage.receiveButton.click();
199+
await expect(stockMovementShowPage.errorMessage).toBeVisible();
200+
await expect(stockMovementShowPage.errorMessage).toContainText(
201+
'Stock movement ' +
202+
STOCK_MOVEMENT.identifier +
203+
' has already been received'
204+
);
205+
});
206+
});
207+
});

0 commit comments

Comments
 (0)