-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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(test): add user flows to generate some fixtures #15005
Changes from all commits
4673e15
559a0c3
d608b26
d41d1cc
4e5f3bc
2b75ae0
a4706e0
40f90bb
b80bbe5
d0d244c
044fcef
9838462
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,8 @@ import {readJson} from '../test-utils.js'; | |
|
||
const acceptableTrace = readJson('../fixtures/traces/progressive-app-m60.json', import.meta); | ||
const siteWithRedirectTrace = readJson('../fixtures/traces/site-with-redirect.json', import.meta); | ||
const loadTrace = readJson('../fixtures/traces/load.json', import.meta); | ||
const loadTraceOld = readJson('../fixtures/traces/load.json', import.meta); | ||
const loadTrace = readJson('../fixtures/traces/animation.json', import.meta); | ||
const errorTrace = readJson('../fixtures/traces/no_fmp_event.json', import.meta); | ||
|
||
const options = PageExecutionTimings.defaultOptions; | ||
|
@@ -25,15 +26,6 @@ const acceptableTraceExpectations = { | |
garbageCollection: 48, | ||
other: 663, | ||
}; | ||
const siteWithRedirectTraceExpectations = { | ||
parseHTML: 84, | ||
styleLayout: 275, | ||
paintCompositeRender: 12, | ||
scriptEvaluation: 145, | ||
scriptParseCompile: 38, | ||
garbageCollection: 46, | ||
other: 184, | ||
}; | ||
const loadTraceExpectations = { | ||
parseHTML: 25, | ||
styleLayout: 131, | ||
|
@@ -85,14 +77,25 @@ describe('Performance: page execution timings audit', () => { | |
const artifacts = {traces: {defaultPass: siteWithRedirectTrace}}; | ||
|
||
const output = await PageExecutionTimings.audit(artifacts, {options, computedCache: new Map()}); | ||
assert.deepStrictEqual(keyOutput(output), siteWithRedirectTraceExpectations); | ||
assert.equal(Math.round(output.numericValue), 784); | ||
expect(keyOutput(output)).toMatchInlineSnapshot(` | ||
Object { | ||
"garbageCollection": 14, | ||
"other": 188, | ||
"paintCompositeRender": 11, | ||
"parseHTML": 52, | ||
"scriptEvaluation": 577, | ||
"scriptParseCompile": 67, | ||
"styleLayout": 70, | ||
} | ||
`); | ||
expect(Math.round(output.numericValue)).toMatchInlineSnapshot(`979`); | ||
assert.equal(output.details.items.length, 7); | ||
assert.equal(output.score, 1); | ||
}); | ||
|
||
it('should compute the correct values for the load trace', async () => { | ||
const artifacts = {traces: {defaultPass: {traceEvents: loadTrace}}}; | ||
it('should compute the correct values for the load trace (legacy)', async () => { | ||
assert(loadTraceOld.find(e => e.name === 'TracingStartedInPage')); | ||
const artifacts = {traces: {defaultPass: {traceEvents: loadTraceOld}}}; | ||
|
||
const output = await PageExecutionTimings.audit(artifacts, {options, computedCache: new Map()}); | ||
assert.deepStrictEqual(keyOutput(output), loadTraceExpectations); | ||
|
@@ -101,6 +104,26 @@ describe('Performance: page execution timings audit', () => { | |
assert.equal(output.score, 1); | ||
}); | ||
|
||
it('should compute the correct values for the load trace', async () => { | ||
assert(loadTrace.traceEvents.find(e => e.name === 'TracingStartedInBrowser')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not put this assertion in the trace There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because that's pretty far removed from the one place that cares (this test) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, are we really worried about this event being missing in any new traces? The check kinda makes sense for the old trace but if this one is being continually refreshed then I'm not sure we need it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This trace will not be refreshed. We could remove the logic for the old event but only when all our test fixtures have been updated. |
||
const artifacts = {traces: {defaultPass: loadTrace}}; | ||
|
||
const output = await PageExecutionTimings.audit(artifacts, {options, computedCache: new Map()}); | ||
expect(keyOutput(output)).toMatchInlineSnapshot(` | ||
Object { | ||
"other": 59, | ||
"paintCompositeRender": 48, | ||
"parseHTML": 3, | ||
"scriptEvaluation": 11, | ||
"scriptParseCompile": 1, | ||
"styleLayout": 103, | ||
} | ||
`); | ||
expect(Math.round(output.numericValue)).toMatchInlineSnapshot(`224`); | ||
assert.equal(output.details.items.length, 6); | ||
assert.equal(output.score, 1); | ||
}); | ||
|
||
it('should get no data when no events are present', () => { | ||
const artifacts = {traces: {defaultPass: errorTrace}}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -267,106 +267,124 @@ describe('Third party facades audit', () => { | |
expect(results.displayValue).toBeDisplayString('2 facade alternatives available'); | ||
expect(results.details.items[0].product).toBeDisplayString('YouTube Embedded Player (Video)'); | ||
expect(results.details.items[1].product).toBeDisplayString('Vimeo Embedded Player (Video)'); | ||
expect(results.details.items).toMatchObject( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could also just delete this? |
||
[ | ||
{ | ||
entity: 'YouTube', | ||
transferSize: 651350, | ||
blockingTime: 0, | ||
subItems: { | ||
items: [ | ||
{ | ||
blockingTime: 0, | ||
mainThreadTime: 0, | ||
transferSize: 459603, | ||
url: 'https://www.youtube.com/s/player/e0d83c30/player_ias.vflset/en_US/base.js', | ||
}, | ||
{ | ||
blockingTime: 0, | ||
mainThreadTime: 0, | ||
transferSize: 66273, | ||
url: 'https://i.ytimg.com/vi/tgbNymZ7vqY/maxresdefault.jpg', | ||
}, | ||
{ | ||
blockingTime: 0, | ||
mainThreadTime: 0, | ||
transferSize: 50213, | ||
url: 'https://www.youtube.com/s/player/e0d83c30/www-embed-player.vflset/www-embed-player.js', | ||
}, | ||
{ | ||
blockingTime: 0, | ||
mainThreadTime: 0, | ||
transferSize: 46813, | ||
url: 'https://www.youtube.com/s/player/e0d83c30/www-player.css', | ||
}, | ||
{ | ||
blockingTime: 0, | ||
mainThreadTime: 0, | ||
transferSize: 11477, | ||
url: 'https://www.youtube.com/s/player/e0d83c30/player_ias.vflset/en_US/embed.js', | ||
}, | ||
{ | ||
blockingTime: 0, | ||
mainThreadTime: 0, | ||
transferSize: 16971, | ||
url: { | ||
formattedDefault: 'Other resources', | ||
}, | ||
}, | ||
], | ||
type: 'subitems', | ||
expect(results.details.items).toMatchInlineSnapshot(` | ||
Array [ | ||
Object { | ||
"blockingTime": 0, | ||
"entity": "YouTube", | ||
"product": Object { | ||
"formattedDefault": "YouTube Embedded Player (Video)", | ||
"i18nId": "core/audits/third-party-facades.js | categoryVideo", | ||
"values": Object { | ||
"productName": "YouTube Embedded Player", | ||
}, | ||
}, | ||
"subItems": Object { | ||
"items": Array [ | ||
Object { | ||
"blockingTime": 0, | ||
"mainThreadTime": 0, | ||
"transferSize": 459603, | ||
"url": "https://www.youtube.com/s/player/e0d83c30/player_ias.vflset/en_US/base.js", | ||
}, | ||
Object { | ||
"blockingTime": 0, | ||
"mainThreadTime": 0, | ||
"transferSize": 66273, | ||
"url": "https://i.ytimg.com/vi/tgbNymZ7vqY/maxresdefault.jpg", | ||
}, | ||
Object { | ||
"blockingTime": 0, | ||
"mainThreadTime": 0, | ||
"transferSize": 50213, | ||
"url": "https://www.youtube.com/s/player/e0d83c30/www-embed-player.vflset/www-embed-player.js", | ||
}, | ||
Object { | ||
"blockingTime": 0, | ||
"mainThreadTime": 0, | ||
"transferSize": 46813, | ||
"url": "https://www.youtube.com/s/player/e0d83c30/www-player.css", | ||
}, | ||
Object { | ||
"blockingTime": 0, | ||
"mainThreadTime": 0, | ||
"transferSize": 11477, | ||
"url": "https://www.youtube.com/s/player/e0d83c30/player_ias.vflset/en_US/embed.js", | ||
}, | ||
Object { | ||
"blockingTime": 0, | ||
"mainThreadTime": 0, | ||
"transferSize": 16971, | ||
"url": Object { | ||
"formattedDefault": "Other resources", | ||
"i18nId": "core/lib/i18n/i18n.js | otherResourcesLabel", | ||
"values": undefined, | ||
}, | ||
}, | ||
{ | ||
entity: 'Vimeo', | ||
transferSize: 184495, | ||
blockingTime: 0, | ||
subItems: { | ||
items: [ | ||
{ | ||
blockingTime: 0, | ||
mainThreadTime: 0, | ||
transferSize: 145772, | ||
url: 'https://f.vimeocdn.com/p/3.22.3/js/player.js', | ||
}, | ||
{ | ||
blockingTime: 0, | ||
mainThreadTime: 0, | ||
transferSize: 17633, | ||
url: 'https://f.vimeocdn.com/p/3.22.3/css/player.css', | ||
}, | ||
{ | ||
blockingTime: 0, | ||
mainThreadTime: 0, | ||
transferSize: 9313, | ||
url: 'https://i.vimeocdn.com/video/784397921.webp?mw=1200&mh=675&q=70', | ||
}, | ||
{ | ||
blockingTime: 0, | ||
mainThreadTime: 0, | ||
transferSize: 8300, | ||
url: 'https://player.vimeo.com/video/336812660', | ||
}, | ||
{ | ||
blockingTime: 0, | ||
mainThreadTime: 0, | ||
transferSize: 1474, | ||
url: 'https://f.vimeocdn.com/js_opt/modules/utils/vuid.min.js', | ||
}, | ||
{ | ||
blockingTime: 0, | ||
mainThreadTime: 0, | ||
transferSize: 2003, | ||
url: { | ||
formattedDefault: 'Other resources', | ||
}, | ||
}, | ||
], | ||
type: 'subitems', | ||
], | ||
"type": "subitems", | ||
}, | ||
"transferSize": 651350, | ||
}, | ||
Object { | ||
"blockingTime": 0, | ||
"entity": "Vimeo", | ||
"product": Object { | ||
"formattedDefault": "Vimeo Embedded Player (Video)", | ||
"i18nId": "core/audits/third-party-facades.js | categoryVideo", | ||
"values": Object { | ||
"productName": "Vimeo Embedded Player", | ||
}, | ||
}, | ||
"subItems": Object { | ||
"items": Array [ | ||
Object { | ||
"blockingTime": 0, | ||
"mainThreadTime": 0, | ||
"transferSize": 145772, | ||
"url": "https://f.vimeocdn.com/p/3.22.3/js/player.js", | ||
}, | ||
Object { | ||
"blockingTime": 0, | ||
"mainThreadTime": 0, | ||
"transferSize": 17633, | ||
"url": "https://f.vimeocdn.com/p/3.22.3/css/player.css", | ||
}, | ||
Object { | ||
"blockingTime": 0, | ||
"mainThreadTime": 0, | ||
"transferSize": 9313, | ||
"url": "https://i.vimeocdn.com/video/784397921.webp?mw=1200&mh=675&q=70", | ||
}, | ||
Object { | ||
"blockingTime": 0, | ||
"mainThreadTime": 0, | ||
"transferSize": 8300, | ||
"url": "https://player.vimeo.com/video/336812660", | ||
}, | ||
Object { | ||
"blockingTime": 0, | ||
"mainThreadTime": 0, | ||
"transferSize": 1474, | ||
"url": "https://f.vimeocdn.com/js_opt/modules/utils/vuid.min.js", | ||
}, | ||
Object { | ||
"blockingTime": 0, | ||
"mainThreadTime": 0, | ||
"transferSize": 2003, | ||
"url": Object { | ||
"formattedDefault": "Other resources", | ||
"i18nId": "core/lib/i18n/i18n.js | otherResourcesLabel", | ||
"values": undefined, | ||
}, | ||
}, | ||
] | ||
); | ||
], | ||
"type": "subitems", | ||
}, | ||
"transferSize": 184495, | ||
}, | ||
] | ||
`); | ||
}); | ||
|
||
describe('.condenseItems', () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
really any modern chrome trace will do here, which is why I didn't bother making a user flow for a basic page. instead just used
animations
here.