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] Fix and test for Listing of Reports #74453

Merged
merged 7 commits into from
Aug 11, 2020

Conversation

tsullivan
Copy link
Member

@tsullivan tsullivan commented Aug 5, 2020

Summary

Closes: #74799

Fix an issue where the Reporting API route for showing the listing of pages was not working correctly, due to query parameters not being parsed from the request.

Skipping release notes since this bug was not released in the current latest version.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@@ -9,6 +9,6 @@ import { FtrProviderContext } from '../../ftr_provider_context';
export default ({ loadTestFile }: FtrProviderContext) => {
describe('reporting management app', function () {
this.tags('ciGroup7');
loadTestFile(require.resolve('./report_delete_pagination'));
loadTestFile(require.resolve('./report_listing'));
Copy link
Member Author

Choose a reason for hiding this comment

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

renamed the file since it tests more than just deleting a report in the listing

@@ -50,7 +56,7 @@ export function registerJobInfoRoutes(reporting: ReportingCore) {
page: queryPage = '0',
size: querySize = '10',
ids: queryIds = null,
} = req.query as ListQuery;
} = req.query as ListQuery; // NOTE: type inference is not working here. userHandler breaks it?
Copy link
Member Author

Choose a reason for hiding this comment

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

I would like to understand why the type of req.query can not be inferred from the validation. I didn't take much time to look into it.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like to know as well. I spent a good deal of time trying to get types to pass through with the higher order handler (https://github.com/elastic/kibana/blob/master/x-pack/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts#L15), but there's some interesting effects it might have trying to get type information to pass through properly. This was a pretty big change in our codebase to get everything working properly, as a lot of our utilities relied on augmented Hapi request objects since we used the pre handlers fairly extensively. I can take a look at this since I wrote the wrapper handler. Unfortunately nothing is jumping out at me since I pretty much copy/pasted the migration docs for this "higher-order" handler.

@tsullivan tsullivan added Team:Reporting Services release_note:skip Skip the PR/issue when compiling release notes v7.10.0 v8.0.0 labels Aug 5, 2020
@tsullivan tsullivan marked this pull request as ready for review August 5, 2020 22:00
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-reporting-services (Team:Reporting Services)

@@ -35,7 +35,13 @@ export function registerJobInfoRoutes(reporting: ReportingCore) {
router.get(
{
path: `${MAIN_ENTRY}/list`,
validate: false,
validate: {
Copy link
Member Author

Choose a reason for hiding this comment

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

Note from @restrry: "platform doesn’t provide request params / body / query unless validation schema is provided"

Copy link
Contributor

Choose a reason for hiding this comment

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

a couple of remarks

Copy link
Contributor

Choose a reason for hiding this comment

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

Our HoH has roughly the same type passthrough interface. Is there something obvious I'm missing?

@tsullivan
Copy link
Member Author

tsullivan commented Aug 11, 2020

I had to add sleep calls in between clicking the pages before scanning the table and verifying the contents. Right now, the sleep is for 2 seconds.

Instead, there should probably be a paging test subject on the page that we can wait to find, to know that we're on the right page - instead of just waiting a hard 2 seconds

Edit: resolved in 9c7ac46d3f

@tsullivan tsullivan force-pushed the reporting/fix-pagination branch from 9c7ac46 to a39f8af Compare August 11, 2020 15:11
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

page load bundle size

id value diff baseline
reporting 291.0KB +33.0B 291.0KB

History

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

@tsullivan
Copy link
Member Author

Hi @restrry, I'm not exactly clear on the advice in #74453 (comment)

page & size should be number, you parse them below

Does this mean the route validates them as number? And also that it will still be a string in my handler and that I should still parse the string into a number?

I'd recommend either implement it as RequestHandlerWrapper or pass user via RequestHandlerContext.

Is this advice for something to change in each of our route handlers? Or is something not set up right in the x-pack/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts?

Copy link
Contributor

@joelgriffith joelgriffith left a comment

Choose a reason for hiding this comment

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

LGTM. Since this is a blocker (IMO), I'm OK with following up with the np changes in a follow up PR

@tsullivan
Copy link
Member Author

Since this is a blocker (IMO), I'm OK with following up with the np changes in a follow up PR

I agree with this

@tsullivan tsullivan merged commit d786442 into elastic:master Aug 11, 2020
@tsullivan tsullivan deleted the reporting/fix-pagination branch August 11, 2020 19:59
tsullivan added a commit to tsullivan/kibana that referenced this pull request Aug 11, 2020
* [Reporting] Fix and test for Listing of Reports

* add sleeps

* await selector instead of sleep

* reduce changes

* cleanup after csv generated

* fix snapshot
tsullivan added a commit to tsullivan/kibana that referenced this pull request Aug 11, 2020
* [Reporting] Fix and test for Listing of Reports

* add sleeps

* await selector instead of sleep

* reduce changes

* cleanup after csv generated

* fix snapshot
tsullivan added a commit that referenced this pull request Aug 12, 2020
* [Reporting] Fix and test for Listing of Reports (#74453)

* [Reporting] Fix and test for Listing of Reports

* add sleeps

* await selector instead of sleep

* reduce changes

* cleanup after csv generated

* fix snapshot

* fix test asserts
jloleysens added a commit to jloleysens/kibana that referenced this pull request Aug 12, 2020
…nes/processor-forms-a-d

* 'master' of github.com:elastic/kibana: (25 commits)
  [ML] Removing full lodash library imports (elastic#74742)
  [Search] Server strategy example (elastic#71679)
  [Reporting] Fix and test for Listing of Reports (elastic#74453)
  [maps] fix drawing shapes (elastic#74689)
  [Resolver] Improve simulator. Add more click-through tests and panel tests. (elastic#74601)
  Deprecate schema-less specs in Vega (elastic#73805)
  [Security Solution] Rename Administration > Hosts subtab to Endpoints (elastic#74287)
  Timelion deprecation doc (elastic#74508)
  [Functional Tests] Adds a wait time between setting the index pattern and the time field on TSVB (elastic#74736)
  [Lens] Add styling options for x and y axes on the settings popover (elastic#71829)
  [Maps] add initial location option that fits to data bounds (elastic#74583)
  theme function (elastic#73451)
  [data.ui.query] Write filters to query log from default editor. (elastic#74474)
  [data.search.SearchSource] Move some SearchSource dependencies to the server. (elastic#74607)
  [Canvas][tech-debt] Convert renderers (elastic#74134)
  [security solutions][lists] Adds end to end tests (elastic#74473)
  pluralized for occurrences vs occurrence (elastic#74564)
  Update links that pointed to CONTRIBUTING.md (elastic#74757)
  [Ingest pipelines] Implement tabs in processor flyout (elastic#74469)
  [Event log] Use Alerts client & Actions client when fetching these types of SOs (elastic#73257)
  ...

# Conflicts:
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/field_components/text_editor.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/manage_processor_form.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/append.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/bytes.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/circle.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/common_fields/field_name_field.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/common_fields/ignore_missing_field.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/convert.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/csv.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/date.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/date_index_name.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/dissect.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/dot_expander.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/drop.tsx
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/index.ts
#	x-pack/plugins/ingest_pipelines/public/application/components/pipeline_processors_editor/components/manage_processor_form/processors/shared.ts
gmmorris added a commit to gmmorris/kibana that referenced this pull request Aug 12, 2020
* master:
  [Vega] add functional tests for Vega visualization (elastic#74097)
  [ML] Removing full lodash library imports (elastic#74742)
  [Search] Server strategy example (elastic#71679)
  [Reporting] Fix and test for Listing of Reports (elastic#74453)
  [maps] fix drawing shapes (elastic#74689)
  [Resolver] Improve simulator. Add more click-through tests and panel tests. (elastic#74601)
  Deprecate schema-less specs in Vega (elastic#73805)
  [Security Solution] Rename Administration > Hosts subtab to Endpoints (elastic#74287)
  Timelion deprecation doc (elastic#74508)
tsullivan added a commit that referenced this pull request Aug 12, 2020
* [Reporting] Fix and test for Listing of Reports (#74453)

* [Reporting] Fix and test for Listing of Reports

* add sleeps

* await selector instead of sleep

* reduce changes

* cleanup after csv generated

* fix snapshot

* same as 7.9 fix
@tylersmalley tylersmalley added the bug Fixes for quality problems that affect the customer experience label Aug 12, 2020
@azasypkin azasypkin mentioned this pull request Aug 12, 2020
8 tasks
@mshustov
Copy link
Contributor

Is this advice for something to change in each of our route handlers? Or is something not set up right in the x-pack/plugins/reporting/server/routes/lib/authorized_user_pre_routing.ts?

yes, it has ben fixed in #74879

Does this mean the route validates them as number?

yes, @kbn/config-schema will parse them as numbers

@sophiec20 sophiec20 added the (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead label Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience (Deprecated) Feature:Reporting Use Reporting:Screenshot, Reporting:CSV, or Reporting:Framework instead release_note:skip Skip the PR/issue when compiling release notes v7.9.1 v7.10.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Reporting] Listing of reports pagination is broken
7 participants