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
059a6af4
Commit
059a6af4
authored
Mar 08, 2020
by
Ezekiel Kigbo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added specs for the url_sync component
Checks that the correct url parameters are set when data is updated
parent
422219de
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
10 deletions
+92
-10
ee/app/assets/javascripts/analytics/cycle_analytics/components/url_sync.vue
...scripts/analytics/cycle_analytics/components/url_sync.vue
+1
-1
ee/spec/frontend/analytics/cycle_analytics/components/base_spec.js
...rontend/analytics/cycle_analytics/components/base_spec.js
+91
-1
ee/spec/frontend/analytics/cycle_analytics/store/actions_spec.js
.../frontend/analytics/cycle_analytics/store/actions_spec.js
+0
-8
No files found.
ee/app/assets/javascripts/analytics/cycle_analytics/components/url_sync.vue
View file @
059a6af4
...
...
@@ -23,7 +23,7 @@ export default {
},
},
render
()
{
return
this
.
$slots
.
default
;
return
null
;
},
};
</
script
>
ee/spec/frontend/analytics/cycle_analytics/components/base_spec.js
View file @
059a6af4
...
...
@@ -17,6 +17,9 @@ import Daterange from 'ee/analytics/shared/components/daterange.vue';
import
TasksByTypeChart
from
'
ee/analytics/cycle_analytics/components/tasks_by_type_chart.vue
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
httpStatusCodes
from
'
~/lib/utils/http_status
'
;
import
*
as
commonUtils
from
'
~/lib/utils/common_utils
'
;
import
*
as
urlUtils
from
'
~/lib/utils/url_utility
'
;
import
{
toYmd
}
from
'
ee/analytics/shared/utils
'
;
import
*
as
mockData
from
'
../mock_data
'
;
const
noDataSvgPath
=
'
path/to/no/data
'
;
...
...
@@ -35,7 +38,9 @@ const defaultStubs = {
};
function
createComponent
({
opts
=
{},
opts
=
{
stubs
:
defaultStubs
,
},
shallow
=
true
,
withStageSelected
=
false
,
scatterplotEnabled
=
true
,
...
...
@@ -95,6 +100,13 @@ describe('Cycle Analytics component', () => {
.
findAll
(
'
.stage-nav-item
'
)
.
at
(
index
);
const
shouldSetUrlParams
=
result
=>
{
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
expect
(
urlUtils
.
setUrlParams
).
toHaveBeenCalledWith
(
result
,
window
.
location
.
href
,
true
);
expect
(
commonUtils
.
historyPushState
).
toHaveBeenCalled
();
});
};
const
displaysProjectsDropdownFilter
=
flag
=>
{
expect
(
wrapper
.
find
(
ProjectsDropdownFilter
).
exists
()).
toBe
(
flag
);
};
...
...
@@ -600,4 +612,82 @@ describe('Cycle Analytics component', () => {
});
});
});
describe
(
'
Url Sync
'
,
()
=>
{
beforeEach
(()
=>
{
commonUtils
.
historyPushState
=
jest
.
fn
();
urlUtils
.
setUrlParams
=
jest
.
fn
();
mock
=
new
MockAdapter
(
axios
);
wrapper
=
createComponent
({
shallow
:
false
,
stubs
:
{
...
defaultStubs
,
},
});
wrapper
.
vm
.
$store
.
dispatch
(
'
initializeCycleAnalytics
'
,
{
createdAfter
:
mockData
.
startDate
,
createdBefore
:
mockData
.
endDate
,
});
});
afterEach
(()
=>
{
commonUtils
.
historyPushState
=
null
;
urlUtils
.
setUrlParams
=
null
;
wrapper
.
destroy
();
mock
.
restore
();
});
it
(
'
sets the created_after and created_before url parameters
'
,
()
=>
{
shouldSetUrlParams
({
created_after
:
toYmd
(
mockData
.
startDate
),
created_before
:
toYmd
(
mockData
.
endDate
),
group_id
:
null
,
'
project_ids[]
'
:
[],
});
});
describe
(
'
with a group selected
'
,
()
=>
{
beforeEach
(()
=>
{
wrapper
.
vm
.
$store
.
dispatch
(
'
setSelectedGroup
'
,
{
...
mockData
.
group
,
});
return
wrapper
.
vm
.
$nextTick
();
});
it
(
'
sets the group_id url parameter
'
,
()
=>
{
shouldSetUrlParams
({
created_after
:
toYmd
(
mockData
.
startDate
),
created_before
:
toYmd
(
mockData
.
endDate
),
group_id
:
mockData
.
group
.
full_path
,
'
project_ids[]
'
:
[],
});
});
});
describe
(
'
with a group and selectedProjectIds set
'
,
()
=>
{
const
selectedProjectIds
=
mockData
.
selectedProjects
.
map
(({
id
})
=>
id
);
beforeEach
(()
=>
{
wrapper
.
vm
.
$store
.
dispatch
(
'
setSelectedGroup
'
,
{
...
mockData
.
group
,
});
wrapper
.
vm
.
$store
.
dispatch
(
'
setSelectedProjects
'
,
mockData
.
selectedProjects
);
return
wrapper
.
vm
.
$nextTick
();
});
it
(
'
sets the project_ids url parameter
'
,
()
=>
{
shouldSetUrlParams
({
created_after
:
toYmd
(
mockData
.
startDate
),
created_before
:
toYmd
(
mockData
.
endDate
),
group_id
:
mockData
.
group
.
full_path
,
'
project_ids[]
'
:
selectedProjectIds
,
});
});
});
});
});
ee/spec/frontend/analytics/cycle_analytics/store/actions_spec.js
View file @
059a6af4
import
*
as
commonUtils
from
'
~/lib/utils/common_utils
'
;
import
*
as
urlUtils
from
'
~/lib/utils/url_utility
'
;
import
axios
from
'
axios
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
testAction
from
'
helpers/vuex_action_helper
'
;
...
...
@@ -12,7 +10,6 @@ import {
}
from
'
ee/analytics/cycle_analytics/constants
'
;
import
createFlash
from
'
~/flash
'
;
import
httpStatusCodes
from
'
~/lib/utils/http_status
'
;
import
{
toYmd
}
from
'
ee/analytics/shared/utils
'
;
import
{
group
,
summaryData
,
...
...
@@ -47,9 +44,6 @@ describe('Cycle analytics actions', () => {
}
beforeEach
(()
=>
{
commonUtils
.
historyPushState
=
jest
.
fn
();
urlUtils
.
setUrlParams
=
jest
.
fn
();
state
=
{
startDate
,
endDate
,
...
...
@@ -1526,8 +1520,6 @@ describe('Cycle analytics actions', () => {
};
beforeEach
(()
=>
{
commonUtils
.
historyPushState
=
jest
.
fn
();
urlUtils
.
setUrlParams
=
jest
.
fn
();
mockDispatch
=
jest
.
fn
(()
=>
Promise
.
resolve
());
mockCommit
=
jest
.
fn
();
store
=
{
...
...
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