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/feature_flags/store/new/actions_spec.js')
-rw-r--r--spec/frontend/feature_flags/store/new/actions_spec.js81
1 files changed, 21 insertions, 60 deletions
diff --git a/spec/frontend/feature_flags/store/new/actions_spec.js b/spec/frontend/feature_flags/store/new/actions_spec.js
index 00dfb982ded..7900b200eb2 100644
--- a/spec/frontend/feature_flags/store/new/actions_spec.js
+++ b/spec/frontend/feature_flags/store/new/actions_spec.js
@@ -1,13 +1,7 @@
import MockAdapter from 'axios-mock-adapter';
import testAction from 'helpers/vuex_action_helper';
-import { TEST_HOST } from 'spec/test_constants';
-import {
- ROLLOUT_STRATEGY_ALL_USERS,
- ROLLOUT_STRATEGY_PERCENT_ROLLOUT,
- LEGACY_FLAG,
- NEW_VERSION_FLAG,
-} from '~/feature_flags/constants';
-import { mapFromScopesViewModel, mapStrategiesToRails } from '~/feature_flags/store/helpers';
+import { ROLLOUT_STRATEGY_ALL_USERS } from '~/feature_flags/constants';
+import { mapStrategiesToRails } from '~/feature_flags/store/helpers';
import {
createFeatureFlag,
requestCreateFeatureFlag,
@@ -24,33 +18,13 @@ describe('Feature flags New Module Actions', () => {
let mockedState;
beforeEach(() => {
- mockedState = state({ endpoint: 'feature_flags.json', path: '/feature_flags' });
+ mockedState = state({ endpoint: '/feature_flags.json', path: '/feature_flags' });
});
describe('createFeatureFlag', () => {
let mock;
- const actionParams = {
- name: 'name',
- description: 'description',
- active: true,
- version: LEGACY_FLAG,
- scopes: [
- {
- id: 1,
- environmentScope: 'environmentScope',
- active: true,
- canUpdate: true,
- protected: true,
- shouldBeDestroyed: false,
- rolloutStrategy: ROLLOUT_STRATEGY_ALL_USERS,
- rolloutPercentage: ROLLOUT_STRATEGY_PERCENT_ROLLOUT,
- },
- ],
- };
-
beforeEach(() => {
- mockedState.endpoint = `${TEST_HOST}/endpoint.json`;
mock = new MockAdapter(axios);
});
@@ -60,33 +34,10 @@ describe('Feature flags New Module Actions', () => {
describe('success', () => {
it('dispatches requestCreateFeatureFlag and receiveCreateFeatureFlagSuccess ', (done) => {
- const convertedActionParams = mapFromScopesViewModel(actionParams);
-
- mock.onPost(`${TEST_HOST}/endpoint.json`, convertedActionParams).replyOnce(200);
-
- testAction(
- createFeatureFlag,
- actionParams,
- mockedState,
- [],
- [
- {
- type: 'requestCreateFeatureFlag',
- },
- {
- type: 'receiveCreateFeatureFlagSuccess',
- },
- ],
- done,
- );
- });
-
- it('sends strategies for new style feature flags', (done) => {
- const newVersionFlagParams = {
+ const actionParams = {
name: 'name',
description: 'description',
active: true,
- version: NEW_VERSION_FLAG,
strategies: [
{
name: ROLLOUT_STRATEGY_ALL_USERS,
@@ -97,13 +48,11 @@ describe('Feature flags New Module Actions', () => {
},
],
};
- mock
- .onPost(`${TEST_HOST}/endpoint.json`, mapStrategiesToRails(newVersionFlagParams))
- .replyOnce(200);
+ mock.onPost(mockedState.endpoint, mapStrategiesToRails(actionParams)).replyOnce(200);
testAction(
createFeatureFlag,
- newVersionFlagParams,
+ actionParams,
mockedState,
[],
[
@@ -121,10 +70,22 @@ describe('Feature flags New Module Actions', () => {
describe('error', () => {
it('dispatches requestCreateFeatureFlag and receiveCreateFeatureFlagError ', (done) => {
- const convertedActionParams = mapFromScopesViewModel(actionParams);
-
+ const actionParams = {
+ name: 'name',
+ description: 'description',
+ active: true,
+ strategies: [
+ {
+ name: ROLLOUT_STRATEGY_ALL_USERS,
+ parameters: {},
+ id: 1,
+ scopes: [{ id: 1, environmentScope: 'environmentScope', shouldBeDestroyed: false }],
+ shouldBeDestroyed: false,
+ },
+ ],
+ };
mock
- .onPost(`${TEST_HOST}/endpoint.json`, convertedActionParams)
+ .onPost(mockedState.endpoint, mapStrategiesToRails(actionParams))
.replyOnce(500, { message: [] });
testAction(