Skip to content

Commit cce7648

Browse files
authored
OBPIH-6453 automation test for export all incoming items on inbound list page (#24)
* OBPIH-6453 Fix location choose rfailing test * OBPIH-6453 Add test for export all incomming line items
1 parent 76bd563 commit cce7648

File tree

7 files changed

+169
-7
lines changed

7 files changed

+169
-7
lines changed

src/api/StockMovementService.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,17 @@ class StockMovementService extends BaseServiceModel {
5151
}
5252
}
5353

54+
async getStockMovement(
55+
id: string
56+
): Promise<ApiResponse<StockMovementResponse>> {
57+
try {
58+
const apiResponse = await this.request.get(`./api/stockMovements/${id}`);
59+
return await parseRequestToJSON(apiResponse);
60+
} catch (error) {
61+
throw new Error('Problem deleting stock movement');
62+
}
63+
}
64+
5465
async updateItems(
5566
id: string,
5667
payload: UpdateStockMovementItemsPayload

src/config/AppConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ class AppConfig {
167167
type: LocationTypeCode.DEPOT,
168168
}),
169169
supplier: new LocationConfig({
170-
id: env.get(LOCATION_KEY.SUPPLIER).asString(),
171-
key: 'supplier',
170+
id: env.get('LOCATION_SUPPLIER').asString(),
171+
key: LOCATION_KEY.SUPPLIER,
172172
name: this.uniqueIdentifier.generateUniqueString('supplier'),
173173
requiredActivityCodes: new Set([
174174
ActivityCode.FULFILL_ORDER,

src/pages/inbound/list/InboundListPage.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,28 @@
11
import { Page } from '@playwright/test';
22

3+
import FileHandler from '@/components/FileHandler';
34
import BasePageModel from '@/pages/BasePageModel';
45
import InboundListFilters from '@/pages/inbound/list/InboundListFilters';
56
import InboundStockMovementTable from '@/pages/inbound/list/InboundStockMovementTable';
67

78
class InboundListPage extends BasePageModel {
89
filters: InboundListFilters;
910
table: InboundStockMovementTable;
11+
fileHandler: FileHandler;
1012

1113
constructor(page: Page) {
1214
super(page);
1315
this.filters = new InboundListFilters(page);
1416
this.table = new InboundStockMovementTable(page);
17+
this.fileHandler = new FileHandler(page);
18+
}
19+
20+
get exportDropdownButton() {
21+
return this.page.getByRole('button', { name: 'Export' });
22+
}
23+
24+
get exportAllIncomingItemsButton() {
25+
return this.page.getByRole('link', { name: 'Export all incoming items' });
1526
}
1627

1728
async goToPage() {
@@ -39,6 +50,13 @@ class InboundListPage extends BasePageModel {
3950
this.filters.clearButton.click(),
4051
]);
4152
}
53+
54+
async downloadAllIncomingItems() {
55+
await this.fileHandler.onDownload();
56+
await this.exportDropdownButton.click();
57+
await this.exportAllIncomingItemsButton.click();
58+
return await this.fileHandler.saveFile();
59+
}
4260
}
4361

4462
export default InboundListPage;

src/pages/locationGroup/LocationGroupsListPage.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ class LocationGroupsListPage extends BasePageModel {
1010
return this.page.getByText('Add Location group');
1111
}
1212

13+
async goToPage(params: { max: number }) {
14+
this.page.goto(`./locationGroup/list?max=${params.max}`);
15+
}
16+
1317
getPaginationItem(pageNumber: string) {
1418
return this.page
1519
.getByLabel('pagination')
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
import { expect, test } from '@/fixtures/fixtures';
2+
import { getDateByOffset, getToday } from '@/utils/DateUtils';
3+
import { WorkbookUtils } from '@/utils/WorkbookUtils';
4+
5+
test.describe('Export all incomming items', () => {
6+
let INBOUND_ID: string;
7+
const workbooks: WorkbookUtils[] = [];
8+
9+
test.afterEach(async ({ stockMovementService, stockMovementShowPage }) => {
10+
await stockMovementShowPage.goToPage(INBOUND_ID);
11+
await stockMovementShowPage.isLoaded();
12+
await stockMovementShowPage.rollbackButton.click();
13+
await stockMovementService.deleteStockMovement(INBOUND_ID);
14+
15+
for (const workbook of workbooks) {
16+
workbook.delete();
17+
}
18+
});
19+
20+
test('Export all incomming items should include items shipped not received', async ({
21+
otherProductService,
22+
mainProductService,
23+
mainUserService,
24+
inboundListPage,
25+
supplierLocationService,
26+
createInboundPage,
27+
stockMovementShowPage,
28+
stockMovementService,
29+
}) => {
30+
const ORIGIN = await supplierLocationService.getLocation();
31+
const DESCRIPTION = 'some description';
32+
const USER = await mainUserService.getUser();
33+
const TODAY = getToday();
34+
35+
const PRODUCT_ONE = await mainProductService.getProduct();
36+
const PRODUCT_TWO = await otherProductService.getProduct();
37+
const SHIPMENT_TYPE = 'Land';
38+
const EXPECTED_DELIVERY_DATE = getDateByOffset(TODAY, 1);
39+
40+
const ROWS = [
41+
{
42+
product: {
43+
productCode: PRODUCT_ONE.productCode,
44+
productName: PRODUCT_ONE.name,
45+
},
46+
quantity: '12',
47+
},
48+
{
49+
product: {
50+
productCode: PRODUCT_TWO.productCode,
51+
productName: PRODUCT_TWO.name,
52+
},
53+
quantity: '12',
54+
},
55+
];
56+
57+
await test.step('Go to create stock movement', async () => {
58+
await createInboundPage.goToPage();
59+
await createInboundPage.createStep.isLoaded();
60+
});
61+
62+
await test.step('Create Stock Movement step', async () => {
63+
await createInboundPage.createStep.originSelect.findAndSelectOption(
64+
ORIGIN.name
65+
);
66+
await createInboundPage.createStep.requestedBySelect.findAndSelectOption(
67+
USER.name
68+
);
69+
await createInboundPage.createStep.dateRequestedDatePicker.fill(TODAY);
70+
await createInboundPage.createStep.descriptionField.textbox.fill(
71+
DESCRIPTION
72+
);
73+
});
74+
75+
await test.step('Go next step (Add items)', async () => {
76+
await createInboundPage.nextButton.click();
77+
await createInboundPage.addItemsStep.isLoaded();
78+
});
79+
80+
INBOUND_ID = createInboundPage.getId();
81+
82+
await createInboundPage.addItemsStep.addItems(ROWS);
83+
84+
await test.step('Go to next step (Send)', async () => {
85+
await createInboundPage.nextButton.click();
86+
await createInboundPage.sendStep.isLoaded();
87+
});
88+
89+
await test.step('Fill shipment fields (Send)', async () => {
90+
await createInboundPage.sendStep.shipmentTypeSelect.findAndSelectOption(
91+
SHIPMENT_TYPE
92+
);
93+
await createInboundPage.sendStep.expectedDeliveryDatePicker.fill(
94+
EXPECTED_DELIVERY_DATE
95+
);
96+
});
97+
98+
await test.step('Send shipment', async () => {
99+
await createInboundPage.sendStep.sendShipmentButton.click();
100+
await stockMovementShowPage.waitForUrl();
101+
await stockMovementShowPage.isLoaded();
102+
});
103+
104+
await test.step('Go to inbound list page', async () => {
105+
await inboundListPage.goToPage();
106+
});
107+
108+
let filePath: string;
109+
let downloadedTemplateFile: WorkbookUtils;
110+
111+
await test.step('Download file', async () => {
112+
const { fullFilePath } = await inboundListPage.downloadAllIncomingItems();
113+
filePath = fullFilePath;
114+
});
115+
116+
await test.step('Read file', async () => {
117+
downloadedTemplateFile = WorkbookUtils.read(filePath);
118+
workbooks.push(downloadedTemplateFile);
119+
});
120+
121+
await test.step('Assert that both items from stock movement are included in the epxort file', async () => {
122+
const { data } = await stockMovementService.getStockMovement(INBOUND_ID);
123+
const fileData = downloadedTemplateFile.getData();
124+
125+
const stockMovementItemsFromFile = fileData.filter(
126+
(it) => it[5] === data.identifier
127+
);
128+
expect(stockMovementItemsFromFile).toHaveLength(2);
129+
});
130+
});
131+
});

src/tests/locationChooser/depotInLocationChooser.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import LocationData from '@/utils/LocationData';
1616
import UniqueIdentifier from '@/utils/UniqueIdentifier';
1717

1818
test.describe('Check if depot location is present in location chooser', () => {
19-
const uniqueIdentifier = new UniqueIdentifier();
19+
const uniqueIdentifier = new UniqueIdentifier({ separator: ' ' });
2020
const ORGANIZATION_NAME =
2121
uniqueIdentifier.generateUniqueString('test-Organization');
2222
const GROUP_NAME = uniqueIdentifier.generateUniqueString('test-Group');
@@ -144,9 +144,7 @@ test.describe('Check if depot location is present in location chooser', () => {
144144
});
145145

146146
await test.step('Delete created location group', async () => {
147-
await navbar.configurationButton.click();
148-
await navbar.locationGroup.click();
149-
await locationGroupsListPage.getPaginationItem('3').click();
147+
await locationGroupsListPage.goToPage({ max: 200 });
150148
await locationGroupsListPage.getLocationGroupnToEdit(GROUP_NAME).click();
151149
await editLocationGroupPage.clickDeleteLocationGroup();
152150
});

src/tests/receiving/lotExpirySystemUpdateOnReceiving.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ test.describe('Lot number system expiry date modification on receving workflow',
1010
test.afterEach(async ({ stockMovementShowPage, stockMovementService }) => {
1111
while (STOCK_MOVEMENTS.length > 0) {
1212
const STOCK_MOVEMENT = STOCK_MOVEMENTS.pop() as StockMovementResponse;
13-
13+
1414
await test.step(`Go to stock movement "${STOCK_MOVEMENT.id}" show page`, async () => {
1515
await stockMovementShowPage.goToPage(STOCK_MOVEMENT.id);
1616
await stockMovementShowPage.waitForUrl();

0 commit comments

Comments
 (0)