migrate discover session multiple data view test to discover (#213991)

Closes https://github.com/elastic/kibana/issues/191880

Skipped test had the following problems
* installed/uninstall sample data through the UI
* Generated new dashboard
* Tested discover session embeddable specific code.

This PR resolves these problems by
* Using already installed test data and avoiding UI flakiness of
installing/uninstalling sample data
* Uses pre-built dashboard
* moves test to discover app since its testing the discover session
embeddable and is not dashboard specific.

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Nathan Reese 2025-03-11 15:27:47 -06:00 committed by GitHub
parent e2772d8dc5
commit b7ce4e4f24
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 129 additions and 77 deletions

View file

@ -31,6 +31,5 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./dashboard_filter_bar'));
loadTestFile(require.resolve('./dashboard_filtering'));
loadTestFile(require.resolve('./panel_expand_toggle'));
loadTestFile(require.resolve('./multiple_data_views'));
});
}

View file

@ -1,76 +0,0 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import expect from '@kbn/expect';
import { FtrProviderContext } from '../../../ftr_provider_context';
/**
* Test the filtering behavior of a dashboard with multiple data views
*/
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const dashboardAddPanel = getService('dashboardAddPanel');
const testSubjects = getService('testSubjects');
const filterBar = getService('filterBar');
const kibanaServer = getService('kibanaServer');
const { common, dashboard, timePicker, home } = getPageObjects([
'common',
'dashboard',
'timePicker',
'home',
]);
// Failing: See https://github.com/elastic/kibana/issues/191880
describe.skip('dashboard multiple data views', () => {
before(async () => {
await kibanaServer.uiSettings.update({ 'courier:ignoreFilterIfFieldNotInIndex': true });
await common.navigateToApp('home');
await home.goToSampleDataPage();
await home.addSampleDataSet('flights');
await home.addSampleDataSet('logs');
await dashboard.navigateToApp();
await dashboard.gotoDashboardLandingPage();
await dashboard.clickNewDashboard();
await dashboardAddPanel.addSavedSearches(['[Flights] Flight Log', '[Logs] Visits']);
await dashboard.waitForRenderComplete();
await timePicker.setCommonlyUsedTime('This_week');
});
after(async () => {
await common.navigateToApp('home');
await home.goToSampleDataPage();
await home.removeSampleDataSet('flights');
await home.removeSampleDataSet('logs');
await kibanaServer.uiSettings.unset('courier:ignoreFilterIfFieldNotInIndex');
});
it('ignores filters on panels using a data view without the filter field', async () => {
await filterBar.addFilter({ field: 'Carrier', operation: 'exists' });
const logsSavedSearchPanel = (await testSubjects.findAll('embeddedSavedSearchDocTable'))[1];
expect(
await (
await logsSavedSearchPanel.findByCssSelector('[data-document-number]')
).getAttribute('data-document-number')
).to.not.be('0');
});
it('applies filters on panels using a data view without the filter field', async () => {
await kibanaServer.uiSettings.update({ 'courier:ignoreFilterIfFieldNotInIndex': false });
await dashboard.navigateToApp();
await testSubjects.click('edit-unsaved-New-Dashboard');
await dashboard.waitForRenderComplete();
const logsSavedSearchPanel = (await testSubjects.findAll('embeddedSavedSearchDocTable'))[1];
expect(
await (
await logsSavedSearchPanel.findByCssSelector('[data-document-number]')
).getAttribute('data-document-number')
).to.be('0');
});
});
}

View file

@ -23,5 +23,6 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
});
loadTestFile(require.resolve('./_saved_search_embeddable'));
loadTestFile(require.resolve('./multiple_data_views'));
});
}

View file

