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
f33003a7
Commit
f33003a7
authored
Apr 22, 2021
by
jboyson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update tests to assert events
parent
bcbae358
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
10 deletions
+54
-10
app/assets/javascripts/diffs/components/diff_row.vue
app/assets/javascripts/diffs/components/diff_row.vue
+2
-2
spec/frontend/diffs/components/diff_row_spec.js
spec/frontend/diffs/components/diff_row_spec.js
+52
-8
No files found.
app/assets/javascripts/diffs/components/diff_row.vue
View file @
f33003a7
...
@@ -211,11 +211,11 @@ export default {
...
@@ -211,11 +211,11 @@ export default {
<span
<span
v-if=
"shouldRenderCommentButton && !line.hasDiscussionsLeft"
v-if=
"shouldRenderCommentButton && !line.hasDiscussionsLeft"
v-gl-tooltip
v-gl-tooltip
data-testid=
"leftCommentButton"
class=
"add-diff-note tooltip-wrapper"
class=
"add-diff-note tooltip-wrapper"
:title=
"addCommentTooltipLeft"
:title=
"addCommentTooltipLeft"
>
>
<div
<div
data-testid=
"leftCommentButton"
role=
"button"
role=
"button"
tabindex=
"0"
tabindex=
"0"
:draggable=
"!line.left.commentsDisabled && glFeatures.dragCommentSelection"
:draggable=
"!line.left.commentsDisabled && glFeatures.dragCommentSelection"
...
@@ -318,11 +318,11 @@ export default {
...
@@ -318,11 +318,11 @@ export default {
<span
<span
v-if=
"shouldRenderCommentButton && !line.hasDiscussionsRight"
v-if=
"shouldRenderCommentButton && !line.hasDiscussionsRight"
v-gl-tooltip
v-gl-tooltip
data-testid=
"rightCommentButton"
class=
"add-diff-note tooltip-wrapper"
class=
"add-diff-note tooltip-wrapper"
:title=
"addCommentTooltipRight"
:title=
"addCommentTooltipRight"
>
>
<div
<div
data-testid=
"rightCommentButton"
role=
"button"
role=
"button"
tabindex=
"0"
tabindex=
"0"
:draggable=
"!line.right.commentsDisabled && glFeatures.dragCommentSelection"
:draggable=
"!line.right.commentsDisabled && glFeatures.dragCommentSelection"
...
...
spec/frontend/diffs/components/diff_row_spec.js
View file @
f33003a7
import
{
getByTestId
,
fireEvent
}
from
'
@testing-library/dom
'
;
import
{
getByTestId
,
fireEvent
}
from
'
@testing-library/dom
'
;
import
{
shallowMount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
Vue
from
'
vue
'
;
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
DiffRow
from
'
~/diffs/components/diff_row.vue
'
;
import
DiffRow
from
'
~/diffs/components/diff_row.vue
'
;
import
{
mapParallel
}
from
'
~/diffs/components/diff_row_utils
'
;
import
{
mapParallel
}
from
'
~/diffs/components/diff_row_utils
'
;
...
@@ -28,12 +29,12 @@ describe('DiffRow', () => {
...
@@ -28,12 +29,12 @@ describe('DiffRow', () => {
},
},
];
];
const
createWrapper
=
({
props
,
state
,
isLoggedIn
=
true
})
=>
{
const
createWrapper
=
({
props
,
state
,
actions
,
isLoggedIn
=
true
})
=>
{
const
localVue
=
createLocalVue
();
Vue
.
use
(
Vuex
);
localVue
.
use
(
Vuex
);
const
diffs
=
diffsModule
();
const
diffs
=
diffsModule
();
diffs
.
state
=
{
...
diffs
.
state
,
...
state
};
diffs
.
state
=
{
...
diffs
.
state
,
...
state
};
diffs
.
actions
=
{
...
diffs
.
actions
,
...
actions
};
const
getters
=
{
isLoggedIn
:
()
=>
isLoggedIn
};
const
getters
=
{
isLoggedIn
:
()
=>
isLoggedIn
};
...
@@ -54,7 +55,7 @@ describe('DiffRow', () => {
...
@@ -54,7 +55,7 @@ describe('DiffRow', () => {
glFeatures
:
{
dragCommentSelection
:
true
},
glFeatures
:
{
dragCommentSelection
:
true
},
};
};
return
shallowMount
(
DiffRow
,
{
propsData
,
localVue
,
store
,
provide
});
return
shallowMount
(
DiffRow
,
{
propsData
,
store
,
provide
});
};
};
it
(
'
isHighlighted returns true given line.left
'
,
()
=>
{
it
(
'
isHighlighted returns true given line.left
'
,
()
=>
{
...
@@ -95,6 +96,8 @@ describe('DiffRow', () => {
...
@@ -95,6 +96,8 @@ describe('DiffRow', () => {
expect
(
wrapper
.
vm
.
isHighlighted
).
toBe
(
false
);
expect
(
wrapper
.
vm
.
isHighlighted
).
toBe
(
false
);
});
});
const
getCommentButton
=
(
wrapper
,
side
)
=>
wrapper
.
find
(
`[data-testid="
${
side
}
CommentButton"]`
);
describe
.
each
`
describe
.
each
`
side
side
${
'
left
'
}
${
'
left
'
}
...
@@ -106,9 +109,50 @@ describe('DiffRow', () => {
...
@@ -106,9 +109,50 @@ describe('DiffRow', () => {
expect
(
wrapper
.
find
(
`[data-testid="
${
side
}
EmptyCell"]`
).
exists
()).
toBe
(
true
);
expect
(
wrapper
.
find
(
`[data-testid="
${
side
}
EmptyCell"]`
).
exists
()).
toBe
(
true
);
});
});
it
(
'
renders comment button
'
,
()
=>
{
describe
(
'
comment button
'
,
()
=>
{
const
wrapper
=
createWrapper
({
props
:
{
line
:
testLines
[
3
],
inline
:
false
}
});
const
showCommentForm
=
jest
.
fn
();
expect
(
wrapper
.
find
(
`[data-testid="
${
side
}
CommentButton"]`
).
exists
()).
toBe
(
true
);
let
line
;
beforeEach
(()
=>
{
showCommentForm
.
mockReset
();
// https://eslint.org/docs/rules/prefer-destructuring#when-not-to-use-it
// eslint-disable-next-line prefer-destructuring
line
=
testLines
[
3
];
});
it
(
'
renders
'
,
()
=>
{
const
wrapper
=
createWrapper
({
props
:
{
line
,
inline
:
false
}
});
expect
(
getCommentButton
(
wrapper
,
side
).
exists
()).
toBe
(
true
);
});
it
(
'
responds to click and keyboard events
'
,
async
()
=>
{
const
wrapper
=
createWrapper
({
props
:
{
line
,
inline
:
false
},
actions
:
{
showCommentForm
},
});
const
commentButton
=
getCommentButton
(
wrapper
,
side
);
await
commentButton
.
trigger
(
'
click
'
);
await
commentButton
.
trigger
(
'
keydown.enter
'
);
await
commentButton
.
trigger
(
'
keydown.space
'
);
expect
(
showCommentForm
).
toHaveBeenCalledTimes
(
3
);
});
it
(
'
ignores click and keyboard events when comments are disabled
'
,
async
()
=>
{
line
[
side
].
commentsDisabled
=
true
;
const
wrapper
=
createWrapper
({
props
:
{
line
,
inline
:
false
},
actions
:
{
showCommentForm
},
});
const
commentButton
=
getCommentButton
(
wrapper
,
side
);
await
commentButton
.
trigger
(
'
click
'
);
await
commentButton
.
trigger
(
'
keydown.enter
'
);
await
commentButton
.
trigger
(
'
keydown.space
'
);
expect
(
showCommentForm
).
not
.
toHaveBeenCalled
();
});
});
});
it
(
'
renders avatars
'
,
()
=>
{
it
(
'
renders avatars
'
,
()
=>
{
...
...
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