From 69a8d061299c10075d34d26bb0359a77778a8f70 Mon Sep 17 00:00:00 2001 From: Tim Sullivan Date: Thu, 27 Aug 2020 08:40:56 -0700 Subject: [PATCH] [Reporting/Download CSV] Get the file name from savedSearch data (#76031) * [Reporting/Download CSV] provide title even if panel \titles are hidden in the dashboard * add functional test * Update embeddable_panel.tsx * Update download_csv.ts --- .../public/lib/panel/embeddable_panel.tsx | 1 + .../panel_actions/get_csv_panel_action.tsx | 2 +- .../apps/dashboard/reporting/download_csv.ts | 46 +++++++++++++----- .../reporting/ecommerce_kibana/data.json.gz | Bin 4138 -> 4219 bytes 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/plugins/embeddable/public/lib/panel/embeddable_panel.tsx b/src/plugins/embeddable/public/lib/panel/embeddable_panel.tsx index d8659680dceb9..ca5cb5ca4f0d5 100644 --- a/src/plugins/embeddable/public/lib/panel/embeddable_panel.tsx +++ b/src/plugins/embeddable/public/lib/panel/embeddable_panel.tsx @@ -211,6 +211,7 @@ export class EmbeddablePanel extends React.Component { const kibanaTimezone = this.core.uiSettings.get('dateFormat:tz'); const id = `search:${embeddable.getSavedSearch().id}`; - const filename = embeddable.getTitle(); + const filename = embeddable.getSavedSearch().title; const timezone = kibanaTimezone === 'Browser' ? moment.tz.guess() : kibanaTimezone; const fromTime = dateMath.parse(from); const toTime = dateMath.parse(to); diff --git a/x-pack/test/functional/apps/dashboard/reporting/download_csv.ts b/x-pack/test/functional/apps/dashboard/reporting/download_csv.ts index b39613b3dbd1b..5c41945cb88d8 100644 --- a/x-pack/test/functional/apps/dashboard/reporting/download_csv.ts +++ b/x-pack/test/functional/apps/dashboard/reporting/download_csv.ts @@ -14,15 +14,27 @@ import { FtrProviderContext } from '../../../ftr_provider_context'; const csvPath = path.resolve(REPO_ROOT, 'target/functional-tests/downloads/Ecommerce Data.csv'); +// checks every 100ms for the file to exist in the download dir +// just wait up to 5 seconds +const getDownload$ = (filePath: string) => { + return Rx.interval(100).pipe( + map(() => fs.existsSync(filePath)), + filter((value) => value === true), + first(), + timeout(5000) + ); +}; + export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const browser = getService('browser'); const dashboardPanelActions = getService('dashboardPanelActions'); const log = getService('log'); const testSubjects = getService('testSubjects'); + const find = getService('find'); const PageObjects = getPageObjects(['reporting', 'common', 'dashboard']); - describe('Reporting Download CSV', () => { + describe('Download CSV', () => { before('initialize tests', async () => { log.debug('ReportingPage:initTests'); await esArchiver.loadIfNeeded('reporting/ecommerce'); @@ -33,10 +45,13 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { after('clean up archives and previous file download', async () => { await esArchiver.unload('reporting/ecommerce'); await esArchiver.unload('reporting/ecommerce_kibana'); + }); + + afterEach('remove download', () => { try { fs.unlinkSync(csvPath); } catch (e) { - // nothing to worry + // it might not have been there to begin with } }); @@ -50,19 +65,26 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { await testSubjects.click('embeddablePanelAction-downloadCsvReport'); await testSubjects.existOrFail('csvDownloadStarted'); // validate toast panel - // check every 100ms for the file to exist in the download dir - // just wait up to 5 seconds - const success$ = Rx.interval(100).pipe( - map(() => fs.existsSync(csvPath)), - filter((value) => value === true), - first(), - timeout(5000) - ); - - const fileExists = await success$.toPromise(); + const fileExists = await getDownload$(csvPath).toPromise(); expect(fileExists).to.be(true); // no need to validate download contents, API Integration tests do that some different variations }); + + it('Gets the correct filename if panel titles are hidden', async () => { + await PageObjects.common.navigateToApp('dashboard'); + await PageObjects.dashboard.loadSavedDashboard('Ecom Dashboard Hidden Panel Titles'); + const savedSearchPanel = await find.byCssSelector( + '[data-test-embeddable-id="94eab06f-60ac-4a85-b771-3a8ed475c9bb"]' + ); // panel title is hidden + await dashboardPanelActions.toggleContextMenu(savedSearchPanel); + + await testSubjects.existOrFail('embeddablePanelAction-downloadCsvReport'); + await testSubjects.click('embeddablePanelAction-downloadCsvReport'); + await testSubjects.existOrFail('csvDownloadStarted'); + + const fileExists = await getDownload$(csvPath).toPromise(); // file exists with proper name + expect(fileExists).to.be(true); + }); }); } diff --git a/x-pack/test/functional/es_archives/reporting/ecommerce_kibana/data.json.gz b/x-pack/test/functional/es_archives/reporting/ecommerce_kibana/data.json.gz index 454d260a518cd39001004d026afd8dc00c5e01d6..d4dd21528a882aa45d262280bb0323f2b9b46bf3 100644 GIT binary patch delta 4208 zcmV-$5RdPwAp0PHABzYGp4~=Y0s~}WbYU)Pb8l_{?OjWcB7NSQ45BSr)9&B6%c3tTUPAP9_jVi<$mWDqCusv8$s zwBhymC-gSRkI1Pik|HH)TI#nZ0;apAQ?Kv5>YPIsIUl}%rYH?|I3|s*((og%(d2|Z z9HgA`A$)$0Enwf<}SUZdPj`Zx{PJ2@0nbK3omja0v5 zX{x3XN5yS_O;b@Hn?}bo`;OUeWW$g0c^Wb4lbD1aNnno08TCogoQo)9qoAi_4$tpl z##?oyIVy5g&Dusz7g=3XYXR+jx!lof{O9Pk*FIcY=$*CDUoLb_hefybc30QCn%=UU z&LxD-NI*t}#fRPE)AF)EkGEpxigwb3#Bbwdi;!@CGh$Rs$>NmEh%V=38sYik(NW83 z>z5FZkbyeJjFC9(E~NRTrB_*_Dxy9mfzO57c>Li`Bg7-J)9CIrdeq-(G|EAV1DJJ^`v1r6B_vg3pN;(=iAQzV>mD5KbaE_J-IE_;g$cK*NJUOa_=$ zsWHKS{{1)_y%~9rxWJNpmZN4BA!lk)kh1Ts;7q(ICRLnaI&w)YXv@IKiBouT^1^_G zeN+*ZiB-|%4Nql5ivzT82-S-0@ANHbtZ=aCel>*y; zqjL+A3S1gOmc<)x!EMP1)8Ot)bwDCIZh4d)F0r-T0l-nnXb8T!VyI!!_^?NlsOLrg z%HR$ns8?tdR`EhxZyZq$XBu*;>DEBQaDcob_A$a?+Q%MC<3;nQTMX}Iu&W=~tD>I{ z>3|mE`NeD78;Uj(<|?GK<2dqDk0q^th0)%krI*33zNJ@1KW*tntBVuT8^_cmi)C3u z9Q1qrAi}q^+gEX?A!Vxw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