@ -0,0 +1,73 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
* License v3.0 only", 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 dashboardExpect = getService('dashboardExpect');
const esArchiver = getService('esArchiver');
const kibanaServer = getService('kibanaServer');
const testSubjects = getService('testSubjects');
const { dashboard } = getPageObjects(['dashboard']);
describe('discover session multiple data views', () => {
before(async () => {
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/logstash_functional');
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/dashboard/current/data');
await kibanaServer.savedObjects.cleanStandardList();
await kibanaServer.importExport.load(
'test/functional/fixtures/kbn_archiver/dashboard/current/kibana'
);
await kibanaServer.uiSettings.replace({
defaultIndex: '0bf35f60-3dc9-11e8-8660-4d65aa086b3c',
});
});
after(async () => {
await kibanaServer.savedObjects.cleanStandardList();
});
describe('courier:ignoreFilterIfFieldNotInIndex disabled', () => {
before(async () => {
await dashboard.navigateToApp();
await dashboard.loadSavedDashboard('discover session multiple data views');
await dashboard.waitForRenderComplete();
});
it('Should display no results from logstash-* when filtered by animals data view', async function () {
await dashboard.waitForRenderComplete();
await dashboardExpect.savedSearchNoResult();
});
});
describe('courier:ignoreFilterIfFieldNotInIndex enabled', () => {
before(async () => {
await kibanaServer.uiSettings.update({ 'courier:ignoreFilterIfFieldNotInIndex': true });
await dashboard.navigateToApp();
await dashboard.loadSavedDashboard('discover session multiple data views');
await dashboard.waitForRenderComplete();
});
after(async () => {
await kibanaServer.uiSettings.unset('courier:ignoreFilterIfFieldNotInIndex');
});
it('Should display results from logstash-* when filtered by animals data view', async function () {
const logstashSavedSearchPanel = await testSubjects.find('embeddedSavedSearchDocTable');
expect(
await (
await logstashSavedSearchPanel.findByCssSelector('[data-document-number]')
).getAttribute('data-document-number')
).to.be('500');
});
});
});
}

View file

@ -3329,4 +3329,59 @@
"managed": false,
"coreMigrationVersion": "8.8.0",
"typeMigrationVersion": "10.2.0"
}
{
"id": "ce023765-c6b8-4198-8d0b-318229c2294b",
"type": "dashboard",
"namespaces": [
"default"
],
"updated_at": "2025-03-11T18:18:29.712Z",
"created_at": "2025-03-11T18:18:23.099Z",
"version": "WzExNSwxXQ==",
"attributes": {
"version": 3,
"description": "",
"refreshInterval": {
"pause": true,
"value": 60000
},
"timeRestore": true,
"timeFrom": "now-15y",
"title": "discover session multiple data views",
"timeTo": "now",
"controlGroupInput": {
"chainingSystem": "HIERARCHICAL",
"controlStyle": "oneLine",
"ignoreParentSettingsJSON": "{\"ignoreFilters\":false,\"ignoreQuery\":false,\"ignoreTimerange\":false,\"ignoreValidations\":false}",
"panelsJSON": "{}",
"showApplySelections": false
},
"optionsJSON": "{\"useMargins\":true,\"syncColors\":false,\"syncCursor\":true,\"syncTooltips\":false,\"hidePanelTitles\":false}",
"panelsJSON": "[{\"type\":\"search\",\"title\":\"Rendering Test: saved search\",\"panelRefName\":\"panel_acc95967-6664-4922-b4e8-5cdeed30d5d8\",\"embeddableConfig\":{\"description\":\"\",\"enhancements\":{\"dynamicActions\":{\"events\":[]}},\"columns\":[\"bytes\",\"clientip\"],\"rowsPerPage\":10,\"grid\":{}},\"panelIndex\":\"acc95967-6664-4922-b4e8-5cdeed30d5d8\",\"gridData\":{\"x\":0,\"y\":0,\"w\":24,\"h\":15,\"i\":\"acc95967-6664-4922-b4e8-5cdeed30d5d8\"}}]",
"kibanaSavedObjectMeta": {
"searchSourceJSON": "{\"filter\":[{\"meta\":{\"disabled\":false,\"negate\":false,\"alias\":null,\"key\":\"animal\",\"field\":\"animal\",\"type\":\"exists\",\"indexRefName\":\"kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index\"},\"query\":{\"exists\":{\"field\":\"animal\"}},\"$state\":{\"store\":\"appState\"}}],\"query\":{\"query\":\"\",\"language\":\"kuery\"}}"
}
},
"references": [
{
"name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index",
"type": "index-pattern",
"id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c"
},
{
"name": "acc95967-6664-4922-b4e8-5cdeed30d5d8:panel_acc95967-6664-4922-b4e8-5cdeed30d5d8",
"type": "search",
"id": "be5accf0-3dca-11e8-8660-4d65aa086b3c"
},
{
"name": "kibanaSavedObjectMeta.searchSourceJSON.filter[0].meta.index",
"type": "index-pattern",
"id": "a0f483a0-3dc9-11e8-8660-4d65aa086b3c"
}
],
"managed": false,
"coreMigrationVersion": "8.8.0",
"typeMigrationVersion": "10.2.0"
}