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

core(fr): add supportedModes filter to categories #13161

Merged
merged 8 commits into from
Oct 4, 2021
Merged

Conversation

adamraine
Copy link
Member

This is a fancy way of hiding PWA in timespan and snapshot. Filter is defined in the config.

@adamraine adamraine requested a review from a team as a code owner October 1, 2021 23:51
@adamraine adamraine requested review from patrickhulce and removed request for a team October 1, 2021 23:51
@google-cla google-cla bot added the cla: yes label Oct 1, 2021
import {flowResult} from '../sample-flow';
import {I18nProvider} from '../../src/i18n/i18n';
import {FlowResultContext} from '../../src/util';

let wrapper: FunctionComponent;

beforeEach(() => {
// Include sample flowResult for locale in I18nProvider.
Copy link
Member Author

Choose a reason for hiding this comment

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

Drive by change to this test so the expectations don't change every time the sample is updated.

Copy link
Collaborator

Choose a reason for hiding this comment

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

quite a few lines for a drive by ;)

@@ -13,7 +13,10 @@ import {LH_ROOT} from '../../root.js';
import UserFlow from '../fraggle-rock/user-flow.js';

(async () => {
const browser = await puppeteer.launch({headless: false});
const browser = await puppeteer.launch({
executablePath: process.env.CHROME_PATH,
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 was noticing the FPS was rendered incorrectly on the default puppeteer chrome. We could also update the puppeteer version in this PR. Not sure it started showing up now though.

@@ -134,6 +134,7 @@ declare module Config {
auditRefs: AuditRefJson[];
description?: string | IcuMessage;
manualDescription?: string | IcuMessage;
supportedModes?: Gatherer.GatherMode[];
Copy link
Member Author

Choose a reason for hiding this comment

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

Required in v9?

Copy link
Collaborator

Choose a reason for hiding this comment

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

meh, leaving as the default to always run seems fine even in v9, but I'll leave it up to you

@Mbellsudteen

This comment has been minimized.

@Mbellsudteen

This comment has been minimized.

@Mbellsudteen

This comment has been minimized.

@Mbellsudteen

This comment has been minimized.

import {flowResult} from '../sample-flow';
import {I18nProvider} from '../../src/i18n/i18n';
import {FlowResultContext} from '../../src/util';

let wrapper: FunctionComponent;

beforeEach(() => {
// Include sample flowResult for locale in I18nProvider.
Copy link
Collaborator

Choose a reason for hiding this comment

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

quite a few lines for a drive by ;)

@@ -134,6 +134,7 @@ declare module Config {
auditRefs: AuditRefJson[];
description?: string | IcuMessage;
manualDescription?: string | IcuMessage;
supportedModes?: Gatherer.GatherMode[];
Copy link
Collaborator

Choose a reason for hiding this comment

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

meh, leaving as the default to always run seems fine even in v9, but I'll leave it up to you

@patrickhulce
Copy link
Collaborator

sample JSON needs an update

@brendankenny
Copy link
Member

Thinking out loud but not sure if there's something worthwhile here:

Something about the fact that this is largely about filling in the filtering gaps created because an audit can be in more than one category, and that there's redundancy with onlyCategories, makes this feel like a config structural problem that an additional option will add complexity to, rather than simplify.

I understand sharing the default config between the classic and new navigation modes, but is there a reason we haven't made a default-timespan-config.js and default-snapshot-config.js yet? e.g. rather than implicit filtering, make config entry points, either with extends: 'lighthouse:default'/onlyCategories or more ambitious reorgs (import what a config needs, require('./perf-category.js') or whatever). I don't know if that really fixes the structural issue since it's essentially functionally equivalent, but it would avoid a new config option and it may be more in the spirit of LH supporting config files (plural :).

@adamraine
Copy link
Member Author

I understand sharing the default config between the classic and new navigation modes, but is there a reason we haven't made a default-timespan-config.js and default-snapshot-config.js yet?

This would mean we need 6 configs (desktop/mobile and 3 gather modes for each). We would probably have to repeat some config implementation somewhere.

Maybe we could have used separate configs for (#13013), but I think the problem is that we don't want simulated throttling to even be possible with timespan modes. I'm not sure we even want PWA to be available at all in snapshot or timespan through onlyCategories.

Maybe we could hardcode an override for PWA like we did with throttling settings. With this however, a new audit in SEO that works in all three modes would quietly add SEO to all timespan reports (unless we hardcode another exception).

I like the ability to explicitly control which categories appear for each mode, and I don't think a supportedModes filter is any more complicated than having 6 default configs.

@patrickhulce
Copy link
Collaborator

is there a reason we haven't made a default-timespan-config.js and default-snapshot-config.js yet? e.g. rather than implicit filtering, make config entry points, either with extends: 'lighthouse:default'/onlyCategories or more ambitious reorgs (import what a config needs, require('./perf-category.js') or whatever).

My primary thoughts here in general are that relying on manual configuration rather than the property-based enforcement we see in this PR complicates the story not just for us but all other config authors as well.

For example, a plugin author would need to publish 3 different versions of their plugin for each gather mode, three npm namespaces, with different configs, etc.

Relying on manual configuration instead of automatic enforcement also tends to be more prone to errors (oops we forgot to update the timespan-config rather than "oh hey we adjusted this audit, adjust the top of the same file")

@brendankenny
Copy link
Member

Ha, well if y'all feel that good about this, that's fine :)

Long term, I don't think six default configs is that big of a deal. We have three pretty different modes, we have multiple methods of config composition available to us to make maintenance easier (our extends, but they're also just JS objects), and presumably the three desktop variants are just going to override the emulation settings of the mobile versions and that's it.

I suspect the more the different modes diverge in expected or required behavior the less desirable it's going to be to smooth over the differences with more configuration options and the easier it's going to be to just define them separately, but obviously this isn't the straw that breaks that particular camel's back :) An option to keep in our back pocket, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants