From 33a2a8b0d6bc1982b8daf264b81c05b49a9a090e Mon Sep 17 00:00:00 2001 From: LeeDr Date: Wed, 12 Feb 2020 15:19:12 -0600 Subject: [PATCH 1/3] handle viewing sample dashboards on default dist --- .../components/sample_data_view_data_button.js | 1 + test/functional/page_objects/home_page.ts | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/legacy/core_plugins/kibana/public/home/np_ready/components/sample_data_view_data_button.js b/src/legacy/core_plugins/kibana/public/home/np_ready/components/sample_data_view_data_button.js index e6f5c07c94f9f..cb43c18a8e78b 100644 --- a/src/legacy/core_plugins/kibana/public/home/np_ready/components/sample_data_view_data_button.js +++ b/src/legacy/core_plugins/kibana/public/home/np_ready/components/sample_data_view_data_button.js @@ -112,6 +112,7 @@ export class SampleDataViewDataButton extends React.Component { closePopover={this.closePopover} panelPaddingSize="none" anchorPosition="downCenter" + data-test-subj={`launchSampleDataSet${this.props.id}`} > diff --git a/test/functional/page_objects/home_page.ts b/test/functional/page_objects/home_page.ts index a641fbda023c3..63cb3356de720 100644 --- a/test/functional/page_objects/home_page.ts +++ b/test/functional/page_objects/home_page.ts @@ -19,9 +19,12 @@ import { FtrProviderContext } from '../ftr_provider_context'; -export function HomePageProvider({ getService }: FtrProviderContext) { +export function HomePageProvider({ getService, getPageObjects }: FtrProviderContext) { const testSubjects = getService('testSubjects'); const retry = getService('retry'); + const find = getService('find'); + const PageObjects = getPageObjects(['common']); + let isOss = true; class HomePage { async clickSynopsis(title: string) { @@ -66,6 +69,15 @@ export function HomePageProvider({ getService }: FtrProviderContext) { async launchSampleDataSet(id: string) { await this.addSampleDataSet(id); await testSubjects.click(`launchSampleDataSet${id}`); + // On OSS there's currently only sample dashboards so the launch button opens the dashboard + // but on default dist there's more items. The only tests that are calling this method are in OSS + // so they always expect Dashboard. isOss isn't really the right test. It should be based on + // the number of items. + // x-pack sample data tests seem to skip this navigation and open the saved objects directly. + isOss = await PageObjects.common.isOss(); + if (!isOss) { + await find.clickByLinkText('Dashboard'); + } } async loadSavedObjects() { From 1498c2da902efb8df23b1e2dc6d56e78e9b36ce2 Mon Sep 17 00:00:00 2001 From: LeeDr Date: Wed, 12 Feb 2020 17:27:03 -0600 Subject: [PATCH 2/3] re-work change to not break jest test --- test/functional/apps/home/_sample_data.ts | 8 ++++---- test/functional/page_objects/home_page.ts | 15 +++++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/test/functional/apps/home/_sample_data.ts b/test/functional/apps/home/_sample_data.ts index 8088b5a0f9da9..8bc528e045566 100644 --- a/test/functional/apps/home/_sample_data.ts +++ b/test/functional/apps/home/_sample_data.ts @@ -84,7 +84,7 @@ export default function({ getService, getPageObjects }: FtrProviderContext) { }); it('should launch sample flights data set dashboard', async () => { - await PageObjects.home.launchSampleDataSet('flights'); + await PageObjects.home.launchSampleDashboard('flights'); await PageObjects.header.waitUntilLoadingHasFinished(); await renderable.waitForRender(); const todayYearMonthDay = moment().format('MMM D, YYYY'); @@ -96,7 +96,7 @@ export default function({ getService, getPageObjects }: FtrProviderContext) { }); it('should render visualizations', async () => { - await PageObjects.home.launchSampleDataSet('flights'); + await PageObjects.home.launchSampleDashboard('flights'); await PageObjects.header.waitUntilLoadingHasFinished(); await renderable.waitForRender(); log.debug('Checking pie charts rendered'); @@ -115,7 +115,7 @@ export default function({ getService, getPageObjects }: FtrProviderContext) { }); it('should launch sample logs data set dashboard', async () => { - await PageObjects.home.launchSampleDataSet('logs'); + await PageObjects.home.launchSampleDashboard('logs'); await PageObjects.header.waitUntilLoadingHasFinished(); await renderable.waitForRender(); const todayYearMonthDay = moment().format('MMM D, YYYY'); @@ -127,7 +127,7 @@ export default function({ getService, getPageObjects }: FtrProviderContext) { }); it('should launch sample ecommerce data set dashboard', async () => { - await PageObjects.home.launchSampleDataSet('ecommerce'); + await PageObjects.home.launchSampleDashboard('ecommerce'); await PageObjects.header.waitUntilLoadingHasFinished(); await renderable.waitForRender(); const todayYearMonthDay = moment().format('MMM D, YYYY'); diff --git a/test/functional/page_objects/home_page.ts b/test/functional/page_objects/home_page.ts index 63cb3356de720..6225b4e3aca62 100644 --- a/test/functional/page_objects/home_page.ts +++ b/test/functional/page_objects/home_page.ts @@ -66,20 +66,19 @@ export function HomePageProvider({ getService, getPageObjects }: FtrProviderCont }); } - async launchSampleDataSet(id: string) { - await this.addSampleDataSet(id); - await testSubjects.click(`launchSampleDataSet${id}`); - // On OSS there's currently only sample dashboards so the launch button opens the dashboard - // but on default dist there's more items. The only tests that are calling this method are in OSS - // so they always expect Dashboard. isOss isn't really the right test. It should be based on - // the number of items. - // x-pack sample data tests seem to skip this navigation and open the saved objects directly. + async launchSampleDashboard(id: string) { + await this.launchSampleDataSet(id); isOss = await PageObjects.common.isOss(); if (!isOss) { await find.clickByLinkText('Dashboard'); } } + async launchSampleDataSet(id: string) { + await this.addSampleDataSet(id); + await testSubjects.click(`launchSampleDataSet${id}`); + } + async loadSavedObjects() { await retry.try(async () => { await testSubjects.click('loadSavedObjects'); From f402bff8139a89a60c946ad4b2a42162f7bf006e Mon Sep 17 00:00:00 2001 From: LeeDr Date: Thu, 13 Feb 2020 09:45:10 -0600 Subject: [PATCH 3/3] Update snap for addition of data-test-subj --- .../__snapshots__/sample_data_view_data_button.test.js.snap | 1 + 1 file changed, 1 insertion(+) diff --git a/src/legacy/core_plugins/kibana/public/home/np_ready/components/__snapshots__/sample_data_view_data_button.test.js.snap b/src/legacy/core_plugins/kibana/public/home/np_ready/components/__snapshots__/sample_data_view_data_button.test.js.snap index e08d802406fff..661d1d33a5283 100644 --- a/src/legacy/core_plugins/kibana/public/home/np_ready/components/__snapshots__/sample_data_view_data_button.test.js.snap +++ b/src/legacy/core_plugins/kibana/public/home/np_ready/components/__snapshots__/sample_data_view_data_button.test.js.snap @@ -14,6 +14,7 @@ exports[`should render popover when appLinks is not empty 1`] = ` } closePopover={[Function]} + data-test-subj="launchSampleDataSetecommerce" display="inlineBlock" hasArrow={true} id="sampleDataLinksecommerce"