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(scoring): set is-crawlable weight high enough to fail SEO category #15933

Merged
merged 3 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion core/config/default-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -601,12 +601,17 @@ const defaultConfig = {
manualDescription: str_(UIStrings.seoCategoryManualDescription),
supportedModes: ['navigation', 'snapshot'],
auditRefs: [
// Should be at least 31% of the score, such that this audit failing
// results in the SEO category failing.
// Solve for w:
// w / (w + T) >= 0.31
// where T is the sum of all the other weights.
{id: 'is-crawlable', weight: 93/23, group: 'seo-crawl'},
{id: 'document-title', weight: 1, group: 'seo-content'},
{id: 'meta-description', weight: 1, group: 'seo-content'},
{id: 'http-status-code', weight: 1, group: 'seo-crawl'},
{id: 'link-text', weight: 1, group: 'seo-content'},
{id: 'crawlable-anchors', weight: 1, group: 'seo-crawl'},
{id: 'is-crawlable', weight: 1, group: 'seo-crawl'},
{id: 'robots-txt', weight: 1, group: 'seo-crawl'},
{id: 'image-alt', weight: 1, group: 'seo-content'},
{id: 'hreflang', weight: 1, group: 'seo-content'},
Expand Down
11 changes: 11 additions & 0 deletions core/test/config/default-config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import assert from 'assert/strict';

import defaultConfig from '../../config/default-config.js';
import {ReportScoring} from '../../scoring.js';

describe('Default Config', () => {
it('relevantAudits map to existing perf audit', () => {
Expand All @@ -23,4 +24,14 @@ describe('Default Config', () => {
}
}
});

it('SEO fails if is-crawlable is failing', () => {
const scores = defaultConfig.categories.seo.auditRefs.map(auditRef => ({
score: auditRef.id === 'is-crawlable' ? 0 : 1,
weight: auditRef.weight,
}));
const score = ReportScoring.arithmeticMean(scores);
assert(score < 0.7);
assert(score >= 0.65);
});
});
22 changes: 11 additions & 11 deletions core/test/fixtures/user-flows/reports/sample-flow-result.json
Original file line number Diff line number Diff line change
Expand Up @@ -4519,6 +4519,11 @@
"snapshot"
],
"auditRefs": [
{
"id": "is-crawlable",
"weight": 4.043478260869565,
"group": "seo-crawl"
},
{
"id": "document-title",
"weight": 1,
Expand All @@ -4544,11 +4549,6 @@
"weight": 1,
"group": "seo-crawl"
},
{
"id": "is-crawlable",
"weight": 1,
"group": "seo-crawl"
},
{
"id": "robots-txt",
"weight": 0,
Expand Down Expand Up @@ -22074,6 +22074,11 @@
"snapshot"
],
"auditRefs": [
{
"id": "is-crawlable",
"weight": 4.043478260869565,
"group": "seo-crawl"
},
{
"id": "document-title",
"weight": 1,
Expand All @@ -22099,11 +22104,6 @@
"weight": 1,
"group": "seo-crawl"
},
{
"id": "is-crawlable",
"weight": 1,
"group": "seo-crawl"
},
{
"id": "robots-txt",
"weight": 0,
Expand All @@ -22130,7 +22130,7 @@
}
],
"id": "seo",
"score": 0.88
"score": 0.91
},
"pwa": {
"title": "PWA",
Expand Down
12 changes: 6 additions & 6 deletions core/test/results/sample_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -6606,6 +6606,11 @@
"snapshot"
],
"auditRefs": [
{
"id": "is-crawlable",
"weight": 4.043478260869565,
"group": "seo-crawl"
},
{
"id": "document-title",
"weight": 1,
Expand All @@ -6631,11 +6636,6 @@
"weight": 1,
"group": "seo-crawl"
},
{
"id": "is-crawlable",
"weight": 1,
"group": "seo-crawl"
},
{
"id": "robots-txt",
"weight": 0,
Expand All @@ -6662,7 +6662,7 @@
}
],
"id": "seo",
"score": 0.63
"score": 0.73
},
"pwa": {
"title": "PWA",
Expand Down
2 changes: 1 addition & 1 deletion report/test/generator/report-generator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ category,score
\\"performance\\",\\"0.28\\"
\\"accessibility\\",\\"0.78\\"
\\"best-practices\\",\\"0.39\\"
\\"seo\\",\\"0.63\\"
\\"seo\\",\\"0.73\\"
\\"pwa\\",\\"0.38\\"

category,audit,score,displayValue,description
Expand Down
Loading