From 9561ecf76e6f347b77821e2c1c650d80bbc0736a Mon Sep 17 00:00:00 2001 From: Maja Grubic Date: Tue, 2 Mar 2021 16:36:33 +0000 Subject: [PATCH] Adding a functional test --- test/functional/apps/dashboard/index.ts | 1 + .../apps/dashboard/saved_search_embeddable.ts | 63 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 test/functional/apps/dashboard/saved_search_embeddable.ts diff --git a/test/functional/apps/dashboard/index.ts b/test/functional/apps/dashboard/index.ts index 212e747fadd97..d7bd9f6b51522 100644 --- a/test/functional/apps/dashboard/index.ts +++ b/test/functional/apps/dashboard/index.ts @@ -57,6 +57,7 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) { loadTestFile(require.resolve('./dashboard_back_button')); loadTestFile(require.resolve('./dashboard_error_handling')); loadTestFile(require.resolve('./legacy_urls')); + loadTestFile(require.resolve('./saved_search_embeddable')); // Note: This one must be last because it unloads some data for one of its tests! // No, this isn't ideal, but loading/unloading takes so much time and these are all bunched diff --git a/test/functional/apps/dashboard/saved_search_embeddable.ts b/test/functional/apps/dashboard/saved_search_embeddable.ts new file mode 100644 index 0000000000000..71f19b23da9dd --- /dev/null +++ b/test/functional/apps/dashboard/saved_search_embeddable.ts @@ -0,0 +1,63 @@ +/* + * 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'; +import { FtrProviderContext } from '../../ftr_provider_context'; + +export default function ({ getService, getPageObjects }: FtrProviderContext) { + const dashboardAddPanel = getService('dashboardAddPanel'); + const filterBar = getService('filterBar'); + const find = getService('find'); + const esArchiver = getService('esArchiver'); + const kibanaServer = getService('kibanaServer'); + const PageObjects = getPageObjects(['common', 'dashboard', 'header', 'timePicker', 'discover']); + + describe('dashboard saved search embeddable', () => { + before(async () => { + await esArchiver.loadIfNeeded('logstash_functional'); + await esArchiver.loadIfNeeded('dashboard/current/data'); + await esArchiver.loadIfNeeded('dashboard/current/kibana'); + await kibanaServer.uiSettings.replace({ + defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c', + }); + await PageObjects.common.navigateToApp('dashboard'); + await filterBar.ensureFieldEditorModalIsClosed(); + await PageObjects.dashboard.gotoDashboardLandingPage(); + await PageObjects.dashboard.clickNewDashboard(); + await PageObjects.timePicker.setAbsoluteRange( + 'Sep 22, 2015 @ 00:00:00.000', + 'Sep 23, 2015 @ 00:00:00.000' + ); + }); + + it('highlighting on filtering works', async function () { + await dashboardAddPanel.addSavedSearch('Rendering-Test:-saved-search'); + await filterBar.addFilter('agent', 'is', 'Mozilla'); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.dashboard.waitForRenderComplete(); + const dataTable = await find.byCssSelector(`[data-test-subj="embeddedSavedSearchDocTable"]`); + const $ = await dataTable.parseDomContent(); + const marks = $('mark') + .toArray() + .map((mark) => $(mark).text()); + expect(marks.length).to.be(50); + }); + + it('removing a filter removes highlights', async function () { + await filterBar.removeAllFilters(); + await PageObjects.header.waitUntilLoadingHasFinished(); + await PageObjects.dashboard.waitForRenderComplete(); + const dataTable = await find.byCssSelector(`[data-test-subj="embeddedSavedSearchDocTable"]`); + const $ = await dataTable.parseDomContent(); + const marks = $('mark') + .toArray() + .map((mark) => $(mark).text()); + expect(marks.length).to.be(0); + }); + }); +}