[Reporting] Functional test structure & improvements (#114298)

* [Reporting] Functional test structure & improvements

* show the error of the report generation failure in the test failure

* update snapshot

* remove import to non-existent functional app test

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Tim Sullivan 2021-10-14 07:37:15 -07:00 committed by GitHub
parent 55a444b17a
commit c5e23b6a5b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 35 additions and 79 deletions

View file

@ -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'
]

View file

@ -82,6 +82,7 @@ Array [
"reactNode": <React.Fragment>
<EuiCallOut
color="danger"
data-test-errorText="this is the failed report error"
iconType="alert"
size="m"
title="The reporting job failed"

View file

@ -35,6 +35,7 @@ export const getFailureToast = (
})}
color="danger"
iconType="alert"
data-test-errorText={errorText}
>
{errorText}
</EuiCallOut>

View file

@ -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`

View file

@ -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'));
});
}

View file

@ -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');
});
});
}

View file

@ -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.

View file

@ -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
);
try {
const url = await this.testSubjects.getAttribute(
'downloadCompletedReportButton',
'href',
timeout
);
this.log.debug(`getReportURL got url: ${url}`);
this.log.debug(`getReportURL got url: ${url}`);
return 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() {