Skip to content

Commit 1c044c3

Browse files
Add functional test for cell expanded content popover
1 parent 09040ac commit 1c044c3

File tree

7 files changed

+56
-15
lines changed

7 files changed

+56
-15
lines changed

test/functional/apps/discover/_data_grid_doc_table.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ import expect from '@kbn/expect';
1010
import { FtrProviderContext } from '../../ftr_provider_context';
1111

1212
export default function ({ getService, getPageObjects }: FtrProviderContext) {
13+
const find = getService('find');
1314
const dataGrid = getService('dataGrid');
1415
const log = getService('log');
1516
const retry = getService('retry');
1617
const esArchiver = getService('esArchiver');
1718
const kibanaServer = getService('kibanaServer');
19+
const monacoEditor = getService('monacoEditor');
1820
const PageObjects = getPageObjects(['common', 'discover', 'header', 'timePicker']);
1921
const defaultSettings = {
2022
defaultIndex: 'logstash-*',
@@ -56,6 +58,24 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
5658
await PageObjects.timePicker.setDefaultAbsoluteRange();
5759
});
5860

61+
it('should show popover with expanded cell content by click on expand button', async () => {
62+
log.debug('open popover with expanded cell content to get json from the editor');
63+
const documentCell = await dataGrid.getCellElement(1, 3);
64+
await documentCell.click();
65+
const expandCellContentButton = await documentCell.findByClassName(
66+
'euiDataGridRowCell__expandButtonIcon'
67+
);
68+
await expandCellContentButton.click();
69+
const popoverJson = await monacoEditor.getCodeEditorValue();
70+
71+
log.debug('open expanded document flyout to get json');
72+
await dataGrid.clickRowToggle();
73+
await find.clickByCssSelectorWhenNotDisabled('#kbn_doc_viewer_tab_1');
74+
const flyoutJson = await monacoEditor.getCodeEditorValue();
75+
76+
expect(popoverJson).to.be(flyoutJson);
77+
});
78+
5979
describe('expand a document row', function () {
6080
const rowToInspect = 1;
6181

test/functional/apps/visualize/_inspector.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
1414
const log = getService('log');
1515
const inspector = getService('inspector');
1616
const filterBar = getService('filterBar');
17+
const monacoEditor = getService('monacoEditor');
1718
const testSubjects = getService('testSubjects');
1819
const PageObjects = getPageObjects(['visualize', 'visEditor', 'visChart', 'timePicker']);
1920

@@ -42,7 +43,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
4243
await inspector.openInspectorRequestsView();
4344
const requestTab = await inspector.getOpenRequestDetailRequestButton();
4445
await requestTab.click();
45-
const requestJSON = JSON.parse(await inspector.getCodeEditorValue());
46+
const requestJSON = JSON.parse(await monacoEditor.getCodeEditorValue());
4647

4748
expect(requestJSON.aggs['2'].max).property('missing', 10);
4849
});

test/functional/page_objects/tile_map_page.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export function TileMapPageProvider({ getService, getPageObjects }: FtrProviderC
1414
const retry = getService('retry');
1515
const log = getService('log');
1616
const inspector = getService('inspector');
17+
const monacoEditor = getService('monacoEditor');
1718
const { header } = getPageObjects(['header']);
1819

1920
class TileMapPage {
@@ -40,7 +41,7 @@ export function TileMapPageProvider({ getService, getPageObjects }: FtrProviderC
4041
await testSubjects.click('inspectorViewChooserRequests');
4142
await testSubjects.click('inspectorRequestDetailRequest');
4243

43-
return await inspector.getCodeEditorValue();
44+
return await monacoEditor.getCodeEditorValue();
4445
}
4546

4647
public async getMapBounds(): Promise<object> {

test/functional/services/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import { ListingTableProvider } from './listing_table';
4646
import { SavedQueryManagementComponentProvider } from './saved_query_management_component';
4747
import { KibanaSupertestProvider } from './supertest';
4848
import { MenuToggleProvider } from './menu_toggle';
49+
import { MonacoEditorProvider } from './monaco_editor';
4950

5051
export const services = {
5152
...commonServiceProviders,
@@ -81,5 +82,6 @@ export const services = {
8182
elasticChart: ElasticChartProvider,
8283
supertest: KibanaSupertestProvider,
8384
managementMenu: ManagementMenuProvider,
85+
monacoEditor: MonacoEditorProvider,
8486
MenuToggle: MenuToggleProvider,
8587
};

test/functional/services/inspector.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -235,18 +235,6 @@ export function InspectorProvider({ getService }: FtrProviderContext) {
235235
public getOpenRequestDetailResponseButton() {
236236
return testSubjects.find('inspectorRequestDetailResponse');
237237
}
238-
239-
public async getCodeEditorValue() {
240-
let request: string = '';
241-
242-
await retry.try(async () => {
243-
request = await browser.execute(
244-
() => (window as any).MonacoEnvironment.monaco.editor.getModels()[0].getValue() as string
245-
);
246-
});
247-
248-
return request;
249-
}
250238
}
251239

252240
return new Inspector();
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0 and the Server Side Public License, v 1; you may not use this file except
5+
* in compliance with, at your election, the Elastic License 2.0 or the Server
6+
* Side Public License, v 1.
7+
*/
8+
9+
import { FtrProviderContext } from '../ftr_provider_context';
10+
11+
export function MonacoEditorProvider({ getService }: FtrProviderContext) {
12+
const retry = getService('retry');
13+
const browser = getService('browser');
14+
15+
return new (class MonacoEditor {
16+
public async getCodeEditorValue() {
17+
let request: string = '';
18+
19+
await retry.try(async () => {
20+
request = await browser.execute(
21+
() => (window as any).MonacoEnvironment.monaco.editor.getModels()[0].getValue() as string
22+
);
23+
});
24+
25+
return request;
26+
}
27+
})();
28+
}

x-pack/test/functional/apps/maps/documents_source/docvalue_fields.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import expect from '@kbn/expect';
1010
export default function ({ getPageObjects, getService }) {
1111
const PageObjects = getPageObjects(['maps']);
1212
const inspector = getService('inspector');
13+
const monacoEditor = getService('monacoEditor');
1314
const testSubjects = getService('testSubjects');
1415
const security = getService('security');
1516

@@ -27,7 +28,7 @@ export default function ({ getPageObjects, getService }) {
2728
await inspector.open();
2829
await inspector.openInspectorRequestsView();
2930
await testSubjects.click('inspectorRequestDetailResponse');
30-
const responseBody = await inspector.getCodeEditorValue();
31+
const responseBody = await monacoEditor.getCodeEditorValue();
3132
await inspector.close();
3233
return JSON.parse(responseBody);
3334
}

0 commit comments

Comments
 (0)