From c2415a1ac34065ec8629341df74d2c44a4a105cb Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Wed, 5 Aug 2020 13:19:04 -0700 Subject: [PATCH 1/6] [Reporting] Fix and test for Listing of Reports --- .../plugins/reporting/server/routes/jobs.ts | 10 +- .../apps/reporting_management/index.ts | 2 +- .../report_delete_pagination.ts | 59 --------- .../reporting_management/report_listing.ts | 118 ++++++++++++++++++ 4 files changed, 127 insertions(+), 62 deletions(-) delete mode 100644 x-pack/test/functional/apps/reporting_management/report_delete_pagination.ts create mode 100644 x-pack/test/functional/apps/reporting_management/report_listing.ts diff --git a/x-pack/plugins/reporting/server/routes/jobs.ts b/x-pack/plugins/reporting/server/routes/jobs.ts index 4033719b053ba..e8eac9e577beb 100644 --- a/x-pack/plugins/reporting/server/routes/jobs.ts +++ b/x-pack/plugins/reporting/server/routes/jobs.ts @@ -35,7 +35,13 @@ export function registerJobInfoRoutes(reporting: ReportingCore) { router.get( { path: `${MAIN_ENTRY}/list`, - validate: false, + validate: { + query: schema.object({ + page: schema.string({ defaultValue: '0' }), + size: schema.string({ defaultValue: '10' }), + ids: schema.maybe(schema.string()), + }), + }, }, userHandler(async (user, context, req, res) => { // ensure the async dependencies are loaded @@ -50,7 +56,7 @@ export function registerJobInfoRoutes(reporting: ReportingCore) { page: queryPage = '0', size: querySize = '10', ids: queryIds = null, - } = req.query as ListQuery; + } = req.query as ListQuery; // NOTE: type inference is not working here. userHandler breaks it? const page = parseInt(queryPage, 10) || 0; const size = Math.min(100, parseInt(querySize, 10) || 10); const jobIds = queryIds ? queryIds.split(',') : null; diff --git a/x-pack/test/functional/apps/reporting_management/index.ts b/x-pack/test/functional/apps/reporting_management/index.ts index f44d5858d53a1..8606c46053ab0 100644 --- a/x-pack/test/functional/apps/reporting_management/index.ts +++ b/x-pack/test/functional/apps/reporting_management/index.ts @@ -9,6 +9,6 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default ({ loadTestFile }: FtrProviderContext) => { describe('reporting management app', function () { this.tags('ciGroup7'); - loadTestFile(require.resolve('./report_delete_pagination')); + loadTestFile(require.resolve('./report_listing')); }); }; diff --git a/x-pack/test/functional/apps/reporting_management/report_delete_pagination.ts b/x-pack/test/functional/apps/reporting_management/report_delete_pagination.ts deleted file mode 100644 index 488314030085f..0000000000000 --- a/x-pack/test/functional/apps/reporting_management/report_delete_pagination.ts +++ /dev/null @@ -1,59 +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; - * you may not use this file except in compliance with the Elastic License. - */ - -import expect from '@kbn/expect'; -import { FtrProviderContext } from '../../ftr_provider_context'; - -export default ({ getPageObjects, getService }: FtrProviderContext) => { - const pageObjects = getPageObjects(['common', 'reporting']); - const log = getService('log'); - const retry = getService('retry'); - const security = getService('security'); - - const testSubjects = getService('testSubjects'); - const esArchiver = getService('esArchiver'); - - describe('Delete reports', function () { - before(async () => { - await security.testUser.setRoles(['kibana_admin', 'reporting_user']); - await esArchiver.load('empty_kibana'); - await esArchiver.load('reporting/archived_reports'); - await pageObjects.common.navigateToApp('reporting'); - await testSubjects.existOrFail('reportJobListing', { timeout: 200000 }); - }); - - after(async () => { - await esArchiver.unload('empty_kibana'); - await esArchiver.unload('reporting/archived_reports'); - await security.testUser.restoreDefaults(); - }); - - it('Confirm single report deletion works', async () => { - log.debug('Checking for reports.'); - await retry.try(async () => { - await testSubjects.click('checkboxSelectRow-k9a9xlwl0gpe1457b10rraq3'); - }); - const deleteButton = await testSubjects.find('deleteReportButton'); - await retry.waitFor('delete button to become enabled', async () => { - return await deleteButton.isEnabled(); - }); - await deleteButton.click(); - await testSubjects.exists('confirmModalBodyText'); - await testSubjects.click('confirmModalConfirmButton'); - await retry.try(async () => { - await testSubjects.waitForDeleted('checkboxSelectRow-k9a9xlwl0gpe1457b10rraq3'); - }); - }); - - // functional test for report pagination: https://github.com/elastic/kibana/pull/62881 - it('Report pagination', async () => { - const previousButton = await testSubjects.find('pagination-button-previous'); - expect(await previousButton.getAttribute('disabled')).to.be('true'); - await testSubjects.click('pagination-button-1'); - expect(await previousButton.getAttribute('disabled')).to.be(null); - }); - }); -}; diff --git a/x-pack/test/functional/apps/reporting_management/report_listing.ts b/x-pack/test/functional/apps/reporting_management/report_listing.ts new file mode 100644 index 0000000000000..952f5e1f98c51 --- /dev/null +++ b/x-pack/test/functional/apps/reporting_management/report_listing.ts @@ -0,0 +1,118 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +import expect from '@kbn/expect'; +import { WebElementWrapper } from 'test/functional/services/lib/web_element_wrapper'; +import { FtrProviderContext } from '../../ftr_provider_context'; + +const getTableTextFromElement = async (tableEl: WebElementWrapper) => { + const rows = await tableEl.findAllByCssSelector('tbody tr'); + return ( + await Promise.all( + rows.map(async (row) => { + return await row.getVisibleText(); + }) + ) + ).join('\n'); +}; + +export default ({ getPageObjects, getService }: FtrProviderContext) => { + const pageObjects = getPageObjects(['common', 'reporting']); + const log = getService('log'); + const retry = getService('retry'); + const security = getService('security'); + + const testSubjects = getService('testSubjects'); + const esArchiver = getService('esArchiver'); + + describe('Listing of Reports', function () { + before(async () => { + await security.testUser.setRoles(['kibana_admin', 'reporting_user']); + await esArchiver.load('empty_kibana'); + }); + + beforeEach(async () => { + // to reset the data after deletion testing + await esArchiver.load('reporting/archived_reports'); + await pageObjects.common.navigateToApp('reporting'); + await testSubjects.existOrFail('reportJobListing', { timeout: 200000 }); + }); + + after(async () => { + await esArchiver.unload('empty_kibana'); + await security.testUser.restoreDefaults(); + }); + + afterEach(async () => { + await esArchiver.unload('reporting/archived_reports'); + }); + + it('Confirm single report deletion works', async () => { + log.debug('Checking for reports.'); + await retry.try(async () => { + await testSubjects.click('checkboxSelectRow-k9a9xlwl0gpe1457b10rraq3'); + }); + const deleteButton = await testSubjects.find('deleteReportButton'); + await retry.waitFor('delete button to become enabled', async () => { + return await deleteButton.isEnabled(); + }); + await deleteButton.click(); + await testSubjects.exists('confirmModalBodyText'); + await testSubjects.click('confirmModalConfirmButton'); + await retry.try(async () => { + await testSubjects.waitForDeleted('checkboxSelectRow-k9a9xlwl0gpe1457b10rraq3'); + }); + }); + + it('Paginates content', async () => { + const previousButton = await testSubjects.find('pagination-button-previous'); + + // previous CAN NOT be clicked + expect(await previousButton.getAttribute('disabled')).to.be('true'); + + // scan page 1 + let tableText = await getTableTextFromElement(await testSubjects.find('reportJobListing')); + const PAGE_CONTENT_1 = `[Logs] File Type Scatter Plot\nvisualization\n2020-04-21 @ 07:01 PM\ntest_user\nCompleted at 2020-04-21 @ 07:02 PM +[Logs] File Type Scatter Plot\nvisualization\n2020-04-21 @ 07:01 PM\ntest_user\nCompleted at 2020-04-21 @ 07:02 PM +[Logs] Heatmap\nvisualization\n2020-04-21 @ 07:00 PM\ntest_user\nCompleted at 2020-04-21 @ 07:01 PM +[Logs] Heatmap\nvisualization\n2020-04-21 @ 07:00 PM\ntest_user\nCompleted at 2020-04-21 @ 07:01 PM +[Flights] Flight Delays\nvisualization\n2020-04-21 @ 07:00 PM\ntest_user\nCompleted at 2020-04-21 @ 07:01 PM +[Flights] Flight Delays\nvisualization\n2020-04-21 @ 07:00 PM\ntest_user\nCompleted at 2020-04-21 @ 07:01 PM +pdf\ndashboard\n2020-04-21 @ 07:00 PM\ntest_user\nCompleted at 2020-04-21 @ 07:00 PM +pdf\ndashboard\n2020-04-21 @ 07:00 PM\ntest_user\nCompleted at 2020-04-21 @ 07:00 PM +[Flights] Flight Cancellations\nvisualization\n2020-04-21 @ 06:59 PM\ntest_user\nCompleted at 2020-04-21 @ 07:00 PM +[Flights] Markdown Instructions\nvisualization\n2020-04-21 @ 06:59 PM\ntest_user\nCompleted at 2020-04-21 @ 07:00 PM`; + expect(tableText).to.be(PAGE_CONTENT_1); + + // click page 2 + await testSubjects.click('pagination-button-1'); + + // previous CAN be clicked + expect(await previousButton.getAttribute('disabled')).to.be(null); + + // scan page 2 + tableText = await getTableTextFromElement(await testSubjects.find('reportJobListing')); + const PAGE_CONTENT_2 = `[eCommerce] Revenue Tracking\ncanvas workpad\n2020-04-21 @ 06:58 PM\ntest_user\nCompleted at 2020-04-21 @ 06:59 PM +[Logs] Web Traffic\ncanvas workpad\n2020-04-21 @ 06:58 PM\ntest_user\nCompleted at 2020-04-21 @ 06:59 PM +[Flights] Overview\ncanvas workpad\n2020-04-21 @ 06:58 PM\ntest_user\nCompleted at 2020-04-21 @ 06:59 PM +[eCommerce] Revenue Dashboard\ndashboard\n2020-04-21 @ 06:57 PM\ntest_user\nCompleted at 2020-04-21 @ 06:58 PM +[Logs] Web Traffic\ndashboard\n2020-04-21 @ 06:57 PM\ntest_user\nCompleted at 2020-04-21 @ 06:58 PM +[Flights] Global Flight Dashboard\ndashboard\n2020-04-21 @ 06:56 PM\ntest_user\nCompleted at 2020-04-21 @ 06:57 PM +[Flights] Global Flight Dashboard\ndashboard\n2020-04-21 @ 06:56 PM\ntest_user\nCompleted at 2020-04-21 @ 06:57 PM +report4csv\n2020-04-21 @ 06:55 PM\ntest_user\nCompleted at 2020-04-21 @ 06:56 PM - Max size reached\nreport3csv\n2020-04-21 @ 06:55 PM +test_user\nCompleted at 2020-04-21 @ 06:55 PM - Max size reached\nreport2csv\n2020-04-21 @ 06:54 PM\ntest_user\nCompleted at 2020-04-21 @ 06:55 PM - Max size reached`; + expect(tableText).to.be(PAGE_CONTENT_2); + + // click page 3 + await testSubjects.click('pagination-button-2'); + + // scan page 3 + tableText = await getTableTextFromElement(await testSubjects.find('reportJobListing')); + const PAGE_CONTENT_3 = `report1csv\n2020-04-21 @ 06:54 PM\ntest_user\nCompleted at 2020-04-21 @ 06:54 PM - Max size reached`; + expect(tableText).to.be(PAGE_CONTENT_3); + }); + }); +}; From cb6dd51a6bac38fb31bedb452a98dccf6bd09de2 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Mon, 10 Aug 2020 16:09:00 -0700 Subject: [PATCH 2/6] add sleeps --- .../test/functional/apps/reporting_management/report_listing.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/x-pack/test/functional/apps/reporting_management/report_listing.ts b/x-pack/test/functional/apps/reporting_management/report_listing.ts index 952f5e1f98c51..52135a31ecee9 100644 --- a/x-pack/test/functional/apps/reporting_management/report_listing.ts +++ b/x-pack/test/functional/apps/reporting_management/report_listing.ts @@ -92,6 +92,7 @@ pdf\ndashboard\n2020-04-21 @ 07:00 PM\ntest_user\nCompleted at 2020-04-21 @ 07:0 // previous CAN be clicked expect(await previousButton.getAttribute('disabled')).to.be(null); + await pageObjects.common.sleep(2000); // scan page 2 tableText = await getTableTextFromElement(await testSubjects.find('reportJobListing')); @@ -108,6 +109,7 @@ test_user\nCompleted at 2020-04-21 @ 06:55 PM - Max size reached\nreport2csv\n20 // click page 3 await testSubjects.click('pagination-button-2'); + await pageObjects.common.sleep(2000); // scan page 3 tableText = await getTableTextFromElement(await testSubjects.find('reportJobListing')); From e60f215e8c81fb68093f371768a5d276562c1071 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Mon, 10 Aug 2020 17:27:39 -0700 Subject: [PATCH 3/6] await selector instead of sleep --- .../public/components/report_listing.tsx | 1 + .../apps/dashboard/reporting/download_csv.ts | 6 +- .../apps/dashboard/reporting/screenshots.ts | 68 ++++++++++--------- .../functional/apps/discover/reporting.ts | 54 +++++++-------- .../functional/apps/lens/lens_reporting.ts | 16 +++-- .../reporting_management/report_listing.ts | 5 +- .../functional/apps/visualize/reporting.ts | 44 ++++++------ .../functional/page_objects/reporting_page.ts | 12 ++-- 8 files changed, 113 insertions(+), 93 deletions(-) diff --git a/x-pack/plugins/reporting/public/components/report_listing.tsx b/x-pack/plugins/reporting/public/components/report_listing.tsx index afcae93a8db16..80ef9311fd0e5 100644 --- a/x-pack/plugins/reporting/public/components/report_listing.tsx +++ b/x-pack/plugins/reporting/public/components/report_listing.tsx @@ -513,6 +513,7 @@ class ReportListingUi extends Component { isSelectable={true} onChange={this.onTableChange} data-test-subj="reportJobListing" + data-test-page={this.state.page} /> {this.state.selectedJobs.length > 0 ? this.renderDeleteButton() : null} 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..be707c24041e1 100644 --- a/x-pack/test/functional/apps/dashboard/reporting/download_csv.ts +++ b/x-pack/test/functional/apps/dashboard/reporting/download_csv.ts @@ -20,7 +20,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const dashboardPanelActions = getService('dashboardPanelActions'); const log = getService('log'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['reporting', 'common', 'dashboard']); + const pageObjects = getPageObjects(['reporting', 'common', 'dashboard']); describe('Reporting Download CSV', () => { before('initialize tests', async () => { @@ -41,8 +41,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('Downloads a CSV export of a saved search panel', async function () { - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.loadSavedDashboard('Ecom Dashboard'); + await pageObjects.common.navigateToApp('dashboard'); + await pageObjects.dashboard.loadSavedDashboard('Ecom Dashboard'); const savedSearchPanel = await testSubjects.find('embeddablePanelHeading-EcommerceData'); await dashboardPanelActions.toggleContextMenu(savedSearchPanel); diff --git a/x-pack/test/functional/apps/dashboard/reporting/screenshots.ts b/x-pack/test/functional/apps/dashboard/reporting/screenshots.ts index da1131d051581..05a86616451ea 100644 --- a/x-pack/test/functional/apps/dashboard/reporting/screenshots.ts +++ b/x-pack/test/functional/apps/dashboard/reporting/screenshots.ts @@ -16,12 +16,13 @@ const mkdirAsync = promisify(fs.mkdir); const REPORTS_FOLDER = path.resolve(__dirname, 'reports'); -export default function ({ getService, getPageObjects }: FtrProviderContext) { +export default function ({ getPageObjects, getService }: FtrProviderContext) { + const pageObjects = getPageObjects(['reporting', 'common', 'dashboard']); const esArchiver = getService('esArchiver'); const browser = getService('browser'); const log = getService('log'); const config = getService('config'); - const PageObjects = getPageObjects(['reporting', 'common', 'dashboard']); + const es = getService('es'); describe('Screenshots', () => { before('initialize tests', async () => { @@ -33,20 +34,25 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { after('clean up archives', async () => { await esArchiver.unload('reporting/ecommerce'); await esArchiver.unload('reporting/ecommerce_kibana'); + await es.deleteByQuery({ + index: '.reporting-*', + refresh: true, + body: { query: { match_all: {} } }, + }); }); describe('Print PDF button', () => { it('is not available if new', async () => { - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.reporting.openPdfReportingPanel(); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); + await pageObjects.common.navigateToApp('dashboard'); + await pageObjects.dashboard.clickNewDashboard(); + await pageObjects.reporting.openPdfReportingPanel(); + expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); }); it('becomes available when saved', async () => { - await PageObjects.dashboard.saveDashboard('My PDF Dashboard'); - await PageObjects.reporting.openPdfReportingPanel(); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); + await pageObjects.dashboard.saveDashboard('My PDF Dashboard'); + await pageObjects.reporting.openPdfReportingPanel(); + expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); }); }); @@ -55,14 +61,14 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { // Generating and then comparing reports can take longer than the default 60s timeout because the comparePngs // function is taking about 15 seconds per comparison in jenkins. this.timeout(300000); - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.loadSavedDashboard('Ecom Dashboard'); - await PageObjects.reporting.openPdfReportingPanel(); - await PageObjects.reporting.checkUsePrintLayout(); - await PageObjects.reporting.clickGenerateReportButton(); + await pageObjects.common.navigateToApp('dashboard'); + await pageObjects.dashboard.loadSavedDashboard('Ecom Dashboard'); + await pageObjects.reporting.openPdfReportingPanel(); + await pageObjects.reporting.checkUsePrintLayout(); + await pageObjects.reporting.clickGenerateReportButton(); - const url = await PageObjects.reporting.getReportURL(60000); - const res = await PageObjects.reporting.getResponse(url); + const url = await pageObjects.reporting.getReportURL(60000); + const res = await pageObjects.reporting.getResponse(url); expect(res.statusCode).to.equal(200); expect(res.headers['content-type']).to.equal('application/pdf'); @@ -71,16 +77,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Print PNG button', () => { it('is not available if new', async () => { - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.clickNewDashboard(); - await PageObjects.reporting.openPngReportingPanel(); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); + await pageObjects.common.navigateToApp('dashboard'); + await pageObjects.dashboard.clickNewDashboard(); + await pageObjects.reporting.openPngReportingPanel(); + expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); }); it('becomes available when saved', async () => { - await PageObjects.dashboard.saveDashboard('My PNG Dash'); - await PageObjects.reporting.openPngReportingPanel(); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); + await pageObjects.dashboard.saveDashboard('My PNG Dash'); + await pageObjects.reporting.openPngReportingPanel(); + expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); }); }); @@ -102,15 +108,15 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { this.timeout(300000); - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.loadSavedDashboard('Ecom Dashboard'); - await PageObjects.reporting.openPngReportingPanel(); - await PageObjects.reporting.forceSharedItemsContainerSize({ width: 1405 }); - await PageObjects.reporting.clickGenerateReportButton(); - await PageObjects.reporting.removeForceSharedItemsContainerSize(); + await pageObjects.common.navigateToApp('dashboard'); + await pageObjects.dashboard.loadSavedDashboard('Ecom Dashboard'); + await pageObjects.reporting.openPngReportingPanel(); + await pageObjects.reporting.forceSharedItemsContainerSize({ width: 1405 }); + await pageObjects.reporting.clickGenerateReportButton(); + await pageObjects.reporting.removeForceSharedItemsContainerSize(); - const url = await PageObjects.reporting.getReportURL(60000); - const reportData = await PageObjects.reporting.getRawPdfReportData(url); + const url = await pageObjects.reporting.getReportURL(60000); + const reportData = await pageObjects.reporting.getRawPdfReportData(url); const reportFileName = 'dashboard_preserve_layout'; const sessionReportPath = await writeSessionReport(reportFileName, reportData, 'png'); const percentSimilar = await checkIfPngsMatch( diff --git a/x-pack/test/functional/apps/discover/reporting.ts b/x-pack/test/functional/apps/discover/reporting.ts index 32ccc59913dbc..cb30eb966636c 100644 --- a/x-pack/test/functional/apps/discover/reporting.ts +++ b/x-pack/test/functional/apps/discover/reporting.ts @@ -11,7 +11,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const log = getService('log'); const esArchiver = getService('esArchiver'); const browser = getService('browser'); - const PageObjects = getPageObjects(['reporting', 'common', 'discover']); + const pageObjects = getPageObjects(['reporting', 'common', 'discover']); const filterBar = getService('filterBar'); describe('Discover', () => { @@ -25,51 +25,51 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); describe('Generate CSV button', () => { - beforeEach(() => PageObjects.common.navigateToApp('discover')); + beforeEach(() => pageObjects.common.navigateToApp('discover')); it('is not available if new', async () => { - await PageObjects.reporting.openCsvReportingPanel(); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); + await pageObjects.reporting.openCsvReportingPanel(); + expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); }); it('becomes available when saved', async () => { - await PageObjects.discover.saveSearch('my search - expectEnabledGenerateReportButton'); - await PageObjects.reporting.openCsvReportingPanel(); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); + await pageObjects.discover.saveSearch('my search - expectEnabledGenerateReportButton'); + await pageObjects.reporting.openCsvReportingPanel(); + expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); }); it('becomes available/not available when a saved search is created, changed and saved again', async () => { // create new search, csv export is not available - await PageObjects.discover.clickNewSearchButton(); - await PageObjects.reporting.openCsvReportingPanel(); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); + await pageObjects.discover.clickNewSearchButton(); + await pageObjects.reporting.openCsvReportingPanel(); + expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); // save search, csv export is available - await PageObjects.discover.saveSearch('my search - expectEnabledGenerateReportButton 2'); - await PageObjects.reporting.openCsvReportingPanel(); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); + await pageObjects.discover.saveSearch('my search - expectEnabledGenerateReportButton 2'); + await pageObjects.reporting.openCsvReportingPanel(); + expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); // add filter, csv export is not available await filterBar.addFilter('currency', 'is', 'EUR'); - await PageObjects.reporting.openCsvReportingPanel(); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); + await pageObjects.reporting.openCsvReportingPanel(); + expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); // save search again, csv export is available - await PageObjects.discover.saveSearch('my search - expectEnabledGenerateReportButton 2'); - await PageObjects.reporting.openCsvReportingPanel(); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); + await pageObjects.discover.saveSearch('my search - expectEnabledGenerateReportButton 2'); + await pageObjects.reporting.openCsvReportingPanel(); + expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); }); it('generates a report with data', async () => { - await PageObjects.discover.clickNewSearchButton(); - await PageObjects.reporting.setTimepickerInDataRange(); - await PageObjects.discover.saveSearch('my search - with data - expectReportCanBeCreated'); - await PageObjects.reporting.openCsvReportingPanel(); - expect(await PageObjects.reporting.canReportBeCreated()).to.be(true); + await pageObjects.discover.clickNewSearchButton(); + await pageObjects.reporting.setTimepickerInDataRange(); + await pageObjects.discover.saveSearch('my search - with data - expectReportCanBeCreated'); + await pageObjects.reporting.openCsvReportingPanel(); + expect(await pageObjects.reporting.canReportBeCreated()).to.be(true); }); it('generates a report with no data', async () => { - await PageObjects.reporting.setTimepickerInNoDataRange(); - await PageObjects.discover.saveSearch('my search - no data - expectReportCanBeCreated'); - await PageObjects.reporting.openCsvReportingPanel(); - expect(await PageObjects.reporting.canReportBeCreated()).to.be(true); + await pageObjects.reporting.setTimepickerInNoDataRange(); + await pageObjects.discover.saveSearch('my search - no data - expectReportCanBeCreated'); + await pageObjects.reporting.openCsvReportingPanel(); + expect(await pageObjects.reporting.canReportBeCreated()).to.be(true); }); }); }); diff --git a/x-pack/test/functional/apps/lens/lens_reporting.ts b/x-pack/test/functional/apps/lens/lens_reporting.ts index 3e3d217b9d8d7..bcdaf819af53b 100644 --- a/x-pack/test/functional/apps/lens/lens_reporting.ts +++ b/x-pack/test/functional/apps/lens/lens_reporting.ts @@ -8,7 +8,8 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const PageObjects = getPageObjects(['common', 'dashboard', 'reporting']); + const pageObjects = getPageObjects(['common', 'dashboard', 'reporting']); + const es = getService('es'); const esArchiver = getService('esArchiver'); const listingTable = getService('listingTable'); @@ -19,14 +20,19 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { after(async () => { await esArchiver.unload('lens/reporting'); + await es.deleteByQuery({ + index: '.reporting-*', + refresh: true, + body: { query: { match_all: {} } }, + }); }); it('should not cause PDF reports to fail', async () => { - await PageObjects.common.navigateToApp('dashboard'); + await pageObjects.common.navigateToApp('dashboard'); await listingTable.clickItemLink('dashboard', 'Lens reportz'); - await PageObjects.reporting.openPdfReportingPanel(); - await PageObjects.reporting.clickGenerateReportButton(); - const url = await PageObjects.reporting.getReportURL(60000); + await pageObjects.reporting.openPdfReportingPanel(); + await pageObjects.reporting.clickGenerateReportButton(); + const url = await pageObjects.reporting.getReportURL(60000); expect(url).to.be.ok(); }); diff --git a/x-pack/test/functional/apps/reporting_management/report_listing.ts b/x-pack/test/functional/apps/reporting_management/report_listing.ts index 52135a31ecee9..5bb36103fc6f6 100644 --- a/x-pack/test/functional/apps/reporting_management/report_listing.ts +++ b/x-pack/test/functional/apps/reporting_management/report_listing.ts @@ -26,6 +26,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const security = getService('security'); const testSubjects = getService('testSubjects'); + const findInstance = getService('find'); const esArchiver = getService('esArchiver'); describe('Listing of Reports', function () { @@ -89,10 +90,10 @@ pdf\ndashboard\n2020-04-21 @ 07:00 PM\ntest_user\nCompleted at 2020-04-21 @ 07:0 // click page 2 await testSubjects.click('pagination-button-1'); + await findInstance.byCssSelector('[data-test-page="1"]'); // previous CAN be clicked expect(await previousButton.getAttribute('disabled')).to.be(null); - await pageObjects.common.sleep(2000); // scan page 2 tableText = await getTableTextFromElement(await testSubjects.find('reportJobListing')); @@ -109,7 +110,7 @@ test_user\nCompleted at 2020-04-21 @ 06:55 PM - Max size reached\nreport2csv\n20 // click page 3 await testSubjects.click('pagination-button-2'); - await pageObjects.common.sleep(2000); + await findInstance.byCssSelector('[data-test-page="2"]'); // scan page 3 tableText = await getTableTextFromElement(await testSubjects.find('reportJobListing')); diff --git a/x-pack/test/functional/apps/visualize/reporting.ts b/x-pack/test/functional/apps/visualize/reporting.ts index 02fd74e9480f7..5e1b9a602170b 100644 --- a/x-pack/test/functional/apps/visualize/reporting.ts +++ b/x-pack/test/functional/apps/visualize/reporting.ts @@ -8,10 +8,11 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { + const es = getService('es'); const esArchiver = getService('esArchiver'); const browser = getService('browser'); const log = getService('log'); - const PageObjects = getPageObjects([ + const pageObjects = getPageObjects([ 'reporting', 'common', 'dashboard', @@ -29,38 +30,43 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { after('clean up archives', async () => { await esArchiver.unload('reporting/ecommerce'); await esArchiver.unload('reporting/ecommerce_kibana'); + await es.deleteByQuery({ + index: '.reporting-*', + refresh: true, + body: { query: { match_all: {} } }, + }); }); describe('Print PDF button', () => { it('is not available if new', async () => { - await PageObjects.common.navigateToUrl('visualize', 'new', { useActualUrl: true }); - await PageObjects.visualize.clickAreaChart(); - await PageObjects.visualize.clickNewSearch('ecommerce'); - await PageObjects.reporting.openPdfReportingPanel(); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); + await pageObjects.common.navigateToUrl('visualize', 'new', { useActualUrl: true }); + await pageObjects.visualize.clickAreaChart(); + await pageObjects.visualize.clickNewSearch('ecommerce'); + await pageObjects.reporting.openPdfReportingPanel(); + expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); }); it('becomes available when saved', async () => { - await PageObjects.reporting.setTimepickerInDataRange(); - await PageObjects.visEditor.clickBucket('X-axis'); - await PageObjects.visEditor.selectAggregation('Date Histogram'); - await PageObjects.visEditor.clickGo(); - await PageObjects.visualize.saveVisualization('my viz'); - await PageObjects.reporting.openPdfReportingPanel(); - expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); + await pageObjects.reporting.setTimepickerInDataRange(); + await pageObjects.visEditor.clickBucket('X-axis'); + await pageObjects.visEditor.selectAggregation('Date Histogram'); + await pageObjects.visEditor.clickGo(); + await pageObjects.visualize.saveVisualization('my viz'); + await pageObjects.reporting.openPdfReportingPanel(); + expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); }); it('downloaded PDF has OK status', async function () { // Generating and then comparing reports can take longer than the default 60s timeout this.timeout(180000); - await PageObjects.common.navigateToApp('dashboard'); - await PageObjects.dashboard.loadSavedDashboard('Ecom Dashboard'); - await PageObjects.reporting.openPdfReportingPanel(); - await PageObjects.reporting.clickGenerateReportButton(); + await pageObjects.common.navigateToApp('dashboard'); + await pageObjects.dashboard.loadSavedDashboard('Ecom Dashboard'); + await pageObjects.reporting.openPdfReportingPanel(); + await pageObjects.reporting.clickGenerateReportButton(); - const url = await PageObjects.reporting.getReportURL(60000); - const res = await PageObjects.reporting.getResponse(url); + const url = await pageObjects.reporting.getReportURL(60000); + const res = await pageObjects.reporting.getResponse(url); expect(res.statusCode).to.equal(200); expect(res.headers['content-type']).to.equal('application/pdf'); diff --git a/x-pack/test/functional/page_objects/reporting_page.ts b/x-pack/test/functional/page_objects/reporting_page.ts index 7631d0cbce59a..aef9283f44a07 100644 --- a/x-pack/test/functional/page_objects/reporting_page.ts +++ b/x-pack/test/functional/page_objects/reporting_page.ts @@ -14,7 +14,7 @@ export function ReportingPageProvider({ getService, getPageObjects }: FtrProvide const retry = getService('retry'); const testSubjects = getService('testSubjects'); - const PageObjects = getPageObjects(['common', 'security' as any, 'share', 'timePicker']); // FIXME: Security PageObject is not Typescript + const pageObjects = getPageObjects(['common', 'security' as any, 'share', 'timePicker']); // FIXME: Security PageObject is not Typescript class ReportingPage { async forceSharedItemsContainerSize({ width }: { width: number }) { @@ -86,17 +86,17 @@ export function ReportingPageProvider({ getService, getPageObjects }: FtrProvide async openCsvReportingPanel() { log.debug('openCsvReportingPanel'); - await PageObjects.share.openShareMenuItem('CSV Reports'); + await pageObjects.share.openShareMenuItem('CSV Reports'); } async openPdfReportingPanel() { log.debug('openPdfReportingPanel'); - await PageObjects.share.openShareMenuItem('PDF Reports'); + await pageObjects.share.openShareMenuItem('PDF Reports'); } async openPngReportingPanel() { log.debug('openPngReportingPanel'); - await PageObjects.share.openShareMenuItem('PNG Reports'); + await pageObjects.share.openShareMenuItem('PNG Reports'); } async clearToastNotifications() { @@ -156,14 +156,14 @@ export function ReportingPageProvider({ getService, getPageObjects }: FtrProvide log.debug('Reporting:setTimepickerInDataRange'); const fromTime = 'Sep 19, 2015 @ 06:31:44.000'; const toTime = 'Sep 19, 2015 @ 18:01:44.000'; - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); + await pageObjects.timePicker.setAbsoluteRange(fromTime, toTime); } async setTimepickerInNoDataRange() { log.debug('Reporting:setTimepickerInNoDataRange'); const fromTime = 'Sep 19, 1999 @ 06:31:44.000'; const toTime = 'Sep 23, 1999 @ 18:31:44.000'; - await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); + await pageObjects.timePicker.setAbsoluteRange(fromTime, toTime); } } return new ReportingPage(); From 44df9ced3bedad2dceac717d6bfd1761fb51e0e8 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Tue, 11 Aug 2020 08:17:29 -0700 Subject: [PATCH 4/6] reduce changes --- .../apps/dashboard/reporting/download_csv.ts | 6 +- .../apps/dashboard/reporting/screenshots.ts | 60 +++++++++---------- .../functional/apps/discover/reporting.ts | 54 ++++++++--------- .../functional/apps/lens/lens_reporting.ts | 10 ++-- .../functional/apps/visualize/reporting.ts | 38 ++++++------ .../functional/page_objects/reporting_page.ts | 12 ++-- 6 files changed, 90 insertions(+), 90 deletions(-) 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 be707c24041e1..b39613b3dbd1b 100644 --- a/x-pack/test/functional/apps/dashboard/reporting/download_csv.ts +++ b/x-pack/test/functional/apps/dashboard/reporting/download_csv.ts @@ -20,7 +20,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const dashboardPanelActions = getService('dashboardPanelActions'); const log = getService('log'); const testSubjects = getService('testSubjects'); - const pageObjects = getPageObjects(['reporting', 'common', 'dashboard']); + const PageObjects = getPageObjects(['reporting', 'common', 'dashboard']); describe('Reporting Download CSV', () => { before('initialize tests', async () => { @@ -41,8 +41,8 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('Downloads a CSV export of a saved search panel', async function () { - await pageObjects.common.navigateToApp('dashboard'); - await pageObjects.dashboard.loadSavedDashboard('Ecom Dashboard'); + await PageObjects.common.navigateToApp('dashboard'); + await PageObjects.dashboard.loadSavedDashboard('Ecom Dashboard'); const savedSearchPanel = await testSubjects.find('embeddablePanelHeading-EcommerceData'); await dashboardPanelActions.toggleContextMenu(savedSearchPanel); diff --git a/x-pack/test/functional/apps/dashboard/reporting/screenshots.ts b/x-pack/test/functional/apps/dashboard/reporting/screenshots.ts index 05a86616451ea..cf70e5a7b8b6c 100644 --- a/x-pack/test/functional/apps/dashboard/reporting/screenshots.ts +++ b/x-pack/test/functional/apps/dashboard/reporting/screenshots.ts @@ -17,7 +17,7 @@ const mkdirAsync = promisify(fs.mkdir); const REPORTS_FOLDER = path.resolve(__dirname, 'reports'); export default function ({ getPageObjects, getService }: FtrProviderContext) { - const pageObjects = getPageObjects(['reporting', 'common', 'dashboard']); + const PageObjects = getPageObjects(['reporting', 'common', 'dashboard']); const esArchiver = getService('esArchiver'); const browser = getService('browser'); const log = getService('log'); @@ -43,16 +43,16 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('Print PDF button', () => { it('is not available if new', async () => { - await pageObjects.common.navigateToApp('dashboard'); - await pageObjects.dashboard.clickNewDashboard(); - await pageObjects.reporting.openPdfReportingPanel(); - expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); + await PageObjects.common.navigateToApp('dashboard'); + await PageObjects.dashboard.clickNewDashboard(); + await PageObjects.reporting.openPdfReportingPanel(); + expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); }); it('becomes available when saved', async () => { - await pageObjects.dashboard.saveDashboard('My PDF Dashboard'); - await pageObjects.reporting.openPdfReportingPanel(); - expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); + await PageObjects.dashboard.saveDashboard('My PDF Dashboard'); + await PageObjects.reporting.openPdfReportingPanel(); + expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); }); }); @@ -61,14 +61,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { // Generating and then comparing reports can take longer than the default 60s timeout because the comparePngs // function is taking about 15 seconds per comparison in jenkins. this.timeout(300000); - await pageObjects.common.navigateToApp('dashboard'); - await pageObjects.dashboard.loadSavedDashboard('Ecom Dashboard'); - await pageObjects.reporting.openPdfReportingPanel(); - await pageObjects.reporting.checkUsePrintLayout(); - await pageObjects.reporting.clickGenerateReportButton(); + await PageObjects.common.navigateToApp('dashboard'); + await PageObjects.dashboard.loadSavedDashboard('Ecom Dashboard'); + await PageObjects.reporting.openPdfReportingPanel(); + await PageObjects.reporting.checkUsePrintLayout(); + await PageObjects.reporting.clickGenerateReportButton(); - const url = await pageObjects.reporting.getReportURL(60000); - const res = await pageObjects.reporting.getResponse(url); + const url = await PageObjects.reporting.getReportURL(60000); + const res = await PageObjects.reporting.getResponse(url); expect(res.statusCode).to.equal(200); expect(res.headers['content-type']).to.equal('application/pdf'); @@ -77,16 +77,16 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { describe('Print PNG button', () => { it('is not available if new', async () => { - await pageObjects.common.navigateToApp('dashboard'); - await pageObjects.dashboard.clickNewDashboard(); - await pageObjects.reporting.openPngReportingPanel(); - expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); + await PageObjects.common.navigateToApp('dashboard'); + await PageObjects.dashboard.clickNewDashboard(); + await PageObjects.reporting.openPngReportingPanel(); + expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); }); it('becomes available when saved', async () => { - await pageObjects.dashboard.saveDashboard('My PNG Dash'); - await pageObjects.reporting.openPngReportingPanel(); - expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); + await PageObjects.dashboard.saveDashboard('My PNG Dash'); + await PageObjects.reporting.openPngReportingPanel(); + expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); }); }); @@ -108,15 +108,15 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { this.timeout(300000); - await pageObjects.common.navigateToApp('dashboard'); - await pageObjects.dashboard.loadSavedDashboard('Ecom Dashboard'); - await pageObjects.reporting.openPngReportingPanel(); - await pageObjects.reporting.forceSharedItemsContainerSize({ width: 1405 }); - await pageObjects.reporting.clickGenerateReportButton(); - await pageObjects.reporting.removeForceSharedItemsContainerSize(); + await PageObjects.common.navigateToApp('dashboard'); + await PageObjects.dashboard.loadSavedDashboard('Ecom Dashboard'); + await PageObjects.reporting.openPngReportingPanel(); + await PageObjects.reporting.forceSharedItemsContainerSize({ width: 1405 }); + await PageObjects.reporting.clickGenerateReportButton(); + await PageObjects.reporting.removeForceSharedItemsContainerSize(); - const url = await pageObjects.reporting.getReportURL(60000); - const reportData = await pageObjects.reporting.getRawPdfReportData(url); + const url = await PageObjects.reporting.getReportURL(60000); + const reportData = await PageObjects.reporting.getRawPdfReportData(url); const reportFileName = 'dashboard_preserve_layout'; const sessionReportPath = await writeSessionReport(reportFileName, reportData, 'png'); const percentSimilar = await checkIfPngsMatch( diff --git a/x-pack/test/functional/apps/discover/reporting.ts b/x-pack/test/functional/apps/discover/reporting.ts index cb30eb966636c..32ccc59913dbc 100644 --- a/x-pack/test/functional/apps/discover/reporting.ts +++ b/x-pack/test/functional/apps/discover/reporting.ts @@ -11,7 +11,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const log = getService('log'); const esArchiver = getService('esArchiver'); const browser = getService('browser'); - const pageObjects = getPageObjects(['reporting', 'common', 'discover']); + const PageObjects = getPageObjects(['reporting', 'common', 'discover']); const filterBar = getService('filterBar'); describe('Discover', () => { @@ -25,51 +25,51 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); describe('Generate CSV button', () => { - beforeEach(() => pageObjects.common.navigateToApp('discover')); + beforeEach(() => PageObjects.common.navigateToApp('discover')); it('is not available if new', async () => { - await pageObjects.reporting.openCsvReportingPanel(); - expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); + await PageObjects.reporting.openCsvReportingPanel(); + expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); }); it('becomes available when saved', async () => { - await pageObjects.discover.saveSearch('my search - expectEnabledGenerateReportButton'); - await pageObjects.reporting.openCsvReportingPanel(); - expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); + await PageObjects.discover.saveSearch('my search - expectEnabledGenerateReportButton'); + await PageObjects.reporting.openCsvReportingPanel(); + expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); }); it('becomes available/not available when a saved search is created, changed and saved again', async () => { // create new search, csv export is not available - await pageObjects.discover.clickNewSearchButton(); - await pageObjects.reporting.openCsvReportingPanel(); - expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); + await PageObjects.discover.clickNewSearchButton(); + await PageObjects.reporting.openCsvReportingPanel(); + expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); // save search, csv export is available - await pageObjects.discover.saveSearch('my search - expectEnabledGenerateReportButton 2'); - await pageObjects.reporting.openCsvReportingPanel(); - expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); + await PageObjects.discover.saveSearch('my search - expectEnabledGenerateReportButton 2'); + await PageObjects.reporting.openCsvReportingPanel(); + expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); // add filter, csv export is not available await filterBar.addFilter('currency', 'is', 'EUR'); - await pageObjects.reporting.openCsvReportingPanel(); - expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); + await PageObjects.reporting.openCsvReportingPanel(); + expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); // save search again, csv export is available - await pageObjects.discover.saveSearch('my search - expectEnabledGenerateReportButton 2'); - await pageObjects.reporting.openCsvReportingPanel(); - expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); + await PageObjects.discover.saveSearch('my search - expectEnabledGenerateReportButton 2'); + await PageObjects.reporting.openCsvReportingPanel(); + expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); }); it('generates a report with data', async () => { - await pageObjects.discover.clickNewSearchButton(); - await pageObjects.reporting.setTimepickerInDataRange(); - await pageObjects.discover.saveSearch('my search - with data - expectReportCanBeCreated'); - await pageObjects.reporting.openCsvReportingPanel(); - expect(await pageObjects.reporting.canReportBeCreated()).to.be(true); + await PageObjects.discover.clickNewSearchButton(); + await PageObjects.reporting.setTimepickerInDataRange(); + await PageObjects.discover.saveSearch('my search - with data - expectReportCanBeCreated'); + await PageObjects.reporting.openCsvReportingPanel(); + expect(await PageObjects.reporting.canReportBeCreated()).to.be(true); }); it('generates a report with no data', async () => { - await pageObjects.reporting.setTimepickerInNoDataRange(); - await pageObjects.discover.saveSearch('my search - no data - expectReportCanBeCreated'); - await pageObjects.reporting.openCsvReportingPanel(); - expect(await pageObjects.reporting.canReportBeCreated()).to.be(true); + await PageObjects.reporting.setTimepickerInNoDataRange(); + await PageObjects.discover.saveSearch('my search - no data - expectReportCanBeCreated'); + await PageObjects.reporting.openCsvReportingPanel(); + expect(await PageObjects.reporting.canReportBeCreated()).to.be(true); }); }); }); diff --git a/x-pack/test/functional/apps/lens/lens_reporting.ts b/x-pack/test/functional/apps/lens/lens_reporting.ts index bcdaf819af53b..4974b63be6f72 100644 --- a/x-pack/test/functional/apps/lens/lens_reporting.ts +++ b/x-pack/test/functional/apps/lens/lens_reporting.ts @@ -8,7 +8,7 @@ import expect from '@kbn/expect'; import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { - const pageObjects = getPageObjects(['common', 'dashboard', 'reporting']); + const PageObjects = getPageObjects(['common', 'dashboard', 'reporting']); const es = getService('es'); const esArchiver = getService('esArchiver'); const listingTable = getService('listingTable'); @@ -28,11 +28,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); it('should not cause PDF reports to fail', async () => { - await pageObjects.common.navigateToApp('dashboard'); + await PageObjects.common.navigateToApp('dashboard'); await listingTable.clickItemLink('dashboard', 'Lens reportz'); - await pageObjects.reporting.openPdfReportingPanel(); - await pageObjects.reporting.clickGenerateReportButton(); - const url = await pageObjects.reporting.getReportURL(60000); + await PageObjects.reporting.openPdfReportingPanel(); + await PageObjects.reporting.clickGenerateReportButton(); + const url = await PageObjects.reporting.getReportURL(60000); expect(url).to.be.ok(); }); diff --git a/x-pack/test/functional/apps/visualize/reporting.ts b/x-pack/test/functional/apps/visualize/reporting.ts index 5e1b9a602170b..d1cea5a4481b1 100644 --- a/x-pack/test/functional/apps/visualize/reporting.ts +++ b/x-pack/test/functional/apps/visualize/reporting.ts @@ -12,7 +12,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { const esArchiver = getService('esArchiver'); const browser = getService('browser'); const log = getService('log'); - const pageObjects = getPageObjects([ + const PageObjects = getPageObjects([ 'reporting', 'common', 'dashboard', @@ -39,34 +39,34 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { describe('Print PDF button', () => { it('is not available if new', async () => { - await pageObjects.common.navigateToUrl('visualize', 'new', { useActualUrl: true }); - await pageObjects.visualize.clickAreaChart(); - await pageObjects.visualize.clickNewSearch('ecommerce'); - await pageObjects.reporting.openPdfReportingPanel(); - expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); + await PageObjects.common.navigateToUrl('visualize', 'new', { useActualUrl: true }); + await PageObjects.visualize.clickAreaChart(); + await PageObjects.visualize.clickNewSearch('ecommerce'); + await PageObjects.reporting.openPdfReportingPanel(); + expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be('true'); }); it('becomes available when saved', async () => { - await pageObjects.reporting.setTimepickerInDataRange(); - await pageObjects.visEditor.clickBucket('X-axis'); - await pageObjects.visEditor.selectAggregation('Date Histogram'); - await pageObjects.visEditor.clickGo(); - await pageObjects.visualize.saveVisualization('my viz'); - await pageObjects.reporting.openPdfReportingPanel(); - expect(await pageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); + await PageObjects.reporting.setTimepickerInDataRange(); + await PageObjects.visEditor.clickBucket('X-axis'); + await PageObjects.visEditor.selectAggregation('Date Histogram'); + await PageObjects.visEditor.clickGo(); + await PageObjects.visualize.saveVisualization('my viz'); + await PageObjects.reporting.openPdfReportingPanel(); + expect(await PageObjects.reporting.isGenerateReportButtonDisabled()).to.be(null); }); it('downloaded PDF has OK status', async function () { // Generating and then comparing reports can take longer than the default 60s timeout this.timeout(180000); - await pageObjects.common.navigateToApp('dashboard'); - await pageObjects.dashboard.loadSavedDashboard('Ecom Dashboard'); - await pageObjects.reporting.openPdfReportingPanel(); - await pageObjects.reporting.clickGenerateReportButton(); + await PageObjects.common.navigateToApp('dashboard'); + await PageObjects.dashboard.loadSavedDashboard('Ecom Dashboard'); + await PageObjects.reporting.openPdfReportingPanel(); + await PageObjects.reporting.clickGenerateReportButton(); - const url = await pageObjects.reporting.getReportURL(60000); - const res = await pageObjects.reporting.getResponse(url); + const url = await PageObjects.reporting.getReportURL(60000); + const res = await PageObjects.reporting.getResponse(url); expect(res.statusCode).to.equal(200); expect(res.headers['content-type']).to.equal('application/pdf'); diff --git a/x-pack/test/functional/page_objects/reporting_page.ts b/x-pack/test/functional/page_objects/reporting_page.ts index aef9283f44a07..7631d0cbce59a 100644 --- a/x-pack/test/functional/page_objects/reporting_page.ts +++ b/x-pack/test/functional/page_objects/reporting_page.ts @@ -14,7 +14,7 @@ export function ReportingPageProvider({ getService, getPageObjects }: FtrProvide const retry = getService('retry'); const testSubjects = getService('testSubjects'); - const pageObjects = getPageObjects(['common', 'security' as any, 'share', 'timePicker']); // FIXME: Security PageObject is not Typescript + const PageObjects = getPageObjects(['common', 'security' as any, 'share', 'timePicker']); // FIXME: Security PageObject is not Typescript class ReportingPage { async forceSharedItemsContainerSize({ width }: { width: number }) { @@ -86,17 +86,17 @@ export function ReportingPageProvider({ getService, getPageObjects }: FtrProvide async openCsvReportingPanel() { log.debug('openCsvReportingPanel'); - await pageObjects.share.openShareMenuItem('CSV Reports'); + await PageObjects.share.openShareMenuItem('CSV Reports'); } async openPdfReportingPanel() { log.debug('openPdfReportingPanel'); - await pageObjects.share.openShareMenuItem('PDF Reports'); + await PageObjects.share.openShareMenuItem('PDF Reports'); } async openPngReportingPanel() { log.debug('openPngReportingPanel'); - await pageObjects.share.openShareMenuItem('PNG Reports'); + await PageObjects.share.openShareMenuItem('PNG Reports'); } async clearToastNotifications() { @@ -156,14 +156,14 @@ export function ReportingPageProvider({ getService, getPageObjects }: FtrProvide log.debug('Reporting:setTimepickerInDataRange'); const fromTime = 'Sep 19, 2015 @ 06:31:44.000'; const toTime = 'Sep 19, 2015 @ 18:01:44.000'; - await pageObjects.timePicker.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); } async setTimepickerInNoDataRange() { log.debug('Reporting:setTimepickerInNoDataRange'); const fromTime = 'Sep 19, 1999 @ 06:31:44.000'; const toTime = 'Sep 23, 1999 @ 18:31:44.000'; - await pageObjects.timePicker.setAbsoluteRange(fromTime, toTime); + await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime); } } return new ReportingPage(); From 2609d034ac32d54a2d339a6f9828615efe59bc6d Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Tue, 11 Aug 2020 08:26:18 -0700 Subject: [PATCH 5/6] cleanup after csv generated --- x-pack/test/functional/apps/discover/reporting.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/x-pack/test/functional/apps/discover/reporting.ts b/x-pack/test/functional/apps/discover/reporting.ts index 32ccc59913dbc..7181bf0c74271 100644 --- a/x-pack/test/functional/apps/discover/reporting.ts +++ b/x-pack/test/functional/apps/discover/reporting.ts @@ -9,6 +9,7 @@ import { FtrProviderContext } from '../../ftr_provider_context'; export default function ({ getService, getPageObjects }: FtrProviderContext) { const log = getService('log'); + const es = getService('es'); const esArchiver = getService('esArchiver'); const browser = getService('browser'); const PageObjects = getPageObjects(['reporting', 'common', 'discover']); @@ -22,6 +23,11 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) { }); after('clean up archives', async () => { await esArchiver.unload('reporting/ecommerce'); + await es.deleteByQuery({ + index: '.reporting-*', + refresh: true, + body: { query: { match_all: {} } }, + }); }); describe('Generate CSV button', () => { From d0215ab08be7d20386748aa9e5b543a6e4a122e9 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Tue, 11 Aug 2020 08:39:39 -0700 Subject: [PATCH 6/6] fix snapshot --- .../components/__snapshots__/report_listing.test.tsx.snap | 3 +++ 1 file changed, 3 insertions(+) diff --git a/x-pack/plugins/reporting/public/components/__snapshots__/report_listing.test.tsx.snap b/x-pack/plugins/reporting/public/components/__snapshots__/report_listing.test.tsx.snap index ddba7842f1199..66c3aea8acc13 100644 --- a/x-pack/plugins/reporting/public/components/__snapshots__/report_listing.test.tsx.snap +++ b/x-pack/plugins/reporting/public/components/__snapshots__/report_listing.test.tsx.snap @@ -30,6 +30,7 @@ Array [ }, ] } + data-test-page={0} data-test-subj="reportJobListing" isSelectable={true} itemId="id" @@ -56,6 +57,7 @@ Array [ >
@@ -366,6 +368,7 @@ Array [ ,