diff options
Diffstat (limited to 'spec/frontend/feature_flags')
10 files changed, 108 insertions, 1098 deletions
diff --git a/spec/frontend/feature_flags/components/edit_feature_flag_spec.js b/spec/frontend/feature_flags/components/edit_feature_flag_spec.js index 0948b08f942..799b567a2c0 100644 --- a/spec/frontend/feature_flags/components/edit_feature_flag_spec.js +++ b/spec/frontend/feature_flags/components/edit_feature_flag_spec.js @@ -1,21 +1,16 @@ import { GlToggle, GlAlert } from '@gitlab/ui'; -import { createLocalVue, shallowMount } from '@vue/test-utils'; +import { shallowMount } from '@vue/test-utils'; import MockAdapter from 'axios-mock-adapter'; +import Vue from 'vue'; import Vuex from 'vuex'; import { mockTracking } from 'helpers/tracking_helper'; import { TEST_HOST } from 'spec/test_constants'; import EditFeatureFlag from '~/feature_flags/components/edit_feature_flag.vue'; import Form from '~/feature_flags/components/form.vue'; -import { LEGACY_FLAG, NEW_VERSION_FLAG } from '~/feature_flags/constants'; import createStore from '~/feature_flags/store/edit'; import axios from '~/lib/utils/axios_utils'; -const localVue = createLocalVue(); -localVue.use(Vuex); - -const userCalloutId = 'feature_flags_new_version'; -const userCalloutsPath = `${TEST_HOST}/user_callouts`; - +Vue.use(Vuex); describe('Edit feature flag form', () => { let wrapper; let mock; @@ -25,20 +20,14 @@ describe('Edit feature flag form', () => { endpoint: `${TEST_HOST}/feature_flags.json`, }); - const factory = (opts = {}) => { + const factory = (provide = {}) => { if (wrapper) { wrapper.destroy(); wrapper = null; } wrapper = shallowMount(EditFeatureFlag, { - localVue, store, - provide: { - showUserCallout: true, - userCalloutId, - userCalloutsPath, - ...opts, - }, + provide, }); }; @@ -52,18 +41,8 @@ describe('Edit feature flag form', () => { updated_at: '2019-01-17T17:27:39.778Z', name: 'feature_flag', description: '', - version: LEGACY_FLAG, edit_path: '/h5bp/html5-boilerplate/-/feature_flags/21/edit', destroy_path: '/h5bp/html5-boilerplate/-/feature_flags/21', - scopes: [ - { - id: 21, - active: false, - environment_scope: '*', - created_at: '2019-01-17T17:27:39.778Z', - updated_at: '2019-01-17T17:27:39.778Z', - }, - ], }); factory(); setImmediate(() => done()); @@ -74,9 +53,7 @@ describe('Edit feature flag form', () => { mock.restore(); }); - const findAlert = () => wrapper.find(GlAlert); - const findWarningGlAlert = () => - wrapper.findAll(GlAlert).filter((c) => c.props('variant') === 'warning'); + const findWarningGlAlert = () => wrapper.findComponent(GlAlert); it('should display the iid', () => { expect(wrapper.find('h3').text()).toContain('^5'); @@ -86,21 +63,13 @@ describe('Edit feature flag form', () => { expect(wrapper.find(GlToggle).exists()).toBe(true); }); - it('should set the value of the toggle to whether or not the flag is active', () => { - expect(wrapper.find(GlToggle).props('value')).toBe(true); - }); - - it('should alert users the flag is read-only', () => { - expect(findAlert().text()).toContain('GitLab is moving to a new way of managing feature flags'); - }); - describe('with error', () => { it('should render the error', () => { store.dispatch('receiveUpdateFeatureFlagError', { message: ['The name is required'] }); return wrapper.vm.$nextTick(() => { const warningGlAlert = findWarningGlAlert(); - expect(warningGlAlert.at(1).exists()).toEqual(true); - expect(warningGlAlert.at(1).text()).toContain('The name is required'); + expect(warningGlAlert.exists()).toEqual(true); + expect(warningGlAlert.text()).toContain('The name is required'); }); }); }); @@ -114,32 +83,6 @@ describe('Edit feature flag form', () => { expect(wrapper.find(Form).exists()).toEqual(true); }); - it('should set the version of the form from the feature flag', () => { - expect(wrapper.find(Form).props('version')).toBe(LEGACY_FLAG); - - mock.resetHandlers(); - - mock.onGet(`${TEST_HOST}/feature_flags.json`).replyOnce(200, { - id: 21, - iid: 5, - active: true, - created_at: '2019-01-17T17:27:39.778Z', - updated_at: '2019-01-17T17:27:39.778Z', - name: 'feature_flag', - description: '', - version: NEW_VERSION_FLAG, - edit_path: '/h5bp/html5-boilerplate/-/feature_flags/21/edit', - destroy_path: '/h5bp/html5-boilerplate/-/feature_flags/21', - strategies: [], - }); - - factory(); - - return axios.waitForAll().then(() => { - expect(wrapper.find(Form).props('version')).toBe(NEW_VERSION_FLAG); - }); - }); - it('should track when the toggle is clicked', () => { const toggle = wrapper.find(GlToggle); const spy = mockTracking('_category_', toggle.element, jest.spyOn); diff --git a/spec/frontend/feature_flags/components/feature_flags_table_spec.js b/spec/frontend/feature_flags/components/feature_flags_table_spec.js index 816bc9b9707..d06d60ae310 100644 --- a/spec/frontend/feature_flags/components/feature_flags_table_spec.js +++ b/spec/frontend/feature_flags/components/feature_flags_table_spec.js @@ -8,9 +8,6 @@ import { ROLLOUT_STRATEGY_PERCENT_ROLLOUT, ROLLOUT_STRATEGY_USER_ID, ROLLOUT_STRATEGY_GITLAB_USER_LIST, - NEW_VERSION_FLAG, - LEGACY_FLAG, - DEFAULT_PERCENT_ROLLOUT, } from '~/feature_flags/constants'; const getDefaultProps = () => ({ @@ -23,17 +20,28 @@ const getDefaultProps = () => ({ description: 'flag description', destroy_path: 'destroy/path', edit_path: 'edit/path', - version: LEGACY_FLAG, - scopes: [ + scopes: [], + strategies: [ { - id: 1, - active: true, - environmentScope: 'scope', - canUpdate: true, - protected: false, - rolloutStrategy: ROLLOUT_STRATEGY_ALL_USERS, - rolloutPercentage: DEFAULT_PERCENT_ROLLOUT, - shouldBeDestroyed: false, + name: ROLLOUT_STRATEGY_ALL_USERS, + parameters: {}, + scopes: [{ environment_scope: '*' }], + }, + { + name: ROLLOUT_STRATEGY_PERCENT_ROLLOUT, + parameters: { percentage: '50' }, + scopes: [{ environment_scope: 'production' }, { environment_scope: 'staging' }], + }, + { + name: ROLLOUT_STRATEGY_USER_ID, + parameters: { userIds: '1,2,3,4' }, + scopes: [{ environment_scope: 'review/*' }], + }, + { + name: ROLLOUT_STRATEGY_GITLAB_USER_LIST, + parameters: {}, + user_list: { name: 'test list' }, + scopes: [{ environment_scope: '*' }], }, ], }, @@ -43,6 +51,7 @@ const getDefaultProps = () => ({ describe('Feature flag table', () => { let wrapper; let props; + let badges; const createWrapper = (propsData, opts = {}) => { wrapper = shallowMount(FeatureFlagsTable, { @@ -56,6 +65,15 @@ describe('Feature flag table', () => { beforeEach(() => { props = getDefaultProps(); + createWrapper(props, { + provide: { csrfToken: 'fakeToken' }, + }); + + badges = wrapper.findAll('[data-testid="strategy-badge"]'); + }); + + beforeEach(() => { + props = getDefaultProps(); }); afterEach(() => { @@ -97,17 +115,10 @@ describe('Feature flag table', () => { ); }); - it('should render an environments specs column', () => { - const envColumn = wrapper.find('.js-feature-flag-environments'); - - expect(envColumn).toBeDefined(); - expect(trimText(envColumn.text())).toBe('scope'); - }); - it('should render an environments specs badge with active class', () => { const envColumn = wrapper.find('.js-feature-flag-environments'); - expect(trimText(envColumn.find(GlBadge).text())).toBe('scope'); + expect(trimText(envColumn.find(GlBadge).text())).toBe('All Users: All Environments'); }); it('should render an actions column', () => { @@ -120,11 +131,13 @@ describe('Feature flag table', () => { describe('when active and with an update toggle', () => { let toggle; + let spy; beforeEach(() => { props.featureFlags[0].update_path = props.featureFlags[0].destroy_path; createWrapper(props); toggle = wrapper.find(GlToggle); + spy = mockTracking('_category_', toggle.element, jest.spyOn); }); it('should have a toggle', () => { @@ -143,123 +156,40 @@ describe('Feature flag table', () => { expect(wrapper.emitted('toggle-flag')).toEqual([[flag]]); }); }); - }); - - describe('with an active scope and a percentage rollout strategy', () => { - beforeEach(() => { - props.featureFlags[0].scopes[0].rolloutStrategy = ROLLOUT_STRATEGY_PERCENT_ROLLOUT; - props.featureFlags[0].scopes[0].rolloutPercentage = '54'; - createWrapper(props); - }); - it('should render an environments specs badge with percentage', () => { - const envColumn = wrapper.find('.js-feature-flag-environments'); + it('tracks a click', () => { + toggle.trigger('click'); - expect(trimText(envColumn.find(GlBadge).text())).toBe('scope: 54%'); + expect(spy).toHaveBeenCalledWith('_category_', 'click_button', { + label: 'feature_flag_toggle', + }); }); }); - describe('with an inactive scope', () => { - beforeEach(() => { - props.featureFlags[0].scopes[0].active = false; - createWrapper(props); - }); - - it('should render an environments specs badge with inactive class', () => { - const envColumn = wrapper.find('.js-feature-flag-environments'); - - expect(trimText(envColumn.find(GlBadge).text())).toBe('scope'); - }); + it('shows All Environments if the environment scope is *', () => { + expect(badges.at(0).text()).toContain('All Environments'); }); - describe('with a new version flag', () => { - let toggle; - let spy; - let badges; - - beforeEach(() => { - const newVersionProps = { - ...props, - featureFlags: [ - { - id: 1, - iid: 1, - active: true, - name: 'flag name', - description: 'flag description', - destroy_path: 'destroy/path', - edit_path: 'edit/path', - update_path: 'update/path', - version: NEW_VERSION_FLAG, - scopes: [], - strategies: [ - { - name: ROLLOUT_STRATEGY_ALL_USERS, - parameters: {}, - scopes: [{ environment_scope: '*' }], - }, - { - name: ROLLOUT_STRATEGY_PERCENT_ROLLOUT, - parameters: { percentage: '50' }, - scopes: [{ environment_scope: 'production' }, { environment_scope: 'staging' }], - }, - { - name: ROLLOUT_STRATEGY_USER_ID, - parameters: { userIds: '1,2,3,4' }, - scopes: [{ environment_scope: 'review/*' }], - }, - { - name: ROLLOUT_STRATEGY_GITLAB_USER_LIST, - parameters: {}, - user_list: { name: 'test list' }, - scopes: [{ environment_scope: '*' }], - }, - ], - }, - ], - }; - createWrapper(newVersionProps, { - provide: { csrfToken: 'fakeToken', glFeatures: { featureFlagsNewVersion: true } }, - }); - - toggle = wrapper.find(GlToggle); - spy = mockTracking('_category_', toggle.element, jest.spyOn); - badges = wrapper.findAll('[data-testid="strategy-badge"]'); - }); - - it('shows All Environments if the environment scope is *', () => { - expect(badges.at(0).text()).toContain('All Environments'); - }); - - it('shows the environment scope if another is set', () => { - expect(badges.at(1).text()).toContain('production'); - expect(badges.at(1).text()).toContain('staging'); - expect(badges.at(2).text()).toContain('review/*'); - }); - - it('shows All Users for the default strategy', () => { - expect(badges.at(0).text()).toContain('All Users'); - }); - - it('shows the percent for a percent rollout', () => { - expect(badges.at(1).text()).toContain('Percent of users - 50%'); - }); + it('shows the environment scope if another is set', () => { + expect(badges.at(1).text()).toContain('production'); + expect(badges.at(1).text()).toContain('staging'); + expect(badges.at(2).text()).toContain('review/*'); + }); - it('shows the number of users for users with ID', () => { - expect(badges.at(2).text()).toContain('User IDs - 4 users'); - }); + it('shows All Users for the default strategy', () => { + expect(badges.at(0).text()).toContain('All Users'); + }); - it('shows the name of a user list for user list', () => { - expect(badges.at(3).text()).toContain('User List - test list'); - }); + it('shows the percent for a percent rollout', () => { + expect(badges.at(1).text()).toContain('Percent of users - 50%'); + }); - it('tracks a click', () => { - toggle.trigger('click'); + it('shows the number of users for users with ID', () => { + expect(badges.at(2).text()).toContain('User IDs - 4 users'); + }); - expect(spy).toHaveBeenCalledWith('_category_', 'click_button', { - label: 'feature_flag_toggle', - }); - }); + it('shows the name of a user list for user list', () => { + expect(badges.at(3).text()).toContain('User List - test list'); }); it('renders a feature flag without an iid', () => { diff --git a/spec/frontend/feature_flags/components/form_spec.js b/spec/frontend/feature_flags/components/form_spec.js index 6c3fce68618..c0f9638390a 100644 --- a/spec/frontend/feature_flags/components/form_spec.js +++ b/spec/frontend/feature_flags/components/form_spec.js @@ -1,18 +1,12 @@ -import { GlFormTextarea, GlFormCheckbox, GlButton, GlToggle } from '@gitlab/ui'; +import { GlButton } from '@gitlab/ui'; import { shallowMount } from '@vue/test-utils'; -import { uniqueId } from 'lodash'; import { extendedWrapper } from 'helpers/vue_test_utils_helper'; import Api from '~/api'; -import EnvironmentsDropdown from '~/feature_flags/components/environments_dropdown.vue'; import Form from '~/feature_flags/components/form.vue'; import Strategy from '~/feature_flags/components/strategy.vue'; import { ROLLOUT_STRATEGY_ALL_USERS, ROLLOUT_STRATEGY_PERCENT_ROLLOUT, - INTERNAL_ID_PREFIX, - DEFAULT_PERCENT_ROLLOUT, - LEGACY_FLAG, - NEW_VERSION_FLAG, } from '~/feature_flags/constants'; import RelatedIssuesRoot from '~/related_issues/components/related_issues_root.vue'; import { featureFlag, userList, allUsersStrategy } from '../mock_data'; @@ -29,15 +23,8 @@ describe('feature flag form', () => { const requiredInjections = { environmentsEndpoint: '/environments.json', projectId: '1', - glFeatures: { - featureFlagPermissions: true, - featureFlagsNewVersion: true, - }, }; - const findAddNewScopeRow = () => wrapper.findByTestId('add-new-scope'); - const findGlToggle = () => wrapper.find(GlToggle); - const factory = (props = {}, provide = {}) => { wrapper = extendedWrapper( shallowMount(Form, { @@ -100,328 +87,6 @@ describe('feature flag form', () => { it('should render description textarea', () => { expect(wrapper.find('#feature-flag-description').exists()).toBe(true); }); - - describe('scopes', () => { - it('should render scopes table', () => { - expect(wrapper.find('.js-scopes-table').exists()).toBe(true); - }); - - it('should render scopes table with a new row ', () => { - expect(findAddNewScopeRow().exists()).toBe(true); - }); - - describe('status toggle', () => { - describe('without filled text input', () => { - it('should add a new scope with the text value empty and the status', () => { - findGlToggle().vm.$emit('change', true); - - expect(wrapper.vm.formScopes).toHaveLength(1); - expect(wrapper.vm.formScopes[0].active).toEqual(true); - expect(wrapper.vm.formScopes[0].environmentScope).toEqual(''); - - expect(wrapper.vm.newScope).toEqual(''); - }); - }); - - it('has label', () => { - expect(findGlToggle().props('label')).toBe(Form.i18n.statusLabel); - }); - - it('should be disabled if the feature flag is not active', (done) => { - wrapper.setProps({ active: false }); - wrapper.vm.$nextTick(() => { - expect(findGlToggle().props('disabled')).toBe(true); - done(); - }); - }); - }); - }); - }); - - describe('with provided data', () => { - beforeEach(() => { - factory({ - ...requiredProps, - name: featureFlag.name, - description: featureFlag.description, - active: true, - version: LEGACY_FLAG, - scopes: [ - { - id: 1, - active: true, - environmentScope: 'scope', - canUpdate: true, - protected: false, - rolloutStrategy: ROLLOUT_STRATEGY_PERCENT_ROLLOUT, - rolloutPercentage: '54', - rolloutUserIds: '123', - shouldIncludeUserIds: true, - }, - { - id: 2, - active: true, - environmentScope: 'scope', - canUpdate: false, - protected: true, - rolloutStrategy: ROLLOUT_STRATEGY_PERCENT_ROLLOUT, - rolloutPercentage: '54', - rolloutUserIds: '123', - shouldIncludeUserIds: true, - }, - ], - }); - }); - - describe('scopes', () => { - it('should be possible to remove a scope', () => { - expect(wrapper.findByTestId('feature-flag-delete').exists()).toEqual(true); - }); - - it('renders empty row to add a new scope', () => { - expect(findAddNewScopeRow().exists()).toEqual(true); - }); - - it('renders the user id checkbox', () => { - expect(wrapper.find(GlFormCheckbox).exists()).toBe(true); - }); - - it('renders the user id text area', () => { - expect(wrapper.find(GlFormTextarea).exists()).toBe(true); - - expect(wrapper.find(GlFormTextarea).vm.value).toBe('123'); - }); - - describe('update scope', () => { - describe('on click on toggle', () => { - it('should update the scope', () => { - findGlToggle().vm.$emit('change', false); - - expect(wrapper.vm.formScopes[0].active).toBe(false); - }); - - it('should be disabled if the feature flag is not active', (done) => { - wrapper.setProps({ active: false }); - - wrapper.vm.$nextTick(() => { - expect(findGlToggle().props('disabled')).toBe(true); - done(); - }); - }); - }); - describe('on strategy change', () => { - it('should not include user IDs if All Users is selected', () => { - const scope = wrapper.find({ ref: 'scopeRow' }); - scope.find('select').setValue(ROLLOUT_STRATEGY_ALL_USERS); - return wrapper.vm.$nextTick().then(() => { - expect(scope.find('#rollout-user-id-0').exists()).toBe(false); - }); - }); - }); - }); - - describe('deleting an existing scope', () => { - beforeEach(() => { - wrapper.find('.js-delete-scope').vm.$emit('click'); - }); - - it('should add `shouldBeDestroyed` key the clicked scope', () => { - expect(wrapper.vm.formScopes[0].shouldBeDestroyed).toBe(true); - }); - - it('should not render deleted scopes', () => { - expect(wrapper.vm.filteredScopes).toEqual([expect.objectContaining({ id: 2 })]); - }); - }); - - describe('deleting a new scope', () => { - it('should remove the scope from formScopes', () => { - factory({ - ...requiredProps, - name: 'feature_flag_1', - description: 'this is a feature flag', - scopes: [ - { - environmentScope: 'new_scope', - active: false, - id: uniqueId(INTERNAL_ID_PREFIX), - canUpdate: true, - protected: false, - strategies: [ - { - name: ROLLOUT_STRATEGY_ALL_USERS, - parameters: {}, - }, - ], - }, - ], - }); - - wrapper.find('.js-delete-scope').vm.$emit('click'); - - expect(wrapper.vm.formScopes).toEqual([]); - }); - }); - - describe('with * scope', () => { - beforeEach(() => { - factory({ - ...requiredProps, - name: 'feature_flag_1', - description: 'this is a feature flag', - scopes: [ - { - environmentScope: '*', - active: false, - canUpdate: false, - rolloutStrategy: ROLLOUT_STRATEGY_ALL_USERS, - rolloutPercentage: DEFAULT_PERCENT_ROLLOUT, - }, - ], - }); - }); - - it('renders read-only name', () => { - expect(wrapper.find('.js-scope-all').exists()).toEqual(true); - }); - }); - - describe('without permission to update', () => { - it('should have the flag name input disabled', () => { - const input = wrapper.find('#feature-flag-name'); - - expect(input.element.disabled).toBe(true); - }); - - it('should have the flag discription text area disabled', () => { - const textarea = wrapper.find('#feature-flag-description'); - - expect(textarea.element.disabled).toBe(true); - }); - - it('should have the scope that cannot be updated be disabled', () => { - const row = wrapper.findAll('.gl-responsive-table-row').at(2); - - expect(row.find(EnvironmentsDropdown).vm.disabled).toBe(true); - expect(row.find(GlToggle).props('disabled')).toBe(true); - expect(row.find('.js-delete-scope').exists()).toBe(false); - }); - }); - }); - - describe('on submit', () => { - const selectFirstRolloutStrategyOption = (dropdownIndex) => { - wrapper - .findAll('select.js-rollout-strategy') - .at(dropdownIndex) - .findAll('option') - .at(1) - .setSelected(); - }; - - beforeEach(() => { - factory({ - ...requiredProps, - name: 'feature_flag_1', - active: true, - description: 'this is a feature flag', - scopes: [ - { - id: 1, - environmentScope: 'production', - canUpdate: true, - protected: true, - active: false, - rolloutStrategy: ROLLOUT_STRATEGY_ALL_USERS, - rolloutPercentage: DEFAULT_PERCENT_ROLLOUT, - rolloutUserIds: '', - }, - ], - }); - - return wrapper.vm.$nextTick(); - }); - - it('should emit handleSubmit with the updated data', () => { - wrapper.find('#feature-flag-name').setValue('feature_flag_2'); - - return wrapper.vm - .$nextTick() - .then(() => { - wrapper - .find('.js-new-scope-name') - .find(EnvironmentsDropdown) - .vm.$emit('selectEnvironment', 'review'); - - return wrapper.vm.$nextTick(); - }) - .then(() => { - findAddNewScopeRow().find(GlToggle).vm.$emit('change', true); - }) - .then(() => { - findGlToggle().vm.$emit('change', true); - return wrapper.vm.$nextTick(); - }) - - .then(() => { - selectFirstRolloutStrategyOption(0); - return wrapper.vm.$nextTick(); - }) - .then(() => { - selectFirstRolloutStrategyOption(2); - return wrapper.vm.$nextTick(); - }) - .then(() => { - wrapper.find('.js-rollout-percentage').setValue('55'); - - return wrapper.vm.$nextTick(); - }) - .then(() => { - wrapper.find({ ref: 'submitButton' }).vm.$emit('click'); - - const data = wrapper.emitted().handleSubmit[0][0]; - - expect(data.name).toEqual('feature_flag_2'); - expect(data.description).toEqual('this is a feature flag'); - expect(data.active).toBe(true); - - expect(data.scopes).toEqual([ - { - id: 1, - active: true, - environmentScope: 'production', - canUpdate: true, - protected: true, - rolloutStrategy: ROLLOUT_STRATEGY_PERCENT_ROLLOUT, - rolloutPercentage: '55', - rolloutUserIds: '', - shouldIncludeUserIds: false, - }, - { - id: expect.any(String), - active: false, - environmentScope: 'review', - canUpdate: true, - protected: false, - rolloutStrategy: ROLLOUT_STRATEGY_ALL_USERS, - rolloutPercentage: DEFAULT_PERCENT_ROLLOUT, - rolloutUserIds: '', - }, - { - id: expect.any(String), - active: true, - environmentScope: '', - canUpdate: true, - protected: false, - rolloutStrategy: ROLLOUT_STRATEGY_PERCENT_ROLLOUT, - rolloutPercentage: DEFAULT_PERCENT_ROLLOUT, - rolloutUserIds: '', - shouldIncludeUserIds: false, - }, - ]); - }); - }); - }); }); describe('with strategies', () => { @@ -432,7 +97,6 @@ describe('feature flag form', () => { name: featureFlag.name, description: featureFlag.description, active: true, - version: NEW_VERSION_FLAG, strategies: [ { type: ROLLOUT_STRATEGY_PERCENT_ROLLOUT, diff --git a/spec/frontend/feature_flags/components/new_feature_flag_spec.js b/spec/frontend/feature_flags/components/new_feature_flag_spec.js index e209c14d8c7..fe98b6421d4 100644 --- a/spec/frontend/feature_flags/components/new_feature_flag_spec.js +++ b/spec/frontend/feature_flags/components/new_feature_flag_spec.js @@ -4,7 +4,6 @@ import Vuex from 'vuex'; import { TEST_HOST } from 'spec/test_constants'; import Form from '~/feature_flags/components/form.vue'; import NewFeatureFlag from '~/feature_flags/components/new_feature_flag.vue'; -import { ROLLOUT_STRATEGY_ALL_USERS, DEFAULT_PERCENT_ROLLOUT } from '~/feature_flags/constants'; import createStore from '~/feature_flags/store/new'; import { allUsersStrategy } from '../mock_data'; @@ -71,20 +70,6 @@ describe('New feature flag form', () => { expect(wrapper.find(Form).exists()).toEqual(true); }); - it('should render default * row', () => { - const defaultScope = { - id: expect.any(String), - environmentScope: '*', - active: true, - rolloutStrategy: ROLLOUT_STRATEGY_ALL_USERS, - rolloutPercentage: DEFAULT_PERCENT_ROLLOUT, - rolloutUserIds: '', - }; - expect(wrapper.vm.scopes).toEqual([defaultScope]); - - expect(wrapper.find(Form).props('scopes')).toContainEqual(defaultScope); - }); - it('has an all users strategy by default', () => { const strategies = wrapper.find(Form).props('strategies'); diff --git a/spec/frontend/feature_flags/mock_data.js b/spec/frontend/feature_flags/mock_data.js index 11a91e5b2a8..b5f09ac1957 100644 --- a/spec/frontend/feature_flags/mock_data.js +++ b/spec/frontend/feature_flags/mock_data.js @@ -16,86 +16,24 @@ export const featureFlag = { destroy_path: 'feature_flags/1', update_path: 'feature_flags/1', edit_path: 'feature_flags/1/edit', - scopes: [ + strategies: [ { - id: 1, - active: true, - environment_scope: '*', - can_update: true, - protected: false, - created_at: '2019-01-14T06:41:40.987Z', - updated_at: '2019-01-14T06:41:40.987Z', - strategies: [ - { - name: ROLLOUT_STRATEGY_ALL_USERS, - parameters: {}, - }, - ], + id: 9, + name: ROLLOUT_STRATEGY_ALL_USERS, + parameters: {}, + scopes: [{ id: 17, environment_scope: '*' }], }, { - id: 2, - active: false, - environment_scope: 'production', - can_update: true, - protected: false, - created_at: '2019-01-14T06:41:40.987Z', - updated_at: '2019-01-14T06:41:40.987Z', - strategies: [ - { - name: ROLLOUT_STRATEGY_ALL_USERS, - parameters: {}, - }, - ], + id: 8, + name: ROLLOUT_STRATEGY_PERCENT_ROLLOUT, + parameters: {}, + scopes: [{ id: 18, environment_scope: 'review/*' }], }, { - id: 3, - active: false, - environment_scope: 'review/*', - can_update: true, - protected: false, - created_at: '2019-01-14T06:41:40.987Z', - updated_at: '2019-01-14T06:41:40.987Z', - strategies: [ - { - name: ROLLOUT_STRATEGY_ALL_USERS, - parameters: {}, - }, - ], - }, - { - id: 4, - active: true, - environment_scope: 'development', - can_update: true, - protected: false, - created_at: '2019-01-14T06:41:40.987Z', - updated_at: '2019-01-14T06:41:40.987Z', - strategies: [ - { - name: ROLLOUT_STRATEGY_PERCENT_ROLLOUT, - parameters: { - percentage: '86', - }, - }, - ], - }, - { - id: 5, - active: true, - environment_scope: 'development', - can_update: true, - protected: false, - created_at: '2019-01-14T06:41:40.987Z', - updated_at: '2019-01-14T06:41:40.987Z', - strategies: [ - { - name: ROLLOUT_STRATEGY_FLEXIBLE_ROLLOUT, - parameters: { - rollout: '42', - stickiness: 'DEFAULT', - }, - }, - ], + id: 7, + name: ROLLOUT_STRATEGY_USER_ID, + parameters: { userIds: '1,2,3,4' }, + scopes: [{ id: 19, environment_scope: 'production' }], }, ], }; diff --git a/spec/frontend/feature_flags/store/edit/actions_spec.js b/spec/frontend/feature_flags/store/edit/actions_spec.js index afcac53468c..12fccd79170 100644 --- a/spec/frontend/feature_flags/store/edit/actions_spec.js +++ b/spec/frontend/feature_flags/store/edit/actions_spec.js @@ -1,11 +1,7 @@ import MockAdapter from 'axios-mock-adapter'; import testAction from 'helpers/vuex_action_helper'; import { TEST_HOST } from 'spec/test_constants'; -import { - NEW_VERSION_FLAG, - LEGACY_FLAG, - ROLLOUT_STRATEGY_ALL_USERS, -} from '~/feature_flags/constants'; +import { ROLLOUT_STRATEGY_ALL_USERS } from '~/feature_flags/constants'; import { updateFeatureFlag, requestUpdateFeatureFlag, @@ -19,7 +15,7 @@ import { } from '~/feature_flags/store/edit/actions'; import * as types from '~/feature_flags/store/edit/mutation_types'; import state from '~/feature_flags/store/edit/state'; -import { mapStrategiesToRails, mapFromScopesViewModel } from '~/feature_flags/store/helpers'; +import { mapStrategiesToRails } from '~/feature_flags/store/helpers'; import axios from '~/lib/utils/axios_utils'; jest.mock('~/lib/utils/url_utility'); @@ -46,46 +42,9 @@ describe('Feature flags Edit Module actions', () => { describe('success', () => { it('dispatches requestUpdateFeatureFlag and receiveUpdateFeatureFlagSuccess ', (done) => { const featureFlag = { - name: 'feature_flag', - description: 'feature flag', - scopes: [ - { - id: '1', - environmentScope: '*', - active: true, - shouldBeDestroyed: false, - canUpdate: true, - protected: false, - rolloutStrategy: ROLLOUT_STRATEGY_ALL_USERS, - }, - ], - version: LEGACY_FLAG, - active: true, - }; - mock.onPut(mockedState.endpoint, mapFromScopesViewModel(featureFlag)).replyOnce(200); - - testAction( - updateFeatureFlag, - featureFlag, - mockedState, - [], - [ - { - type: 'requestUpdateFeatureFlag', - }, - { - type: 'receiveUpdateFeatureFlagSuccess', - }, - ], - done, - ); - }); - it('handles new version flags as well', (done) => { - const featureFlag = { name: 'name', description: 'description', active: true, - version: NEW_VERSION_FLAG, strategies: [ { name: ROLLOUT_STRATEGY_ALL_USERS, diff --git a/spec/frontend/feature_flags/store/helpers_spec.js b/spec/frontend/feature_flags/store/helpers_spec.js index 711e2a1286e..2a6211c8cc1 100644 --- a/spec/frontend/feature_flags/store/helpers_spec.js +++ b/spec/frontend/feature_flags/store/helpers_spec.js @@ -1,351 +1,7 @@ -import { uniqueId } from 'lodash'; -import { - ROLLOUT_STRATEGY_ALL_USERS, - ROLLOUT_STRATEGY_PERCENT_ROLLOUT, - ROLLOUT_STRATEGY_USER_ID, - PERCENT_ROLLOUT_GROUP_ID, - INTERNAL_ID_PREFIX, - DEFAULT_PERCENT_ROLLOUT, - LEGACY_FLAG, - NEW_VERSION_FLAG, -} from '~/feature_flags/constants'; -import { - mapToScopesViewModel, - mapFromScopesViewModel, - createNewEnvironmentScope, - mapStrategiesToViewModel, - mapStrategiesToRails, -} from '~/feature_flags/store/helpers'; +import { NEW_VERSION_FLAG } from '~/feature_flags/constants'; +import { mapStrategiesToViewModel, mapStrategiesToRails } from '~/feature_flags/store/helpers'; describe('feature flags helpers spec', () => { - describe('mapToScopesViewModel', () => { - it('converts the data object from the Rails API into something more usable by Vue', () => { - const input = [ - { - id: 3, - environment_scope: 'environment_scope', - active: true, - can_update: true, - protected: true, - strategies: [ - { - name: ROLLOUT_STRATEGY_PERCENT_ROLLOUT, - parameters: { - percentage: '56', - }, - }, - { - name: ROLLOUT_STRATEGY_USER_ID, - parameters: { - userIds: '123,234', - }, - }, - ], - - _destroy: true, - }, - ]; - - const expected = [ - expect.objectContaining({ - id: 3, - environmentScope: 'environment_scope', - active: true, - canUpdate: true, - protected: true, - rolloutStrategy: ROLLOUT_STRATEGY_PERCENT_ROLLOUT, - rolloutPercentage: '56', - rolloutUserIds: '123, 234', - shouldBeDestroyed: true, - }), - ]; - - const actual = mapToScopesViewModel(input); - - expect(actual).toEqual(expected); - }); - - it('returns Boolean properties even when their Rails counterparts were not provided (are `undefined`)', () => { - const input = [ - { - id: 3, - environment_scope: 'environment_scope', - }, - ]; - - const [result] = mapToScopesViewModel(input); - - expect(result).toEqual( - expect.objectContaining({ - active: false, - canUpdate: false, - protected: false, - shouldBeDestroyed: false, - }), - ); - }); - - it('returns an empty array if null or undefined is provided as a parameter', () => { - expect(mapToScopesViewModel(null)).toEqual([]); - expect(mapToScopesViewModel(undefined)).toEqual([]); - }); - - describe('with user IDs per environment', () => { - let oldGon; - - beforeEach(() => { - oldGon = window.gon; - window.gon = { features: { featureFlagsUsersPerEnvironment: true } }; - }); - - afterEach(() => { - window.gon = oldGon; - }); - - it('sets the user IDs as a comma separated string', () => { - const input = [ - { - id: 3, - environment_scope: 'environment_scope', - active: true, - can_update: true, - protected: true, - strategies: [ - { - name: ROLLOUT_STRATEGY_PERCENT_ROLLOUT, - parameters: { - percentage: '56', - }, - }, - { - name: ROLLOUT_STRATEGY_USER_ID, - parameters: { - userIds: '123,234', - }, - }, - ], - - _destroy: true, - }, - ]; - - const expected = [ - { - id: 3, - environmentScope: 'environment_scope', - active: true, - canUpdate: true, - protected: true, - rolloutStrategy: ROLLOUT_STRATEGY_PERCENT_ROLLOUT, - rolloutPercentage: '56', - rolloutUserIds: '123, 234', - shouldBeDestroyed: true, - shouldIncludeUserIds: true, - }, - ]; - - const actual = mapToScopesViewModel(input); - - expect(actual).toEqual(expected); - }); - }); - }); - - describe('mapFromScopesViewModel', () => { - it('converts the object emitted from the Vue component into an object than is in the right format to be submitted to the Rails API', () => { - const input = { - name: 'name', - description: 'description', - active: true, - scopes: [ - { - id: 4, - environmentScope: 'environmentScope', - active: true, - canUpdate: true, - protected: true, - shouldBeDestroyed: true, - shouldIncludeUserIds: true, - rolloutStrategy: ROLLOUT_STRATEGY_PERCENT_ROLLOUT, - rolloutPercentage: '48', - rolloutUserIds: '123, 234', - }, - ], - }; - - const expected = { - operations_feature_flag: { - name: 'name', - description: 'description', - active: true, - version: LEGACY_FLAG, - scopes_attributes: [ - { - id: 4, - environment_scope: 'environmentScope', - active: true, - can_update: true, - protected: true, - _destroy: true, - strategies: [ - { - name: ROLLOUT_STRATEGY_PERCENT_ROLLOUT, - parameters: { - groupId: PERCENT_ROLLOUT_GROUP_ID, - percentage: '48', - }, - }, - { - name: ROLLOUT_STRATEGY_USER_ID, - parameters: { - userIds: '123,234', - }, - }, - ], - }, - ], - }, - }; - - const actual = mapFromScopesViewModel(input); - - expect(actual).toEqual(expected); - }); - - it('should strip out internal IDs', () => { - const input = { - scopes: [{ id: 3 }, { id: uniqueId(INTERNAL_ID_PREFIX) }], - }; - - const result = mapFromScopesViewModel(input); - const [realId, internalId] = result.operations_feature_flag.scopes_attributes; - - expect(realId.id).toBe(3); - expect(internalId.id).toBeUndefined(); - }); - - it('returns scopes_attributes as [] if param.scopes is null or undefined', () => { - let { - operations_feature_flag: { scopes_attributes: actualScopes }, - } = mapFromScopesViewModel({ scopes: null }); - - expect(actualScopes).toEqual([]); - - ({ - operations_feature_flag: { scopes_attributes: actualScopes }, - } = mapFromScopesViewModel({ scopes: undefined })); - - expect(actualScopes).toEqual([]); - }); - describe('with user IDs per environment', () => { - it('sets the user IDs as a comma separated string', () => { - const input = { - name: 'name', - description: 'description', - active: true, - scopes: [ - { - id: 4, - environmentScope: 'environmentScope', - active: true, - canUpdate: true, - protected: true, - shouldBeDestroyed: true, - rolloutStrategy: ROLLOUT_STRATEGY_PERCENT_ROLLOUT, - rolloutPercentage: '48', - rolloutUserIds: '123, 234', - shouldIncludeUserIds: true, - }, - ], - }; - - const expected = { - operations_feature_flag: { - name: 'name', - description: 'description', - version: LEGACY_FLAG, - active: true, - scopes_attributes: [ - { - id: 4, - environment_scope: 'environmentScope', - active: true, - can_update: true, - protected: true, - _destroy: true, - strategies: [ - { - name: ROLLOUT_STRATEGY_PERCENT_ROLLOUT, - parameters: { - groupId: PERCENT_ROLLOUT_GROUP_ID, - percentage: '48', - }, - }, - { - name: ROLLOUT_STRATEGY_USER_ID, - parameters: { - userIds: '123,234', - }, - }, - ], - }, - ], - }, - }; - - const actual = mapFromScopesViewModel(input); - - expect(actual).toEqual(expected); - }); - }); - }); - - describe('createNewEnvironmentScope', () => { - it('should return a new environment scope object populated with the default options', () => { - const expected = { - environmentScope: '', - active: false, - id: expect.stringContaining(INTERNAL_ID_PREFIX), - rolloutStrategy: ROLLOUT_STRATEGY_ALL_USERS, - rolloutPercentage: DEFAULT_PERCENT_ROLLOUT, - rolloutUserIds: '', - }; - - const actual = createNewEnvironmentScope(); - - expect(actual).toEqual(expected); - }); - - it('should return a new environment scope object with overrides applied', () => { - const overrides = { - environmentScope: 'environmentScope', - active: true, - }; - - const expected = { - environmentScope: 'environmentScope', - active: true, - id: expect.stringContaining(INTERNAL_ID_PREFIX), - rolloutStrategy: ROLLOUT_STRATEGY_ALL_USERS, - rolloutPercentage: DEFAULT_PERCENT_ROLLOUT, - rolloutUserIds: '', - }; - - const actual = createNewEnvironmentScope(overrides); - - expect(actual).toEqual(expected); - }); - - it('sets canUpdate and protected when called with featureFlagPermissions=true', () => { - expect(createNewEnvironmentScope({}, true)).toEqual( - expect.objectContaining({ - canUpdate: true, - protected: false, - }), - ); - }); - }); - describe('mapStrategiesToViewModel', () => { it('should map rails casing to view model casing', () => { expect( @@ -380,14 +36,14 @@ describe('feature flags helpers spec', () => { }); it('inserts spaces between user ids', () => { - const strategy = mapStrategiesToViewModel([ + const [strategy] = mapStrategiesToViewModel([ { id: '1', name: 'userWithId', parameters: { userIds: 'user1,user2,user3' }, scopes: [], }, - ])[0]; + ]); expect(strategy.parameters).toEqual({ userIds: 'user1, user2, user3' }); }); @@ -399,7 +55,6 @@ describe('feature flags helpers spec', () => { mapStrategiesToRails({ name: 'test', description: 'test description', - version: NEW_VERSION_FLAG, active: true, strategies: [ { @@ -421,8 +76,8 @@ describe('feature flags helpers spec', () => { operations_feature_flag: { name: 'test', description: 'test description', - version: NEW_VERSION_FLAG, active: true, + version: NEW_VERSION_FLAG, strategies_attributes: [ { id: '1', @@ -447,7 +102,6 @@ describe('feature flags helpers spec', () => { mapStrategiesToRails({ name: 'test', description: 'test description', - version: NEW_VERSION_FLAG, active: true, strategies: [ { @@ -462,8 +116,8 @@ describe('feature flags helpers spec', () => { operations_feature_flag: { name: 'test', description: 'test description', - version: NEW_VERSION_FLAG, active: true, + version: NEW_VERSION_FLAG, strategies_attributes: [ { id: '1', @@ -483,7 +137,6 @@ describe('feature flags helpers spec', () => { it('removes white space between user ids', () => { const result = mapStrategiesToRails({ name: 'test', - version: NEW_VERSION_FLAG, active: true, strategies: [ { @@ -503,7 +156,6 @@ describe('feature flags helpers spec', () => { it('preserves the value of active', () => { const result = mapStrategiesToRails({ name: 'test', - version: NEW_VERSION_FLAG, active: false, strategies: [], }); diff --git a/spec/frontend/feature_flags/store/index/actions_spec.js b/spec/frontend/feature_flags/store/index/actions_spec.js index ec311ef92a3..a59f99f538c 100644 --- a/spec/frontend/feature_flags/store/index/actions_spec.js +++ b/spec/frontend/feature_flags/store/index/actions_spec.js @@ -1,7 +1,6 @@ import MockAdapter from 'axios-mock-adapter'; import testAction from 'helpers/vuex_action_helper'; import { TEST_HOST } from 'spec/test_constants'; -import { mapToScopesViewModel } from '~/feature_flags/store/helpers'; import { requestFeatureFlags, receiveFeatureFlagsSuccess, @@ -255,7 +254,6 @@ describe('Feature flags actions', () => { beforeEach(() => { mockedState.featureFlags = getRequestData.feature_flags.map((flag) => ({ ...flag, - scopes: mapToScopesViewModel(flag.scopes || []), })); mock = new MockAdapter(axios); }); @@ -314,7 +312,6 @@ describe('Feature flags actions', () => { beforeEach(() => { mockedState.featureFlags = getRequestData.feature_flags.map((f) => ({ ...f, - scopes: mapToScopesViewModel(f.scopes || []), })); }); @@ -338,7 +335,6 @@ describe('Feature flags actions', () => { beforeEach(() => { mockedState.featureFlags = getRequestData.feature_flags.map((f) => ({ ...f, - scopes: mapToScopesViewModel(f.scopes || []), })); }); @@ -362,7 +358,6 @@ describe('Feature flags actions', () => { beforeEach(() => { mockedState.featureFlags = getRequestData.feature_flags.map((f) => ({ ...f, - scopes: mapToScopesViewModel(f.scopes || []), })); }); diff --git a/spec/frontend/feature_flags/store/index/mutations_spec.js b/spec/frontend/feature_flags/store/index/mutations_spec.js index b9354196c68..c19f459e124 100644 --- a/spec/frontend/feature_flags/store/index/mutations_spec.js +++ b/spec/frontend/feature_flags/store/index/mutations_spec.js @@ -1,4 +1,3 @@ -import { mapToScopesViewModel } from '~/feature_flags/store/helpers'; import * as types from '~/feature_flags/store/index/mutation_types'; import mutations from '~/feature_flags/store/index/mutations'; import state from '~/feature_flags/store/index/state'; @@ -49,15 +48,6 @@ describe('Feature flags store Mutations', () => { expect(stateCopy.hasError).toEqual(false); }); - it('should set featureFlags with the transformed data', () => { - const expected = getRequestData.feature_flags.map((flag) => ({ - ...flag, - scopes: mapToScopesViewModel(flag.scopes || []), - })); - - expect(stateCopy.featureFlags).toEqual(expected); - }); - it('should set count with the given data', () => { expect(stateCopy.count).toEqual(37); }); @@ -131,13 +121,11 @@ describe('Feature flags store Mutations', () => { beforeEach(() => { stateCopy.featureFlags = getRequestData.feature_flags.map((flag) => ({ ...flag, - scopes: mapToScopesViewModel(flag.scopes || []), })); stateCopy.count = { featureFlags: 1, userLists: 0 }; mutations[types.UPDATE_FEATURE_FLAG](stateCopy, { ...featureFlag, - scopes: mapToScopesViewModel(featureFlag.scopes || []), active: false, }); }); @@ -146,7 +134,6 @@ describe('Feature flags store Mutations', () => { expect(stateCopy.featureFlags).toEqual([ { ...featureFlag, - scopes: mapToScopesViewModel(featureFlag.scopes || []), active: false, }, ]); @@ -158,7 +145,6 @@ describe('Feature flags store Mutations', () => { stateCopy.featureFlags = getRequestData.feature_flags.map((flag) => ({ ...flag, ...flagState, - scopes: mapToScopesViewModel(flag.scopes || []), })); stateCopy.count = stateCount; @@ -174,7 +160,6 @@ describe('Feature flags store Mutations', () => { expect(stateCopy.featureFlags).toEqual([ { ...featureFlag, - scopes: mapToScopesViewModel(featureFlag.scopes || []), active: false, }, ]); @@ -185,7 +170,6 @@ describe('Feature flags store Mutations', () => { beforeEach(() => { stateCopy.featureFlags = getRequestData.feature_flags.map((flag) => ({ ...flag, - scopes: mapToScopesViewModel(flag.scopes || []), })); mutations[types.RECEIVE_UPDATE_FEATURE_FLAG_ERROR](stateCopy, featureFlag.id); }); @@ -194,7 +178,6 @@ describe('Feature flags store Mutations', () => { expect(stateCopy.featureFlags).toEqual([ { ...featureFlag, - scopes: mapToScopesViewModel(featureFlag.scopes || []), active: false, }, ]); 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( |