From afc1c3a573eb26de6c313203000fa6a1f16931b3 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Thu, 7 Oct 2021 07:35:47 -0700 Subject: [PATCH 1/4] [Reporting] Functional test structure & improvements --- .../test/functional/apps/reporting/README.md | 18 ++++++ .../test/functional/apps/reporting/index.ts | 14 ----- .../functional/apps/reporting/reporting.ts | 55 ------------------- 3 files changed, 18 insertions(+), 69 deletions(-) create mode 100644 x-pack/test/functional/apps/reporting/README.md delete mode 100644 x-pack/test/functional/apps/reporting/index.ts delete mode 100644 x-pack/test/functional/apps/reporting/reporting.ts diff --git a/x-pack/test/functional/apps/reporting/README.md b/x-pack/test/functional/apps/reporting/README.md new file mode 100644 index 0000000000000..ec9bba8b88341 --- /dev/null +++ b/x-pack/test/functional/apps/reporting/README.md @@ -0,0 +1,18 @@ +## Reporting functional tests + +Functional tests on report generation are under the applications that use reporting. + +**PDF/PNG Report testing:** + - `x-pack/test/functional/apps/canvas/reports.ts` + - `x-pack/test/functional/apps/dashboard/reporting/screenshots.ts` + - `x-pack/test/functional/apps/lens/lens_reporting.ts` + - `x-pack/test/functional/apps/visualize/reporting.ts` + +**CSV Report testing:** + - `x-pack/test/functional/apps/dashboard/reporting/download_csv.ts` + - `x-pack/test/functional/apps/discover/reporting.ts` + +Reporting Management app tests are in `functional/apps/reporting_management`. + +**Manage reports testing:** + - `x-pack/test/functional/apps/reporting_management` diff --git a/x-pack/test/functional/apps/reporting/index.ts b/x-pack/test/functional/apps/reporting/index.ts deleted file mode 100644 index 286693f01ac52..0000000000000 --- a/x-pack/test/functional/apps/reporting/index.ts +++ /dev/null @@ -1,14 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { FtrProviderContext } from '../../ftr_provider_context'; - -export default function ({ loadTestFile }: FtrProviderContext) { - describe('Reporting', function () { - loadTestFile(require.resolve('./reporting')); - }); -} diff --git a/x-pack/test/functional/apps/reporting/reporting.ts b/x-pack/test/functional/apps/reporting/reporting.ts deleted file mode 100644 index 0d8034f046e02..0000000000000 --- a/x-pack/test/functional/apps/reporting/reporting.ts +++ /dev/null @@ -1,55 +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; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import expect from '@kbn/expect'; -import { FtrProviderContext } from '../../ftr_provider_context'; - -export default function ({ getService, getPageObjects }: FtrProviderContext) { - const pageObjects = getPageObjects(['dashboard', 'common', 'reporting']); - const es = getService('es'); - const kibanaServer = getService('kibanaServer'); - - const retry = getService('retry'); - - describe('Reporting', function () { - this.tags(['smoke', 'ciGroup2']); - before(async () => { - await kibanaServer.importExport.load( - 'x-pack/test/functional/fixtures/kbn_archiver/packaging' - ); - }); - - after(async () => { - await kibanaServer.importExport.unload( - 'x-pack/test/functional/fixtures/kbn_archiver/packaging' - ); - await es.deleteByQuery({ - index: '.reporting-*', - refresh: true, - body: { query: { match_all: {} } }, - }); - }); - - it('downloaded PDF has OK status', async function () { - this.timeout(180000); - - await pageObjects.common.navigateToApp('dashboards'); - await retry.waitFor('dashboard landing page', async () => { - return await pageObjects.dashboard.onDashboardLandingPage(); - }); - await pageObjects.dashboard.loadSavedDashboard('dashboard'); - await pageObjects.reporting.openPdfReportingPanel(); - await pageObjects.reporting.clickGenerateReportButton(); - - const url = await pageObjects.reporting.getReportURL(60000); - const res = await pageObjects.reporting.getResponse(url); - - expect(res.status).to.equal(200); - expect(res.get('content-type')).to.equal('application/pdf'); - }); - }); -} From fd250c939f2e529cbca26bf668436142b8fe8c46 Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Thu, 7 Oct 2021 07:53:30 -0700 Subject: [PATCH 2/4] show the error of the report generation failure in the test failure --- .../reporting/public/notifier/job_failure.tsx | 1 + .../functional/page_objects/reporting_page.ts | 25 ++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/reporting/public/notifier/job_failure.tsx b/x-pack/plugins/reporting/public/notifier/job_failure.tsx index e892a1f93a7c2..7775afc4d9f82 100644 --- a/x-pack/plugins/reporting/public/notifier/job_failure.tsx +++ b/x-pack/plugins/reporting/public/notifier/job_failure.tsx @@ -35,6 +35,7 @@ export const getFailureToast = ( })} color="danger" iconType="alert" + data-test-errorText={errorText} > {errorText} diff --git a/x-pack/test/functional/page_objects/reporting_page.ts b/x-pack/test/functional/page_objects/reporting_page.ts index 552d2c9c831bd..039f4ff0fbc57 100644 --- a/x-pack/test/functional/page_objects/reporting_page.ts +++ b/x-pack/test/functional/page_objects/reporting_page.ts @@ -19,6 +19,7 @@ export class ReportingPageObject extends FtrService { private readonly retry = this.ctx.getService('retry'); private readonly security = this.ctx.getService('security'); private readonly testSubjects = this.ctx.getService('testSubjects'); + private readonly find = this.ctx.getService('find'); private readonly share = this.ctx.getPageObject('share'); private readonly timePicker = this.ctx.getPageObject('timePicker'); @@ -33,15 +34,21 @@ export class ReportingPageObject extends FtrService { async getReportURL(timeout: number) { this.log.debug('getReportURL'); - const url = await this.testSubjects.getAttribute( - 'downloadCompletedReportButton', - 'href', - timeout - ); - - this.log.debug(`getReportURL got url: ${url}`); - - return url; + try { + const url = await this.testSubjects.getAttribute( + 'downloadCompletedReportButton', + 'href', + timeout + ); + this.log.debug(`getReportURL got url: ${url}`); + + return url; + } catch (err) { + const errorTextEl = await this.find.byCssSelector('[data-test-errorText]'); + const errorText = await errorTextEl.getAttribute('data-test-errorText'); + const newError = new Error(`Test report failed: ${errorText}: ${err}`); + throw newError; + } } async removeForceSharedItemsContainerSize() { From c0601dc01238645bf0124b64250469b6f102613d Mon Sep 17 00:00:00 2001 From: Timothy Sullivan Date: Thu, 7 Oct 2021 11:46:04 -0700 Subject: [PATCH 3/4] update snapshot --- .../public/lib/__snapshots__/stream_handler.test.ts.snap | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/plugins/reporting/public/lib/__snapshots__/stream_handler.test.ts.snap b/x-pack/plugins/reporting/public/lib/__snapshots__/stream_handler.test.ts.snap index 3d49e8e695f9b..9c72de2bf0ed8 100644 --- a/x-pack/plugins/reporting/public/lib/__snapshots__/stream_handler.test.ts.snap +++ b/x-pack/plugins/reporting/public/lib/__snapshots__/stream_handler.test.ts.snap @@ -82,6 +82,7 @@ Array [ "reactNode": Date: Mon, 11 Oct 2021 17:57:19 -0700 Subject: [PATCH 4/4] remove import to non-existent functional app test --- vars/kibanaPipeline.groovy | 1 - x-pack/test/functional/config.js | 1 - 2 files changed, 2 deletions(-) diff --git a/vars/kibanaPipeline.groovy b/vars/kibanaPipeline.groovy index 21e41ce55781f..daf6ca7a8e993 100644 --- a/vars/kibanaPipeline.groovy +++ b/vars/kibanaPipeline.groovy @@ -203,7 +203,6 @@ def withGcsArtifactUpload(workerName, closure) { 'x-pack/test/**/screenshots/diff/*.png', 'x-pack/test/**/screenshots/failure/*.png', 'x-pack/test/**/screenshots/session/*.png', - 'x-pack/test/functional/apps/reporting/reports/session/*.pdf', 'x-pack/test/functional/failure_debug/html/*.html', '.es/**/*.hprof' ] diff --git a/x-pack/test/functional/config.js b/x-pack/test/functional/config.js index 04622c5f21fac..2abd91fd0433a 100644 --- a/x-pack/test/functional/config.js +++ b/x-pack/test/functional/config.js @@ -56,7 +56,6 @@ export default async function ({ readConfigFile }) { resolve(__dirname, './apps/transform'), resolve(__dirname, './apps/reporting_management'), resolve(__dirname, './apps/management'), - resolve(__dirname, './apps/reporting'), resolve(__dirname, './apps/lens'), // smokescreen tests cause flakiness in other tests // This license_management file must be last because it is destructive.