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(seo): move non-search audits to best practices #15930

Merged
merged 5 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions cli/test/fixtures/font-size.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
.small {
font-size: 11px;
}
</style>
<style> /* some filler to offset things */ .small-2 { font-size: 11px; }</style>
<style>
/* some filler to offset things */
.small-3 {
font-size: 6px;
}
/*# sourceURL=font-size-inline-magic.css */
</style>
<link rel="stylesheet" href="font-size-styles.css">
</head>
<body>
<h2>Small text but still legible</h2>
<!-- PASS(font-size): amount of illegible text is below the 60% threshold -->
<!-- font-size items are ordered by text length, so force an order with filler for stable expectations. -->
<p class='small'> 1.... </p>
<p class='small-2'> 2... </p>
<p class='small-3'> 3.. </p>
<p class='small-4'> 4. </p>
<h6>2</h6>
<font size="1">3<b>4</b></font>
<div style=''>
<p style='font-size:10px'> 5 </p>
</div>
<script class='small'>
// text from SCRIPT tags should be ignored by the font-size audit
</script>
</body>
</html>
2 changes: 0 additions & 2 deletions cli/test/fixtures/seo/seo-failure-cases.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
<head>
<!-- no <title>SEO audit failures page</title> -->
<meta charset="utf-8">
<!-- FAIL(font-size): missing viewport -->
<meta name="viewport" content="invalid-content=should_have_looked_it_up">
<!-- no <meta name="description" content=""> -->
<!-- FAIL(is-crawlable): noindex on root page, vary the case to make sure we are case insensitive -->
<meta name="RoBots" content="nofollow, NOINDEX, all">
Expand Down
30 changes: 0 additions & 30 deletions cli/test/fixtures/seo/seo-tester.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,6 @@
<link rel="alternate" href="http://example.com/" hreflang="x-default" />
<!-- PASS(canonical): valid canonical URL -->
<link rel="canonical" href="http://localhost:10200/seo/" />

<style>
.small {
font-size: 11px;
}
</style>
<style> /* some filler to offset things */ .small-2 { font-size: 11px; }</style>
<style>
/* some filler to offset things */
.small-3 {
font-size: 6px;
}
/*# sourceURL=seo-tester-inline-magic.css */
</style>
<link rel="stylesheet" href="seo-tester-styles.css">
</head>
<body>
<!-- PASS(hreflang): should ignore links in the body -->
Expand All @@ -49,21 +34,6 @@ <h2>Anchor text</h2>
<a href='https://example.com/non-descriptive-no-follow.html' rel="nofollow">click this</a>
<a href='javascript:;'>click this</a>

<h2>Small text</h2>
<!-- PASS(font-size): amount of illegible text is below the 60% threshold -->
<!-- font-size items are ordered by text length, so force an order with filler for stable expectations. -->
<p class='small'> 1.... </p>
<p class='small-2'> 2... </p>
<p class='small-3'> 3.. </p>
<p class='small-4'> 4. </p>
<h6>2</h6>
<font size="1">3<b>4</b></font>
<div style=''>
<p style='font-size:10px'> 5 </p>
</div>
<script class='small'>
// text from SCRIPT tags should be ignored by the font-size audit
</script>
<!-- override global URL - bug #5701 -->
<script>URL = '';</script>

