-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Spaces] - Reporting updates #21457
Merged
legrego
merged 2 commits into
elastic:spaces-phase-1
from
legrego:fix-reporting-tests-spaces
Aug 16, 2018
Merged
[Spaces] - Reporting updates #21457
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,7 +42,7 @@ beforeEach(() => { | |
'xpack.reporting.kibanaServer.protocol': 'http', | ||
'xpack.reporting.kibanaServer.hostname': 'localhost', | ||
'xpack.reporting.kibanaServer.port': 5601, | ||
'server.basePath': '' | ||
'server.basePath': '/sbp' | ||
}[key]; | ||
}); | ||
|
||
|
@@ -106,6 +106,37 @@ test(`omits blacklisted headers`, async () => { | |
expect(generatePdfObservable).toBeCalledWith(undefined, [], undefined, permittedHeaders, undefined, undefined); | ||
}); | ||
|
||
test('uses basePath from job when creating saved object service', async () => { | ||
const encryptedHeaders = await encryptHeaders({}); | ||
|
||
const logo = 'custom-logo'; | ||
mockServer.uiSettingsServiceFactory().get.mockReturnValue(logo); | ||
|
||
const generatePdfObservable = generatePdfObservableFactory(); | ||
generatePdfObservable.mockReturnValue(Rx.of(Buffer.from(''))); | ||
|
||
const executeJob = executeJobFactory(mockServer); | ||
const jobBasePath = '/sbp/s/marketing'; | ||
await executeJob({ objects: [], headers: encryptedHeaders, basePath: jobBasePath }, cancellationToken); | ||
|
||
expect(mockServer.savedObjects.getScopedSavedObjectsClient.mock.calls[0][0].getBasePath()).toBe(jobBasePath); | ||
}); | ||
|
||
test(`uses basePath from server if job doesn't have a basePath when creating saved object service`, async () => { | ||
const encryptedHeaders = await encryptHeaders({}); | ||
|
||
const logo = 'custom-logo'; | ||
mockServer.uiSettingsServiceFactory().get.mockReturnValue(logo); | ||
|
||
const generatePdfObservable = generatePdfObservableFactory(); | ||
generatePdfObservable.mockReturnValue(Rx.of(Buffer.from(''))); | ||
|
||
const executeJob = executeJobFactory(mockServer); | ||
await executeJob({ objects: [], headers: encryptedHeaders }, cancellationToken); | ||
|
||
expect(mockServer.savedObjects.getScopedSavedObjectsClient.mock.calls[0][0].getBasePath()).toBe('/sbp'); | ||
}); | ||
|
||
test(`gets logo from uiSettings`, async () => { | ||
const encryptedHeaders = await encryptHeaders({}); | ||
|
||
|
@@ -145,9 +176,9 @@ test(`adds forceNow to hash's query, if it exists`, async () => { | |
const executeJob = executeJobFactory(mockServer); | ||
const forceNow = '2000-01-01T00:00:00.000Z'; | ||
|
||
await executeJob({ objects: [{ relativeUrl: 'app/kibana#/something' }], forceNow, headers: encryptedHeaders }, cancellationToken); | ||
await executeJob({ objects: [{ relativeUrl: '/app/kibana#/something' }], forceNow, headers: encryptedHeaders }, cancellationToken); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These relativeUrls had to be changed because switching to using |
||
|
||
expect(generatePdfObservable).toBeCalledWith(undefined, ['http://localhost:5601/app/kibana#/something?forceNow=2000-01-01T00%3A00%3A00.000Z'], undefined, {}, undefined, undefined); | ||
expect(generatePdfObservable).toBeCalledWith(undefined, ['http://localhost:5601/sbp/app/kibana#/something?forceNow=2000-01-01T00%3A00%3A00.000Z'], undefined, {}, undefined, undefined); | ||
}); | ||
|
||
test(`appends forceNow to hash's query, if it exists`, async () => { | ||
|
@@ -160,12 +191,12 @@ test(`appends forceNow to hash's query, if it exists`, async () => { | |
const forceNow = '2000-01-01T00:00:00.000Z'; | ||
|
||
await executeJob({ | ||
objects: [{ relativeUrl: 'app/kibana#/something?_g=something' }], | ||
objects: [{ relativeUrl: '/app/kibana#/something?_g=something' }], | ||
forceNow, | ||
headers: encryptedHeaders | ||
}, cancellationToken); | ||
|
||
expect(generatePdfObservable).toBeCalledWith(undefined, ['http://localhost:5601/app/kibana#/something?_g=something&forceNow=2000-01-01T00%3A00%3A00.000Z'], undefined, {}, undefined, undefined); | ||
expect(generatePdfObservable).toBeCalledWith(undefined, ['http://localhost:5601/sbp/app/kibana#/something?_g=something&forceNow=2000-01-01T00%3A00%3A00.000Z'], undefined, {}, undefined, undefined); | ||
}); | ||
|
||
test(`doesn't append forceNow query to url, if it doesn't exists`, async () => { | ||
|
@@ -176,9 +207,9 @@ test(`doesn't append forceNow query to url, if it doesn't exists`, async () => { | |
|
||
const executeJob = executeJobFactory(mockServer); | ||
|
||
await executeJob({ objects: [{ relativeUrl: 'app/kibana#/something' }], headers: encryptedHeaders }, cancellationToken); | ||
await executeJob({ objects: [{ relativeUrl: '/app/kibana#/something' }], headers: encryptedHeaders }, cancellationToken); | ||
|
||
expect(generatePdfObservable).toBeCalledWith(undefined, ['http://localhost:5601/app/kibana#/something'], undefined, {}, undefined, undefined); | ||
expect(generatePdfObservable).toBeCalledWith(undefined, ['http://localhost:5601/sbp/app/kibana#/something'], undefined, {}, undefined, undefined); | ||
}); | ||
|
||
test(`returns content_type of application/pdf`, async () => { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, now that I see this... I guess reporting is supposed to work when storeStateInSessionStorage is turned on? I have this bug: #20037 because there are issues. But maybe it only fails when the url is too long, otherwise it can work with the setting. Either way, we have no test coverage for this path. I'd have to test manually to see if the new basePath/spaces stuff works with the setting turned on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reporting should be expanding the hashes client-side before creating the job. The
urlHash
is an old version of therelativeUrl
which doesn't include the/app/kibana
prefix that we used to be able to rely upon until Canvas came around and needed to be able to target different "kibana applications".