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
8ea42202
Commit
8ea42202
authored
Oct 01, 2020
by
jakeburden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use releases_sort component and fetch sorted releases
Add releases_sort component Fetch over REST and GraphQL
parent
6ad5ae3e
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
264 additions
and
17 deletions
+264
-17
app/assets/javascripts/releases/components/app_index.vue
app/assets/javascripts/releases/components/app_index.vue
+16
-10
app/assets/javascripts/releases/components/releases_sort.vue
app/assets/javascripts/releases/components/releases_sort.vue
+62
-0
app/assets/javascripts/releases/constants.js
app/assets/javascripts/releases/constants.js
+16
-0
app/assets/javascripts/releases/queries/all_releases.query.graphql
...s/javascripts/releases/queries/all_releases.query.graphql
+9
-2
app/assets/javascripts/releases/queries/release.fragment.graphql
...ets/javascripts/releases/queries/release.fragment.graphql
+1
-0
app/assets/javascripts/releases/stores/modules/list/actions.js
...ssets/javascripts/releases/stores/modules/list/actions.js
+10
-1
app/assets/javascripts/releases/stores/modules/list/mutation_types.js
...avascripts/releases/stores/modules/list/mutation_types.js
+1
-0
app/assets/javascripts/releases/stores/modules/list/mutations.js
...ets/javascripts/releases/stores/modules/list/mutations.js
+4
-0
app/assets/javascripts/releases/stores/modules/list/state.js
app/assets/javascripts/releases/stores/modules/list/state.js
+4
-0
changelogs/unreleased/221101-implement-gitlab-ui-component-for-sorting-releases.yml
...01-implement-gitlab-ui-component-for-sorting-releases.yml
+5
-0
locale/gitlab.pot
locale/gitlab.pot
+3
-0
spec/frontend/releases/components/releases_sort_spec.js
spec/frontend/releases/components/releases_sort_spec.js
+72
-0
spec/frontend/releases/stores/modules/list/actions_spec.js
spec/frontend/releases/stores/modules/list/actions_spec.js
+49
-4
spec/frontend/releases/stores/modules/list/mutations_spec.js
spec/frontend/releases/stores/modules/list/mutations_spec.js
+12
-0
No files found.
app/assets/javascripts/releases/components/app_index.vue
View file @
8ea42202
...
@@ -6,6 +6,7 @@ import { __ } from '~/locale';
...
@@ -6,6 +6,7 @@ import { __ } from '~/locale';
import
ReleaseBlock
from
'
./release_block.vue
'
;
import
ReleaseBlock
from
'
./release_block.vue
'
;
import
ReleasesPagination
from
'
./releases_pagination.vue
'
;
import
ReleasesPagination
from
'
./releases_pagination.vue
'
;
import
ReleaseSkeletonLoader
from
'
./release_skeleton_loader.vue
'
;
import
ReleaseSkeletonLoader
from
'
./release_skeleton_loader.vue
'
;
import
ReleasesSort
from
'
./releases_sort.vue
'
;
export
default
{
export
default
{
name
:
'
ReleasesApp
'
,
name
:
'
ReleasesApp
'
,
...
@@ -16,6 +17,7 @@ export default {
...
@@ -16,6 +17,7 @@ export default {
ReleaseBlock
,
ReleaseBlock
,
ReleasesPagination
,
ReleasesPagination
,
ReleaseSkeletonLoader
,
ReleaseSkeletonLoader
,
ReleasesSort
,
},
},
computed
:
{
computed
:
{
...
mapState
(
'
list
'
,
[
...
mapState
(
'
list
'
,
[
...
@@ -62,16 +64,20 @@ export default {
...
@@ -62,16 +64,20 @@ export default {
</
script
>
</
script
>
<
template
>
<
template
>
<div
class=
"flex flex-column mt-2"
>
<div
class=
"flex flex-column mt-2"
>
<div
class=
"align-self-end mb-2"
>
<releases-sort
class=
"gl-mr-2"
@
sort:changed=
"fetchReleases"
/>
<gl-button
<gl-button
v-if=
"newReleasePath"
v-if=
"newReleasePath"
:href=
"newReleasePath"
:href=
"newReleasePath"
:aria-describedby=
"shouldRenderEmptyState && 'releases-description'"
:aria-describedby=
"shouldRenderEmptyState && 'releases-description'"
category=
"primary"
category=
"primary"
variant=
"success"
variant=
"success"
class=
"align-self-end mb-2
js-new-release-btn"
class=
"
js-new-release-btn"
>
>
{{
__
(
'
New release
'
)
}}
{{
__
(
'
New release
'
)
}}
</gl-button>
</gl-button>
</div>
<release-skeleton-loader
v-if=
"isLoading"
class=
"js-loading"
/>
<release-skeleton-loader
v-if=
"isLoading"
class=
"js-loading"
/>
...
...
app/assets/javascripts/releases/components/releases_sort.vue
0 → 100644
View file @
8ea42202
<
script
>
import
{
GlSorting
,
GlSortingItem
}
from
'
@gitlab/ui
'
;
import
{
mapState
,
mapActions
}
from
'
vuex
'
;
import
{
ASCENDING_ODER
,
DESCENDING_ORDER
,
SORT_OPTIONS
}
from
'
../constants
'
;
export
default
{
name
:
'
ReleasesSort
'
,
components
:
{
GlSorting
,
GlSortingItem
,
},
computed
:
{
...
mapState
(
'
list
'
,
{
orderBy
:
state
=>
state
.
sorting
.
orderBy
,
sort
:
state
=>
state
.
sorting
.
sort
,
}),
sortOptions
()
{
return
SORT_OPTIONS
;
},
sortText
()
{
const
option
=
this
.
sortOptions
.
find
(
s
=>
s
.
orderBy
===
this
.
orderBy
);
return
option
.
label
;
},
isSortAscending
()
{
return
this
.
sort
===
ASCENDING_ODER
;
},
},
methods
:
{
...
mapActions
(
'
list
'
,
[
'
setSorting
'
]),
onDirectionChange
()
{
const
sort
=
this
.
isSortAscending
?
DESCENDING_ORDER
:
ASCENDING_ODER
;
this
.
setSorting
({
sort
});
this
.
$emit
(
'
sort:changed
'
);
},
onSortItemClick
(
item
)
{
this
.
setSorting
({
orderBy
:
item
});
this
.
$emit
(
'
sort:changed
'
);
},
isActiveSortItem
(
item
)
{
const
[
itemOrderBy
]
=
item
.
split
(
'
'
);
return
this
.
orderBy
===
itemOrderBy
;
},
},
};
</
script
>
<
template
>
<gl-sorting
:text=
"sortText"
:is-ascending=
"isSortAscending"
@
sortDirectionChange=
"onDirectionChange"
>
<gl-sorting-item
v-for=
"item in sortOptions"
:key=
"item.orderBy"
:active=
"isActiveSortItem(item.orderBy)"
@
click=
"onSortItemClick(item.orderBy)"
>
{{
item
.
label
}}
</gl-sorting-item>
</gl-sorting>
</
template
>
app/assets/javascripts/releases/constants.js
View file @
8ea42202
import
{
__
}
from
'
~/locale
'
;
export
const
MAX_MILESTONES_TO_DISPLAY
=
5
;
export
const
MAX_MILESTONES_TO_DISPLAY
=
5
;
export
const
BACK_URL_PARAM
=
'
back_url
'
;
export
const
BACK_URL_PARAM
=
'
back_url
'
;
...
@@ -12,3 +14,17 @@ export const ASSET_LINK_TYPE = Object.freeze({
...
@@ -12,3 +14,17 @@ export const ASSET_LINK_TYPE = Object.freeze({
export
const
DEFAULT_ASSET_LINK_TYPE
=
ASSET_LINK_TYPE
.
OTHER
;
export
const
DEFAULT_ASSET_LINK_TYPE
=
ASSET_LINK_TYPE
.
OTHER
;
export
const
PAGE_SIZE
=
20
;
export
const
PAGE_SIZE
=
20
;
export
const
ASCENDING_ODER
=
'
asc
'
;
export
const
DESCENDING_ORDER
=
'
desc
'
;
export
const
SORT_OPTIONS
=
[
{
orderBy
:
'
released_at
'
,
label
:
__
(
'
Released date
'
),
},
{
orderBy
:
'
created_at
'
,
label
:
__
(
'
Created date
'
),
},
];
app/assets/javascripts/releases/queries/all_releases.query.graphql
View file @
8ea42202
#import "./release.fragment.graphql"
#import "./release.fragment.graphql"
query
allReleases
(
$fullPath
:
ID
!,
$first
:
Int
,
$last
:
Int
,
$before
:
String
,
$after
:
String
)
{
query
allReleases
(
$fullPath
:
ID
!
$first
:
Int
$last
:
Int
$before
:
String
$after
:
String
$sort
:
ReleaseSort
)
{
project
(
fullPath
:
$fullPath
)
{
project
(
fullPath
:
$fullPath
)
{
releases
(
first
:
$first
,
last
:
$last
,
before
:
$before
,
after
:
$after
)
{
releases
(
first
:
$first
,
last
:
$last
,
before
:
$before
,
after
:
$after
,
sort
:
$sort
)
{
nodes
{
nodes
{
...
Release
...
Release
}
}
...
...
app/assets/javascripts/releases/queries/release.fragment.graphql
View file @
8ea42202
...
@@ -4,6 +4,7 @@ fragment Release on Release {
...
@@ -4,6 +4,7 @@ fragment Release on Release {
tagPath
tagPath
descriptionHtml
descriptionHtml
releasedAt
releasedAt
createdAt
upcomingRelease
upcomingRelease
assets
{
assets
{
count
count
...
...
app/assets/javascripts/releases/stores/modules/list/actions.js
View file @
8ea42202
...
@@ -42,6 +42,10 @@ export const fetchReleasesGraphQl = (
...
@@ -42,6 +42,10 @@ export const fetchReleasesGraphQl = (
)
=>
{
)
=>
{
commit
(
types
.
REQUEST_RELEASES
);
commit
(
types
.
REQUEST_RELEASES
);
const
{
sort
,
orderBy
}
=
state
.
sorting
;
const
orderByParam
=
orderBy
===
'
created_at
'
?
'
created
'
:
orderBy
;
const
sortParams
=
`
${
orderByParam
.
toUpperCase
()}
_
${
sort
.
toUpperCase
()}
`
;
let
paginationParams
;
let
paginationParams
;
if
(
!
before
&&
!
after
)
{
if
(
!
before
&&
!
after
)
{
paginationParams
=
{
first
:
PAGE_SIZE
};
paginationParams
=
{
first
:
PAGE_SIZE
};
...
@@ -60,6 +64,7 @@ export const fetchReleasesGraphQl = (
...
@@ -60,6 +64,7 @@ export const fetchReleasesGraphQl = (
query
:
allReleasesQuery
,
query
:
allReleasesQuery
,
variables
:
{
variables
:
{
fullPath
:
state
.
projectPath
,
fullPath
:
state
.
projectPath
,
sort
:
sortParams
,
...
paginationParams
,
...
paginationParams
,
},
},
})
})
...
@@ -80,8 +85,10 @@ export const fetchReleasesGraphQl = (
...
@@ -80,8 +85,10 @@ export const fetchReleasesGraphQl = (
export
const
fetchReleasesRest
=
({
dispatch
,
commit
,
state
},
{
page
})
=>
{
export
const
fetchReleasesRest
=
({
dispatch
,
commit
,
state
},
{
page
})
=>
{
commit
(
types
.
REQUEST_RELEASES
);
commit
(
types
.
REQUEST_RELEASES
);
const
{
sort
,
orderBy
}
=
state
.
sorting
;
api
api
.
releases
(
state
.
projectId
,
{
page
})
.
releases
(
state
.
projectId
,
{
page
,
sort
,
order_by
:
orderBy
})
.
then
(({
data
,
headers
})
=>
{
.
then
(({
data
,
headers
})
=>
{
const
restPageInfo
=
parseIntPagination
(
normalizeHeaders
(
headers
));
const
restPageInfo
=
parseIntPagination
(
normalizeHeaders
(
headers
));
const
camelCasedReleases
=
convertObjectPropsToCamelCase
(
data
,
{
deep
:
true
});
const
camelCasedReleases
=
convertObjectPropsToCamelCase
(
data
,
{
deep
:
true
});
...
@@ -98,3 +105,5 @@ export const receiveReleasesError = ({ commit }) => {
...
@@ -98,3 +105,5 @@ export const receiveReleasesError = ({ commit }) => {
commit
(
types
.
RECEIVE_RELEASES_ERROR
);
commit
(
types
.
RECEIVE_RELEASES_ERROR
);
createFlash
(
__
(
'
An error occurred while fetching the releases. Please try again.
'
));
createFlash
(
__
(
'
An error occurred while fetching the releases. Please try again.
'
));
};
};
export
const
setSorting
=
({
commit
},
data
)
=>
commit
(
types
.
SET_SORTING
,
data
);
app/assets/javascripts/releases/stores/modules/list/mutation_types.js
View file @
8ea42202
export
const
REQUEST_RELEASES
=
'
REQUEST_RELEASES
'
;
export
const
REQUEST_RELEASES
=
'
REQUEST_RELEASES
'
;
export
const
RECEIVE_RELEASES_SUCCESS
=
'
RECEIVE_RELEASES_SUCCESS
'
;
export
const
RECEIVE_RELEASES_SUCCESS
=
'
RECEIVE_RELEASES_SUCCESS
'
;
export
const
RECEIVE_RELEASES_ERROR
=
'
RECEIVE_RELEASES_ERROR
'
;
export
const
RECEIVE_RELEASES_ERROR
=
'
RECEIVE_RELEASES_ERROR
'
;
export
const
SET_SORTING
=
'
SET_SORTING
'
;
app/assets/javascripts/releases/stores/modules/list/mutations.js
View file @
8ea42202
...
@@ -39,4 +39,8 @@ export default {
...
@@ -39,4 +39,8 @@ export default {
state
.
restPageInfo
=
{};
state
.
restPageInfo
=
{};
state
.
graphQlPageInfo
=
{};
state
.
graphQlPageInfo
=
{};
},
},
[
types
.
SET_SORTING
](
state
,
sorting
)
{
state
.
sorting
=
{
...
state
.
sorting
,
...
sorting
};
},
};
};
app/assets/javascripts/releases/stores/modules/list/state.js
View file @
8ea42202
...
@@ -16,4 +16,8 @@ export default ({
...
@@ -16,4 +16,8 @@ export default ({
releases
:
[],
releases
:
[],
restPageInfo
:
{},
restPageInfo
:
{},
graphQlPageInfo
:
{},
graphQlPageInfo
:
{},
sorting
:
{
sort
:
'
desc
'
,
orderBy
:
'
released_at
'
,
},
});
});
changelogs/unreleased/221101-implement-gitlab-ui-component-for-sorting-releases.yml
0 → 100644
View file @
8ea42202
---
title
:
Implement gitlab-ui component for sorting Releases
merge_request
:
43963
author
:
type
:
added
locale/gitlab.pot
View file @
8ea42202
...
@@ -22326,6 +22326,9 @@ msgstr ""
...
@@ -22326,6 +22326,9 @@ msgstr ""
msgid "ReleaseAssetLinkType|Runbooks"
msgid "ReleaseAssetLinkType|Runbooks"
msgstr ""
msgstr ""
msgid "Released date"
msgstr ""
msgid "Releases"
msgid "Releases"
msgstr ""
msgstr ""
...
...
spec/frontend/releases/components/releases_sort_spec.js
0 → 100644
View file @
8ea42202
import
Vuex
from
'
vuex
'
;
import
{
GlSorting
,
GlSortingItem
}
from
'
@gitlab/ui
'
;
import
{
mount
,
createLocalVue
}
from
'
@vue/test-utils
'
;
import
stubChildren
from
'
helpers/stub_children
'
;
import
ReleasesSort
from
'
~/releases/components/releases_sort.vue
'
;
import
createStore
from
'
~/releases/stores
'
;
import
createListModule
from
'
~/releases/stores/modules/list
'
;
const
localVue
=
createLocalVue
();
localVue
.
use
(
Vuex
);
describe
(
'
~/releases/components/releases_sort.vue
'
,
()
=>
{
let
wrapper
;
let
store
;
let
sorting
;
let
listModule
;
let
sortingItems
;
const
projectId
=
8
;
const
createComponent
=
()
=>
{
listModule
=
createListModule
({
projectId
});
store
=
createStore
({
modules
:
{
list
:
listModule
,
},
});
store
.
dispatch
=
jest
.
fn
();
wrapper
=
mount
(
ReleasesSort
,
{
store
,
stubs
:
{
...
stubChildren
(
ReleasesSort
),
GlSortingItem
,
},
localVue
,
});
};
const
findReleasesSorting
=
()
=>
wrapper
.
find
(
GlSorting
);
const
findSortingItems
=
()
=>
wrapper
.
findAll
(
GlSortingItem
);
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
=
null
;
});
beforeEach
(()
=>
{
createComponent
();
sorting
=
findReleasesSorting
();
sortingItems
=
findSortingItems
();
});
it
(
'
has all the sortable items
'
,
()
=>
{
expect
(
sortingItems
).
toHaveLength
(
wrapper
.
vm
.
sortOptions
.
length
);
});
it
(
'
on sort change set sorting in vuex and emit event
'
,
()
=>
{
sorting
.
vm
.
$emit
(
'
sortDirectionChange
'
);
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
list/setSorting
'
,
{
sort
:
'
asc
'
});
expect
(
wrapper
.
emitted
(
'
sort:changed
'
)).
toBeTruthy
();
});
it
(
'
on sort item click set sorting and emit event
'
,
()
=>
{
const
item
=
sortingItems
.
at
(
0
);
const
{
orderBy
}
=
wrapper
.
vm
.
sortOptions
[
0
];
item
.
vm
.
$emit
(
'
click
'
);
expect
(
store
.
dispatch
).
toHaveBeenCalledWith
(
'
list/setSorting
'
,
{
orderBy
});
expect
(
wrapper
.
emitted
(
'
sort:changed
'
)).
toBeTruthy
();
});
});
spec/frontend/releases/stores/modules/list/actions_spec.js
View file @
8ea42202
...
@@ -6,6 +6,7 @@ import {
...
@@ -6,6 +6,7 @@ import {
fetchReleasesGraphQl
,
fetchReleasesGraphQl
,
fetchReleasesRest
,
fetchReleasesRest
,
receiveReleasesError
,
receiveReleasesError
,
setSorting
,
}
from
'
~/releases/stores/modules/list/actions
'
;
}
from
'
~/releases/stores/modules/list/actions
'
;
import
createState
from
'
~/releases/stores/modules/list/state
'
;
import
createState
from
'
~/releases/stores/modules/list/state
'
;
import
*
as
types
from
'
~/releases/stores/modules/list/mutation_types
'
;
import
*
as
types
from
'
~/releases/stores/modules/list/mutation_types
'
;
...
@@ -114,7 +115,7 @@ describe('Releases State actions', () => {
...
@@ -114,7 +115,7 @@ describe('Releases State actions', () => {
it
(
'
makes a GraphQl query with a first variable
'
,
()
=>
{
it
(
'
makes a GraphQl query with a first variable
'
,
()
=>
{
expect
(
gqClient
.
query
).
toHaveBeenCalledWith
({
expect
(
gqClient
.
query
).
toHaveBeenCalledWith
({
query
:
allReleasesQuery
,
query
:
allReleasesQuery
,
variables
:
{
fullPath
:
projectPath
,
first
:
PAGE_SIZE
},
variables
:
{
fullPath
:
projectPath
,
first
:
PAGE_SIZE
,
sort
:
'
RELEASED_AT_DESC
'
},
});
});
});
});
});
});
...
@@ -127,7 +128,7 @@ describe('Releases State actions', () => {
...
@@ -127,7 +128,7 @@ describe('Releases State actions', () => {
it
(
'
makes a GraphQl query with last and before variables
'
,
()
=>
{
it
(
'
makes a GraphQl query with last and before variables
'
,
()
=>
{
expect
(
gqClient
.
query
).
toHaveBeenCalledWith
({
expect
(
gqClient
.
query
).
toHaveBeenCalledWith
({
query
:
allReleasesQuery
,
query
:
allReleasesQuery
,
variables
:
{
fullPath
:
projectPath
,
last
:
PAGE_SIZE
,
before
},
variables
:
{
fullPath
:
projectPath
,
last
:
PAGE_SIZE
,
before
,
sort
:
'
RELEASED_AT_DESC
'
},
});
});
});
});
});
});
...
@@ -140,7 +141,7 @@ describe('Releases State actions', () => {
...
@@ -140,7 +141,7 @@ describe('Releases State actions', () => {
it
(
'
makes a GraphQl query with first and after variables
'
,
()
=>
{
it
(
'
makes a GraphQl query with first and after variables
'
,
()
=>
{
expect
(
gqClient
.
query
).
toHaveBeenCalledWith
({
expect
(
gqClient
.
query
).
toHaveBeenCalledWith
({
query
:
allReleasesQuery
,
query
:
allReleasesQuery
,
variables
:
{
fullPath
:
projectPath
,
first
:
PAGE_SIZE
,
after
},
variables
:
{
fullPath
:
projectPath
,
first
:
PAGE_SIZE
,
after
,
sort
:
'
RELEASED_AT_DESC
'
},
});
});
});
});
});
});
...
@@ -156,6 +157,34 @@ describe('Releases State actions', () => {
...
@@ -156,6 +157,34 @@ describe('Releases State actions', () => {
);
);
});
});
});
});
describe
(
'
when the sort parameter is changed
'
,
()
=>
{
beforeEach
(()
=>
{
mockedState
.
sorting
.
sort
=
'
asc
'
;
fetchReleasesGraphQl
(
vuexParams
,
{
before
:
undefined
,
after
:
undefined
});
});
it
(
'
makes a GraphQL query with sort variable for the requested direction
'
,
()
=>
{
expect
(
gqClient
.
query
).
toHaveBeenCalledWith
({
query
:
allReleasesQuery
,
variables
:
{
fullPath
:
projectPath
,
first
:
PAGE_SIZE
,
sort
:
'
RELEASED_AT_ASC
'
},
});
});
});
describe
(
'
when the orderBy parameter is changed
'
,
()
=>
{
beforeEach
(()
=>
{
mockedState
.
sorting
.
orderBy
=
'
created_at
'
;
fetchReleasesGraphQl
(
vuexParams
,
{
before
:
undefined
,
after
:
undefined
});
});
it
(
'
makes a GraphQl query with sort variable for the requested order
'
,
()
=>
{
expect
(
gqClient
.
query
).
toHaveBeenCalledWith
({
query
:
allReleasesQuery
,
variables
:
{
fullPath
:
projectPath
,
first
:
PAGE_SIZE
,
sort
:
'
CREATED_DESC
'
},
});
});
});
});
});
describe
(
'
when the request is successful
'
,
()
=>
{
describe
(
'
when the request is successful
'
,
()
=>
{
...
@@ -230,7 +259,11 @@ describe('Releases State actions', () => {
...
@@ -230,7 +259,11 @@ describe('Releases State actions', () => {
});
});
it
(
'
makes a REST query with a page query parameter
'
,
()
=>
{
it
(
'
makes a REST query with a page query parameter
'
,
()
=>
{
expect
(
api
.
releases
).
toHaveBeenCalledWith
(
projectId
,
{
page
});
expect
(
api
.
releases
).
toHaveBeenCalledWith
(
projectId
,
{
page
,
order_by
:
'
released_at
'
,
sort
:
'
desc
'
,
});
});
});
});
});
});
});
...
@@ -302,4 +335,16 @@ describe('Releases State actions', () => {
...
@@ -302,4 +335,16 @@ describe('Releases State actions', () => {
);
);
});
});
});
});
describe
(
'
setSorting
'
,
()
=>
{
it
(
'
should commit SET_SORTING
'
,
()
=>
{
return
testAction
(
setSorting
,
{
orderBy
:
'
released_at
'
,
sort
:
'
asc
'
},
null
,
[{
type
:
types
.
SET_SORTING
,
payload
:
{
orderBy
:
'
released_at
'
,
sort
:
'
asc
'
}
}],
[],
);
});
});
});
});
spec/frontend/releases/stores/modules/list/mutations_spec.js
View file @
8ea42202
...
@@ -80,4 +80,16 @@ describe('Releases Store Mutations', () => {
...
@@ -80,4 +80,16 @@ describe('Releases Store Mutations', () => {
expect
(
stateCopy
.
graphQlPageInfo
).
toEqual
({});
expect
(
stateCopy
.
graphQlPageInfo
).
toEqual
({});
});
});
});
});
describe
(
'
SET_SORTING
'
,
()
=>
{
it
(
'
should merge the sorting object with sort value
'
,
()
=>
{
mutations
[
types
.
SET_SORTING
](
stateCopy
,
{
sort
:
'
asc
'
});
expect
(
stateCopy
.
sorting
).
toEqual
({
...
stateCopy
.
sorting
,
sort
:
'
asc
'
});
});
it
(
'
should merge the sorting object with order_by value
'
,
()
=>
{
mutations
[
types
.
SET_SORTING
](
stateCopy
,
{
orderBy
:
'
created_at
'
});
expect
(
stateCopy
.
sorting
).
toEqual
({
...
stateCopy
.
sorting
,
orderBy
:
'
created_at
'
});
});
});
});
});
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