Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 23 additions & 5 deletions x-pack/test/functional/apps/dashboard/reporting/screenshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const es = getService('es');
const testSubjects = getService('testSubjects');

describe('Screenshots', () => {
describe('Dashboard Reporting Screenshots', () => {
before('initialize tests', async () => {
log.debug('ReportingPage:initTests');
await esArchiver.loadIfNeeded('reporting/ecommerce');
Expand Down Expand Up @@ -93,8 +93,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
});
});

describe('Preserve Layout', () => {
it('matches baseline report', async function () {
describe('PNG Layout', () => {
it('downloads a PNG file', async function () {
const writeSessionReport = async (name: string, rawPdf: Buffer, reportExt: string) => {
const sessionDirectory = path.resolve(REPORTS_FOLDER, 'session');
await mkdirAsync(sessionDirectory, { recursive: true });
Expand Down Expand Up @@ -122,14 +122,32 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) {
const reportData = await PageObjects.reporting.getRawPdfReportData(url);
const reportFileName = 'dashboard_preserve_layout';
const sessionReportPath = await writeSessionReport(reportFileName, reportData, 'png');
const percentSimilar = await checkIfPngsMatch(
const percentDiff = await checkIfPngsMatch(
sessionReportPath,
getBaselineReportPath(reportFileName, 'png'),
config.get('screenshots.directory'),
log
);

expect(percentSimilar).to.be.lessThan(0.1);
expect(percentDiff).to.be.lessThan(0.09);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with value being (0.08) : I hit this error

       at Assertion.assert (/Users/rashmikulkarni/Documents/kibana/packages/kbn-expect/expect.js:100:11)
       at Assertion.lessThan.Assertion.below (/Users/rashmikulkarni/Documents/kibana/packages/kbn-expect/expect.js:336:8)
       at Function.lessThan (/Users/rashmikulkarni/Documents/kibana/packages/kbn-expect/expect.js:531:15)
       at Context.<anonymous> (test/functional/apps/dashboard/reporting/screenshots.ts:132:35)
       at Object.apply (/Users/rashmikulkarni/Documents/kibana/packages/kbn-test/src/functional_test_runner/lib/mocha/wrap_function.js:84:16)

changing it to (0.09) - solves it.

});
});

describe('Preserve Layout', () => {
it('downloads a PDF file', async function () {
// 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.clickGenerateReportButton();

const url = await PageObjects.reporting.getReportURL(60000);
const res = await PageObjects.reporting.getResponse(url);

expect(res.status).to.equal(200);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Unfortunately, all that the PDF tests are doing is verifying that the job completes successfully. That is ensured by the 200 response.

@elastic/kibana-app-services we need to think of a good way to validate the contents of a PDF file against a baseline. We have an implementation for PNG but not PDF.

expect(res.get('content-type')).to.equal('application/pdf');
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/visualize/reporting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
'visEditor',
]);

describe('Visualize', () => {
describe('Visualize Reporting Screenshots', () => {
before('initialize tests', async () => {
log.debug('ReportingPage:initTests');
await esArchiver.loadIfNeeded('reporting/ecommerce');
Expand Down
Binary file not shown.
Loading