Expand Down
2 changes: 2 additions & 0 deletions cli/test/smokehouse/core-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import dbw from './test-definitions/dobetterweb.js';
import errorsExpiredSsl from './test-definitions/errors-expired-ssl.js';
import errorsIframeExpiredSsl from './test-definitions/errors-iframe-expired-ssl.js';
import errorsInfiniteLoop from './test-definitions/errors-infinite-loop.js';
import fontSize from './test-definitions/font-size.js';
import formsAutoComplete from './test-definitions/forms-autocomplete.js';
import fpsMax from './test-definitions/fps-max.js';
import fpsMaxPassive from './test-definitions/fps-max-passive.js';
Expand Down Expand Up @@ -77,6 +78,7 @@ const smokeTests = [
errorsExpiredSsl,
errorsIframeExpiredSsl,
errorsInfiniteLoop,
fontSize,
formsAutoComplete,
fpsMax,
fpsMaxPassive,
Expand Down
108 changes: 108 additions & 0 deletions cli/test/smokehouse/test-definitions/font-size.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/**
* @license
* Copyright 2024 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @type {Smokehouse.ExpectedRunnerResult}
* Expected Lighthouse audit values for a site that fails seo tests.
*/
const expectations = {
lhr: {
requestedUrl: 'http://localhost:10200/font-size.html',
finalDisplayedUrl: 'http://localhost:10200/font-size.html',
audits: {
'font-size': {
score: 1,
details: {
items: [
{
source: {
url: 'http://localhost:10200/font-size.html',
urlProvider: 'network',
line: 6,
column: 12,
},
selector: '.small',
fontSize: '11px',
},
{
source: {
url: 'http://localhost:10200/font-size.html',
urlProvider: 'network',
line: 10,
column: 55,
},
selector: '.small-2',
fontSize: '11px',
},
{
source: {
url: 'font-size-inline-magic.css',
urlProvider: 'comment',
line: 2,
column: 14,
},
selector: '.small-3',
fontSize: '6px',
},
{
source: {
url: 'font-size-styles-magic.css',
urlProvider: 'comment',
line: 2,
column: 10,
},
selector: '.small-4',
fontSize: '6px',
},
{
source: {type: 'code', value: 'User Agent Stylesheet'},
selector: 'h6',
fontSize: '10.72px',
},
{
source: {type: 'url', value: 'http://localhost:10200/font-size.html'},
selector: {
type: 'node',
selector: 'body',
snippet: '<font size="1">',
},
fontSize: '10px',
},
{
source: {type: 'url', value: 'http://localhost:10200/font-size.html'},
selector: {
type: 'node',
selector: 'font',
snippet: '<b>',
},
fontSize: '10px',
},
{
source: {type: 'url', value: 'http://localhost:10200/font-size.html'},
selector: {
type: 'node',
selector: 'div',
snippet: '<p style="font-size:10px">',
},
fontSize: '10px',
},
{
source: {type: 'code', value: 'Legible text'},
selector: '',
fontSize: '≥ 12px',
},
],
},
},
},
},
};

export default {
id: 'font-size',
expectations,
};

16 changes: 15 additions & 1 deletion cli/test/smokehouse/test-definitions/fps-scaled.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const config = {
extends: 'lighthouse:default',
settings: {
onlyCategories: ['performance'],
onlyAudits: ['font-size'],
},
};

Expand All @@ -28,7 +29,20 @@ const expectations = {
lhr: {
requestedUrl: 'http://localhost:10200/scaled-content.html',
finalDisplayedUrl: 'http://localhost:10200/scaled-content.html',
audits: {},
audits: {
'viewport': {
score: 0,
details: {
type: 'debugdata',
viewportContent: 'initial-scale=0.5',
},
},
'font-size': {
score: 0,
explanation:
'Text is illegible because there\'s no viewport meta tag optimized for mobile screens.',
},
},
fullPageScreenshot: {
nodes: {
_includes: [
Expand Down
12 changes: 0 additions & 12 deletions cli/test/smokehouse/test-definitions/seo-failing.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ const expectations = {
requestedUrl: BASE_URL + 'seo-failure-cases.html?' + failureHeaders,
finalDisplayedUrl: BASE_URL + 'seo-failure-cases.html?' + failureHeaders,
audits: {
'viewport': {
score: 0,
details: {
type: 'debugdata',
viewportContent: 'invalid-content=should_have_looked_it_up',
},
},
'document-title': {
score: 0,
},
Expand All @@ -60,11 +53,6 @@ const expectations = {
'http-status-code': {
score: 1,
},
'font-size': {
score: 0,
explanation:
'Text is illegible because there\'s no viewport meta tag optimized for mobile screens.',
},
'crawlable-anchors': {
score: 0,
details: {
Expand Down
87 changes: 0 additions & 87 deletions cli/test/smokehouse/test-definitions/seo-passing.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,6 @@ const expectations = {
requestedUrl: BASE_URL + 'seo-tester.html?' + passHeaders,
finalDisplayedUrl: BASE_URL + 'seo-tester.html?' + passHeaders,
audits: {
'viewport': {
score: 1,
},
'document-title': {
score: 1,
},
Expand All @@ -49,90 +46,6 @@ const expectations = {
'http-status-code': {
score: 1,
},
'font-size': {
score: 1,
details: {
items: [
{
source: {
url: /seo-tester\.html.+$/,
urlProvider: 'network',
line: 23,
column: 12,
},
selector: '.small',
fontSize: '11px',
},
{
source: {
url: /seo-tester\.html.+$/,
urlProvider: 'network',
line: 27,
column: 55,
},
selector: '.small-2',
fontSize: '11px',
},
{
source: {
url: /seo-tester-inline-magic\.css$/,
urlProvider: 'comment',
line: 2,
column: 14,
},
selector: '.small-3',
fontSize: '6px',
},
{
source: {
url: /seo-tester-styles-magic\.css$/,
urlProvider: 'comment',
line: 2,
column: 10,
},
selector: '.small-4',
fontSize: '6px',
},
{
source: {type: 'code', value: 'User Agent Stylesheet'},
selector: 'h6',
fontSize: '10.72px',
},
{
source: {type: 'url', value: /seo-tester\.html.+$/},
selector: {
type: 'node',
selector: 'body',
snippet: '<font size="1">',
},
fontSize: '10px',
},
{
source: {type: 'url', value: /seo-tester\.html.+$/},
selector: {
type: 'node',
selector: 'font',
snippet: '<b>',
},
fontSize: '10px',
},
{
source: {type: 'url', value: /seo-tester\.html.+$/},
selector: {
type: 'node',
selector: 'div',
snippet: '<p style="font-size:10px">',
},
fontSize: '10px',
},
{
source: {type: 'code', value: 'Legible text'},
selector: '',
fontSize: '≥ 12px',
},
],
},
},
'crawlable-anchors': {
score: 0,
details: {
Expand Down
Loading
Loading