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
5d4dfc46
Commit
5d4dfc46
authored
Jul 23, 2018
by
Winnie Hellmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix timing in AssigneesListComponent tests
parent
dac7b72e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
44 deletions
+53
-44
ee/app/assets/javascripts/boards/components/assignees_list/index.js
...ets/javascripts/boards/components/assignees_list/index.js
+13
-13
ee/spec/javascripts/boards/components/assignees_list/assignees_list_spec.js
...s/boards/components/assignees_list/assignees_list_spec.js
+40
-31
No files found.
ee/app/assets/javascripts/boards/components/assignees_list/index.js
View file @
5d4dfc46
...
...
@@ -27,20 +27,20 @@ export default Vue.extend({
},
methods
:
{
loadAssignees
()
{
if
(
!
this
.
store
.
state
.
assignees
.
length
)
{
axios
.
get
(
this
.
listAssigneesPath
)
.
then
(({
data
})
=>
{
this
.
loading
=
false
;
this
.
store
.
state
.
assignees
=
data
;
})
.
catch
(()
=>
{
this
.
loading
=
false
;
Flash
(
__
(
'
Something went wrong while fetching assignees list
'
),
);
});
if
(
this
.
store
.
state
.
assignees
.
length
)
{
return
Promise
.
resolve
();
}
return
axios
.
get
(
this
.
listAssigneesPath
)
.
then
(({
data
})
=>
{
this
.
loading
=
false
;
this
.
store
.
state
.
assignees
=
data
;
})
.
catch
(()
=>
{
this
.
loading
=
false
;
Flash
(
__
(
'
Something went wrong while fetching assignees list
'
));
});
},
handleItemClick
(
assignee
)
{
if
(
!
this
.
store
.
findList
(
'
title
'
,
assignee
.
name
))
{
...
...
ee/spec/javascripts/boards/components/assignees_list/assignees_list_spec.js
View file @
5d4dfc46
...
...
@@ -7,33 +7,30 @@ import AssigneesListComponent from 'ee/boards/components/assignees_list/';
import
mountComponent
from
'
spec/helpers/vue_mount_component_helper
'
;
import
{
mockAssigneesList
}
from
'
spec/boards/mock_data
'
;
const
createComponent
=
()
=>
mountComponent
(
AssigneesListComponent
,
{
listAssigneesPath
:
`
${
gl
.
TEST_HOST
}
/users.json`
,
});
import
{
TEST_HOST
}
from
'
spec/test_constants
'
;
describe
(
'
AssigneesListComponent
'
,
()
=>
{
const
dummyEndpoint
=
`
${
TEST_HOST
}
/users.json`
;
const
createComponent
=
()
=>
mountComponent
(
AssigneesListComponent
,
{
listAssigneesPath
:
dummyEndpoint
,
});
let
vm
;
let
mock
;
let
statusCode
;
let
response
;
gl
.
issueBoards
.
BoardsStore
.
create
();
gl
.
issueBoards
.
BoardsStore
.
state
.
assignees
=
[];
beforeEach
(()
=>
{
statusCode
=
200
;
response
=
mockAssigneesList
;
mock
=
new
MockAdapter
(
axios
);
document
.
body
.
innerHTML
+=
'
<div class="flash-container"></div>
'
;
mock
.
onGet
(
`
${
gl
.
TEST_HOST
}
/users.json`
).
reply
(()
=>
[
statusCode
,
response
]);
setFixtures
(
'
<div class="flash-container"></div>
'
);
vm
=
createComponent
();
});
afterEach
(()
=>
{
document
.
querySelector
(
'
.flash-container
'
).
remove
();
vm
.
$destroy
();
mock
.
restore
();
});
...
...
@@ -47,35 +44,47 @@ describe('AssigneesListComponent', () => {
describe
(
'
methods
'
,
()
=>
{
describe
(
'
loadAssignees
'
,
()
=>
{
it
(
'
calls axios.get and sets response to store.state.assignees
'
,
(
done
)
=>
{
mock
.
onGet
(
`
${
gl
.
TEST_HOST
}
/users.json`
).
reply
(
200
,
mockAssigneesList
);
it
(
'
calls axios.get and sets response to store.state.assignees
'
,
done
=>
{
mock
.
onGet
(
dummyEndpoint
).
reply
(
200
,
mockAssigneesList
);
gl
.
issueBoards
.
BoardsStore
.
state
.
assignees
=
[];
vm
.
loadAssignees
();
setTimeout
(()
=>
{
expect
(
vm
.
loading
).
toBe
(
false
);
expect
(
vm
.
store
.
state
.
assignees
.
length
).
toBe
(
mockAssigneesList
.
length
);
done
();
},
0
);
vm
.
loadAssignees
()
.
then
(()
=>
{
expect
(
vm
.
loading
).
toBe
(
false
);
expect
(
vm
.
store
.
state
.
assignees
.
length
).
toBe
(
mockAssigneesList
.
length
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
does not call axios.get when store.state.assignees is not empty
'
,
()
=>
{
it
(
'
does not call axios.get when store.state.assignees is not empty
'
,
done
=>
{
spyOn
(
axios
,
'
get
'
);
gl
.
issueBoards
.
BoardsStore
.
state
.
assignees
=
mockAssigneesList
;
vm
.
loadAssignees
();
expect
(
axios
.
get
).
not
.
toHaveBeenCalled
();
vm
.
loadAssignees
()
.
then
(()
=>
{
expect
(
axios
.
get
).
not
.
toHaveBeenCalled
();
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
it
(
'
calls axios.get and shows Flash error when request fails
'
,
(
done
)
=>
{
mock
.
onGet
(
`
${
gl
.
TEST_HOST
}
/users.json`
).
reply
(
500
,
{});
it
(
'
calls axios.get and shows Flash error when request fails
'
,
done
=>
{
mock
.
onGet
(
dummyEndpoint
).
replyOnce
(
500
,
{});
gl
.
issueBoards
.
BoardsStore
.
state
.
assignees
=
[];
vm
.
loadAssignees
();
setTimeout
(()
=>
{
expect
(
vm
.
loading
).
toBe
(
false
);
expect
(
document
.
querySelector
(
'
.flash-text
'
).
innerText
.
trim
()).
toBe
(
'
Something went wrong while fetching assignees list
'
);
done
();
},
0
);
vm
.
loadAssignees
()
.
then
(()
=>
{
expect
(
vm
.
loading
).
toBe
(
false
);
expect
(
document
.
querySelector
(
'
.flash-text
'
).
innerText
.
trim
()).
toBe
(
'
Something went wrong while fetching assignees list
'
,
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
...
...
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