Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/releases/stores')
-rw-r--r--spec/frontend/releases/stores/modules/detail/actions_spec.js1
-rw-r--r--spec/frontend/releases/stores/modules/detail/mutations_spec.js1
-rw-r--r--spec/frontend/releases/stores/modules/list/actions_spec.js48
-rw-r--r--spec/frontend/releases/stores/modules/list/mutations_spec.js12
4 files changed, 56 insertions, 6 deletions
diff --git a/spec/frontend/releases/stores/modules/detail/actions_spec.js b/spec/frontend/releases/stores/modules/detail/actions_spec.js
index d38f6766d4e..abd0db6a589 100644
--- a/spec/frontend/releases/stores/modules/detail/actions_spec.js
+++ b/spec/frontend/releases/stores/modules/detail/actions_spec.js
@@ -47,7 +47,6 @@ describe('Release detail actions', () => {
releasesPagePath: 'path/to/releases/page',
markdownDocsPath: 'path/to/markdown/docs',
markdownPreviewPath: 'path/to/markdown/preview',
- updateReleaseApiDocsPath: 'path/to/api/docs',
}),
...getters,
...rootState,
diff --git a/spec/frontend/releases/stores/modules/detail/mutations_spec.js b/spec/frontend/releases/stores/modules/detail/mutations_spec.js
index f3e84262754..88eddc4019c 100644
--- a/spec/frontend/releases/stores/modules/detail/mutations_spec.js
+++ b/spec/frontend/releases/stores/modules/detail/mutations_spec.js
@@ -18,7 +18,6 @@ describe('Release detail mutations', () => {
releasesPagePath: 'path/to/releases/page',
markdownDocsPath: 'path/to/markdown/docs',
markdownPreviewPath: 'path/to/markdown/preview',
- updateReleaseApiDocsPath: 'path/to/api/docs',
});
release = convertObjectPropsToCamelCase(originalRelease);
});
diff --git a/spec/frontend/releases/stores/modules/list/actions_spec.js b/spec/frontend/releases/stores/modules/list/actions_spec.js
index 4e235e1d00f..35551b77dc4 100644
--- a/spec/frontend/releases/stores/modules/list/actions_spec.js
+++ b/spec/frontend/releases/stores/modules/list/actions_spec.js
@@ -6,6 +6,7 @@ import {
fetchReleasesGraphQl,
fetchReleasesRest,
receiveReleasesError,
+ setSorting,
} from '~/releases/stores/modules/list/actions';
import createState from '~/releases/stores/modules/list/state';
import * as types from '~/releases/stores/modules/list/mutation_types';
@@ -114,7 +115,7 @@ describe('Releases State actions', () => {
it('makes a GraphQl query with a first variable', () => {
expect(gqClient.query).toHaveBeenCalledWith({
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', () => {
it('makes a GraphQl query with last and before variables', () => {
expect(gqClient.query).toHaveBeenCalledWith({
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', () => {
it('makes a GraphQl query with first and after variables', () => {
expect(gqClient.query).toHaveBeenCalledWith({
query: allReleasesQuery,
- variables: { fullPath: projectPath, first: PAGE_SIZE, after },
+ variables: { fullPath: projectPath, first: PAGE_SIZE, after, sort: 'RELEASED_AT_DESC' },
});
});
});
@@ -156,6 +157,29 @@ describe('Releases State actions', () => {
);
});
});
+
+ describe('when the sort parameters are provided', () => {
+ it.each`
+ sort | orderBy | ReleaseSort
+ ${'asc'} | ${'released_at'} | ${'RELEASED_AT_ASC'}
+ ${'desc'} | ${'released_at'} | ${'RELEASED_AT_DESC'}
+ ${'asc'} | ${'created_at'} | ${'CREATED_ASC'}
+ ${'desc'} | ${'created_at'} | ${'CREATED_DESC'}
+ `(
+ 'correctly sets $ReleaseSort based on $sort and $orderBy',
+ ({ sort, orderBy, ReleaseSort }) => {
+ mockedState.sorting.sort = sort;
+ mockedState.sorting.orderBy = orderBy;
+
+ fetchReleasesGraphQl(vuexParams, { before: undefined, after: undefined });
+
+ expect(gqClient.query).toHaveBeenCalledWith({
+ query: allReleasesQuery,
+ variables: { fullPath: projectPath, first: PAGE_SIZE, sort: ReleaseSort },
+ });
+ },
+ );
+ });
});
describe('when the request is successful', () => {
@@ -230,7 +254,11 @@ describe('Releases State actions', () => {
});
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 +330,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' } }],
+ [],
+ );
+ });
+ });
});
diff --git a/spec/frontend/releases/stores/modules/list/mutations_spec.js b/spec/frontend/releases/stores/modules/list/mutations_spec.js
index 521418cbddb..78071573072 100644
--- a/spec/frontend/releases/stores/modules/list/mutations_spec.js
+++ b/spec/frontend/releases/stores/modules/list/mutations_spec.js
@@ -80,4 +80,16 @@ describe('Releases Store Mutations', () => {
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' });
+ });
+ });
});