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
Léo-Paul Géneau
gitlab-ce
Commits
bdaaa43f
Commit
bdaaa43f
authored
Mar 06, 2018
by
Shah El-Rahman
Committed by
Phil Hughes
Mar 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Group Leave action is broken on Groups Dashboard and Homepage"
parent
4cb348c1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
33 deletions
+36
-33
app/assets/javascripts/groups/components/app.vue
app/assets/javascripts/groups/components/app.vue
+5
-5
spec/javascripts/groups/components/app_spec.js
spec/javascripts/groups/components/app_spec.js
+31
-28
No files found.
app/assets/javascripts/groups/components/app.vue
View file @
bdaaa43f
...
@@ -152,14 +152,14 @@ export default {
...
@@ -152,14 +152,14 @@ export default {
showLeaveGroupModal
(
group
,
parentGroup
)
{
showLeaveGroupModal
(
group
,
parentGroup
)
{
this
.
targetGroup
=
group
;
this
.
targetGroup
=
group
;
this
.
targetParentGroup
=
parentGroup
;
this
.
targetParentGroup
=
parentGroup
;
this
.
update
Modal
=
true
;
this
.
show
Modal
=
true
;
this
.
groupLeaveConfirmationMessage
=
s__
(
`GroupsTree|Are you sure you want to leave the "
${
group
.
fullName
}
" group?`
);
this
.
groupLeaveConfirmationMessage
=
s__
(
`GroupsTree|Are you sure you want to leave the "
${
group
.
fullName
}
" group?`
);
},
},
hideLeaveGroupModal
()
{
hideLeaveGroupModal
()
{
this
.
update
Modal
=
false
;
this
.
show
Modal
=
false
;
},
},
leaveGroup
()
{
leaveGroup
()
{
this
.
update
Modal
=
false
;
this
.
show
Modal
=
false
;
this
.
targetGroup
.
isBeingRemoved
=
true
;
this
.
targetGroup
.
isBeingRemoved
=
true
;
this
.
service
.
leaveGroup
(
this
.
targetGroup
.
leavePath
)
this
.
service
.
leaveGroup
(
this
.
targetGroup
.
leavePath
)
.
then
(
res
=>
res
.
json
())
.
then
(
res
=>
res
.
json
())
...
@@ -208,9 +208,9 @@ export default {
...
@@ -208,9 +208,9 @@ export default {
:page-info=
"pageInfo"
:page-info=
"pageInfo"
/>
/>
<modal
<modal
v-show=
"showModal"
v-if=
"showModal"
:primary-button-label=
"__('Leave')"
kind=
"warning"
kind=
"warning"
:primary-button-label=
"__('Leave')"
:title=
"__('Are you sure?')"
:title=
"__('Are you sure?')"
:text=
"groupLeaveConfirmationMessage"
:text=
"groupLeaveConfirmationMessage"
@
cancel=
"hideLeaveGroupModal"
@
cancel=
"hideLeaveGroupModal"
...
...
spec/javascripts/groups/components/app_spec.js
View file @
bdaaa43f
...
@@ -129,7 +129,7 @@ describe('AppComponent', () => {
...
@@ -129,7 +129,7 @@ describe('AppComponent', () => {
vm
.
fetchGroups
({});
vm
.
fetchGroups
({});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
isLoading
).
toBe
Falsy
(
);
expect
(
vm
.
isLoading
).
toBe
(
false
);
expect
(
$
.
scrollTo
).
toHaveBeenCalledWith
(
0
);
expect
(
$
.
scrollTo
).
toHaveBeenCalledWith
(
0
);
expect
(
window
.
Flash
).
toHaveBeenCalledWith
(
'
An error occurred. Please try again.
'
);
expect
(
window
.
Flash
).
toHaveBeenCalledWith
(
'
An error occurred. Please try again.
'
);
done
();
done
();
...
@@ -144,10 +144,10 @@ describe('AppComponent', () => {
...
@@ -144,10 +144,10 @@ describe('AppComponent', () => {
spyOn
(
vm
,
'
updateGroups
'
).
and
.
callThrough
();
spyOn
(
vm
,
'
updateGroups
'
).
and
.
callThrough
();
vm
.
fetchAllGroups
();
vm
.
fetchAllGroups
();
expect
(
vm
.
isLoading
).
toBe
Truthy
(
);
expect
(
vm
.
isLoading
).
toBe
(
true
);
expect
(
vm
.
fetchGroups
).
toHaveBeenCalled
();
expect
(
vm
.
fetchGroups
).
toHaveBeenCalled
();
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
isLoading
).
toBe
Falsy
(
);
expect
(
vm
.
isLoading
).
toBe
(
false
);
expect
(
vm
.
updateGroups
).
toHaveBeenCalled
();
expect
(
vm
.
updateGroups
).
toHaveBeenCalled
();
done
();
done
();
},
0
);
},
0
);
...
@@ -181,7 +181,7 @@ describe('AppComponent', () => {
...
@@ -181,7 +181,7 @@ describe('AppComponent', () => {
spyOn
(
$
,
'
scrollTo
'
);
spyOn
(
$
,
'
scrollTo
'
);
vm
.
fetchPage
(
2
,
null
,
null
,
true
);
vm
.
fetchPage
(
2
,
null
,
null
,
true
);
expect
(
vm
.
isLoading
).
toBe
Truthy
(
);
expect
(
vm
.
isLoading
).
toBe
(
true
);
expect
(
vm
.
fetchGroups
).
toHaveBeenCalledWith
({
expect
(
vm
.
fetchGroups
).
toHaveBeenCalledWith
({
page
:
2
,
page
:
2
,
filterGroupsBy
:
null
,
filterGroupsBy
:
null
,
...
@@ -190,7 +190,7 @@ describe('AppComponent', () => {
...
@@ -190,7 +190,7 @@ describe('AppComponent', () => {
archived
:
true
,
archived
:
true
,
});
});
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
isLoading
).
toBe
Falsy
(
);
expect
(
vm
.
isLoading
).
toBe
(
false
);
expect
(
$
.
scrollTo
).
toHaveBeenCalledWith
(
0
);
expect
(
$
.
scrollTo
).
toHaveBeenCalledWith
(
0
);
expect
(
utils
.
mergeUrlParams
).
toHaveBeenCalledWith
({
page
:
2
},
jasmine
.
any
(
String
));
expect
(
utils
.
mergeUrlParams
).
toHaveBeenCalledWith
({
page
:
2
},
jasmine
.
any
(
String
));
expect
(
window
.
history
.
replaceState
).
toHaveBeenCalledWith
({
expect
(
window
.
history
.
replaceState
).
toHaveBeenCalledWith
({
...
@@ -216,7 +216,7 @@ describe('AppComponent', () => {
...
@@ -216,7 +216,7 @@ describe('AppComponent', () => {
spyOn
(
vm
.
store
,
'
setGroupChildren
'
);
spyOn
(
vm
.
store
,
'
setGroupChildren
'
);
vm
.
toggleChildren
(
groupItem
);
vm
.
toggleChildren
(
groupItem
);
expect
(
groupItem
.
isChildrenLoading
).
toBe
Truthy
(
);
expect
(
groupItem
.
isChildrenLoading
).
toBe
(
true
);
expect
(
vm
.
fetchGroups
).
toHaveBeenCalledWith
({
expect
(
vm
.
fetchGroups
).
toHaveBeenCalledWith
({
parentId
:
groupItem
.
id
,
parentId
:
groupItem
.
id
,
});
});
...
@@ -232,7 +232,7 @@ describe('AppComponent', () => {
...
@@ -232,7 +232,7 @@ describe('AppComponent', () => {
vm
.
toggleChildren
(
groupItem
);
vm
.
toggleChildren
(
groupItem
);
expect
(
vm
.
fetchGroups
).
not
.
toHaveBeenCalled
();
expect
(
vm
.
fetchGroups
).
not
.
toHaveBeenCalled
();
expect
(
groupItem
.
isOpen
).
toBe
Truthy
(
);
expect
(
groupItem
.
isOpen
).
toBe
(
true
);
});
});
it
(
'
should collapse group if it is already expanded
'
,
()
=>
{
it
(
'
should collapse group if it is already expanded
'
,
()
=>
{
...
@@ -241,16 +241,16 @@ describe('AppComponent', () => {
...
@@ -241,16 +241,16 @@ describe('AppComponent', () => {
vm
.
toggleChildren
(
groupItem
);
vm
.
toggleChildren
(
groupItem
);
expect
(
vm
.
fetchGroups
).
not
.
toHaveBeenCalled
();
expect
(
vm
.
fetchGroups
).
not
.
toHaveBeenCalled
();
expect
(
groupItem
.
isOpen
).
toBe
Falsy
(
);
expect
(
groupItem
.
isOpen
).
toBe
(
false
);
});
});
it
(
'
should set `isChildrenLoading` back to `false` if load request fails
'
,
(
done
)
=>
{
it
(
'
should set `isChildrenLoading` back to `false` if load request fails
'
,
(
done
)
=>
{
spyOn
(
vm
,
'
fetchGroups
'
).
and
.
returnValue
(
returnServicePromise
({},
true
));
spyOn
(
vm
,
'
fetchGroups
'
).
and
.
returnValue
(
returnServicePromise
({},
true
));
vm
.
toggleChildren
(
groupItem
);
vm
.
toggleChildren
(
groupItem
);
expect
(
groupItem
.
isChildrenLoading
).
toBe
Truthy
(
);
expect
(
groupItem
.
isChildrenLoading
).
toBe
(
true
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
groupItem
.
isChildrenLoading
).
toBe
Falsy
(
);
expect
(
groupItem
.
isChildrenLoading
).
toBe
(
false
);
done
();
done
();
},
0
);
},
0
);
});
});
...
@@ -268,10 +268,10 @@ describe('AppComponent', () => {
...
@@ -268,10 +268,10 @@ describe('AppComponent', () => {
it
(
'
updates props which show modal confirmation dialog
'
,
()
=>
{
it
(
'
updates props which show modal confirmation dialog
'
,
()
=>
{
const
group
=
Object
.
assign
({},
mockParentGroupItem
);
const
group
=
Object
.
assign
({},
mockParentGroupItem
);
expect
(
vm
.
updateModal
).
toBeFalsy
(
);
expect
(
vm
.
showModal
).
toBe
(
false
);
expect
(
vm
.
groupLeaveConfirmationMessage
).
toBe
(
''
);
expect
(
vm
.
groupLeaveConfirmationMessage
).
toBe
(
''
);
vm
.
showLeaveGroupModal
(
group
,
mockParentGroupItem
);
vm
.
showLeaveGroupModal
(
group
,
mockParentGroupItem
);
expect
(
vm
.
updateModal
).
toBeTruthy
(
);
expect
(
vm
.
showModal
).
toBe
(
true
);
expect
(
vm
.
groupLeaveConfirmationMessage
).
toBe
(
`Are you sure you want to leave the "
${
group
.
fullName
}
" group?`
);
expect
(
vm
.
groupLeaveConfirmationMessage
).
toBe
(
`Are you sure you want to leave the "
${
group
.
fullName
}
" group?`
);
});
});
});
});
...
@@ -280,9 +280,9 @@ describe('AppComponent', () => {
...
@@ -280,9 +280,9 @@ describe('AppComponent', () => {
it
(
'
hides modal confirmation which is shown before leaving the group
'
,
()
=>
{
it
(
'
hides modal confirmation which is shown before leaving the group
'
,
()
=>
{
const
group
=
Object
.
assign
({},
mockParentGroupItem
);
const
group
=
Object
.
assign
({},
mockParentGroupItem
);
vm
.
showLeaveGroupModal
(
group
,
mockParentGroupItem
);
vm
.
showLeaveGroupModal
(
group
,
mockParentGroupItem
);
expect
(
vm
.
updateModal
).
toBeTruthy
(
);
expect
(
vm
.
showModal
).
toBe
(
true
);
vm
.
hideLeaveGroupModal
();
vm
.
hideLeaveGroupModal
();
expect
(
vm
.
updateModal
).
toBeFalsy
(
);
expect
(
vm
.
showModal
).
toBe
(
false
);
});
});
});
});
...
@@ -307,8 +307,8 @@ describe('AppComponent', () => {
...
@@ -307,8 +307,8 @@ describe('AppComponent', () => {
spyOn
(
$
,
'
scrollTo
'
);
spyOn
(
$
,
'
scrollTo
'
);
vm
.
leaveGroup
();
vm
.
leaveGroup
();
expect
(
vm
.
updateModal
).
toBeFalsy
(
);
expect
(
vm
.
showModal
).
toBe
(
false
);
expect
(
vm
.
targetGroup
.
isBeingRemoved
).
toBe
Truthy
(
);
expect
(
vm
.
targetGroup
.
isBeingRemoved
).
toBe
(
true
);
expect
(
vm
.
service
.
leaveGroup
).
toHaveBeenCalledWith
(
vm
.
targetGroup
.
leavePath
);
expect
(
vm
.
service
.
leaveGroup
).
toHaveBeenCalledWith
(
vm
.
targetGroup
.
leavePath
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
$
.
scrollTo
).
toHaveBeenCalledWith
(
0
);
expect
(
$
.
scrollTo
).
toHaveBeenCalledWith
(
0
);
...
@@ -325,12 +325,12 @@ describe('AppComponent', () => {
...
@@ -325,12 +325,12 @@ describe('AppComponent', () => {
spyOn
(
window
,
'
Flash
'
);
spyOn
(
window
,
'
Flash
'
);
vm
.
leaveGroup
();
vm
.
leaveGroup
();
expect
(
vm
.
targetGroup
.
isBeingRemoved
).
toBe
Truthy
(
);
expect
(
vm
.
targetGroup
.
isBeingRemoved
).
toBe
(
true
);
expect
(
vm
.
service
.
leaveGroup
).
toHaveBeenCalledWith
(
childGroupItem
.
leavePath
);
expect
(
vm
.
service
.
leaveGroup
).
toHaveBeenCalledWith
(
childGroupItem
.
leavePath
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
store
.
removeGroup
).
not
.
toHaveBeenCalled
();
expect
(
vm
.
store
.
removeGroup
).
not
.
toHaveBeenCalled
();
expect
(
window
.
Flash
).
toHaveBeenCalledWith
(
message
);
expect
(
window
.
Flash
).
toHaveBeenCalledWith
(
message
);
expect
(
vm
.
targetGroup
.
isBeingRemoved
).
toBe
Falsy
(
);
expect
(
vm
.
targetGroup
.
isBeingRemoved
).
toBe
(
false
);
done
();
done
();
},
0
);
},
0
);
});
});
...
@@ -342,12 +342,12 @@ describe('AppComponent', () => {
...
@@ -342,12 +342,12 @@ describe('AppComponent', () => {
spyOn
(
window
,
'
Flash
'
);
spyOn
(
window
,
'
Flash
'
);
vm
.
leaveGroup
(
childGroupItem
,
groupItem
);
vm
.
leaveGroup
(
childGroupItem
,
groupItem
);
expect
(
vm
.
targetGroup
.
isBeingRemoved
).
toBe
Truthy
(
);
expect
(
vm
.
targetGroup
.
isBeingRemoved
).
toBe
(
true
);
expect
(
vm
.
service
.
leaveGroup
).
toHaveBeenCalledWith
(
childGroupItem
.
leavePath
);
expect
(
vm
.
service
.
leaveGroup
).
toHaveBeenCalledWith
(
childGroupItem
.
leavePath
);
setTimeout
(()
=>
{
setTimeout
(()
=>
{
expect
(
vm
.
store
.
removeGroup
).
not
.
toHaveBeenCalled
();
expect
(
vm
.
store
.
removeGroup
).
not
.
toHaveBeenCalled
();
expect
(
window
.
Flash
).
toHaveBeenCalledWith
(
message
);
expect
(
window
.
Flash
).
toHaveBeenCalledWith
(
message
);
expect
(
vm
.
targetGroup
.
isBeingRemoved
).
toBe
Falsy
(
);
expect
(
vm
.
targetGroup
.
isBeingRemoved
).
toBe
(
false
);
done
();
done
();
},
0
);
},
0
);
});
});
...
@@ -379,10 +379,10 @@ describe('AppComponent', () => {
...
@@ -379,10 +379,10 @@ describe('AppComponent', () => {
it
(
'
should set `isSearchEmpty` prop based on groups count
'
,
()
=>
{
it
(
'
should set `isSearchEmpty` prop based on groups count
'
,
()
=>
{
vm
.
updateGroups
(
mockGroups
);
vm
.
updateGroups
(
mockGroups
);
expect
(
vm
.
isSearchEmpty
).
toBe
Falsy
(
);
expect
(
vm
.
isSearchEmpty
).
toBe
(
false
);
vm
.
updateGroups
([]);
vm
.
updateGroups
([]);
expect
(
vm
.
isSearchEmpty
).
toBe
Truthy
(
);
expect
(
vm
.
isSearchEmpty
).
toBe
(
true
);
});
});
});
});
});
});
...
@@ -473,13 +473,16 @@ describe('AppComponent', () => {
...
@@ -473,13 +473,16 @@ describe('AppComponent', () => {
});
});
});
});
it
(
'
renders modal confirmation dialog
'
,
()
=>
{
it
(
'
renders modal confirmation dialog
'
,
(
done
)
=>
{
vm
.
groupLeaveConfirmationMessage
=
'
Are you sure you want to leave the "foo" group?
'
;
vm
.
groupLeaveConfirmationMessage
=
'
Are you sure you want to leave the "foo" group?
'
;
vm
.
updateModal
=
true
;
vm
.
showModal
=
true
;
const
modalDialogEl
=
vm
.
$el
.
querySelector
(
'
.modal
'
);
Vue
.
nextTick
(()
=>
{
expect
(
modalDialogEl
).
not
.
toBe
(
null
);
const
modalDialogEl
=
vm
.
$el
.
querySelector
(
'
.modal
'
);
expect
(
modalDialogEl
.
querySelector
(
'
.modal-title
'
).
innerText
.
trim
()).
toBe
(
'
Are you sure?
'
);
expect
(
modalDialogEl
).
not
.
toBe
(
null
);
expect
(
modalDialogEl
.
querySelector
(
'
.btn.btn-warning
'
).
innerText
.
trim
()).
toBe
(
'
Leave
'
);
expect
(
modalDialogEl
.
querySelector
(
'
.modal-title
'
).
innerText
.
trim
()).
toBe
(
'
Are you sure?
'
);
expect
(
modalDialogEl
.
querySelector
(
'
.btn.btn-warning
'
).
innerText
.
trim
()).
toBe
(
'
Leave
'
);
done
();
});
});
});
});
});
});
});
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