summaryrefslogtreecommitdiff
path: root/spec/frontend/releases/stores/modules/detail/actions_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/releases/stores/modules/detail/actions_spec.js')
-rw-r--r--spec/frontend/releases/stores/modules/detail/actions_spec.js50
1 files changed, 25 insertions, 25 deletions
diff --git a/spec/frontend/releases/stores/modules/detail/actions_spec.js b/spec/frontend/releases/stores/modules/detail/actions_spec.js
index 1b2a705e8f4..d38f6766d4e 100644
--- a/spec/frontend/releases/stores/modules/detail/actions_spec.js
+++ b/spec/frontend/releases/stores/modules/detail/actions_spec.js
@@ -1,10 +1,10 @@
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import testAction from 'helpers/vuex_action_helper';
+import { getJSONFixture } from 'helpers/fixtures';
import { cloneDeep } from 'lodash';
import * as actions from '~/releases/stores/modules/detail/actions';
import * as types from '~/releases/stores/modules/detail/mutation_types';
-import { release as originalRelease } from '../../../mock_data';
import createState from '~/releases/stores/modules/detail/state';
import { deprecatedCreateFlash as createFlash } from '~/flash';
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
@@ -21,6 +21,8 @@ jest.mock('~/lib/utils/url_utility', () => ({
joinPaths: jest.requireActual('~/lib/utils/url_utility').joinPaths,
}));
+const originalRelease = getJSONFixture('api/releases/release.json');
+
describe('Release detail actions', () => {
let state;
let release;
@@ -32,6 +34,12 @@ describe('Release detail actions', () => {
isExistingRelease: true,
};
+ const rootState = {
+ featureFlags: {
+ graphqlIndividualReleasePage: false,
+ },
+ };
+
state = {
...createState({
projectId: '18',
@@ -42,6 +50,7 @@ describe('Release detail actions', () => {
updateReleaseApiDocsPath: 'path/to/api/docs',
}),
...getters,
+ ...rootState,
...updates,
};
};
@@ -152,7 +161,7 @@ describe('Release detail actions', () => {
});
it(`shows a flash message`, () => {
- return actions.fetchRelease({ commit: jest.fn(), state }).then(() => {
+ return actions.fetchRelease({ commit: jest.fn(), state, rootState: state }).then(() => {
expect(createFlash).toHaveBeenCalledTimes(1);
expect(createFlash).toHaveBeenCalledWith(
'Something went wrong while getting the release details',
@@ -207,6 +216,15 @@ describe('Release detail actions', () => {
});
});
+ describe('updateReleaseGroupMilestones', () => {
+ it(`commits ${types.UPDATE_RELEASE_GROUP_MILESTONES} with the updated release group milestones`, () => {
+ const newReleaseGroupMilestones = ['v0.0', 'v0.1'];
+ return testAction(actions.updateReleaseGroupMilestones, newReleaseGroupMilestones, state, [
+ { type: types.UPDATE_RELEASE_GROUP_MILESTONES, payload: newReleaseGroupMilestones },
+ ]);
+ });
+ });
+
describe('addEmptyAssetLink', () => {
it(`commits ${types.ADD_EMPTY_ASSET_LINK}`, () => {
return testAction(actions.addEmptyAssetLink, undefined, state, [
@@ -265,32 +283,14 @@ describe('Release detail actions', () => {
describe('receiveSaveReleaseSuccess', () => {
it(`commits ${types.RECEIVE_SAVE_RELEASE_SUCCESS}`, () =>
- testAction(actions.receiveSaveReleaseSuccess, undefined, { ...state, featureFlags: {} }, [
+ testAction(actions.receiveSaveReleaseSuccess, release, state, [
{ type: types.RECEIVE_SAVE_RELEASE_SUCCESS },
]));
- describe('when the releaseShowPage feature flag is enabled', () => {
- beforeEach(() => {
- const rootState = { featureFlags: { releaseShowPage: true } };
- actions.receiveSaveReleaseSuccess({ commit: jest.fn(), state, rootState }, release);
- });
-
- it("redirects to the release's dedicated page", () => {
- expect(redirectTo).toHaveBeenCalledTimes(1);
- expect(redirectTo).toHaveBeenCalledWith(release._links.self);
- });
- });
-
- describe('when the releaseShowPage feature flag is disabled', () => {
- beforeEach(() => {
- const rootState = { featureFlags: { releaseShowPage: false } };
- actions.receiveSaveReleaseSuccess({ commit: jest.fn(), state, rootState }, release);
- });
-
- it("redirects to the project's main Releases page", () => {
- expect(redirectTo).toHaveBeenCalledTimes(1);
- expect(redirectTo).toHaveBeenCalledWith(state.releasesPagePath);
- });
+ it("redirects to the release's dedicated page", () => {
+ actions.receiveSaveReleaseSuccess({ commit: jest.fn(), state }, release);
+ expect(redirectTo).toHaveBeenCalledTimes(1);
+ expect(redirectTo).toHaveBeenCalledWith(release._links.self);
});
});