-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
viewer: add option for loading from the PSI API #9546
Conversation
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.
at a high level:
- (to @paulirish :) we still shouldn't be making a PSI viewer when there's already a PSI viewer (https://developers.google.com/speed/pagespeed/insights/), it just needs to render the other sections and we have web.dev/measure. But w/e, I guess?
- to @connorjclark: can you encapsulate what can be of the PSI stuff similar to the
github-api.js
file?
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.
can you add an example localhost:8000?url=... URL in the readme just for convenience
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.
viewer code looking good, thanks for sticking with this review process.
Comments mostly on the tests
lighthouse-viewer/types/viewer.d.ts
Outdated
@@ -37,6 +39,14 @@ declare global { | |||
// Inserted by viewer gulpfile build. | |||
LH_CURRENT_VERSION: string; | |||
} | |||
|
|||
interface PSIParams { |
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.
Move into psi-api.js
?
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.
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.
Refactor that loop (do type checking instead of checking the name of the property)? Or don't do this change? Or some way to define the type in jsdoc and keep the same behavior?
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.
oh, ha, that's weird. Somehow the one in d.ts is less strict (setting value
to any
) than doing it in a typedef (setting value
to string | string[] | undefined
)
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.
done.
expect(interceptedUrl.searchParams.getAll('category')).toEqual([ | ||
'seo', | ||
'pwa', | ||
]); |
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.
for these, maybe cleaner to do expect([... interceptedUrl.searchParams.entries()]).toEqual([...])
?
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.
I think these query params should be tested one at a time.
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.
for these, maybe cleaner to do
expect([... interceptedUrl.searchParams.entries()]).toEqual([...])
?
I think these query params should be tested one at a time.
that's fine, I guess what I was really suggesting is that we should be testing all of them (especially strategy
since it gets a default? and probably key, though the exact value matters less) and that form was just a way to cut down on the expect(...).toEqual(...)
verboseness
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.
OK - done
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.
some last nits but otherwise...let's do this
⛵️📎⛳️
// These values aren't set by default. | ||
locale: null, | ||
utm_source: null, | ||
}); |
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.
seems like an elaborate way not to write
expect([...interceptedUrl.searchParams]).toEqual([
['url', 'https://www.example.com'],
['strategy', 'mobile'],
// Order in the api call is important to PSI!
['category', 'performance'],
['category', 'accessibility'],
['category', 'seo'],
['category', 'best-practices'],
['category', 'pwa'],
['key', 'AIzaSyAjcDRNN9CX9dCazhqI4lGR7yyQbkd_oYE'],
// `locale` and `utm_source` aren't set by default.
]);
but either way works :P
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.
the array mumbo jumbo doesn't make for very good error message when the assertion fails.
Split off from #9193
This introduces a way to call PSI from the viewer:
Had to update puppeteer because the version we had didn't work with request interception on newer Chrome.