Skip to content

Commit

Permalink
report: let fireworks eligibility ignore PWA category (#11200)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Sep 14, 2020
1 parent e5dee43 commit d86ce34
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lighthouse-core/report/html/renderer/report-ui-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,14 @@ class ReportUIFeatures {
turnOffTheLights = true;
}

// Fireworks.
const scoresAll100 = Object.values(report.categories).every(cat => cat.score === 1);
const hasAllCoreCategories =
Object.keys(report.categories).filter(id => !Util.isPluginCategory(id)).length >= 5;
if (scoresAll100 && hasAllCoreCategories) {
// Fireworks!
// To get fireworks you need 100 scores in all core categories, except PWA (because going the PWA route is discretionary).
const fireworksRequiredCategoryIds = ['performance', 'accessibility', 'best-practices', 'seo'];
const scoresAll100 = fireworksRequiredCategoryIds.every(id => {
const cat = report.categories[id];
return cat && cat.score === 1;
});
if (scoresAll100) {
turnOffTheLights = true;
this._enableFireworks();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,17 @@ describe('ReportUIFeatures', () => {
assert.ok(container.querySelector('.score100'), 'has fireworks treatment');
});

it('should show fireworks for all 100s except PWA', () => {
const lhr = JSON.parse(JSON.stringify(sampleResults));
Object.values(lhr.categories).forEach(element => {
element.score = 1;
});
lhr.categories.pwa.score = 0;

const container = render(lhr);
assert.ok(container.querySelector('.score100'), 'has fireworks treatment');
});

it('should not render fireworks if all core categories are not present', () => {
const lhr = JSON.parse(JSON.stringify(sampleResults));
delete lhr.categories.performance;
Expand Down

0 comments on commit d86ce34

Please sign in to comment.