Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7026db3a
Commit
7026db3a
authored
Aug 19, 2021
by
Miranda Fluharty
Committed by
Brandon Labuschagne
Aug 19, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add percentage change to performance widgets
parent
c3a5d918
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
29 deletions
+64
-29
ee/app/assets/javascripts/vue_merge_request_widget/components/performance_issue_body.vue
...erge_request_widget/components/performance_issue_body.vue
+11
-3
ee/spec/frontend/vue_mr_widget/components/performance_issue_body_spec.js
...d/vue_mr_widget/components/performance_issue_body_spec.js
+53
-26
No files found.
ee/app/assets/javascripts/vue_merge_request_widget/components/performance_issue_body.vue
View file @
7026db3a
...
...
@@ -3,6 +3,7 @@
* Renders Perfomance issue body text
* [name] :[score] [symbol] [delta] in [link]
*/
import
{
formattedChangeInPercent
}
from
'
~/lib/utils/number_utils
'
;
import
ReportLink
from
'
~/reports/components/report_link.vue
'
;
function
formatScore
(
value
)
{
...
...
@@ -34,10 +35,16 @@ export default {
if
(
!
this
.
issue
.
delta
)
{
return
false
;
}
if
(
this
.
issue
.
delta
>=
0
)
{
return
`+
${
formatScore
(
this
.
issue
.
delta
)}
`
;
return
this
.
issue
.
delta
>=
0
?
`+
${
formatScore
(
this
.
issue
.
delta
)}
`
:
formatScore
(
this
.
issue
.
delta
);
},
issueDeltaPercentage
()
{
if
(
!
this
.
issue
.
delta
||
!
this
.
issue
.
score
||
!
Number
(
this
.
issue
.
score
))
{
return
false
;
}
return
formatScore
(
this
.
issue
.
delta
);
const
oldScore
=
parseFloat
(
this
.
issue
.
score
)
-
this
.
issue
.
delta
;
return
formattedChangeInPercent
(
oldScore
,
this
.
issue
.
score
);
},
},
};
...
...
@@ -52,6 +59,7 @@ export default {
{{
issue
.
name
}}
</
template
>
<
template
v-if=
"issueDelta"
>
(
{{
issueDelta
}}
)
</
template
>
<
template
v-if=
"issueDeltaPercentage"
>
(
{{
issueDeltaPercentage
}}
)
</
template
>
</div>
<report-link
v-if=
"issue.path"
:issue=
"issue"
/>
...
...
ee/spec/frontend/vue_mr_widget/components/performance_issue_body_spec.js
View file @
7026db3a
...
...
@@ -4,35 +4,62 @@ import component from 'ee/vue_merge_request_widget/components/performance_issue_
describe
(
'
performance issue body
'
,
()
=>
{
let
wrapper
;
const
performanceIssue
=
{
delta
:
0.1999999999998181
,
name
:
'
Transfer Size (KB)
'
,
path
:
'
/
'
,
score
:
4974.8
,
};
describe
.
each
`
name | score | delta | expectedScore | expectedDelta | expectedPercentage
${
'
Transfer Size (KB)
'
}
|
${
'
4974.8
'
}
|
${
0.1999999999998181
}
|
${
'
4974.80
'
}
|
${
'
(+0.19)
'
}
|
${
'
(+0%)
'
}
${
'
Speed Index
'
}
|
${
1474
}
|
${
727
}
|
${
'
1474
'
}
|
${
'
(+727)
'
}
|
${
'
(+97%)
'
}
${
'
Checks
'
}
|
${
'
97.73%
'
}
|
${
-
2.27
}
|
${
'
97.73%
'
}
|
${
'
(-2.27)
'
}
|
${
null
}
${
'
RPS
'
}
|
${
22.699900441941768
}
|
${
-
1
}
|
${
'
22.69
'
}
|
${
'
(-1)
'
}
|
${
'
(-4%)
'
}
${
'
TTFB P95
'
}
|
${
205.02902265
}
|
${
0
}
|
${
'
205.02
'
}
|
${
null
}
|
${
null
}
`
(
'
with an example $name performance metric
'
,
({
name
,
score
,
delta
,
expectedScore
,
expectedDelta
,
expectedPercentage
})
=>
{
beforeEach
(()
=>
{
wrapper
=
shallowMount
(
component
,
{
propsData
:
{
issue
:
{
path
:
'
/
'
,
name
,
score
,
delta
,
},
},
});
});
beforeEach
(()
=>
{
wrapper
=
shallowMount
(
component
,
{
propsData
:
{
issue
:
performanceIssue
,
},
});
});
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
=
null
;
});
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
=
null
;
});
it
(
'
renders issue name
'
,
()
=>
{
expect
(
wrapper
.
text
()).
toContain
(
name
);
});
it
(
'
renders issue name
'
,
()
=>
{
expect
(
wrapper
.
text
()).
toContain
(
performanceIssue
.
nam
e
);
});
it
(
'
renders issue score formatted
'
,
()
=>
{
expect
(
wrapper
.
text
()).
toContain
(
expectedScor
e
);
});
it
(
'
renders issue score formatted
'
,
()
=>
{
expect
(
wrapper
.
text
()).
toContain
(
'
4974.80
'
);
});
if
(
delta
)
{
it
(
'
renders issue delta formatted
'
,
()
=>
{
expect
(
wrapper
.
text
()).
toContain
(
expectedDelta
);
});
}
else
{
it
(
'
does not render issue delta formatted
'
,
()
=>
{
expect
(
wrapper
.
text
()).
not
.
toContain
(
'
(+
'
);
expect
(
wrapper
.
text
()).
not
.
toContain
(
'
(-
'
);
});
}
it
(
'
renders issue delta formatted
'
,
()
=>
{
expect
(
wrapper
.
text
()).
toContain
(
'
(+0.19)
'
);
});
if
(
expectedPercentage
)
{
it
(
'
renders issue delta as a percentage
'
,
()
=>
{
expect
(
wrapper
.
text
()).
toContain
(
expectedPercentage
);
});
}
else
{
it
(
'
does not render issue delta as a percentage
'
,
()
=>
{
expect
(
wrapper
.
text
()).
not
.
toContain
(
'
%)
'
);
});
}
},
);
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment