forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Canvas] Fixes the Copy Post Url link (elastic#54831)
* Fixes the Copy Post Url link * Adds tests Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
Showing
5 changed files
with
55 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
x-pack/legacy/plugins/canvas/public/components/workpad_header/workpad_export/utils.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
jest.mock('../../../../common/lib/fetch'); | ||
|
||
import { getPdfUrl, createPdf } from './utils'; | ||
import { workpads } from '../../../../__tests__/fixtures/workpads'; | ||
import { fetch } from '../../../../common/lib/fetch'; | ||
|
||
const addBasePath = jest.fn().mockImplementation(s => `basepath/${s}`); | ||
const workpad = workpads[0]; | ||
|
||
test('getPdfUrl returns the correct url', () => { | ||
const url = getPdfUrl(workpad, { pageCount: 2 }, addBasePath); | ||
|
||
expect(url).toMatchInlineSnapshot( | ||
`"basepath//api/reporting/generate/printablePdf?jobParams=(browserTimezone:America%2FPhoenix,layout:(dimensions:(height:0,width:0),id:preserve_layout),objectType:'canvas%20workpad',relativeUrls:!(%2Fapp%2Fcanvas%23%2Fexport%2Fworkpad%2Fpdf%2Fbase-workpad%2Fpage%2F1,%2Fapp%2Fcanvas%23%2Fexport%2Fworkpad%2Fpdf%2Fbase-workpad%2Fpage%2F2),title:'base%20workpad')"` | ||
); | ||
}); | ||
|
||
test('createPdf posts to create the pdf', () => { | ||
createPdf(workpad, { pageCount: 2 }, addBasePath); | ||
|
||
expect(fetch.post).toBeCalled(); | ||
|
||
const args = (fetch.post as jest.MockedFunction<typeof fetch.post>).mock.calls[0]; | ||
|
||
expect(args[0]).toMatchInlineSnapshot(`"basepath//api/reporting/generate/printablePdf"`); | ||
expect(args[1]).toMatchInlineSnapshot(` | ||
Object { | ||
"jobParams": "(browserTimezone:America/Phoenix,layout:(dimensions:(height:0,width:0),id:preserve_layout),objectType:'canvas workpad',relativeUrls:!(/app/canvas#/export/workpad/pdf/base-workpad/page/1,/app/canvas#/export/workpad/pdf/base-workpad/page/2),title:'base workpad')", | ||
} | ||
`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters