diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /spec/frontend/feature_flags/store/new/actions_spec.js | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/frontend/feature_flags/store/new/actions_spec.js')
-rw-r--r-- | spec/frontend/feature_flags/store/new/actions_spec.js | 81 |
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( |