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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
2cf3fbcf
Commit
2cf3fbcf
authored
May 29, 2019
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes bug with parent row component triggering multiple Vue router pushes
parent
ee277ce0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
2 deletions
+66
-2
app/assets/javascripts/repository/components/table/parent_row.vue
...ts/javascripts/repository/components/table/parent_row.vue
+2
-2
spec/frontend/repository/components/table/parent_row_spec.js
spec/frontend/repository/components/table/parent_row_spec.js
+64
-0
No files found.
app/assets/javascripts/repository/components/table/parent_row.vue
View file @
2cf3fbcf
...
...
@@ -27,8 +27,8 @@ export default {
</
script
>
<
template
>
<tr
v-once
@
click=
"clickRow
"
>
<td
colspan=
"3"
class=
"tree-item-file-name"
>
<tr
class=
"tree-item
"
>
<td
colspan=
"3"
class=
"tree-item-file-name"
@
click.self=
"clickRow"
>
<router-link
:to=
"parentRoute"
:aria-label=
"__('Go to parent')"
>
..
</router-link>
...
...
spec/frontend/repository/components/table/parent_row_spec.js
0 → 100644
View file @
2cf3fbcf
import
{
shallowMount
,
RouterLinkStub
}
from
'
@vue/test-utils
'
;
import
ParentRow
from
'
~/repository/components/table/parent_row.vue
'
;
let
vm
;
let
$router
;
function
factory
(
path
)
{
$router
=
{
push
:
jest
.
fn
(),
};
vm
=
shallowMount
(
ParentRow
,
{
propsData
:
{
commitRef
:
'
master
'
,
path
,
},
stubs
:
{
RouterLink
:
RouterLinkStub
,
},
mocks
:
{
$router
,
},
});
}
describe
(
'
Repository parent row component
'
,
()
=>
{
afterEach
(()
=>
{
vm
.
destroy
();
});
it
.
each
`
path | to
${
'
app
'
}
|
${
'
/tree/master/
'
}
${
'
app/assets
'
}
|
${
'
/tree/master/app
'
}
`
(
'
renders link in $path to $to
'
,
({
path
,
to
})
=>
{
factory
(
path
);
expect
(
vm
.
find
(
RouterLinkStub
).
props
().
to
).
toEqual
({
path
:
to
,
});
});
it
(
'
pushes new router when clicking row
'
,
()
=>
{
factory
(
'
app/assets
'
);
vm
.
find
(
'
td
'
).
trigger
(
'
click
'
);
expect
(
$router
.
push
).
toHaveBeenCalledWith
({
path
:
'
/tree/master/app
'
,
});
});
// We test that it does not get called when clicking any internal
// links as this was causing multipe routes to get pushed
it
(
'
does not trigger router.push when clicking link
'
,
()
=>
{
factory
(
'
app/assets
'
);
vm
.
find
(
'
a
'
).
trigger
(
'
click
'
);
expect
(
$router
.
push
).
not
.
toHaveBeenCalledWith
({
path
:
'
/tree/master/app
'
,
});
});
});
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