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
ef4a4496
Commit
ef4a4496
authored
Jan 18, 2021
by
Justin Boyson
Committed by
Phil Hughes
Jan 18, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add coverage to 'left' side of parallel diff view
Add tests for line coverage
parent
82325168
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
77 additions
and
4 deletions
+77
-4
app/assets/javascripts/diffs/components/diff_row.vue
app/assets/javascripts/diffs/components/diff_row.vue
+18
-4
changelogs/unreleased/297569-inline-code-coverage-visualization-not-displaying-in-inline-mr-dif.yml
...overage-visualization-not-displaying-in-inline-mr-dif.yml
+5
-0
spec/frontend/diffs/components/diff_row_spec.js
spec/frontend/diffs/components/diff_row_spec.js
+54
-0
No files found.
app/assets/javascripts/diffs/components/diff_row.vue
View file @
ef4a4496
...
@@ -76,7 +76,12 @@ export default {
...
@@ -76,7 +76,12 @@ export default {
parallelViewLeftLineType
()
{
parallelViewLeftLineType
()
{
return
utils
.
parallelViewLeftLineType
(
this
.
line
,
this
.
isHighlighted
||
this
.
isCommented
);
return
utils
.
parallelViewLeftLineType
(
this
.
line
,
this
.
isHighlighted
||
this
.
isCommented
);
},
},
coverageState
()
{
coverageStateLeft
()
{
if
(
!
this
.
inline
||
!
this
.
line
.
left
)
return
{};
return
this
.
fileLineCoverage
(
this
.
filePath
,
this
.
line
.
left
.
new_line
);
},
coverageStateRight
()
{
if
(
!
this
.
line
.
right
)
return
{};
return
this
.
fileLineCoverage
(
this
.
filePath
,
this
.
line
.
right
.
new_line
);
return
this
.
fileLineCoverage
(
this
.
filePath
,
this
.
line
.
right
.
new_line
);
},
},
classNameMapCellLeft
()
{
classNameMapCellLeft
()
{
...
@@ -243,7 +248,12 @@ export default {
...
@@ -243,7 +248,12 @@ export default {
>
>
</a>
</a>
</div>
</div>
<div
:class=
"parallelViewLeftLineType"
class=
"diff-td line-coverage left-side"
></div>
<div
v-gl-tooltip
.
hover
:title=
"coverageStateLeft.text"
:class=
"[...parallelViewLeftLineType, coverageStateLeft.class]"
class=
"diff-td line-coverage left-side"
></div>
<div
<div
:id=
"line.left.line_code"
:id=
"line.left.line_code"
:key=
"line.left.line_code"
:key=
"line.left.line_code"
...
@@ -333,8 +343,12 @@ export default {
...
@@ -333,8 +343,12 @@ export default {
</div>
</div>
<div
<div
v-gl-tooltip
.
hover
v-gl-tooltip
.
hover
:title=
"coverageState.text"
:title=
"coverageStateRight.text"
:class=
"[line.right.type, coverageState.class, { hll: isHighlighted, hll: isCommented }]"
:class=
"[
line.right.type,
coverageStateRight.class,
{ hll: isHighlighted, hll: isCommented },
]"
class=
"diff-td line-coverage right-side"
class=
"diff-td line-coverage right-side"
></div>
></div>
<div
<div
...
...
changelogs/unreleased/297569-inline-code-coverage-visualization-not-displaying-in-inline-mr-dif.yml
0 → 100644
View file @
ef4a4496
---
title
:
Fix coverage not showing for inline diffs
merge_request
:
51652
author
:
type
:
fixed
spec/frontend/diffs/components/diff_row_spec.js
View file @
ef4a4496
...
@@ -3,6 +3,8 @@ import { getByTestId, fireEvent } from '@testing-library/dom';
...
@@ -3,6 +3,8 @@ import { getByTestId, fireEvent } from '@testing-library/dom';
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
diffsModule
from
'
~/diffs/store/modules
'
;
import
diffsModule
from
'
~/diffs/store/modules
'
;
import
DiffRow
from
'
~/diffs/components/diff_row.vue
'
;
import
DiffRow
from
'
~/diffs/components/diff_row.vue
'
;
import
diffFileMockData
from
'
../mock_data/diff_file
'
;
import
{
mapParallel
}
from
'
~/diffs/components/diff_row_utils
'
;
describe
(
'
DiffRow
'
,
()
=>
{
describe
(
'
DiffRow
'
,
()
=>
{
const
testLines
=
[
const
testLines
=
[
...
@@ -157,4 +159,56 @@ describe('DiffRow', () => {
...
@@ -157,4 +159,56 @@ describe('DiffRow', () => {
expect
(
wrapper
.
emitted
().
stopdragging
).
toBeTruthy
();
expect
(
wrapper
.
emitted
().
stopdragging
).
toBeTruthy
();
});
});
});
});
describe
(
'
sets coverage title and class
'
,
()
=>
{
const
thisLine
=
diffFileMockData
.
parallel_diff_lines
[
2
];
const
rightLine
=
diffFileMockData
.
parallel_diff_lines
[
2
].
right
;
const
mockDiffContent
=
{
diffFile
:
diffFileMockData
,
shouldRenderDraftRow
:
jest
.
fn
(),
hasParallelDraftLeft
:
jest
.
fn
(),
hasParallelDraftRight
:
jest
.
fn
(),
draftForLine
:
jest
.
fn
(),
};
const
applyMap
=
mapParallel
(
mockDiffContent
);
const
props
=
{
line
:
applyMap
(
thisLine
),
fileHash
:
diffFileMockData
.
file_hash
,
filePath
:
diffFileMockData
.
file_path
,
contextLinesPath
:
'
contextLinesPath
'
,
isHighlighted
:
false
,
};
const
name
=
diffFileMockData
.
file_path
;
const
line
=
rightLine
.
new_line
;
it
(
'
for lines with coverage
'
,
()
=>
{
const
coverageFiles
=
{
files
:
{
[
name
]:
{
[
line
]:
5
}
}
};
const
wrapper
=
createWrapper
({
props
,
state
:
{
coverageFiles
}
});
const
coverage
=
wrapper
.
find
(
'
.line-coverage.right-side
'
);
expect
(
coverage
.
attributes
(
'
title
'
)).
toContain
(
'
Test coverage: 5 hits
'
);
expect
(
coverage
.
classes
(
'
coverage
'
)).
toBeTruthy
();
});
it
(
'
for lines without coverage
'
,
()
=>
{
const
coverageFiles
=
{
files
:
{
[
name
]:
{
[
line
]:
0
}
}
};
const
wrapper
=
createWrapper
({
props
,
state
:
{
coverageFiles
}
});
const
coverage
=
wrapper
.
find
(
'
.line-coverage.right-side
'
);
expect
(
coverage
.
attributes
(
'
title
'
)).
toContain
(
'
No test coverage
'
);
expect
(
coverage
.
classes
(
'
no-coverage
'
)).
toBeTruthy
();
});
it
(
'
for unknown lines
'
,
()
=>
{
const
coverageFiles
=
{};
const
wrapper
=
createWrapper
({
props
,
state
:
{
coverageFiles
}
});
const
coverage
=
wrapper
.
find
(
'
.line-coverage.right-side
'
);
expect
(
coverage
.
attributes
(
'
title
'
)).
toBeFalsy
();
expect
(
coverage
.
classes
(
'
coverage
'
)).
toBeFalsy
();
expect
(
coverage
.
classes
(
'
no-coverage
'
)).
toBeFalsy
();
});
});
});
});
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