mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
Getting flaky tests back in shape for reporting (#46076)
* Rebasing from master, updating test utils and getting report pdf/png generation * Removing legacy functions, packages and updating README/Licenses * Dropping duplicitive test * Better URL check for lens reporting Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
cab5925c59
commit
5b2e315e5a
18 changed files with 109 additions and 322 deletions
|
@ -101,9 +101,6 @@ export const LICENSE_OVERRIDES = {
|
|||
// TODO can be removed if the PR#9 is accepted on the source
|
||||
'pause-stream@0.0.11': ['MIT'],
|
||||
|
||||
// TODO can be removed once we upgrade past or equal pdf-image@2.0.1
|
||||
'pdf-image@1.1.0': ['MIT'],
|
||||
|
||||
// TODO can be removed once we upgrade the use of walk dependency past or equal to v2.3.14
|
||||
'walk@2.3.9': ['MIT'],
|
||||
};
|
||||
|
|
|
@ -371,6 +371,12 @@ export function CommonPageProvider({ getService, getPageObjects }: FtrProviderCo
|
|||
await browser.pressKeys(browser.keys.ENTER);
|
||||
}
|
||||
|
||||
// Pause the browser at a certain place for debugging
|
||||
// Not meant for usage in CI, only for dev-usage
|
||||
async pause() {
|
||||
return browser.pause();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clicks cancel button on modal
|
||||
* @param overlayWillStay pass in true if your test will show multiple modals in succession
|
||||
|
|
|
@ -199,6 +199,14 @@ export async function BrowserProvider({ getService }: FtrProviderContext) {
|
|||
return await driver.get(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pauses the execution in the browser, similar to setting a breakpoint for debugging.
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
public async pause() {
|
||||
await driver.executeAsyncScript(`(async () => { debugger; return Promise.resolve(); })()`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves the remote environment’s mouse cursor to the specified point {x, y} which is
|
||||
* offset to browser page top left corner.
|
||||
|
|
|
@ -28,6 +28,8 @@ export function DashboardAddPanelProvider({ getService, getPageObjects }) {
|
|||
async clickOpenAddPanel() {
|
||||
log.debug('DashboardAddPanel.clickOpenAddPanel');
|
||||
await testSubjects.click('dashboardAddPanelButton');
|
||||
// Give some time for the animation to complete
|
||||
await PageObjects.common.sleep(500);
|
||||
}
|
||||
|
||||
async clickAddNewEmbeddableLink(type) {
|
||||
|
@ -96,8 +98,8 @@ export function DashboardAddPanelProvider({ getService, getPageObjects }) {
|
|||
if (!isOpen) {
|
||||
await retry.try(async () => {
|
||||
await this.clickOpenAddPanel();
|
||||
const isOpen = await this.isAddPanelOpen();
|
||||
if (!isOpen) {
|
||||
const isNowOpen = await this.isAddPanelOpen();
|
||||
if (!isNowOpen) {
|
||||
throw new Error('Add panel still not open, trying again.');
|
||||
}
|
||||
});
|
||||
|
|
|
@ -43,6 +43,7 @@ import { Browsers } from './browsers';
|
|||
|
||||
const throttleOption: string = process.env.TEST_THROTTLE_NETWORK as string;
|
||||
const headlessBrowser: string = process.env.TEST_BROWSER_HEADLESS as string;
|
||||
const remoteDebug: string = process.env.TEST_REMOTE_DEBUG as string;
|
||||
const SECOND = 1000;
|
||||
const MINUTE = 60 * SECOND;
|
||||
const NO_QUEUE_COMMANDS = ['getLog', 'getStatus', 'newSession', 'quit'];
|
||||
|
@ -97,6 +98,10 @@ async function attemptToCreateCommand(
|
|||
// See: https://chromium.googlesource.com/chromium/src/+/lkgr/headless/README.md
|
||||
chromeOptions.push('headless', 'disable-gpu');
|
||||
}
|
||||
if (remoteDebug === '1') {
|
||||
// Visit chrome://inspect in chrome to remotely view/debug
|
||||
chromeOptions.push('headless', 'disable-gpu', 'remote-debugging-port=9222');
|
||||
}
|
||||
chromeCapabilities.set('goog:chromeOptions', {
|
||||
w3c: false,
|
||||
args: chromeOptions,
|
||||
|
|
|
@ -169,10 +169,14 @@ export function TestSubjectsProvider({ getService }: FtrProviderContext) {
|
|||
});
|
||||
}
|
||||
|
||||
public async getAttribute(selector: string, attribute: string): Promise<string> {
|
||||
public async getAttribute(
|
||||
selector: string,
|
||||
attribute: string,
|
||||
timeout?: number
|
||||
): Promise<string> {
|
||||
return await retry.try(async () => {
|
||||
log.debug(`TestSubjects.getAttribute(${selector}, ${attribute})`);
|
||||
const element = await this.find(selector);
|
||||
const element = await this.find(selector, timeout);
|
||||
return await element.getAttribute(attribute);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -590,8 +590,7 @@ describe('CSV Execute Job', function() {
|
|||
});
|
||||
});
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/43069
|
||||
describe.skip('cancellation', function() {
|
||||
describe('cancellation', function() {
|
||||
const scrollId = getRandomScrollId();
|
||||
|
||||
beforeEach(function() {
|
||||
|
@ -618,10 +617,10 @@ describe('CSV Execute Job', function() {
|
|||
cancellationToken
|
||||
);
|
||||
|
||||
await delay(100);
|
||||
await delay(250);
|
||||
const callCount = callWithRequestStub.callCount;
|
||||
cancellationToken.cancel();
|
||||
await delay(100);
|
||||
await delay(250);
|
||||
expect(callWithRequestStub.callCount).to.be(callCount + 1); // last call is to clear the scroll
|
||||
});
|
||||
|
||||
|
|
|
@ -7,8 +7,15 @@
|
|||
import chrome from 'ui/chrome';
|
||||
import { API_BASE_URL } from '../../common/constants';
|
||||
|
||||
export function downloadReport(jobId: string) {
|
||||
export function getReportURL(jobId: string) {
|
||||
const apiBaseUrl = chrome.addBasePath(API_BASE_URL);
|
||||
const downloadLink = `${apiBaseUrl}/jobs/download/${jobId}`;
|
||||
window.open(downloadLink);
|
||||
|
||||
return downloadLink;
|
||||
}
|
||||
|
||||
export function downloadReport(jobId: string) {
|
||||
const location = getReportURL(jobId);
|
||||
|
||||
window.open(location);
|
||||
}
|
||||
|
|
|
@ -149,8 +149,6 @@
|
|||
"mutation-observer": "^1.0.3",
|
||||
"node-fetch": "^2.6.0",
|
||||
"null-loader": "^3.0.0",
|
||||
"pdf-image": "2.0.0",
|
||||
"pdfjs-dist": "^2.0.943",
|
||||
"pixelmatch": "^5.1.0",
|
||||
"proxyquire": "1.8.0",
|
||||
"react-docgen-typescript-loader": "^3.1.1",
|
||||
|
|
|
@ -15,17 +15,12 @@ interface Props {
|
|||
}
|
||||
|
||||
export const DownloadButton = ({ getUrl, job }: Props) => {
|
||||
const downloadReport = () => {
|
||||
window.open(getUrl(job.id));
|
||||
};
|
||||
|
||||
return (
|
||||
<EuiButton
|
||||
size="s"
|
||||
data-test-subj="downloadCompletedReportButton"
|
||||
onClick={() => {
|
||||
downloadReport();
|
||||
}}
|
||||
href={getUrl(job.id)}
|
||||
target="_blank"
|
||||
>
|
||||
<FormattedMessage
|
||||
id="xpack.reporting.publicNotifier.downloadReportButtonLabel"
|
||||
|
|
|
@ -10,7 +10,6 @@ import { FtrProviderContext } from '../../ftr_provider_context';
|
|||
// eslint-disable-next-line import/no-default-export
|
||||
export default function({ getService, getPageObjects }: FtrProviderContext) {
|
||||
const PageObjects = getPageObjects(['common', 'dashboard', 'reporting']);
|
||||
const find = getService('find');
|
||||
const esArchiver = getService('esArchiver');
|
||||
const listingTable = getService('listingTable');
|
||||
|
||||
|
@ -28,8 +27,9 @@ export default function({ getService, getPageObjects }: FtrProviderContext) {
|
|||
await listingTable.clickItemLink('dashboard', 'Lens reportz');
|
||||
await PageObjects.reporting.openPdfReportingPanel();
|
||||
await PageObjects.reporting.clickGenerateReportButton();
|
||||
const url = await PageObjects.reporting.getReportURL(60000);
|
||||
|
||||
expect(await find.byButtonText('Download report', undefined, 60000)).to.be.ok();
|
||||
expect(url).to.be.ok();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -37,34 +37,6 @@ export function ReportingPageProvider({ getService, getPageObjects }) {
|
|||
await browser.setWindowSize(1600, 850);
|
||||
}
|
||||
|
||||
async getUrlOfTab(tabIndex) {
|
||||
return await retry.try(async () => {
|
||||
log.debug(`reportingPage.getUrlOfTab(${tabIndex}`);
|
||||
const handles = await browser.getAllWindowHandles();
|
||||
log.debug(`Switching to window ${handles[tabIndex]}`);
|
||||
await browser.switchToWindow(handles[tabIndex]);
|
||||
|
||||
const url = await browser.getCurrentUrl();
|
||||
if (!url || url === 'about:blank') {
|
||||
throw new Error('url is blank');
|
||||
}
|
||||
|
||||
await browser.switchToWindow(handles[0]);
|
||||
return url;
|
||||
});
|
||||
}
|
||||
|
||||
async closeTab(tabIndex) {
|
||||
return await retry.try(async () => {
|
||||
log.debug(`reportingPage.closeTab(${tabIndex}`);
|
||||
const handles = await browser.getAllWindowHandles();
|
||||
log.debug(`Switching to window ${handles[tabIndex]}`);
|
||||
await browser.switchToWindow(handles[tabIndex]);
|
||||
await browser.closeCurrentWindow();
|
||||
await browser.switchToWindow(handles[0]);
|
||||
});
|
||||
}
|
||||
|
||||
async forceSharedItemsContainerSize({ width }) {
|
||||
await browser.execute(`
|
||||
var el = document.querySelector('[data-shared-items-container]');
|
||||
|
@ -73,6 +45,16 @@ export function ReportingPageProvider({ getService, getPageObjects }) {
|
|||
`);
|
||||
}
|
||||
|
||||
async getReportURL(timeout) {
|
||||
log.debug('getReportURL');
|
||||
|
||||
const url = await testSubjects.getAttribute('downloadCompletedReportButton', 'href', timeout);
|
||||
|
||||
log.debug(`getReportURL got url: ${url}`);
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
async removeForceSharedItemsContainerSize() {
|
||||
await browser.execute(`
|
||||
var el = document.querySelector('[data-shared-items-container]');
|
||||
|
@ -81,9 +63,8 @@ export function ReportingPageProvider({ getService, getPageObjects }) {
|
|||
`);
|
||||
}
|
||||
|
||||
getRawPdfReportData(url) {
|
||||
log.debug(`getRawPdfReportData for ${url}`);
|
||||
let data = []; // List of Buffer objects
|
||||
getResponse(url) {
|
||||
log.debug(`getResponse for ${url}`);
|
||||
const auth = config.get('servers.elasticsearch.auth');
|
||||
const headers = {
|
||||
Authorization: `Basic ${Buffer.from(auth).toString('base64')}`,
|
||||
|
@ -100,13 +81,7 @@ export function ReportingPageProvider({ getService, getPageObjects }) {
|
|||
headers,
|
||||
},
|
||||
res => {
|
||||
res.on('data', function(chunk) {
|
||||
data.push(chunk);
|
||||
});
|
||||
res.on('end', function() {
|
||||
data = Buffer.concat(data);
|
||||
resolve(data);
|
||||
});
|
||||
resolve(res);
|
||||
}
|
||||
)
|
||||
.on('error', e => {
|
||||
|
@ -115,6 +90,18 @@ export function ReportingPageProvider({ getService, getPageObjects }) {
|
|||
});
|
||||
}
|
||||
|
||||
async getRawPdfReportData(url) {
|
||||
const data = []; // List of Buffer objects
|
||||
log.debug(`getRawPdfReportData for ${url}`);
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const response = await this.getResponse(url).catch(reject);
|
||||
|
||||
response.on('data', chunk => data.push(chunk));
|
||||
response.on('end', () => resolve(Buffer.concat(data)));
|
||||
});
|
||||
}
|
||||
|
||||
async openCsvReportingPanel() {
|
||||
log.debug('openCsvReportingPanel');
|
||||
await PageObjects.share.openShareMenuItem('CSV Reports');
|
||||
|
@ -130,10 +117,6 @@ export function ReportingPageProvider({ getService, getPageObjects }) {
|
|||
await PageObjects.share.openShareMenuItem('PNG Reports');
|
||||
}
|
||||
|
||||
async clickDownloadReportButton(timeout) {
|
||||
await testSubjects.click('downloadCompletedReportButton', timeout);
|
||||
}
|
||||
|
||||
async clearToastNotifications() {
|
||||
const toasts = await testSubjects.findAll('toastCloseButton');
|
||||
await Promise.all(toasts.map(async t => await t.click()));
|
||||
|
@ -175,7 +158,9 @@ export function ReportingPageProvider({ getService, getPageObjects }) {
|
|||
|
||||
async setTimepickerInDataRange() {
|
||||
log.debug('Reporting:setTimepickerInDataRange');
|
||||
await PageObjects.timePicker.setDefaultAbsoluteRange();
|
||||
const fromTime = 'Sep 19, 2015 @ 06:31:44.000';
|
||||
const toTime = 'Sep 19, 2015 @ 18:01:44.000';
|
||||
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
|
||||
}
|
||||
|
||||
async setTimepickerInNoDataRange() {
|
||||
|
|
|
@ -9,8 +9,8 @@ Reporting tests have their own top level test folder because:
|
|||
### Running the tests
|
||||
|
||||
There is more information on running x-pack tests here: https://github.com/elastic/kibana/blob/master/x-pack/README.md#running-functional-tests. Similar to running the API tests, you need to specify a reporting configuration file. Reporting currently has two configuration files you can point to:
|
||||
- test/reporting/configs/chromium_api.js
|
||||
- test/reporting/configs/chromium_functional.js
|
||||
- test/reporting/configs/chromium_api.js
|
||||
- test/reporting/configs/chromium_functional.js
|
||||
|
||||
The `api` versions hit the reporting api and ensure report generation completes successfully, but does not verify the output of the reports. This is done in the `functional` test versions, which does a snapshot comparison of the generated URL against a baseline to determine success.
|
||||
|
||||
|
@ -33,10 +33,6 @@ node scripts/functional_tests_server.js --config test/reporting/configs/[test_co
|
|||
node ../scripts/functional_test_runner.js --config test/reporting/configs/[test_config_name_here].js
|
||||
```
|
||||
|
||||
**Prerequisites**
|
||||
The reporting functional tests use [pdf-image](https://www.npmjs.com/package/pdf-image) to convert PDF's pages to png files for image comparisons between generated reports and baseline reports.
|
||||
pdf-image requires the system commands `convert`, `gs`, and `pdfinfo` to function. Those can be set up by running the following.
|
||||
|
||||
```sh
|
||||
//OSX
|
||||
brew install imagemagick ghostscript poppler
|
||||
|
@ -99,7 +95,7 @@ node ../scripts/es_archiver.js --es-url http://elastic:changeme@localhost:9200 l
|
|||
7. Generate some reporting URLs
|
||||
- Use a mixture of Visualize, Discover (CSV), Dashboard
|
||||
- Can view the current test coverage by checkout out [api/generation_urls.js](https://github.com/elastic/kibana/blob/master/x-pack/test/reporting/api/generation_urls.js). You can use different ones for better test coverage (e.g. different dashboards, different visualizations).
|
||||
- Don’t generate urls from huge dashboards since this is time consuming.
|
||||
- Don’t generate urls from huge dashboards since this is time consuming.
|
||||
- Use dashboards that have time saved with them if you wish to have data included.
|
||||
8. Save these reporting urls.
|
||||
9. Navigate back to the main branch via `git checkout master`. Then create, or work off your branch as usual to add the extra test coverage.
|
||||
|
|
|
@ -25,6 +25,8 @@ export default async function({ readConfigFile }) {
|
|||
'["info","warning","error","fatal","optimize","reporting"]',
|
||||
'--xpack.endpoint.enabled=true',
|
||||
'--xpack.reporting.csv.enablePanelActionDownload=true',
|
||||
'--xpack.reporting.csv.checkForFormulas=false',
|
||||
'--xpack.reporting.csv.maxSizeBytes=25000000',
|
||||
'--xpack.security.session.idleTimeout=3600000',
|
||||
'--xpack.spaces.enabled=false',
|
||||
],
|
||||
|
|
|
@ -1,85 +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 path from 'path';
|
||||
import fs from 'fs';
|
||||
import { promisify } from 'util';
|
||||
import { PDFImage } from 'pdf-image';
|
||||
import PDFJS from 'pdfjs-dist';
|
||||
import { comparePngs } from '../../../../../test/functional/services/lib/compare_pngs';
|
||||
|
||||
const mkdirAsync = promisify(fs.mkdir);
|
||||
|
||||
export async function checkIfPdfsMatch(actualPdfPath, baselinePdfPath, screenshotsDirectory, log) {
|
||||
log.debug(`checkIfPdfsMatch: ${actualPdfPath} vs ${baselinePdfPath}`);
|
||||
// Copy the pdfs into the screenshot session directory, as that's where the generated pngs will automatically be
|
||||
// stored.
|
||||
const sessionDirectoryPath = path.resolve(screenshotsDirectory, 'session');
|
||||
const failureDirectoryPath = path.resolve(screenshotsDirectory, 'failure');
|
||||
|
||||
await mkdirAsync(sessionDirectoryPath, { recursive: true });
|
||||
await mkdirAsync(failureDirectoryPath, { recursive: true });
|
||||
|
||||
const actualPdfFileName = path.basename(actualPdfPath, '.pdf');
|
||||
const baselinePdfFileName = path.basename(baselinePdfPath, '.pdf');
|
||||
|
||||
const baselineCopyPath = path.resolve(
|
||||
sessionDirectoryPath,
|
||||
`${baselinePdfFileName}_baseline.pdf`
|
||||
);
|
||||
const actualCopyPath = path.resolve(sessionDirectoryPath, `${actualPdfFileName}_actual.pdf`);
|
||||
|
||||
// Don't cause a test failure if the baseline snapshot doesn't exist - we don't have all OS's covered and we
|
||||
// don't want to start causing failures for other devs working on OS's which are lacking snapshots. We have
|
||||
// mac and linux covered which is better than nothing for now.
|
||||
try {
|
||||
log.debug(`writeFileSync: ${baselineCopyPath}`);
|
||||
fs.writeFileSync(baselineCopyPath, fs.readFileSync(baselinePdfPath));
|
||||
} catch (error) {
|
||||
log.error(`No baseline pdf found at ${baselinePdfPath}`);
|
||||
return 0;
|
||||
}
|
||||
log.debug(`writeFileSync: ${actualCopyPath}`);
|
||||
fs.writeFileSync(actualCopyPath, fs.readFileSync(actualPdfPath));
|
||||
|
||||
const convertOptions = {};
|
||||
|
||||
const actualPdfImage = new PDFImage(actualCopyPath, { convertOptions });
|
||||
const expectedPdfImage = new PDFImage(baselineCopyPath, { convertOptions });
|
||||
|
||||
log.debug(`Calculating numberOfPages`);
|
||||
|
||||
const actualDoc = await PDFJS.getDocument(actualCopyPath);
|
||||
const expectedDoc = await PDFJS.getDocument(baselineCopyPath);
|
||||
const actualPages = actualDoc.numPages;
|
||||
const expectedPages = expectedDoc.numPages;
|
||||
|
||||
if (actualPages !== expectedPages) {
|
||||
throw new Error(
|
||||
`Expected ${expectedPages} pages but got ${actualPages} in PDFs expected: "${baselineCopyPath}" actual: "${actualCopyPath}".`
|
||||
);
|
||||
}
|
||||
|
||||
let diffTotal = 0;
|
||||
|
||||
for (let pageNum = 0; pageNum <= expectedPages; ++pageNum) {
|
||||
log.debug(`Converting expected pdf page ${pageNum} to png`);
|
||||
const expectedPagePng = await expectedPdfImage.convertPage(pageNum);
|
||||
log.debug(`Converting actual pdf page ${pageNum} to png`);
|
||||
const actualPagePng = await actualPdfImage.convertPage(pageNum);
|
||||
const diffPngPath = path.resolve(failureDirectoryPath, `${baselinePdfFileName}-${pageNum}.png`);
|
||||
diffTotal += await comparePngs(
|
||||
actualPagePng,
|
||||
expectedPagePng,
|
||||
diffPngPath,
|
||||
sessionDirectoryPath,
|
||||
log
|
||||
);
|
||||
pageNum++;
|
||||
}
|
||||
|
||||
return diffTotal;
|
||||
}
|
|
@ -4,5 +4,4 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
export { checkIfPdfsMatch } from './compare_pdfs';
|
||||
export { checkIfPngsMatch } from './compare_pngs';
|
||||
|
|
|
@ -8,7 +8,7 @@ import expect from '@kbn/expect';
|
|||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { promisify } from 'util';
|
||||
import { checkIfPdfsMatch, checkIfPngsMatch } from './lib';
|
||||
import { checkIfPngsMatch } from './lib';
|
||||
|
||||
const writeFileAsync = promisify(fs.writeFile);
|
||||
const mkdirAsync = promisify(fs.mkdir);
|
||||
|
@ -29,9 +29,7 @@ export default function({ getService, getPageObjects }) {
|
|||
]);
|
||||
const log = getService('log');
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/45499
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/48721
|
||||
describe.skip('Reporting', () => {
|
||||
describe('Reporting', () => {
|
||||
before('initialize tests', async () => {
|
||||
await PageObjects.reporting.initTests();
|
||||
});
|
||||
|
@ -68,7 +66,9 @@ export default function({ getService, getPageObjects }) {
|
|||
|
||||
const getBaselineReportPath = (fileName, reportExt = 'pdf') => {
|
||||
const baselineFolder = path.resolve(REPORTS_FOLDER, 'baseline');
|
||||
return path.resolve(baselineFolder, `${fileName}.${reportExt}`);
|
||||
const fullPath = path.resolve(baselineFolder, `${fileName}.${reportExt}`);
|
||||
log.debug(`getBaselineReportPath (${fullPath})`);
|
||||
return fullPath;
|
||||
};
|
||||
|
||||
describe('Dashboard', () => {
|
||||
|
@ -83,118 +83,40 @@ export default function({ getService, getPageObjects }) {
|
|||
});
|
||||
|
||||
it('becomes available when saved', async () => {
|
||||
await PageObjects.dashboard.saveDashboard('mypdfdash');
|
||||
await PageObjects.dashboard.saveDashboard('My PDF Dashboard');
|
||||
await PageObjects.reporting.openPdfReportingPanel();
|
||||
await expectEnabledGenerateReportButton();
|
||||
});
|
||||
});
|
||||
|
||||
describe.skip('Print Layout', () => {
|
||||
it('matches baseline report', async function() {
|
||||
describe('Print 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(360000);
|
||||
this.timeout(300000);
|
||||
|
||||
await PageObjects.dashboard.switchToEditMode();
|
||||
await PageObjects.reporting.setTimepickerInDataRange();
|
||||
const visualizations = PageObjects.dashboard.getTestVisualizationNames();
|
||||
|
||||
// There is a current issue causing reports with tilemaps to timeout:
|
||||
// https://github.com/elastic/kibana/issues/14136. Once that is resolved, add the tilemap visualization
|
||||
// back in!
|
||||
const tileMapIndex = visualizations.indexOf('Visualization TileMap');
|
||||
visualizations.splice(tileMapIndex, 1);
|
||||
|
||||
await PageObjects.dashboard.addVisualizations(visualizations);
|
||||
|
||||
await PageObjects.dashboard.saveDashboard('report test');
|
||||
|
||||
await PageObjects.reporting.openPdfReportingPanel();
|
||||
await PageObjects.reporting.checkUsePrintLayout();
|
||||
await PageObjects.reporting.clickGenerateReportButton();
|
||||
await PageObjects.reporting.clickDownloadReportButton(60000);
|
||||
PageObjects.reporting.clearToastNotifications();
|
||||
|
||||
const url = await PageObjects.reporting.getUrlOfTab(1);
|
||||
await PageObjects.reporting.closeTab(1);
|
||||
const reportData = await PageObjects.reporting.getRawPdfReportData(url);
|
||||
const reportFileName = 'dashboard_print';
|
||||
const sessionReportPath = await writeSessionReport(reportFileName, reportData);
|
||||
const percentSimilar = await checkIfPdfsMatch(
|
||||
sessionReportPath,
|
||||
getBaselineReportPath(reportFileName),
|
||||
config.get('screenshots.directory'),
|
||||
log
|
||||
);
|
||||
// After expected OS differences, the diff count came to be around 128k
|
||||
expect(percentSimilar).to.be.lessThan(0.05);
|
||||
});
|
||||
|
||||
it('matches same baseline report with margins turned on', 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(360000);
|
||||
|
||||
await PageObjects.dashboard.switchToEditMode();
|
||||
await PageObjects.dashboard.useMargins(true);
|
||||
await PageObjects.dashboard.saveDashboard('report test');
|
||||
await PageObjects.reporting.openPdfReportingPanel();
|
||||
await PageObjects.reporting.checkUsePrintLayout();
|
||||
await PageObjects.reporting.clickGenerateReportButton();
|
||||
await PageObjects.reporting.clickDownloadReportButton(60000);
|
||||
PageObjects.reporting.clearToastNotifications();
|
||||
|
||||
const url = await PageObjects.reporting.getUrlOfTab(1);
|
||||
const reportData = await PageObjects.reporting.getRawPdfReportData(url);
|
||||
const url = await PageObjects.reporting.getReportURL(60000);
|
||||
const res = await PageObjects.reporting.getResponse(url);
|
||||
|
||||
await PageObjects.reporting.closeTab(1);
|
||||
const reportFileName = 'dashboard_print';
|
||||
const sessionReportPath = await writeSessionReport(reportFileName, reportData);
|
||||
const percentSimilar = await checkIfPdfsMatch(
|
||||
sessionReportPath,
|
||||
getBaselineReportPath(reportFileName),
|
||||
config.get('screenshots.directory'),
|
||||
log
|
||||
);
|
||||
// After expected OS differences, the diff count came to be around 128k
|
||||
expect(percentSimilar).to.be.lessThan(0.05);
|
||||
expect(res.statusCode).to.equal(200);
|
||||
expect(res.headers['content-type']).to.equal('application/pdf');
|
||||
});
|
||||
});
|
||||
|
||||
// TODO Re-enable the tests after removing Phantom:
|
||||
// https://github.com/elastic/kibana/issues/21485
|
||||
describe.skip('Preserve Layout', () => {
|
||||
it('matches baseline report', 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(360000);
|
||||
|
||||
await PageObjects.reporting.openPdfReportingPanel();
|
||||
await PageObjects.reporting.forceSharedItemsContainerSize({ width: 1405 });
|
||||
await PageObjects.reporting.clickGenerateReportButton();
|
||||
await PageObjects.reporting.removeForceSharedItemsContainerSize();
|
||||
|
||||
await PageObjects.reporting.clickDownloadReportButton(60000);
|
||||
PageObjects.reporting.clearToastNotifications();
|
||||
|
||||
const url = await PageObjects.reporting.getUrlOfTab(1);
|
||||
await PageObjects.reporting.closeTab(1);
|
||||
const reportData = await PageObjects.reporting.getRawPdfReportData(url);
|
||||
|
||||
const reportFileName = 'dashboard_preserve_layout';
|
||||
const sessionReportPath = await writeSessionReport(reportFileName, reportData);
|
||||
|
||||
const percentSimilar = await checkIfPdfsMatch(
|
||||
sessionReportPath,
|
||||
getBaselineReportPath(reportFileName),
|
||||
config.get('screenshots.directory'),
|
||||
log
|
||||
);
|
||||
expect(percentSimilar).to.be.lessThan(0.05);
|
||||
});
|
||||
});
|
||||
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/43131
|
||||
describe.skip('Print PNG button', () => {
|
||||
describe('Print PNG button', () => {
|
||||
it('is not available if new', async () => {
|
||||
await PageObjects.common.navigateToApp('dashboard');
|
||||
await PageObjects.dashboard.clickNewDashboard();
|
||||
|
@ -203,45 +125,32 @@ export default function({ getService, getPageObjects }) {
|
|||
});
|
||||
|
||||
it('becomes available when saved', async () => {
|
||||
await PageObjects.dashboard.saveDashboard('mypngdash');
|
||||
await PageObjects.dashboard.saveDashboard('My PNG Dash');
|
||||
await PageObjects.reporting.openPngReportingPanel();
|
||||
await expectEnabledGenerateReportButton();
|
||||
});
|
||||
});
|
||||
|
||||
// TODO Re-enable the tests after removing Phantom:
|
||||
// https://github.com/elastic/kibana/issues/21485
|
||||
describe.skip('Preserve Layout', () => {
|
||||
describe('Preserve Layout', () => {
|
||||
it('matches baseline report', 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(360000);
|
||||
this.timeout(300000);
|
||||
|
||||
await PageObjects.dashboard.switchToEditMode();
|
||||
await PageObjects.reporting.setTimepickerInDataRange();
|
||||
const visualizations = PageObjects.dashboard.getTestVisualizationNames();
|
||||
|
||||
// There is a current issue causing reports with tilemaps to timeout:
|
||||
// https://github.com/elastic/kibana/issues/14136. Once that is resolved, add the tilemap visualization
|
||||
// back in!
|
||||
const visualizations = PageObjects.dashboard.getTestVisualizationNames();
|
||||
const tileMapIndex = visualizations.indexOf('Visualization TileMap');
|
||||
visualizations.splice(tileMapIndex, 1);
|
||||
|
||||
await PageObjects.dashboard.addVisualizations(visualizations);
|
||||
|
||||
await PageObjects.dashboard.saveDashboard('PNG report test');
|
||||
|
||||
await PageObjects.reporting.openPngReportingPanel();
|
||||
await PageObjects.reporting.forceSharedItemsContainerSize({ width: 1405 });
|
||||
await PageObjects.reporting.clickGenerateReportButton();
|
||||
await PageObjects.reporting.removeForceSharedItemsContainerSize();
|
||||
|
||||
await PageObjects.reporting.clickDownloadReportButton(60000);
|
||||
PageObjects.reporting.clearToastNotifications();
|
||||
|
||||
const url = await PageObjects.reporting.getUrlOfTab(1);
|
||||
await PageObjects.reporting.closeTab(1);
|
||||
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(
|
||||
|
@ -250,14 +159,14 @@ export default function({ getService, getPageObjects }) {
|
|||
config.get('screenshots.directory'),
|
||||
log
|
||||
);
|
||||
expect(percentSimilar).to.be.lessThan(0.05);
|
||||
|
||||
expect(percentSimilar).to.be.lessThan(0.1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Discover', () => {
|
||||
// FLAKY: https://github.com/elastic/kibana/issues/31379
|
||||
describe.skip('Generate CSV button', () => {
|
||||
describe('Generate CSV button', () => {
|
||||
beforeEach(() => PageObjects.common.navigateToApp('discover'));
|
||||
|
||||
it('is not available if new', async () => {
|
||||
|
@ -307,31 +216,19 @@ export default function({ getService, getPageObjects }) {
|
|||
await expectEnabledGenerateReportButton();
|
||||
});
|
||||
|
||||
// TODO Re-enable the tests after removing Phantom:
|
||||
// https://github.com/elastic/kibana/issues/21485
|
||||
it.skip('matches baseline report', async function() {
|
||||
it('matches baseline report', 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(180000);
|
||||
|
||||
await PageObjects.reporting.openPdfReportingPanel();
|
||||
await PageObjects.reporting.clickGenerateReportButton();
|
||||
await PageObjects.reporting.clickDownloadReportButton(60000);
|
||||
PageObjects.reporting.clearToastNotifications();
|
||||
|
||||
const url = await PageObjects.reporting.getUrlOfTab(1);
|
||||
const reportData = await PageObjects.reporting.getRawPdfReportData(url);
|
||||
const url = await PageObjects.reporting.getReportURL(60000);
|
||||
const res = await PageObjects.reporting.getResponse(url);
|
||||
|
||||
await PageObjects.reporting.closeTab(1);
|
||||
const reportFileName = 'visualize_print';
|
||||
const sessionReportPath = await writeSessionReport(reportFileName, reportData);
|
||||
const percentSimilar = await checkIfPdfsMatch(
|
||||
sessionReportPath,
|
||||
getBaselineReportPath(reportFileName),
|
||||
config.get('screenshots.directory'),
|
||||
log
|
||||
);
|
||||
expect(percentSimilar).to.be.lessThan(0.05);
|
||||
expect(res.statusCode).to.equal(200);
|
||||
expect(res.headers['content-type']).to.equal('application/pdf');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
32
yarn.lock
32
yarn.lock
|
@ -11309,7 +11309,7 @@ es6-promise-pool@^2.5.0:
|
|||
resolved "https://registry.yarnpkg.com/es6-promise-pool/-/es6-promise-pool-2.5.0.tgz#147c612b36b47f105027f9d2bf54a598a99d9ccb"
|
||||
integrity sha1-FHxhKza0fxBQJ/nSv1SlmKmdnMs=
|
||||
|
||||
es6-promise@^4.0.3, es6-promise@~4.2.4:
|
||||
es6-promise@^4.0.3:
|
||||
version "4.2.4"
|
||||
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.4.tgz#dc4221c2b16518760bd8c39a52d8f356fc00ed29"
|
||||
integrity sha512-/NdNZVJg+uZgtm9eS3O6lrOLYmQag2DjdEXuPaHlZ6RuVqgqaVZfgYCepEIKsLqwdQArOPtC3XzRLqGGfT8KQQ==
|
||||
|
@ -20199,11 +20199,6 @@ node-dir@^0.1.10:
|
|||
dependencies:
|
||||
minimatch "^3.0.2"
|
||||
|
||||
node-ensure@^0.0.0:
|
||||
version "0.0.0"
|
||||
resolved "https://registry.yarnpkg.com/node-ensure/-/node-ensure-0.0.0.tgz#ecae764150de99861ec5c810fd5d096b183932a7"
|
||||
integrity sha1-7K52QVDemYYexcgQ/V0Jaxg5Mqc=
|
||||
|
||||
node-environment-flags@1.0.5:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/node-environment-flags/-/node-environment-flags-1.0.5.tgz#fa930275f5bf5dae188d6192b24b4c8bbac3d76a"
|
||||
|
@ -21801,21 +21796,6 @@ pbkdf2@^3.0.3:
|
|||
safe-buffer "^5.0.1"
|
||||
sha.js "^2.4.8"
|
||||
|
||||
pdf-image@2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/pdf-image/-/pdf-image-2.0.0.tgz#f134296876c3d5aacb6bb5805ad15d0a46775fd5"
|
||||
integrity sha512-RyB8f/Khw8wZt2xXGWtQu/5ZyKl4pzNSi9/dnYNJOuGnxRiZvmUVmz6xmG6Xts53k8ZZaOBjDwoT4jjAVzIoPQ==
|
||||
dependencies:
|
||||
es6-promise "~4.2.4"
|
||||
|
||||
pdfjs-dist@^2.0.943:
|
||||
version "2.0.943"
|
||||
resolved "https://registry.yarnpkg.com/pdfjs-dist/-/pdfjs-dist-2.0.943.tgz#32fb9a2d863df5a1d89521a0b3cd900c16e7edde"
|
||||
integrity sha512-iLhNcm4XceTHRaSU5o22ZGCm4YpuW5+rf4+BJFH/feBhMQLbCGBry+Jet8Q419QDI4qgARaIQzXuiNrsNWS8Yw==
|
||||
dependencies:
|
||||
node-ensure "^0.0.0"
|
||||
worker-loader "^2.0.0"
|
||||
|
||||
pdfkit@>=0.8.1, pdfkit@^0.11.0:
|
||||
version "0.11.0"
|
||||
resolved "https://registry.yarnpkg.com/pdfkit/-/pdfkit-0.11.0.tgz#9cdb2fc42bd2913587fe3ddf48cc5bbb3c36f7de"
|
||||
|
@ -25356,7 +25336,7 @@ schema-utils@^0.3.0:
|
|||
dependencies:
|
||||
ajv "^5.0.0"
|
||||
|
||||
schema-utils@^0.4.0, schema-utils@^0.4.5:
|
||||
schema-utils@^0.4.5:
|
||||
version "0.4.7"
|
||||
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-0.4.7.tgz#ba74f597d2be2ea880131746ee17d0a093c68187"
|
||||
integrity sha512-v/iwU6wvwGK8HbU9yi3/nhGzP0yGSuhQMzL6ySiec1FSrZZDkhm4noOSWzrNFo/jEc+SJY6jRTwuwbSXJPDUnQ==
|
||||
|
@ -30394,14 +30374,6 @@ worker-farm@^1.7.0:
|
|||
dependencies:
|
||||
errno "~0.1.7"
|
||||
|
||||
worker-loader@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/worker-loader/-/worker-loader-2.0.0.tgz#45fda3ef76aca815771a89107399ee4119b430ac"
|
||||
integrity sha512-tnvNp4K3KQOpfRnD20m8xltE3eWh89Ye+5oj7wXEEHKac1P4oZ6p9oTj8/8ExqoSBnk9nu5Pr4nKfQ1hn2APJw==
|
||||
dependencies:
|
||||
loader-utils "^1.0.0"
|
||||
schema-utils "^0.4.0"
|
||||
|
||||
worker-rpc@^0.1.0:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/worker-rpc/-/worker-rpc-0.1.1.tgz#cb565bd6d7071a8f16660686051e969ad32f54d5"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue