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
7f7de4eb
Commit
7f7de4eb
authored
Mar 16, 2020
by
Vitaly Slobodin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate ee/group_member_contributions to Jest
Closes
https://gitlab.com/gitlab-org/gitlab/-/issues/194287
parent
d0ce09be
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
31 deletions
+32
-31
ee/app/assets/javascripts/group_member_contributions/components/app.vue
...javascripts/group_member_contributions/components/app.vue
+1
-1
ee/spec/frontend/group_member_contributions/components/app_spec.js
...rontend/group_member_contributions/components/app_spec.js
+17
-21
ee/spec/frontend/group_member_contributions/components/table_body_spec.js
.../group_member_contributions/components/table_body_spec.js
+1
-1
ee/spec/frontend/group_member_contributions/components/table_header_spec.js
...roup_member_contributions/components/table_header_spec.js
+3
-3
ee/spec/frontend/group_member_contributions/mock_data.js
ee/spec/frontend/group_member_contributions/mock_data.js
+0
-0
ee/spec/frontend/group_member_contributions/store/group_member_store_spec.js
...oup_member_contributions/store/group_member_store_spec.js
+10
-5
No files found.
ee/app/assets/javascripts/group_member_contributions/components/app.vue
View file @
7f7de4eb
...
@@ -43,7 +43,7 @@ export default {
...
@@ -43,7 +43,7 @@ export default {
<gl-loading-icon
<gl-loading-icon
v-if=
"isLoading"
v-if=
"isLoading"
:label=
"__('Loading contribution stats for group members')"
:label=
"__('Loading contribution stats for group members')"
:size=
"2
"
size=
"md
"
class=
"loading-animation prepend-top-20 append-bottom-20"
class=
"loading-animation prepend-top-20 append-bottom-20"
/>
/>
<table
v-else
class=
"table gl-sortable"
>
<table
v-else
class=
"table gl-sortable"
>
...
...
ee/spec/
javascripts
/group_member_contributions/components/app_spec.js
→
ee/spec/
frontend
/group_member_contributions/components/app_spec.js
View file @
7f7de4eb
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
mountComponent
from
'
spec/
helpers/vue_mount_component_helper
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
AppComponent
from
'
ee/group_member_contributions/components/app.vue
'
;
import
AppComponent
from
'
ee/group_member_contributions/components/app.vue
'
;
import
GroupMemberStore
from
'
ee/group_member_contributions/store/group_member_store
'
;
import
GroupMemberStore
from
'
ee/group_member_contributions/store/group_member_store
'
;
...
@@ -30,7 +30,7 @@ describe('AppComponent', () => {
...
@@ -30,7 +30,7 @@ describe('AppComponent', () => {
describe
(
'
methods
'
,
()
=>
{
describe
(
'
methods
'
,
()
=>
{
describe
(
'
handleColumnClick
'
,
()
=>
{
describe
(
'
handleColumnClick
'
,
()
=>
{
it
(
'
calls store.sortMembers with columnName param
'
,
()
=>
{
it
(
'
calls store.sortMembers with columnName param
'
,
()
=>
{
spyOn
(
vm
.
store
,
'
sortMembers
'
);
jest
.
spyOn
(
vm
.
store
,
'
sortMembers
'
).
mockImplementation
(()
=>
{}
);
const
columnName
=
'
fullname
'
;
const
columnName
=
'
fullname
'
;
vm
.
handleColumnClick
(
columnName
);
vm
.
handleColumnClick
(
columnName
);
...
@@ -49,29 +49,25 @@ describe('AppComponent', () => {
...
@@ -49,29 +49,25 @@ describe('AppComponent', () => {
expect
(
vm
.
$el
.
querySelector
(
'
h3
'
).
innerText
.
trim
()).
toBe
(
'
Contributions per group member
'
);
expect
(
vm
.
$el
.
querySelector
(
'
h3
'
).
innerText
.
trim
()).
toBe
(
'
Contributions per group member
'
);
});
});
it
(
'
shows loading icon when isLoading prop is true
'
,
done
=>
{
it
(
'
shows loading icon when isLoading prop is true
'
,
()
=>
{
vm
.
store
.
state
.
isLoading
=
true
;
vm
.
store
.
state
.
isLoading
=
true
;
vm
.
$nextTick
()
.
then
(()
=>
{
return
vm
.
$nextTick
().
then
(()
=>
{
const
loadingEl
=
vm
.
$el
.
querySelector
(
'
.loading-animation
'
);
const
loadingEl
=
vm
.
$el
.
querySelector
(
'
.loading-animation
'
);
expect
(
loadingEl
).
not
.
toBeNull
();
expect
(
loadingEl
).
not
.
toBeNull
();
expect
(
loadingEl
.
querySelector
(
'
span
'
).
getAttribute
(
'
aria-label
'
)).
toBe
(
expect
(
loadingEl
.
querySelector
(
'
span
'
).
getAttribute
(
'
aria-label
'
)).
toBe
(
'
Loading contribution stats for group members
'
,
'
Loading contribution stats for group members
'
,
);
);
})
});
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
it
(
'
renders table container element
'
,
done
=>
{
it
(
'
renders table container element
'
,
()
=>
{
vm
.
store
.
state
.
isLoading
=
false
;
vm
.
store
.
state
.
isLoading
=
false
;
vm
.
$nextTick
()
.
then
(()
=>
{
return
vm
.
$nextTick
().
then
(()
=>
{
expect
(
vm
.
$el
.
querySelector
(
'
table.table.gl-sortable
'
)).
not
.
toBeNull
();
expect
(
vm
.
$el
.
querySelector
(
'
table.table.gl-sortable
'
)).
not
.
toBeNull
();
})
});
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
});
});
});
});
ee/spec/
javascripts
/group_member_contributions/components/table_body_spec.js
→
ee/spec/
frontend
/group_member_contributions/components/table_body_spec.js
View file @
7f7de4eb
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
mountComponent
from
'
spec/
helpers/vue_mount_component_helper
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
TableBodyComponent
from
'
ee/group_member_contributions/components/table_body.vue
'
;
import
TableBodyComponent
from
'
ee/group_member_contributions/components/table_body.vue
'
;
import
GroupMemberStore
from
'
ee/group_member_contributions/store/group_member_store
'
;
import
GroupMemberStore
from
'
ee/group_member_contributions/store/group_member_store
'
;
...
...
ee/spec/
javascripts
/group_member_contributions/components/table_header_spec.js
→
ee/spec/
frontend
/group_member_contributions/components/table_header_spec.js
View file @
7f7de4eb
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
mountComponent
from
'
spec/
helpers/vue_mount_component_helper
'
;
import
mountComponent
from
'
helpers/vue_mount_component_helper
'
;
import
TableHeaderComponent
from
'
ee/group_member_contributions/components/table_header.vue
'
;
import
TableHeaderComponent
from
'
ee/group_member_contributions/components/table_header.vue
'
;
import
defaultColumns
from
'
ee/group_member_contributions/constants
'
;
import
defaultColumns
from
'
ee/group_member_contributions/constants
'
;
...
@@ -66,14 +66,14 @@ describe('TableHeaderComponent', () => {
...
@@ -66,14 +66,14 @@ describe('TableHeaderComponent', () => {
describe
(
'
onColumnClick
'
,
()
=>
{
describe
(
'
onColumnClick
'
,
()
=>
{
it
(
'
emits `onColumnClick` event with columnName param on component instance
'
,
()
=>
{
it
(
'
emits `onColumnClick` event with columnName param on component instance
'
,
()
=>
{
spyOn
(
vm
,
'
$emit
'
);
jest
.
spyOn
(
vm
,
'
$emit
'
).
mockImplementation
(()
=>
{}
);
vm
.
onColumnClick
(
columnName
);
vm
.
onColumnClick
(
columnName
);
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
onColumnClick
'
,
columnName
);
expect
(
vm
.
$emit
).
toHaveBeenCalledWith
(
'
onColumnClick
'
,
columnName
);
});
});
it
(
'
updates columnIconMeta prop for provided columnName
'
,
()
=>
{
it
(
'
updates columnIconMeta prop for provided columnName
'
,
()
=>
{
spyOn
(
vm
,
'
getColumnIconMeta
'
);
jest
.
spyOn
(
vm
,
'
getColumnIconMeta
'
);
vm
.
onColumnClick
(
columnName
);
vm
.
onColumnClick
(
columnName
);
expect
(
vm
.
getColumnIconMeta
).
toHaveBeenCalledWith
(
columnName
,
vm
.
sortOrders
);
expect
(
vm
.
getColumnIconMeta
).
toHaveBeenCalledWith
(
columnName
,
vm
.
sortOrders
);
...
...
ee/spec/
javascripts
/group_member_contributions/mock_data.js
→
ee/spec/
frontend
/group_member_contributions/mock_data.js
View file @
7f7de4eb
File moved
ee/spec/
javascripts
/group_member_contributions/store/group_member_store_spec.js
→
ee/spec/
frontend
/group_member_contributions/store/group_member_store_spec.js
View file @
7f7de4eb
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
createFlash
from
'
~/flash
'
;
import
GroupMemberStore
from
'
ee/group_member_contributions/store/group_member_store
'
;
import
GroupMemberStore
from
'
ee/group_member_contributions/store/group_member_store
'
;
import
defaultColumns
from
'
ee/group_member_contributions/constants
'
;
import
defaultColumns
from
'
ee/group_member_contributions/constants
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
axios
from
'
~/lib/utils/axios_utils
'
;
import
{
rawMembers
,
contributionsPath
}
from
'
../mock_data
'
;
import
{
rawMembers
,
contributionsPath
}
from
'
../mock_data
'
;
jest
.
mock
(
'
~/flash
'
);
describe
(
'
GroupMemberStore
'
,
()
=>
{
describe
(
'
GroupMemberStore
'
,
()
=>
{
let
store
;
let
store
;
...
@@ -13,6 +15,10 @@ describe('GroupMemberStore', () => {
...
@@ -13,6 +15,10 @@ describe('GroupMemberStore', () => {
store
=
new
GroupMemberStore
(
contributionsPath
);
store
=
new
GroupMemberStore
(
contributionsPath
);
});
});
afterEach
(()
=>
{
createFlash
.
mockClear
();
});
describe
(
'
setColumns
'
,
()
=>
{
describe
(
'
setColumns
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
store
.
setColumns
(
defaultColumns
);
store
.
setColumns
(
defaultColumns
);
...
@@ -58,7 +64,6 @@ describe('GroupMemberStore', () => {
...
@@ -58,7 +64,6 @@ describe('GroupMemberStore', () => {
beforeEach
(()
=>
{
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
mock
=
new
MockAdapter
(
axios
);
setFixtures
(
'
<div class="flash-container"></div>
'
);
});
});
afterEach
(()
=>
{
afterEach
(()
=>
{
...
@@ -67,8 +72,8 @@ describe('GroupMemberStore', () => {
...
@@ -67,8 +72,8 @@ describe('GroupMemberStore', () => {
it
(
'
calls service.getContributedMembers and sets response to the store on success
'
,
done
=>
{
it
(
'
calls service.getContributedMembers and sets response to the store on success
'
,
done
=>
{
mock
.
onGet
(
contributionsPath
).
reply
(
200
,
rawMembers
);
mock
.
onGet
(
contributionsPath
).
reply
(
200
,
rawMembers
);
spyOn
(
store
,
'
setColumns
'
);
jest
.
spyOn
(
store
,
'
setColumns
'
).
mockImplementation
(()
=>
{}
);
spyOn
(
store
,
'
setMembers
'
);
jest
.
spyOn
(
store
,
'
setMembers
'
).
mockImplementation
(()
=>
{}
);
store
store
.
fetchContributedMembers
()
.
fetchContributedMembers
()
...
@@ -92,7 +97,7 @@ describe('GroupMemberStore', () => {
...
@@ -92,7 +97,7 @@ describe('GroupMemberStore', () => {
.
catch
(
e
=>
{
.
catch
(
e
=>
{
expect
(
e
.
message
).
toBe
(
'
Request failed with status code 500
'
);
expect
(
e
.
message
).
toBe
(
'
Request failed with status code 500
'
);
expect
(
store
.
isLoading
).
toBe
(
false
);
expect
(
store
.
isLoading
).
toBe
(
false
);
expect
(
document
.
querySelector
(
'
.flash-text
'
).
innerText
.
trim
()).
toBe
(
expect
(
createFlash
).
toHaveBeenCalledWith
(
'
Something went wrong while fetching group member contributions
'
,
'
Something went wrong while fetching group member contributions
'
,
);
);
})
})
...
...
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