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
e68f628a
Commit
e68f628a
authored
Jun 14, 2021
by
Thomas Randolph
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch classes to use data-testid
parent
04f9732b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
16 deletions
+20
-16
app/assets/javascripts/diffs/components/diff_stats.vue
app/assets/javascripts/diffs/components/diff_stats.vue
+2
-2
spec/features/merge_request/user_sees_versions_spec.rb
spec/features/merge_request/user_sees_versions_spec.rb
+4
-4
spec/frontend/diffs/components/diff_stats_spec.js
spec/frontend/diffs/components/diff_stats_spec.js
+14
-10
No files found.
app/assets/javascripts/diffs/components/diff_stats.vue
View file @
e68f628a
...
...
@@ -70,14 +70,14 @@ export default {
:class=
"
{ bold: isCompareVersionsHeader }"
>
<span>
+
</span>
<span
class
=
"js-file-addition-line"
>
{{
addedLines
}}
</span>
<span
data-testid
=
"js-file-addition-line"
>
{{
addedLines
}}
</span>
</div>
<div
class=
"diff-stats-group gl-text-red-500 gl-display-flex gl-align-items-center"
:class=
"
{ bold: isCompareVersionsHeader }"
>
<span>
-
</span>
<span
class
=
"js-file-deletion-line"
>
{{
removedLines
}}
</span>
<span
data-testid
=
"js-file-deletion-line"
>
{{
removedLines
}}
</span>
</div>
</div>
</div>
...
...
spec/features/merge_request/user_sees_versions_spec.rb
View file @
e68f628a
...
...
@@ -129,8 +129,8 @@ RSpec.describe 'Merge request > User sees versions', :js do
)
expect
(
page
).
to
have_content
'4 files'
additions_content
=
page
.
find
(
'.diff-stats.is-compare-versions-header .diff-stats-group
.js-file-addition-line
'
).
text
deletions_content
=
page
.
find
(
'.diff-stats.is-compare-versions-header .diff-stats-group
.js-file-deletion-line
'
).
text
additions_content
=
page
.
find
(
'.diff-stats.is-compare-versions-header .diff-stats-group
[data-testid="js-file-addition-line"]
'
).
text
deletions_content
=
page
.
find
(
'.diff-stats.is-compare-versions-header .diff-stats-group
[data-testid="js-file-deletion-line"]
'
).
text
expect
(
additions_content
).
to
eq
'15'
expect
(
deletions_content
).
to
eq
'6'
...
...
@@ -152,8 +152,8 @@ RSpec.describe 'Merge request > User sees versions', :js do
end
it
'show diff between new and old version'
do
additions_content
=
page
.
find
(
'.diff-stats.is-compare-versions-header .diff-stats-group
.js-file-addition-line
'
).
text
deletions_content
=
page
.
find
(
'.diff-stats.is-compare-versions-header .diff-stats-group
.js-file-deletion-line
'
).
text
additions_content
=
page
.
find
(
'.diff-stats.is-compare-versions-header .diff-stats-group
[data-testid="js-file-addition-line"]
'
).
text
deletions_content
=
page
.
find
(
'.diff-stats.is-compare-versions-header .diff-stats-group
[data-testid="js-file-deletion-line"]
'
).
text
expect
(
page
).
to
have_content
'4 files'
expect
(
additions_content
).
to
eq
'15'
...
...
spec/frontend/diffs/components/diff_stats_spec.js
View file @
e68f628a
import
{
GlIcon
}
from
'
@gitlab/ui
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
extendedWrapper
}
from
'
helpers/vue_test_utils_helper
'
;
import
DiffStats
from
'
~/diffs/components/diff_stats.vue
'
;
import
mockDiffFile
from
'
../mock_data/diff_file
'
;
...
...
@@ -12,13 +14,15 @@ describe('diff_stats', () => {
let
wrapper
;
const
createComponent
=
(
props
=
{})
=>
{
wrapper
=
shallowMount
(
DiffStats
,
{
propsData
:
{
addedLines
:
TEST_ADDED_LINES
,
removedLines
:
TEST_REMOVED_LINES
,
...
props
,
},
});
wrapper
=
extendedWrapper
(
shallowMount
(
DiffStats
,
{
propsData
:
{
addedLines
:
TEST_ADDED_LINES
,
removedLines
:
TEST_REMOVED_LINES
,
...
props
,
},
}),
);
};
describe
(
'
diff stats group
'
,
()
=>
{
...
...
@@ -64,18 +68,18 @@ describe('diff_stats', () => {
});
describe
(
'
line changes
'
,
()
=>
{
const
findFileLine
=
(
name
)
=>
wrapper
.
find
(
name
);
const
findFileLine
=
(
name
)
=>
wrapper
.
find
ByTestId
(
name
);
beforeEach
(()
=>
{
createComponent
();
});
it
(
'
shows the amount of lines added
'
,
()
=>
{
expect
(
findFileLine
(
'
.
js-file-addition-line
'
).
text
()).
toBe
(
TEST_ADDED_LINES
.
toString
());
expect
(
findFileLine
(
'
js-file-addition-line
'
).
text
()).
toBe
(
TEST_ADDED_LINES
.
toString
());
});
it
(
'
shows the amount of lines removed
'
,
()
=>
{
expect
(
findFileLine
(
'
.
js-file-deletion-line
'
).
text
()).
toBe
(
TEST_REMOVED_LINES
.
toString
());
expect
(
findFileLine
(
'
js-file-deletion-line
'
).
text
()).
toBe
(
TEST_REMOVED_LINES
.
toString
());
});
});
...
...
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