Skip to content

Commit

Permalink
Fix error with reporting urls generated prior to 6.2 (when there was …
Browse files Browse the repository at this point in the history
…no layout parameter) (#23508) (#23595)

* removed passing of ID in to creation of layout and added a new test without a layout param

* renamed test constant so it reflects what we are testing and added comment

* Recommended Changes

* removed */ from end of line
  • Loading branch information
tsullivan committed Oct 19, 2018
1 parent ea221a4 commit 73cc697
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ interface LayoutParams {
dimensions: Size;
}

export function createLayout(server: KbnServer, layoutParams: LayoutParams): Layout {
export function createLayout(server: KbnServer, layoutParams?: LayoutParams): Layout {
if (layoutParams && layoutParams.id === LayoutTypes.PRESERVE_LAYOUT) {
return new PreserveLayout(layoutParams.id, layoutParams.dimensions);
return new PreserveLayout(layoutParams.dimensions);
}

// this is the default because some jobs won't have anything specified
return new PrintLayout(server, layoutParams.id);
return new PrintLayout(server);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
import path from 'path';
import { Size } from '../../../../../types';
import { LayoutTypes } from '../../../common/constants';
import { Layout, PageSizeParams } from './layout';

// We use a zoom of two to bump up the resolution of the screenshot a bit.
Expand All @@ -25,8 +26,8 @@ export class PreserveLayout extends Layout {
private readonly scaledHeight: number;
private readonly scaledWidth: number;

constructor(id: string, size: Size) {
super(id);
constructor(size: Size) {
super(LayoutTypes.PRESERVE_LAYOUT);
this.height = size.height;
this.width = size.width;
this.scaledHeight = size.height * ZOOM;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
import path from 'path';
import { EvaluateOptions, KbnServer, Size } from '../../../../../types';
import { LayoutTypes } from '../../../common/constants';
import { Layout } from './layout';
import { CaptureConfig } from './types';

Expand All @@ -25,8 +26,8 @@ export class PrintLayout extends Layout {

private captureConfig: CaptureConfig;

constructor(server: KbnServer, id: string) {
super(id);
constructor(server: KbnServer) {
super(LayoutTypes.PRINT);
this.captureConfig = server.config().get('xpack.reporting.capture');
}

Expand Down
15 changes: 15 additions & 0 deletions x-pack/test/reporting/api/bwc_generation_urls.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ export default function ({ getService }) {
const usageAPI = getService('usageAPI');

describe('BWC report generation urls', () => {
describe('Pre 6_2', () => {
before(async () => {
await reportingAPI.deleteAllReportingIndexes();
});

// The URL being tested was captured from release 6.4 and then the layout section was removed to test structure before
// preserve_layout was introduced. See https://github.com/elastic/kibana/issues/23414
it('job posted successfully', async () => {
const path = await reportingAPI.postJob(GenerationUrls.PDF_PRINT_DASHBOARD_PRE_6_2);
await reportingAPI.waitForJobToFinish(path);
const stats = await usageAPI.getUsageStats();
reportingAPI.expectCompletedReportCount(stats, 1);
}).timeout(500000);
});

describe('6_2', () => {
before(async () => {
await reportingAPI.deleteAllReportingIndexes();
Expand Down
5 changes: 5 additions & 0 deletions x-pack/test/reporting/api/generation_urls.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 73cc697

Please sign in to comment.