Skip to content

Commit 7daa39f

Browse files
OBPIH-6952 Add test for asserting receiving bin location is created (#45)
* OBPIH-6952 add test for asserting creation of receiving bin location * OBPIH-6952 add receiving bin prefix- to env and AppConfig * OBPIH-6952 bring back accidentally removed changes * OBPIH-6952 fix import order * OBPIH-6952 Add receiving bin prefix default env var value --------- Co-authored-by: Walkowiak <awalkowiak@soldevelo.com>
1 parent 66b496e commit 7daa39f

5 files changed

Lines changed: 176 additions & 1 deletion

File tree

.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,4 @@ PRODUCT_TWO=productId
1818
PRODUCT_THREE=productId
1919
PRODUCT_FOUR=productId
2020
PRODUCT_FIVE=productId
21+
RECEIVING_BIN_PREFIX=receivingBinPrefix

.github/workflows/playwright.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ jobs:
7070
PRODUCT_THREE: ${{ secrets.PRODUCT_THREE }}
7171
PRODUCT_FOUR: ${{ secrets.PRODUCT_FOUR }}
7272
PRODUCT_FIVE: ${{ secrets.PRODUCT_FIVE }}
73+
RECEIVING_BIN_PREFIX: ${{ secrets.RECEIVING_BIN_PREFIX != null && secrets.RECEIVING_BIN_PREFIX || 'R-' }}
7374
run: |
7475
echo "Running playwright tests on the ${{ inputs.environment || 'obdev5' }} server"
7576
npx playwright test

src/config/AppConfig.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ class AppConfig {
6666
// test products used in all of the tests
6767
public products!: Record<PRODUCT_KEY, ProductConfig>;
6868

69+
//recivingbin configurable prefix
70+
public receivingBinPrefix!: string;
71+
6972
// Private constructor to enforce singleton pattern.
7073
private constructor() {
7174
this.uniqueIdentifier = new UniqueIdentifier();
@@ -284,6 +287,11 @@ class AppConfig {
284287
required: false,
285288
}),
286289
};
290+
291+
this.receivingBinPrefix = env
292+
.get('RECEIVING_BIN_PREFIX')
293+
.default('R-')
294+
.asString();
287295
}
288296
}
289297

src/pages/location/createLocation/tabs/BinLocationsTabSection.ts

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

33
import BasePageModel from '@/pages/BasePageModel';
44
import AddBinLocationDialog from '@/pages/location/createLocation/components/AddBinLocationDialog';
@@ -21,6 +21,18 @@ class BinLocationsTabSection extends BasePageModel {
2121
).toBeVisible();
2222
}
2323

24+
get table() {
25+
return this.page.locator('.box').getByRole('table');
26+
}
27+
28+
get rows() {
29+
return this.table.getByRole('row');
30+
}
31+
32+
row(index: number) {
33+
return new Row(this.page, this.rows.nth(index));
34+
}
35+
2436
get addBinLocationButton() {
2537
return this.page.getByRole('button', { name: 'Add Bin Location' });
2638
}
@@ -36,6 +48,21 @@ class BinLocationsTabSection extends BasePageModel {
3648
get editBinButton() {
3749
return this.page.getByRole('link', { name: 'Edit', exact: true });
3850
}
51+
52+
get emptyBinLocationTable() {
53+
return this.table.getByText('No matching records found');
54+
}
55+
}
56+
class Row extends BasePageModel {
57+
row: Locator;
58+
constructor(page: Page, row: Locator) {
59+
super(page);
60+
this.row = row;
61+
}
62+
63+
get binLocation() {
64+
return this.row.locator('td').nth(1).getByRole('link');
65+
}
3966
}
4067

