Skip to content

Commit e726277

Browse files
gurbirkalsiportante
authored andcommitted
Enhance search page component e2e test verification with pattern
matching against mocked data
1 parent 58655b2 commit e726277

File tree

2 files changed

+61
-39
lines changed

2 files changed

+61
-39
lines changed

web-server/v0.4/mock/api.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ export const mockMappings = {
7474
user: { type: 'string', index: 'not_analyzed' },
7575
},
7676
},
77+
'@metadata': {
78+
properties: {
79+
controller_dir: { type: 'string', index: 'not_analyzed' },
80+
},
81+
},
7782
},
7883
},
7984
},
@@ -92,6 +97,9 @@ export const mockSearch = {
9297
script: 'test',
9398
user: 'test_user',
9499
},
100+
'@metadata': {
101+
controller_dir: 'test_controller',
102+
},
95103
},
96104
},
97105
],

web-server/v0.4/src/e2e/search.e2e.js

Lines changed: 53 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -45,55 +45,69 @@ afterAll(() => {
4545
});
4646

4747
describe('search page component', () => {
48-
test(
49-
'should load run mapping',
50-
async done => {
51-
await page.waitForSelector('.ant-table-tbody', { visible: true });
52-
done();
53-
},
54-
30000
55-
);
48+
test('should load month indices', async () => {
49+
await page.waitForSelector(
50+
'.ant-form-item-control > .ant-form-item-children > .ant-select > .ant-select-selection > .ant-select-selection__rendered'
51+
);
52+
const testMonth = await page.$eval(
53+
'.ant-select-selection > .ant-select-selection__rendered > ul > li.ant-select-selection__choice',
54+
elem => elem.getAttribute('title')
55+
);
56+
expect(testMonth).toBe(mockIndices[0].index.split('.').pop());
57+
});
58+
59+
test('should load mappings', async () => {
60+
await page.waitForSelector(
61+
'div.ant-col.ant-col-md-24.ant-col-lg-7 > div > div.ant-card-body > div:nth-child(2) > p:nth-child(2) > span:nth-child(1)'
62+
);
63+
const testField = await page.$eval(
64+
'div.ant-col.ant-col-md-24.ant-col-lg-7 > div > div.ant-card-body > div:nth-child(2) > p:nth-child(2) > span:nth-child(1)',
65+
elem => elem.innerHTML
66+
);
67+
expect(testField).toBe('config');
68+
});
69+
70+
test('should select month index', async () => {
71+
await page.waitForSelector('.ant-select-selection', { visible: true });
72+
await page.click('.ant-select-selection');
73+
await page.click('.ant-select-dropdown-menu-item');
74+
await page.click('.ant-select-dropdown-menu-item[aria-selected="false"]');
75+
});
5676

57-
test('should select search filter tag', async () => {
77+
test('should select field tag', async () => {
5878
await page.waitForSelector('.ant-tag', { visible: true });
5979
await page.click('.ant-tag');
6080
});
6181

62-
test('should reset search filter tags', async () => {
63-
await page.waitForSelector('button[name="Reset"]', { visible: true });
64-
await page.click('button[name="Reset"]');
82+
test('should apply filter changes', async () => {
83+
await page.waitForSelector(
84+
'.ant-card-head > .ant-card-head-wrapper > .ant-card-extra > div > .ant-btn-primary'
85+
);
86+
await page.click(
87+
'.ant-card-head > .ant-card-head-wrapper > .ant-card-extra > div > .ant-btn-primary'
88+
);
89+
});
90+
91+
test('should reset filter changes', async () => {
92+
await page.waitForSelector(
93+
'.ant-card-head > .ant-card-head-wrapper > .ant-card-extra > div > .ant-btn:nth-child(1)'
94+
);
95+
await page.click(
96+
'.ant-card-head > .ant-card-head-wrapper > .ant-card-extra > div > .ant-btn:nth-child(1)'
97+
);
6598
});
6699

67100
test('should input search query', async () => {
68101
await page.type('.ant-input', 'test', { delay: 50 });
69102
});
70103

71-
test(
72-
'should execute search query',
73-
async () => {
74-
await page.waitForSelector('.ant-input-search-button', { visible: true });
75-
await page.click('.ant-input-search-button');
76-
await page.waitForResponse(response => response.status() === 200);
77-
},
78-
30000
79-
);
80-
81-
test('should select month index', async () => {
82-
await page.waitForSelector('.ant-select-selection', { visible: true });
83-
await page.click('.ant-select-selection');
84-
await page.click('.ant-select-dropdown-menu-item');
85-
await page.click('.ant-select-dropdown-menu-item[aria-selected="false"]');
104+
test('should execute search query', async () => {
105+
await page.waitForSelector('.ant-input-search-button', { visible: true });
106+
await page.click('.ant-input-search-button');
107+
const testResult = await page.$eval(
108+
'.ant-table-tbody > tr > td:nth-child(2)',
109+
elem => elem.innerHTML
110+
);
111+
expect(testResult).toBe('test_run');
86112
});
87-
88-
test(
89-
'should update search results for selected month index',
90-
async done => {
91-
await page.waitForSelector('button[name="Apply"]', { visible: true });
92-
await page.click('button[name="Apply"]');
93-
await page.waitForResponse(response => response.status() === 200);
94-
await page.waitForSelector('.ant-table-tbody', { visible: true });
95-
done();
96-
},
97-
30000
98-
);
99113
});

0 commit comments

Comments
 (0)