Skip to content
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
24 changes: 21 additions & 3 deletions cli/test/smokehouse/test-definitions/dobetterweb.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,29 @@ const expectations = {
numericValue: 153,
details: {
items: [
{statistic: 'Total DOM Elements', value: 153},
{statistic: 'Maximum DOM Depth', value: 4},
{
statistic: 'Total DOM Elements',
value: {
type: 'numeric',
granularity: 1,
value: 153,
},
},
{
statistic: 'Maximum DOM Depth',
value: {
type: 'numeric',
granularity: 1,
value: 4,
},
},
{
statistic: 'Maximum Child Elements',
value: 100,
value: {
type: 'numeric',
granularity: 1,
value: 100,
},
node: {snippet: '<div id="shadow-root-container">'},
},
],
Expand Down
18 changes: 15 additions & 3 deletions core/audits/dobetterweb/dom-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,29 @@ class DOMSize extends Audit {
const items = [
{
statistic: str_(UIStrings.statisticDOMElements),
value: stats.totalBodyElements,
value: {
type: 'numeric',
granularity: 1,
value: stats.totalBodyElements,
},
},
{
node: Audit.makeNodeItem(stats.depth),
statistic: str_(UIStrings.statisticDOMDepth),
value: stats.depth.max,
value: {
type: 'numeric',
granularity: 1,
value: stats.depth.max,
},
},
{
node: Audit.makeNodeItem(stats.width),
statistic: str_(UIStrings.statisticDOMWidth),
value: stats.width.max,
value: {
type: 'numeric',
granularity: 1,
value: stats.width.max,
},
},
];

Expand Down
6 changes: 3 additions & 3 deletions core/test/audits/dobetterweb/dom-size-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ describe('DOMSize audit', () => {
assert.equal(auditResult.score, 0.43);
assert.equal(auditResult.numericValue, numElements);
expect(auditResult.displayValue).toBeDisplayString('1,500 elements');
assert.equal(auditResult.details.items[0].value, numElements);
assert.equal(auditResult.details.items[1].value, 1);
assert.equal(auditResult.details.items[2].value, 2);
assert.equal(auditResult.details.items[0].value.value, numElements);
assert.equal(auditResult.details.items[1].value.value, 1);
assert.equal(auditResult.details.items[2].value.value, 2);
});

it('calculates score hitting top distribution', () => {
Expand Down
54 changes: 45 additions & 9 deletions core/test/fixtures/fraggle-rock/reports/sample-flow-result.json
Original file line number Diff line number Diff line change
Expand Up @@ -3342,7 +3342,11 @@
"items": [
{
"statistic": "Total DOM Elements",
"value": 70
"value": {
"type": "numeric",
"granularity": 1,
"value": 70
}
},
{
"node": {
Expand All @@ -3362,7 +3366,11 @@
"nodeLabel": "div.flex > div.inline-block > svg.h-6 > path"
},
"statistic": "Maximum DOM Depth",
"value": 9
"value": {
"type": "numeric",
"granularity": 1,
"value": 9
}
},
{
"node": {
Expand All @@ -3382,7 +3390,11 @@
"nodeLabel": "body"
},
"statistic": "Maximum Child Elements",
"value": 14
"value": {
"type": "numeric",
"granularity": 1,
"value": 14
}
}
]
}
Expand Down Expand Up @@ -12025,7 +12037,11 @@
"items": [
{
"statistic": "Total DOM Elements",
"value": 155
"value": {
"type": "numeric",
"granularity": 1,
"value": 155
}
},
{
"node": {
Expand All @@ -12045,7 +12061,11 @@
"nodeLabel": "Oscar:"
},
"statistic": "Maximum DOM Depth",
"value": 11
"value": {
"type": "numeric",
"granularity": 1,
"value": 11
}
},
{
"node": {
Expand All @@ -12065,7 +12085,11 @@
"nodeLabel": "body"
},
"statistic": "Maximum Child Elements",
"value": 17
"value": {
"type": "numeric",
"granularity": 1,
"value": 17
}
}
]
}
Expand Down Expand Up @@ -17417,7 +17441,11 @@
"items": [
{
"statistic": "Total DOM Elements",
"value": 81
"value": {
"type": "numeric",
"granularity": 1,
"value": 81
}
},
{
"node": {
Expand All @@ -17437,7 +17465,11 @@
"nodeLabel": "div.flex > div.inline-block > svg.h-6 > path"
},
"statistic": "Maximum DOM Depth",
"value": 9
"value": {
"type": "numeric",
"granularity": 1,
"value": 9
}
},
{
"node": {
Expand All @@ -17457,7 +17489,11 @@
"nodeLabel": "body"
},
"statistic": "Maximum Child Elements",
"value": 13
"value": {
"type": "numeric",
"granularity": 1,
"value": 13
}
}
]
}
Expand Down
18 changes: 15 additions & 3 deletions core/test/results/sample_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -5253,7 +5253,11 @@
"items": [
{
"statistic": "Total DOM Elements",
"value": 153
"value": {
"type": "numeric",
"granularity": 1,
"value": 153
}
},
{
"node": {
Expand All @@ -5273,7 +5277,11 @@
"nodeLabel": "body > div > svg.social-facebook > title#social-facebook-5"
},
"statistic": "Maximum DOM Depth",
"value": 4
"value": {
"type": "numeric",
"granularity": 1,
"value": 4
}
},
{
"node": {
Expand All @@ -5293,7 +5301,11 @@
"nodeLabel": "body > div#shadow-root-container"
},
"statistic": "Maximum Child Elements",
"value": 100
"value": {
"type": "numeric",
"granularity": 1,
"value": 100
}
}
]
}
Expand Down