4168
export default BinLocationsTabSection;
Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
import AppConfig from '@/config/AppConfig';
2+
import { ShipmentType } from '@/constants/ShipmentType';
3+
import { expect, test } from '@/fixtures/fixtures';
4+
import CreateLocationPage from '@/pages/location/createLocation/CreateLocationPage';
5+
import LocationListPage from '@/pages/location/LocationListPage';
6+
import { StockMovementResponse } from '@/types';
7+
8+
test.describe('Assert creation of receiving bin', () => {
9+
test.describe.configure({ timeout: 60000 });
10+
//timeout has been added for this test to make sure that the content on bin location tab will load as it can include a lot of data
11+
let STOCK_MOVEMENT: StockMovementResponse;
12+
13+
test.beforeEach(
14+
async ({
15+
supplierLocationService,
16+
stockMovementService,
17+
mainProductService,
18+
otherProductService,
19+
}) => {
20+
const supplierLocation = await supplierLocationService.getLocation();
21+
const PRODUCT_ONE = await mainProductService.getProduct();
22+
const PRODUCT_TWO = await otherProductService.getProduct();
23+
24+
STOCK_MOVEMENT = await stockMovementService.createInbound({
25+
originId: supplierLocation.id,
26+
});
27+
28+
await stockMovementService.addItemsToInboundStockMovement(
29+
STOCK_MOVEMENT.id,
30+
[
31+
{
32+
productId: PRODUCT_ONE.id,
33+
quantity: 100,
34+
},
35+
{ productId: PRODUCT_TWO.id, quantity: 10 },
36+
]
37+
);
38+
39+
await stockMovementService.sendInboundStockMovement(STOCK_MOVEMENT.id, {
40+
shipmentType: ShipmentType.AIR,
41+
});
42+
}
43+
);
44+
45+
test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => {
46+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
47+
await stockMovementShowPage.rollbackButton.click();
48+
await stockMovementService.deleteStockMovement(STOCK_MOVEMENT.id);
49+
});
50+
51+
test('Assert receiving bin is not created when shipment is shipped', async ({
52+
stockMovementShowPage,
53+
receivingPage,
54+
page,
55+
locationListPage,
56+
mainLocationService,
57+
createLocationPage,
58+
browser,
59+
}) => {
60+
await test.step('Go to stock movement show page and assert shipped status', async () => {
61+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
62+
await stockMovementShowPage.isLoaded();
63+
await expect(stockMovementShowPage.statusTag).toHaveText('Shipped');
64+
});
65+
66+
await test.step('Go to Bin location tab of edit location page', async () => {
67+
const mainLocation = await mainLocationService.getLocation();
68+
await page.goto('./location/list');
69+
await locationListPage.searchByLocationNameField.fill(mainLocation.name);
70+
await locationListPage.findButton.click();
71+
await expect(
72+
locationListPage.getLocationEditButton(mainLocation.name)
73+
).toBeVisible();
74+
await locationListPage.getLocationEditButton(mainLocation.name).click();
75+
await createLocationPage.binLocationTab.click();
76+
await createLocationPage.binLocationTabSection.isLoaded();
77+
});
78+
79+
await test.step('Assert Bin location is not created yet', async () => {
80+
const receivingBin =
81+
AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;
82+
await createLocationPage.binLocationTabSection.searchField.fill(
83+
receivingBin
84+
);
85+
await createLocationPage.binLocationTabSection.searchField.press('Enter');
86+
await createLocationPage.binLocationTabSection.isLoaded();
87+
await expect(
88+
createLocationPage.binLocationTabSection.emptyBinLocationTable
89+
).toBeVisible();
90+
});
91+
92+
await test.step('Go to stock movement show page', async () => {
93+
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
94+
await stockMovementShowPage.isLoaded();
95+
});
96+
97+
await test.step('Click on receive button', async () => {
98+
await stockMovementShowPage.receiveButton.click();
99+
await receivingPage.receivingStep.isLoaded();
100+
});
101+
102+
await test.step('Assert receiving bin has been created', async () => {
103+
const newPage = await browser.newPage();
104+
const newLocationListPage = new LocationListPage(newPage);
105+
const newCreateLocationPage = new CreateLocationPage(newPage);
106+
const mainLocation = await mainLocationService.getLocation();
107+
await newPage.goto('./location/list');
108+
await newLocationListPage.searchByLocationNameField.fill(
109+
mainLocation.name
110+
);
111+
await newLocationListPage.findButton.click();
112+
await expect(
113+
newLocationListPage.getLocationEditButton(mainLocation.name)
114+
).toBeVisible();
115+
await newLocationListPage
116+
.getLocationEditButton(mainLocation.name)
117+
.click();
118+
await newCreateLocationPage.binLocationTab.click();
119+
await newCreateLocationPage.binLocationTabSection.isLoaded();
120+
const receivingBin =
121+
AppConfig.instance.receivingBinPrefix + STOCK_MOVEMENT.identifier;
122+
await newCreateLocationPage.binLocationTabSection.searchField.fill(
123+
receivingBin
124+
);
125+
await newCreateLocationPage.binLocationTabSection.searchField.press(
126+
'Enter'
127+
);
128+
await newCreateLocationPage.binLocationTabSection.isLoaded();
129+
await expect(
130+
newCreateLocationPage.binLocationTabSection.emptyBinLocationTable
131+
).toBeHidden();
132+
await expect(
133+
newCreateLocationPage.binLocationTabSection.row(1).binLocation
134+
).toHaveText(receivingBin);
135+
await newPage.close();
136+
});
137+
});
138+
});

0 commit comments

Comments
 (0)