-
Notifications
You must be signed in to change notification settings - Fork 8.3k
/
Copy pathruntime_fields.ts
77 lines (71 loc) · 3.2 KB
/
runtime_fields.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../ftr_provider_context';
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['visualize', 'lens', 'common', 'header']);
const filterBar = getService('filterBar');
const fieldEditor = getService('fieldEditor');
const retry = getService('retry');
describe('lens runtime fields', () => {
it('should be able to add runtime field and use it', async () => {
await PageObjects.visualize.navigateToNewVisualization();
await PageObjects.visualize.clickVisType('lens');
await PageObjects.lens.goToTimeRange();
await PageObjects.lens.switchToVisualization('lnsDatatable');
await retry.try(async () => {
await PageObjects.lens.clickAddField();
await fieldEditor.setName('runtimefield');
await fieldEditor.enableValue();
await fieldEditor.typeScript("emit('abc')");
await fieldEditor.save();
await PageObjects.header.waitUntilLoadingHasFinished();
await PageObjects.lens.searchField('runtime');
await PageObjects.lens.waitForField('runtimefield');
await PageObjects.lens.dragFieldToWorkspace('runtimefield');
});
await PageObjects.lens.waitForVisualization();
expect(await PageObjects.lens.getDatatableHeaderText(0)).to.equal(
'Top values of runtimefield'
);
expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('abc');
});
it('should able to filter runtime fields', async () => {
await retry.try(async () => {
await PageObjects.lens.clickTableCellAction(0, 0, 'lensDatatableFilterOut');
await PageObjects.lens.waitForVisualization();
expect(await PageObjects.lens.isShowingNoResults()).to.equal(true);
});
await filterBar.removeAllFilters();
await PageObjects.lens.waitForVisualization();
});
it('should able to edit field', async () => {
await PageObjects.lens.clickField('runtimefield');
await PageObjects.lens.editField();
await fieldEditor.setName('runtimefield2', true, true);
await fieldEditor.save();
await fieldEditor.confirmSave();
await PageObjects.lens.searchField('runtime');
await PageObjects.lens.waitForField('runtimefield2');
await PageObjects.lens.dragFieldToDimensionTrigger(
'runtimefield2',
'lnsDatatable_rows > lns-dimensionTrigger'
);
await PageObjects.lens.waitForVisualization();
expect(await PageObjects.lens.getDatatableHeaderText(0)).to.equal(
'Top values of runtimefield2'
);
expect(await PageObjects.lens.getDatatableCellText(0, 0)).to.eql('abc');
});
it('should able to remove field', async () => {
await PageObjects.lens.clickField('runtimefield2');
await PageObjects.lens.removeField();
await fieldEditor.confirmDelete();
await PageObjects.lens.waitForFieldMissing('runtimefield2');
});
});
}