kibana/test/functional/apps/management/_scripted_fields_preview.js
Brandon Kobel 4584a8b570
Elastic License 2.0 (#90099)
* Updating everything except the license headers themselves

* Applying ESLint rules

* Manually replacing the stragglers
2021-02-03 18:12:39 -08:00

58 lines
2.3 KiB
JavaScript

/*
* 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 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import expect from '@kbn/expect';
export default function ({ getService, getPageObjects }) {
const browser = getService('browser');
const PageObjects = getPageObjects(['settings']);
const SCRIPTED_FIELD_NAME = 'myScriptedField';
// FLAKY: https://github.com/elastic/kibana/issues/89475
describe.skip('scripted fields preview', () => {
before(async function () {
await browser.setWindowSize(1200, 800);
await PageObjects.settings.createIndexPattern();
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.clickIndexPatternLogstash();
await PageObjects.settings.clickScriptedFieldsTab();
await PageObjects.settings.clickAddScriptedField();
await PageObjects.settings.setScriptedFieldName(SCRIPTED_FIELD_NAME);
});
after(async function afterAll() {
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.removeLogstashIndexPatternIfExist();
});
it('should display script error when script is invalid', async function () {
const scriptResults = await PageObjects.settings.executeScriptedField(
`i n v a l i d s c r i p t`
);
expect(scriptResults).to.contain('search_phase_execution_exception');
});
it('should display script results when script is valid', async function () {
const scriptResults = await PageObjects.settings.executeScriptedField(
`doc['bytes'].value * 2`
);
expect(scriptResults.replace(/\s/g, '')).to.contain('"myScriptedField":[6196');
});
it('should display additional fields', async function () {
const scriptResults = await PageObjects.settings.executeScriptedField(
`doc['bytes'].value * 2`,
['bytes']
);
expect(scriptResults.replace(/\s/g, '')).to.contain('"bytes":3098');
});
});
}