Skip to content
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

[Reporting] Remove ReportingCore references from server/export_types shared code #158031

Merged
merged 16 commits into from
May 22, 2023

Conversation

rshen91
Copy link
Contributor

@rshen91 rshen91 commented May 17, 2023

Summary

Part of #158092

Removing calls to ReportingCore in export types functions

Checklist

@rshen91 rshen91 added the Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) label May 17, 2023
@rshen91 rshen91 self-assigned this May 17, 2023
@rshen91 rshen91 added (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead release_note:skip Skip the PR/issue when compiling release notes labels May 18, 2023
@rshen91 rshen91 marked this pull request as ready for review May 18, 2023 20:41
@rshen91 rshen91 requested a review from a team as a code owner May 18, 2023 20:41
@elasticmachine
Copy link
Contributor

Pinging @elastic/appex-sharedux (Team:SharedUX)

@rshen91 rshen91 requested a review from tsullivan May 18, 2023 20:41
Copy link
Member

@tsullivan tsullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes on the way mocks are provided in the unit tests.

Otherwise, this is starting to look great!

@@ -34,8 +34,9 @@ test(`gets logo from uiSettings`, async () => {
mockReportingPlugin.getUiSettingsServiceFactory = jest.fn().mockResolvedValue({
get: mockGet,
});

const { logo } = await getCustomLogo(mockReportingPlugin, headers, 'spaceyMcSpaceIdFace', logger);
const fakeRequest = mockReportingPlugin.getFakeRequest(headers, 'spaceyMcSpaceIdFace', logger);
Copy link
Member

@tsullivan tsullivan May 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to take mock reporting core usages out of the unit tests in x-pack/plugins/reporting/server/export_types.

For the fake request:

import { httpServerMock } from '@kbn/core-http-server-mocks';
const mockRequest = httpServerMock.createKibanaRequest();

For the UI Settings client:

import { uiSettingsServiceMock } from '@kbn/core/public/mocks';
const mockUiSettings = uiSettingsServiceMock.createStartContract();

edit: sorry for the bad example -- uiSettingsServiceMock can't be imported from public in this code

@@ -30,7 +30,8 @@ beforeEach(async () => {
const getMockJob = (base: object) => base as TaskPayloadPNG & TaskPayloadPDF;

test(`fails if no URL is passed`, async () => {
const fn = () => getFullUrls(mockReporting, getMockJob({}));
const fn = () =>
getFullUrls(mockReporting.getServerInfo(), mockReporting.getConfig(), getMockJob({}));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above: the server info and config should be mocked without a mockReportingCore

expect(
getFullRedirectAppUrl(
reporting.getConfig(),
reporting.getServerInfo(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above: the server info and config should be mocked without a mockReportingCore

return lastValueFrom(
generatePngObservable(reporting, logger, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😎

return generatePdfObservable(reporting, {
// make a new function that will call reporting.getScreenshots
const snapshotFn = () =>
reporting.getScreenshots({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's OK to leave reportingCore in the execute_job / create_job functions for now. We'll sweep through these in the next PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just wanted to make sure I wasn't misinterpreting this - so how this file and others are is ok, right? I had refactored the generatePdfObservable() to take in the snapshot function vs all of reporting core.

Eventually I will remove any call to reporting.getScreenshots() etc in this file and others in future PRs :yay: but for this PR, this can stay as it is right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, these files called x-pack/plugins/reporting/server/export_types/*/execute_job* as well as x-pack/plugins/reporting/server/export_types/csv_v2/create_job.ts are OK, and how I would expect them to be at this stage of our progress.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok thank you!!

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Unknown metric groups

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
securitySolution 399 403 +4
total +6

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
securitySolution 479 483 +4
total +6

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @rshen91

@rshen91 rshen91 requested a review from tsullivan May 22, 2023 20:18
Copy link
Member

@tsullivan tsullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

reviewed the code

@tsullivan tsullivan changed the title [Reporting] Remove ReportingCore from Export Types [Reporting] Remove ReportingCore references from server/export_types shared code May 22, 2023
@rshen91 rshen91 merged commit 8fcc8aa into elastic:main May 22, 2023
@kibanamachine kibanamachine added v8.9.0 backport:skip This commit does not require backporting labels May 22, 2023
@rshen91 rshen91 deleted the rep-et branch May 22, 2023 20:50
delanni pushed a commit to delanni/kibana that referenced this pull request May 25, 2023
## Summary

Part of elastic#158092

Removing calls to `ReportingCore` in export types functions

### Checklist
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead release_note:skip Skip the PR/issue when compiling release notes Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) v8.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants