mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* [Discover] fix csv report for filtered discover result on dashboard * [Discover] fix tests * [Discover] add functional test * [Discover] fix the case when timeFilter was not applied, but others filters were applied for non time based data views Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> # Conflicts: # src/plugins/discover/public/application/apps/main/utils/get_sharing_data.ts Co-authored-by: Dmitry Tomashevich <39378793+Dmitriynj@users.noreply.github.com>
This commit is contained in:
parent
ecd74c0864
commit
56d52f71aa
3 changed files with 86 additions and 4 deletions
|
@ -9,7 +9,7 @@
|
|||
import type { Capabilities } from 'kibana/public';
|
||||
import type { IUiSettingsClient } from 'src/core/public';
|
||||
import type { DataPublicPluginStart } from 'src/plugins/data/public';
|
||||
import type { ISearchSource, SearchSourceFields } from 'src/plugins/data/common';
|
||||
import type { Filter, ISearchSource, SearchSourceFields } from 'src/plugins/data/common';
|
||||
import { DOC_HIDE_TIME_COLUMN_SETTING, SORT_DEFAULT_ORDER_SETTING } from '../../../../../common';
|
||||
import type { SavedSearch, SortOrder } from '../../../../saved_searches';
|
||||
import { getSortForSearchSource } from '../components/doc_table';
|
||||
|
@ -26,6 +26,7 @@ export async function getSharingData(
|
|||
const { uiSettings: config, data } = services;
|
||||
const searchSource = currentSearchSource.createCopy();
|
||||
const index = searchSource.getField('index')!;
|
||||
const existingFilter = searchSource.getField('filter');
|
||||
|
||||
searchSource.setField(
|
||||
'sort',
|
||||
|
@ -55,11 +56,21 @@ export async function getSharingData(
|
|||
|
||||
return {
|
||||
getSearchSource: (absoluteTime?: boolean): SearchSourceFields => {
|
||||
const filter = absoluteTime
|
||||
const timeFilter = absoluteTime
|
||||
? data.query.timefilter.timefilter.createFilter(index)
|
||||
: data.query.timefilter.timefilter.createRelativeFilter(index);
|
||||
|
||||
searchSource.setField('filter', filter);
|
||||
if (existingFilter && timeFilter) {
|
||||
searchSource.setField(
|
||||
'filter',
|
||||
Array.isArray(existingFilter)
|
||||
? [timeFilter, ...existingFilter]
|
||||
: ([timeFilter, existingFilter] as Filter[])
|
||||
);
|
||||
} else {
|
||||
const filter = timeFilter || existingFilter;
|
||||
searchSource.setField('filter', filter);
|
||||
}
|
||||
|
||||
return searchSource.getSerializedFields(true);
|
||||
},
|
||||
|
|
|
@ -562,6 +562,37 @@ exports[`dashboard Reporting Download CSV E-Commerce Data Downloads a filtered C
|
|||
"
|
||||
`;
|
||||
|
||||
exports[`dashboard Reporting Download CSV E-Commerce Data Downloads filtered Discover saved search report 1`] = `
|
||||
"\\"order_date\\",\\"customer_first_name\\",\\"customer_last_name\\",\\"customer_full_name\\"
|
||||
\\"Jun 25, 2019 @ 00:00:00.000\\",Betty,Reese,\\"Betty Reese\\"
|
||||
\\"Jun 25, 2019 @ 00:00:00.000\\",Betty,Brewer,\\"Betty Brewer\\"
|
||||
\\"Jun 25, 2019 @ 00:00:00.000\\",Betty,Bryant,\\"Betty Bryant\\"
|
||||
\\"Jun 25, 2019 @ 00:00:00.000\\",Betty,Perkins,\\"Betty Perkins\\"
|
||||
\\"Jun 24, 2019 @ 00:00:00.000\\",Betty,Stokes,\\"Betty Stokes\\"
|
||||
\\"Jun 24, 2019 @ 00:00:00.000\\",Betty,Jackson,\\"Betty Jackson\\"
|
||||
\\"Jun 24, 2019 @ 00:00:00.000\\",Betty,Farmer,\\"Betty Farmer\\"
|
||||
\\"Jun 24, 2019 @ 00:00:00.000\\",Betty,Rivera,\\"Betty Rivera\\"
|
||||
\\"Jun 23, 2019 @ 00:00:00.000\\",Betty,King,\\"Betty King\\"
|
||||
\\"Jun 23, 2019 @ 00:00:00.000\\",Betty,Graham,\\"Betty Graham\\"
|
||||
\\"Jun 23, 2019 @ 00:00:00.000\\",Betty,Allison,\\"Betty Allison\\"
|
||||
\\"Jun 23, 2019 @ 00:00:00.000\\",Betty,Gilbert,\\"Betty Gilbert\\"
|
||||
\\"Jun 22, 2019 @ 00:00:00.000\\",Betty,Jimenez,\\"Betty Jimenez\\"
|
||||
\\"Jun 22, 2019 @ 00:00:00.000\\",Betty,Fletcher,\\"Betty Fletcher\\"
|
||||
\\"Jun 22, 2019 @ 00:00:00.000\\",Betty,Mccarthy,\\"Betty Mccarthy\\"
|
||||
\\"Jun 22, 2019 @ 00:00:00.000\\",Betty,Bryant,\\"Betty Bryant\\"
|
||||
\\"Jun 22, 2019 @ 00:00:00.000\\",Betty,Maldonado,\\"Betty Maldonado\\"
|
||||
\\"Jun 22, 2019 @ 00:00:00.000\\",Betty,Ruiz,\\"Betty Ruiz\\"
|
||||
\\"Jun 22, 2019 @ 00:00:00.000\\",Betty,Morrison,\\"Betty Morrison\\"
|
||||
\\"Jun 22, 2019 @ 00:00:00.000\\",Betty,Cross,\\"Betty Cross\\"
|
||||
\\"Jun 22, 2019 @ 00:00:00.000\\",Betty,Swanson,\\"Betty Swanson\\"
|
||||
\\"Jun 21, 2019 @ 00:00:00.000\\",Betty,Bryan,\\"Betty Bryan\\"
|
||||
\\"Jun 21, 2019 @ 00:00:00.000\\",Betty,Thompson,\\"Betty Thompson\\"
|
||||
\\"Jun 21, 2019 @ 00:00:00.000\\",Betty,Ramsey,\\"Betty Ramsey\\"
|
||||
\\"Jun 21, 2019 @ 00:00:00.000\\",Betty,Webb,\\"Betty Webb\\"
|
||||
\\"Jun 21, 2019 @ 00:00:00.000\\",Betty,Massey,\\"Betty Massey\\"
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`dashboard Reporting Download CSV Field Formatters and Scripted Fields Download CSV export of a saved search panel 1`] = `
|
||||
"date,\\"_id\\",name,gender,value,year,\\"years_ago\\",\\"date_informal\\"
|
||||
\\"Jan 1, 1982 @ 00:00:00.000\\",\\"1982-Fethany-F\\",Fethany,F,780,1982,\\"37.00000000000000000000\\",\\"Jan 1st 82\\"
|
||||
|
|
|
@ -22,7 +22,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
const filterBar = getService('filterBar');
|
||||
const find = getService('find');
|
||||
const retry = getService('retry');
|
||||
const PageObjects = getPageObjects(['reporting', 'common', 'dashboard', 'timePicker']);
|
||||
const PageObjects = getPageObjects([
|
||||
'reporting',
|
||||
'common',
|
||||
'dashboard',
|
||||
'timePicker',
|
||||
'discover',
|
||||
]);
|
||||
const dashboardAddPanel = getService('dashboardAddPanel');
|
||||
|
||||
const ecommerceSOPath = 'x-pack/test/functional/fixtures/kbn_archiver/reporting/ecommerce.json';
|
||||
const ecommerceDataPath = 'x-pack/test/functional/es_archives/reporting/ecommerce';
|
||||
|
@ -121,6 +128,39 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
|||
const csvFile = await getDownload(getCsvPath('Ecommerce Data')); // file exists with proper name
|
||||
expect(csvFile).to.not.be(null);
|
||||
});
|
||||
|
||||
it('Downloads filtered Discover saved search report', async () => {
|
||||
const setTimeRange = async () => {
|
||||
const fromTime = 'Jun 20, 2019 @ 23:56:51.374';
|
||||
const toTime = 'Jun 25, 2019 @ 16:18:51.821';
|
||||
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
|
||||
};
|
||||
|
||||
PageObjects.common.navigateToApp('discover');
|
||||
await setTimeRange();
|
||||
await PageObjects.discover.selectIndexPattern('ecommerce');
|
||||
await PageObjects.discover.clickNewSearchButton();
|
||||
|
||||
await PageObjects.discover.clickFieldListItemAdd('customer_first_name');
|
||||
await PageObjects.discover.clickFieldListItemAdd('customer_last_name');
|
||||
await PageObjects.discover.clickFieldListItemAdd('customer_full_name');
|
||||
await filterBar.addFilter('customer_first_name', 'is', 'Betty');
|
||||
await PageObjects.discover.saveSearch('search-by-name');
|
||||
|
||||
await PageObjects.common.navigateToApp('dashboard');
|
||||
await PageObjects.dashboard.gotoDashboardLandingPage();
|
||||
await PageObjects.dashboard.clickNewDashboard();
|
||||
await setTimeRange();
|
||||
await dashboardAddPanel.addSavedSearch('search-by-name');
|
||||
await PageObjects.dashboard.saveDashboard('filtered-result');
|
||||
|
||||
await PageObjects.dashboard.clickCancelOutOfEditMode();
|
||||
await clickActionsMenu('search-by-name');
|
||||
await clickDownloadCsv();
|
||||
|
||||
const csvFile = await getDownload(getCsvPath('search-by-name'));
|
||||
expectSnapshot(csvFile).toMatch();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Field Formatters and Scripted Fields', () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue