Skip to content

Commit

Permalink
Merge branch 'main' into Increase-name-size
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark authored May 7, 2024
2 parents 8431cc8 + 2ed3b31 commit 4cbe5a1
Show file tree
Hide file tree
Showing 36 changed files with 75,330 additions and 112 deletions.
1 change: 0 additions & 1 deletion .lighthouserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ module.exports = {
'unused-javascript': 'off',

label: 'off',
'content-width': 'off',
'color-contrast': 'off',
bypass: 'off',
'tap-targets': 'off',
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,7 @@ _Optional_ The maximum number of requests to send to the PageSpeed Insights API
##### `psiCollectCron.sites[i].categories`
_Optional_ An array containing the categories to test for each url in this site. Defaults to `['performance', 'accessibility', 'best-practices', 'pwa', 'seo']` (all categories).
_Optional_ An array containing the categories to test for each url in this site. Defaults to `['performance', 'accessibility', 'best-practices', 'seo']` (all categories).
##### `psiCollectCron.sites[i].strategy`
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"https-proxy-agent": "^5.0.0",
"inquirer": "^6.3.1",
"isomorphic-fetch": "^3.0.0",
"lighthouse": "11.4.0",
"lighthouse": "12.0.0",
"lighthouse-logger": "1.2.0",
"open": "^7.1.0",
"tmp": "^0.1.0",
Expand Down
6 changes: 5 additions & 1 deletion packages/cli/src/assert/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ function buildCommand(yargs) {
type: 'boolean',
description: 'Whether to include the results of passed assertions in the output.',
},
lhr: {
description:
'Path to LHRs (either a folder or a single file path). Not recursive. If not provided, .lighthouseci is used',
},
});
}

Expand All @@ -53,7 +57,7 @@ async function runCommand(options) {
// If we have a budgets file, convert it to our assertions format.
if (budgetsFile) options = await convertBudgetsToAssertions(readBudgets(budgetsFile));

const lhrs = loadSavedLHRs().map(json => JSON.parse(json));
const lhrs = loadSavedLHRs(options.lhr).map(json => JSON.parse(json));
const uniqueUrls = new Set(lhrs.map(lhr => lhr.finalUrl));
const allResults = getAllAssertionResults(options, lhrs);
const groupedResults = _.groupBy(allResults, result => result.url);
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/src/collect/fallback-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ class FallbackServer {
.filter(fileOrDir => fileOrDir.isDirectory())
.map(dir => dir.name);

const htmlFiles = files.filter(file => file.endsWith('.html')).map(file => ({file, depth: 0}));
const htmlFiles = files
.filter(file => file.endsWith('.html') || file.endsWith('.htm'))
.map(file => ({file, depth: 0}));

if (depth === 0) return htmlFiles;

Expand Down
13 changes: 6 additions & 7 deletions packages/cli/test/assert.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ describe('Lighthouse CI assert CLI', () => {
if (!fs.existsSync(lighthouseciDir)) fs.mkdirSync(lighthouseciDir, {recursive: true});
const fakeLhrPath = path.join(lighthouseciDir, 'lhr-12345.json');
const fakeLhr = {categories: {}, audits: {}};
fakeLhr.categories.pwa = {score: 0};
fakeLhr.audits['performance-budget'] = {score: 0};
for (const key of Object.keys(fullPreset.assertions)) {
fakeLhr.audits[key] = {score: passingAuditIds.includes(key) ? 1 : 0, details: {items: [{}]}};
Expand All @@ -55,8 +54,8 @@ describe('Lighthouse CI assert CLI', () => {
it('should run the recommended preset', async () => {
const result = await run([`--preset=lighthouse:recommended`]);
expect(result.status).toEqual(1);
expect(result.failures.length).toMatchInlineSnapshot(`115`);
expect(result.warnings.length).toMatchInlineSnapshot(`17`);
expect(result.failures.length).toMatchInlineSnapshot(`108`);
expect(result.warnings.length).toMatchInlineSnapshot(`16`);
expect(result.passes.length).toMatchInlineSnapshot(`0`);
expect(result.failures).toContain('deprecations failure');
expect(result.failures).toContain('viewport failure');
Expand All @@ -65,8 +64,8 @@ describe('Lighthouse CI assert CLI', () => {
it('should run the no-pwa preset', async () => {
const result = await run([`--preset=lighthouse:no-pwa`]);
expect(result.status).toEqual(1);
expect(result.failures.length).toMatchInlineSnapshot(`109`);
expect(result.warnings.length).toMatchInlineSnapshot(`16`);
expect(result.failures.length).toMatchInlineSnapshot(`107`);
expect(result.warnings.length).toMatchInlineSnapshot(`15`);
expect(result.passes.length).toMatchInlineSnapshot(`0`);
expect(result.failures).toContain('deprecations failure');
expect(result.failures).not.toContain('viewport failure');
Expand All @@ -91,8 +90,8 @@ describe('Lighthouse CI assert CLI', () => {
it('should return passing audits', async () => {
const result = await run([`--preset=lighthouse:recommended`, '--include-passed-assertions']);
expect(result.status).toEqual(1);
expect(result.warnings.length).toMatchInlineSnapshot(`17`);
expect(result.failures.length).toMatchInlineSnapshot(`115`);
expect(result.warnings.length).toMatchInlineSnapshot(`16`);
expect(result.failures.length).toMatchInlineSnapshot(`108`);
expect(result.passes.length).toMatchInlineSnapshot(`1`);
expect(result.passes).toContain('first-contentful-paint passing');
expect(result.failures).toContain('viewport failure');
Expand Down
38 changes: 19 additions & 19 deletions packages/cli/test/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ describe('Lighthouse CI CLI', () => {
it('should assert failures', async () => {
const {stdout, stderr, status} = await runCLI([
'assert',
`--assertions.installable-manifest=error`,
`--assertions.prioritize-lcp-image=error`,
]);

expect(stdout).toMatchInlineSnapshot(`""`);
Expand All @@ -327,9 +327,9 @@ describe('Lighthouse CI CLI', () => {
1 result(s) for http://localhost:XXXX/app/ :
[31mX[0m [1minstallable-manifest[0m failure for [1mminScore[0m assertion
Web app manifest or service worker do not meet the installability requirements
https://developer.chrome.com/docs/lighthouse/pwa/installable-manifest/
[31mX[0m [1mprioritize-lcp-image[0m failure for [1mminScore[0m assertion
Preload Largest Contentful Paint image
https://web.dev/articles/optimize-lcp#optimize_when_the_resource_is_discovered
expected: >=0.9
found: 0
Expand All @@ -356,13 +356,13 @@ describe('Lighthouse CI CLI', () => {
1 result(s) for http://localhost:XXXX/app/ :
[31mX[0m [1mperformance-budget[0m.script.size failure for [1mmaxNumericValue[0m assertion
Performance budget
https://developers.google.com/web/tools/lighthouse/audits/budgets
[31mX[0m [1mprioritize-lcp-image[0m failure for [1mminScore[0m assertion
Preload Largest Contentful Paint image
https://web.dev/articles/optimize-lcp#optimize_when_the_resource_is_discovered
expected: <=[32mXXXX[0m
found: [31mXXXX[0m
[2mall values: XXXX[0m
expected: >=[32m1[0m
found: [31m0[0m
[2mall values: 0, 0[0m
Assertion failed. Exiting with status code 1.
"
Expand All @@ -379,9 +379,9 @@ describe('Lighthouse CI CLI', () => {
1 result(s) for http://localhost:XXXX/app/ :
[31mX[0m [1minstallable-manifest[0m failure for [1mminScore[0m assertion
Web app manifest or service worker do not meet the installability requirements
https://developer.chrome.com/docs/lighthouse/pwa/installable-manifest/
[31mX[0m [1mprioritize-lcp-image[0m failure for [1mminScore[0m assertion
Preload Largest Contentful Paint image
https://web.dev/articles/optimize-lcp#optimize_when_the_resource_is_discovered
expected: >=0.9
found: 0
Expand Down Expand Up @@ -416,13 +416,13 @@ describe('Lighthouse CI CLI', () => {
all values: XXXX, XXXX
[31mX[0m [1mperformance-budget[0m.script.size failure for [1mmaxNumericValue[0m assertion
Performance budget
https://developers.google.com/web/tools/lighthouse/audits/budgets
[31mX[0m [1mprioritize-lcp-image[0m failure for [1mminScore[0m assertion
Preload Largest Contentful Paint image
https://web.dev/articles/optimize-lcp#optimize_when_the_resource_is_discovered
expected: <=[32mXXXX[0m
found: [31mXXXX[0m
[2mall values: XXXX[0m
expected: >=[32m1[0m
found: [31m0[0m
[2mall values: 0, 0[0m
Assertion failed. Exiting with status code 1.
"
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/test/fixtures/lighthouserc-matrix.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"matchingUrlPattern": "app",
"assertions": {
"installable-manifest": "error"
"prioritize-lcp-image": "error"
}
},
{
Expand Down
1 change: 0 additions & 1 deletion packages/cli/test/fixtures/lighthouserc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module.exports = {
ci: {
assert: {
assertions: {
'categories.pwa': 'off',
'speed-index': ['error', {minScore: 0.8}],
interactive: ['error', {minScore: 0.8}],
'performance-budget': ['error', {minScore: 1}],
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/test/fixtures/lighthouserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
"ci": {
"assert": {
"assertions": {
"categories.pwa": "off",
"speed-index": ["error", {"minScore": 0.8}],
"interactive": ["error", {"minScore": 0.8}],
"performance-budget": ["error", {"minScore": 1}]
"prioritize-lcp-image": ["error", {"minScore": 1}]
}
},
"collect": {
Expand Down
7 changes: 3 additions & 4 deletions packages/cli/test/upload-url-hash.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ describe('Lighthouse CI upload filesystem reports with url hash', () => {

const writeLhr = () => {
const fakeLhr = {finalUrl: 'foo.com', categories: {}, audits: {}};
fakeLhr.categories.pwa = {score: 0};
fakeLhr.categories.performance = {score: 0};
fakeLhr.audits['performance-budget'] = {score: 0};
for (const key of Object.keys(fullPreset.assertions)) {
Expand Down Expand Up @@ -95,21 +94,21 @@ describe('Lighthouse CI upload filesystem reports with url hash', () => {
isRepresentativeRun: true,
htmlPath: path.join(outputDir, 'www_example_com-_-_page1-2022_10_25_22_34_01.report.html'),
jsonPath: path.join(outputDir, 'www_example_com-_-_page1-2022_10_25_22_34_01.report.json'),
summary: {performance: 0.5, pwa: 0},
summary: {performance: 0.5},
},
{
url: 'https://www.example.com/#/page2',
isRepresentativeRun: true,
htmlPath: path.join(outputDir, 'www_example_com-_-_page2-2022_10_25_22_34_02.report.html'),
jsonPath: path.join(outputDir, 'www_example_com-_-_page2-2022_10_25_22_34_02.report.json'),
summary: {performance: 0.5, pwa: 0},
summary: {performance: 0.5},
},
{
url: 'https://www.example.com/#/page3',
isRepresentativeRun: true,
htmlPath: path.join(outputDir, 'www_example_com-_-_page3-2022_10_25_22_34_03.report.html'),
jsonPath: path.join(outputDir, 'www_example_com-_-_page3-2022_10_25_22_34_03.report.json'),
summary: {performance: 0.5, pwa: 0},
summary: {performance: 0.5},
},
]);
}, 15000);
Expand Down
7 changes: 3 additions & 4 deletions packages/cli/test/upload.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ describe('Lighthouse CI upload CLI', () => {

const writeLhr = () => {
const fakeLhr = {finalUrl: 'foo.com', categories: {}, audits: {}};
fakeLhr.categories.pwa = {score: 0};
fakeLhr.categories.performance = {score: 0};
fakeLhr.audits['performance-budget'] = {score: 0};
for (const key of Object.keys(fullPreset.assertions)) {
Expand Down Expand Up @@ -205,21 +204,21 @@ describe('Lighthouse CI upload CLI', () => {
isRepresentativeRun: false,
htmlPath: path.join(outputDir, 'www_example_com-_page-2020_05_22_22_12_01.report.html'),
jsonPath: path.join(outputDir, 'www_example_com-_page-2020_05_22_22_12_01.report.json'),
summary: {performance: 0, pwa: 0},
summary: {performance: 0},
},
{
url: 'https://www.example.com/page',
isRepresentativeRun: false,
htmlPath: path.join(outputDir, 'www_example_com-_page-2020_05_22_22_12_02.report.html'),
jsonPath: path.join(outputDir, 'www_example_com-_page-2020_05_22_22_12_02.report.json'),
summary: {performance: 0, pwa: 0},
summary: {performance: 0},
},
{
url: 'https://www.example.com/page',
isRepresentativeRun: true,
htmlPath: path.join(outputDir, 'www_example_com-_page-2020_05_22_22_12_03.report.html'),
jsonPath: path.join(outputDir, 'www_example_com-_page-2020_05_22_22_12_03.report.json'),
summary: {performance: 0.5, pwa: 0},
summary: {performance: 0.5},
},
]);
}, 15000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import lhr1010A_ from '../../../../../test/fixtures/lh-10-1-0-coursehero-a.json'
import lhr1010B_ from '../../../../../test/fixtures/lh-10-1-0-coursehero-b.json';
import lhr1140A_ from '../../../../../test/fixtures/lh-11-4-0-coursehero-a.json';
import lhr1140B_ from '../../../../../test/fixtures/lh-11-4-0-coursehero-b.json';
import lhr1200A_ from '../../../../../test/fixtures/lh-12-0-0-coursehero-a.json';
import lhr1200B_ from '../../../../../test/fixtures/lh-12-0-0-coursehero-b.json';
import lhrSubitemsA_ from '../../../../../test/fixtures/lh-subitems-a.json';
import lhrSubitemsB_ from '../../../../../test/fixtures/lh-subitems-b.json';
import lhrPsi800A_ from '../../../../../test/fixtures/psi-8-0-0-dkdev-a.json';
Expand Down Expand Up @@ -54,6 +56,8 @@ const lhr1010A = /** @type {any} */ (lhr1010A_);
const lhr1010B = /** @type {any} */ (lhr1010B_);
const lhr1140A = /** @type {any} */ (lhr1140A_);
const lhr1140B = /** @type {any} */ (lhr1140B_);
const lhr1200A = /** @type {any} */ (lhr1200A_);
const lhr1200B = /** @type {any} */ (lhr1200B_);
const lhrSubitemsA = /** @type {any} */ (lhrSubitemsA_);
const lhrSubitemsB = /** @type {any} */ (lhrSubitemsB_);
const lhrPsi800A = /** @type {any} */ (lhrPsi800A_);
Expand All @@ -68,6 +72,7 @@ const auditPairs800 = createAuditPairs(lhr800A, lhr800B);
const auditPairs930 = createAuditPairs(lhr930A, lhr930B);
const auditPairs1010 = createAuditPairs(lhr1010A, lhr1010B);
const auditPairs1140 = createAuditPairs(lhr1140A, lhr1140B);
const auditPairs1200 = createAuditPairs(lhr1200A, lhr1200B);
const auditPairsPsi800 = createAuditPairs(lhrPsi800A, lhrPsi800B);
const auditPairsSubitems = createAuditPairs(lhrSubitemsA, lhrSubitemsB, {
filter: pair =>
Expand Down Expand Up @@ -161,6 +166,15 @@ export const Version1140 = () => (
/>
);

export const Version1200 = () => (
<AuditDetailPane
selectedAuditId={auditPairs1200[1].audit.id || ''}
setSelectedAuditId={action('setSelectedAuditId')}
pairs={auditPairs1200}
baseLhr={lhr1200B}
/>
);

export const VersionPsi800 = () => (
<AuditDetailPane
selectedAuditId={auditPairsPsi800[1].audit.id || ''}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import lhr1010A_ from '../../../../test/fixtures/lh-10-1-0-coursehero-a.json';
import lhr1010B_ from '../../../../test/fixtures/lh-10-1-0-coursehero-b.json';
import lhr1140A_ from '../../../../test/fixtures/lh-11-4-0-coursehero-a.json';
import lhr1140B_ from '../../../../test/fixtures/lh-11-4-0-coursehero-b.json';
import lhr1200A_ from '../../../../test/fixtures/lh-12-0-0-coursehero-a.json';
import lhr1200B_ from '../../../../test/fixtures/lh-12-0-0-coursehero-b.json';
import lhrPsi800A_ from '../../../../test/fixtures/psi-8-0-0-dkdev-a.json';
import lhrPsi800B_ from '../../../../test/fixtures/psi-8-0-0-dkdev-b.json';

Expand All @@ -50,6 +52,8 @@ const lhr1010A = /** @type {any} */ (lhr1010A_);
const lhr1010B = /** @type {any} */ (lhr1010B_);
const lhr1140A = /** @type {any} */ (lhr1140A_);
const lhr1140B = /** @type {any} */ (lhr1140B_);
const lhr1200A = /** @type {any} */ (lhr1200A_);
const lhr1200B = /** @type {any} */ (lhr1200B_);
const lhrPsi800A = /** @type {any} */ (lhrPsi800A_);
const lhrPsi800B = /** @type {any} */ (lhrPsi800B_);

Expand Down Expand Up @@ -110,6 +114,12 @@ export const Version1140 = () => (
</Wrapper>
);

export const Version1200 = () => (
<Wrapper>
<LhrComparison lhr={lhr1200A} baseLhr={lhr1200B} hookElements={{}} />
</Wrapper>
);

export const VersionPsi800 = () => (
<Wrapper>
<LhrComparison lhr={lhrPsi800A} baseLhr={lhrPsi800B} hookElements={{}} />
Expand Down
Loading

0 comments on commit 4cbe5a1

Please sign in to comment.