Commit cbc6f400 authored by Jason Goodman's avatar Jason Goodman Committed by Andrew Fontaine

Default feature flag strategy dropdown to all users

Default to all users for new flags and existing flags
parent 6566448f
...@@ -175,7 +175,7 @@ export default { ...@@ -175,7 +175,7 @@ export default {
}, },
addStrategy() { addStrategy() {
this.formStrategies.push({ name: '', parameters: {}, scopes: [] }); this.formStrategies.push({ name: ROLLOUT_STRATEGY_ALL_USERS, parameters: {}, scopes: [] });
}, },
deleteStrategy(s) { deleteStrategy(s) {
......
...@@ -3,7 +3,12 @@ import { createNamespacedHelpers } from 'vuex'; ...@@ -3,7 +3,12 @@ import { createNamespacedHelpers } from 'vuex';
import { GlAlert } from '@gitlab/ui'; import { GlAlert } from '@gitlab/ui';
import store from '../store/index'; import store from '../store/index';
import FeatureFlagForm from './form.vue'; import FeatureFlagForm from './form.vue';
import { LEGACY_FLAG, NEW_VERSION_FLAG, NEW_FLAG_ALERT } from '../constants'; import {
LEGACY_FLAG,
NEW_VERSION_FLAG,
NEW_FLAG_ALERT,
ROLLOUT_STRATEGY_ALL_USERS,
} from '../constants';
import { createNewEnvironmentScope } from '../store/modules/helpers'; import { createNewEnvironmentScope } from '../store/modules/helpers';
import featureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin'; import featureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
...@@ -58,7 +63,7 @@ export default { ...@@ -58,7 +63,7 @@ export default {
return this.glFeatures.featureFlagsNewVersion; return this.glFeatures.featureFlagsNewVersion;
}, },
strategies() { strategies() {
return [{ name: '', parameters: {}, scopes: [] }]; return [{ name: ROLLOUT_STRATEGY_ALL_USERS, parameters: {}, scopes: [] }];
}, },
}, },
created() { created() {
......
---
title: Default new feature flag strategies to all users
merge_request: 35883
author:
type: changed
...@@ -14,7 +14,7 @@ import { ...@@ -14,7 +14,7 @@ import {
NEW_VERSION_FLAG, NEW_VERSION_FLAG,
} from 'ee/feature_flags/constants'; } from 'ee/feature_flags/constants';
import ToggleButton from '~/vue_shared/components/toggle_button.vue'; import ToggleButton from '~/vue_shared/components/toggle_button.vue';
import { featureFlag, userList } from '../mock_data'; import { featureFlag, userList, allUsersStrategy } from '../mock_data';
import RelatedIssuesRoot from 'ee/related_issues/components/related_issues_root.vue'; import RelatedIssuesRoot from 'ee/related_issues/components/related_issues_root.vue';
jest.mock('ee/api.js'); jest.mock('ee/api.js');
...@@ -454,9 +454,15 @@ describe('feature flag form', () => { ...@@ -454,9 +454,15 @@ describe('feature flag form', () => {
expect(wrapper.findAll(Strategy)).toHaveLength(2); expect(wrapper.findAll(Strategy)).toHaveLength(2);
}); });
it('should add a strategy when clicking the Add button', () => { it('adds an all users strategy when clicking the Add button', () => {
wrapper.find(GlDeprecatedButton).vm.$emit('click'); wrapper.find(GlDeprecatedButton).vm.$emit('click');
return wrapper.vm.$nextTick().then(() => expect(wrapper.findAll(Strategy)).toHaveLength(3));
return wrapper.vm.$nextTick().then(() => {
const strategies = wrapper.findAll(Strategy);
expect(strategies).toHaveLength(3);
expect(strategies.at(2).props('strategy')).toEqual(allUsersStrategy);
});
}); });
it('should remove a strategy on delete', () => { it('should remove a strategy on delete', () => {
......
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
DEFAULT_PERCENT_ROLLOUT, DEFAULT_PERCENT_ROLLOUT,
NEW_FLAG_ALERT, NEW_FLAG_ALERT,
} from 'ee/feature_flags/constants'; } from 'ee/feature_flags/constants';
import { allUsersStrategy } from '../mock_data';
describe('New feature flag form', () => { describe('New feature flag form', () => {
let wrapper; let wrapper;
...@@ -74,6 +75,7 @@ describe('New feature flag form', () => { ...@@ -74,6 +75,7 @@ describe('New feature flag form', () => {
expect(wrapper.find(Form).props('scopes')).toContainEqual(defaultScope); expect(wrapper.find(Form).props('scopes')).toContainEqual(defaultScope);
}); });
it('should alert users that feature flags are changing soon', () => { it('should alert users that feature flags are changing soon', () => {
expect(wrapper.find(GlAlert).text()).toBe(NEW_FLAG_ALERT); expect(wrapper.find(GlAlert).text()).toBe(NEW_FLAG_ALERT);
}); });
...@@ -81,4 +83,10 @@ describe('New feature flag form', () => { ...@@ -81,4 +83,10 @@ describe('New feature flag form', () => {
it('should pass in the project ID', () => { it('should pass in the project ID', () => {
expect(wrapper.find(Form).props('projectId')).toBe('8'); expect(wrapper.find(Form).props('projectId')).toBe('8');
}); });
it('has an all users strategy by default', () => {
const strategies = wrapper.find(Form).props('strategies');
expect(strategies).toEqual([allUsersStrategy]);
});
}); });
...@@ -100,3 +100,9 @@ export const userList = { ...@@ -100,3 +100,9 @@ export const userList = {
updated_at: '2020-02-04T08:13:10.507Z', updated_at: '2020-02-04T08:13:10.507Z',
path: '/path/to/user/list', path: '/path/to/user/list',
}; };
export const allUsersStrategy = {
name: ROLLOUT_STRATEGY_ALL_USERS,
parameters: {},
scopes: [],
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment