Skip to content

Commit

Permalink
[Reporting/Legacy] Remove reporting legacy job params compatibility s…
Browse files Browse the repository at this point in the history
…him (#52539)

* [Reporting/Tests] consolidate functional test configs

* remove console.log

* trash

* Update

* add more to the comment

* restore historic archive for wip ui functional tests

* [Reporting/Legacy] Remove reporting legacy job params compatibility shimmy shim shim

* objectType: objectType

* fix jest test and get_urls logging

* simplify change

Co-authored-by: Elastic Machine <[email protected]>
  • Loading branch information
tsullivan and elasticmachine authored Jan 6, 2020
1 parent 9481cbf commit fef8485
Show file tree
Hide file tree
Showing 17 changed files with 38 additions and 713 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test(`fails if no URL is passed`, async () => {
server: mockServer,
} as FullUrlsOpts);
expect(fn).toThrowErrorMatchingInlineSnapshot(
`"No valid URL fields found in Job Params! Expected \`job.relativeUrl\` or \`job.objects[{ relativeUrl }]\`"`
`"No valid URL fields found in Job Params! Expected \`job.relativeUrl: string\` or \`job.relativeUrls: string[]\`"`
);
});

Expand Down Expand Up @@ -64,7 +64,10 @@ test(`fails if URLs are file-protocols for PDF`, async () => {
const relativeUrl = 'file://etc/passwd/#/something';
const fn = () =>
getFullUrls({
job: { objects: [{ relativeUrl }], forceNow },
job: {
relativeUrls: [relativeUrl],
forceNow,
},
server: mockServer,
} as FullUrlsOpts);
expect(fn).toThrowErrorMatchingInlineSnapshot(
Expand All @@ -79,11 +82,7 @@ test(`fails if URLs are absolute for PDF`, async () => {
const fn = () =>
getFullUrls({
job: {
objects: [
{
relativeUrl,
},
],
relativeUrls: [relativeUrl],
forceNow,
},
server: mockServer,
Expand All @@ -95,18 +94,15 @@ test(`fails if URLs are absolute for PDF`, async () => {

test(`fails if any URLs are absolute or file's for PDF`, async () => {
const forceNow = '2000-01-01T00:00:00.000Z';
const objects = [
{ relativeUrl: '/app/kibana#/something_aaa' },
{
relativeUrl:
'http://169.254.169.254/latest/meta-data/iam/security-credentials/profileName/#/something',
},
{ relativeUrl: 'file://etc/passwd/#/something' },
const relativeUrls = [
'/app/kibana#/something_aaa',
'http://169.254.169.254/latest/meta-data/iam/security-credentials/profileName/#/something',
'file://etc/passwd/#/something',
];

const fn = () =>
getFullUrls({
job: { objects, forceNow },
job: { relativeUrls, forceNow },
server: mockServer,
} as FullUrlsOpts);
expect(fn).toThrowErrorMatchingInlineSnapshot(
Expand Down Expand Up @@ -163,11 +159,11 @@ test(`adds forceNow to each of multiple urls`, async () => {
const forceNow = '2000-01-01T00:00:00.000Z';
const urls = await getFullUrls({
job: {
objects: [
{ relativeUrl: '/app/kibana#/something_aaa' },
{ relativeUrl: '/app/kibana#/something_bbb' },
{ relativeUrl: '/app/kibana#/something_ccc' },
{ relativeUrl: '/app/kibana#/something_ddd' },
relativeUrls: [
'/app/kibana#/something_aaa',
'/app/kibana#/something_bbb',
'/app/kibana#/something_ccc',
'/app/kibana#/something_ddd',
],
forceNow,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function isPngJob(job: JobDocPayloadPNG | JobDocPayloadPDF): job is JobDocPayloa
return (job as JobDocPayloadPNG).relativeUrl !== undefined;
}
function isPdfJob(job: JobDocPayloadPNG | JobDocPayloadPDF): job is JobDocPayloadPDF {
return (job as JobDocPayloadPDF).objects !== undefined;
return (job as JobDocPayloadPDF).relativeUrls !== undefined;
}

export function getFullUrls<JobDocPayloadType>({
Expand All @@ -45,10 +45,10 @@ export function getFullUrls<JobDocPayloadType>({
if (isPngJob(job)) {
relativeUrls = [job.relativeUrl];
} else if (isPdfJob(job)) {
relativeUrls = job.objects.map(obj => obj.relativeUrl);
relativeUrls = job.relativeUrls;
} else {
throw new Error(
`No valid URL fields found in Job Params! Expected \`job.relativeUrl\` or \`job.objects[{ relativeUrl }]\``
`No valid URL fields found in Job Params! Expected \`job.relativeUrl: string\` or \`job.relativeUrls: string[]\``
);
}

Expand Down

This file was deleted.

Loading

0 comments on commit fef8485

Please sign in to comment.