Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding sorting test to scripted fields in discover #75520

Merged
merged 10 commits into from
Aug 24, 2020
96 changes: 91 additions & 5 deletions test/functional/apps/management/_scripted_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ export default function ({ getService, getPageObjects }) {
await kibanaServer.uiSettings.update({});
});

after(async function afterAll() {
await PageObjects.settings.navigateTo();
await PageObjects.settings.clickKibanaIndexPatterns();
await PageObjects.settings.removeLogstashIndexPatternIfExist();
});
// after(async function afterAll() {
// await PageObjects.settings.navigateTo();
// await PageObjects.settings.clickKibanaIndexPatterns();
// await PageObjects.settings.removeLogstashIndexPatternIfExist();
// });
rashmivkulkarni marked this conversation as resolved.
Show resolved Hide resolved

it('should not allow saving of invalid scripts', async function () {
await PageObjects.settings.navigateTo();
Expand Down Expand Up @@ -165,6 +165,27 @@ export default function ({ getService, getPageObjects }) {
});
});

//add a test to sort numeric scripted field
it('should sort scripted field value in Discover', async function () {
await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName}`);
// after the first click on the scripted field, it becomes secondary sort after time.
// click on the timestamp twice to make it be the secondary sort key.
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 17, 2015 @ 10:53:14.181\n-1');
});

await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName}`);
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 17, 2015 @ 06:32:29.479\n20');
});
});

it('should filter by scripted field value in Discover', async function () {
await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName);
await log.debug('filter by the first value (14) in the expanded scripted field list');
Expand Down Expand Up @@ -252,6 +273,27 @@ export default function ({ getService, getPageObjects }) {
});
});

//add a test to sort string scripted field
it('should sort scripted field value in Discover', async function () {
await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
// after the first click on the scripted field, it becomes secondary sort after time.
// click on the timestamp twice to make it be the secondary sort key.
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 17, 2015 @ 09:48:40.594\nbad');
});

await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 17, 2015 @ 06:32:29.479\ngood');
});
});

it('should filter by scripted field value in Discover', async function () {
await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName2);
await log.debug('filter by "bad" in the expanded scripted field list');
Expand Down Expand Up @@ -330,6 +372,28 @@ export default function ({ getService, getPageObjects }) {
await filterBar.removeAllFilters();
});

//add a test to sort boolean
//existing bug: https://github.com/elastic/kibana/issues/75519 hence the issue is skipped.
it.skip('should sort scripted field value in Discover', async function () {
await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
// after the first click on the scripted field, it becomes secondary sort after time.
// click on the timestamp twice to make it be the secondary sort key.
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 18, 2015 @ 18:20:57.916\ntrue');
rashmivkulkarni marked this conversation as resolved.
Show resolved Hide resolved
});

await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 18, 2015 @ 18:20:57.916\nfalse');
});
});

it('should visualize scripted field in vertical bar chart', async function () {
await PageObjects.discover.clickFieldListItemVisualize(scriptedPainlessFieldName2);
await PageObjects.header.waitUntilLoadingHasFinished();
Expand Down Expand Up @@ -384,6 +448,28 @@ export default function ({ getService, getPageObjects }) {
});
});

//add a test to sort date scripted field
//https://github.com/elastic/kibana/issues/75711
it.skip('should sort scripted field value in Discover', async function () {
await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
// after the first click on the scripted field, it becomes secondary sort after time.
// click on the timestamp twice to make it be the secondary sort key.
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await testSubjects.click('docTableHeaderFieldSort_@timestamp');
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 18, 2015 @ 06:52:55.953\n2015-09-18 07:00');
});

await testSubjects.click(`docTableHeaderFieldSort_${scriptedPainlessFieldName2}`);
await PageObjects.header.waitUntilLoadingHasFinished();
await retry.try(async function () {
const rowData = await PageObjects.discover.getDocTableIndex(1);
expect(rowData).to.be('Sep 17, 2015 @ 06:32:29.479\n2015-09-18 07:00');
});
});

it('should filter by scripted field value in Discover', async function () {
await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName2);
await log.debug('filter by "Sep 17, 2015 @ 23:00" in the expanded scripted field list');
Expand Down
8 changes: 4 additions & 4 deletions test/functional/apps/management/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export default function ({ getService, loadTestFile }) {
await esArchiver.loadIfNeeded('makelogs');
});

after(async () => {
await esArchiver.unload('makelogs');
await esArchiver.unload('empty_kibana');
});
// after(async () => {
// await esArchiver.unload('makelogs');
// await esArchiver.unload('empty_kibana');
// });

rashmivkulkarni marked this conversation as resolved.
Show resolved Hide resolved
describe('', function () {
this.tags('ciGroup7');
Expand Down
38 changes: 38 additions & 0 deletions x-pack/test/accessibility/apps/painless_lab.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import expect from '@kbn/expect';
import { FtrProviderContext } from '../ftr_provider_context';

export default function ({ getService, getPageObjects }: FtrProviderContext) {
const PageObjects = getPageObjects(['common', 'security']);
const testSubjects = getService('testSubjects');
const find = getService('find');
const a11y = getService('a11y');

describe('Accessibility Painless Lab Editor', () => {
before(async () => {
await PageObjects.common.navigateToApp('painlessLab');
await a11y.testAppSnapshot();
expect(await testSubjects.exists('painless_lab')).to.be(true);
});

it('click on the output button', async () => {
const painlessTabs = await find.byCssSelector('[data-test-subj="painlessTabs"] #output');
await a11y.testAppSnapshot();
});

it('click on the parameters button', async () => {
const painlessTabs = await find.byCssSelector('[data-test-subj="painlessTabs"] #parameters');
await a11y.testAppSnapshot();
});

it('click on the context button', async () => {
const painlessTabs = await find.byCssSelector('[data-test-subj="painlessTabs"] #context');
await a11y.testAppSnapshot();
});
});
}