Commit d6f7cbd1 authored by Andrew Fontaine's avatar Andrew Fontaine

Merge branch 'default-dropdown-to-all-users' into 'master'

Default Feature Flag Strategy Dropdown to All Users

See merge request gitlab-org/gitlab!35883
parents 908a314a cbc6f400
......@@ -175,7 +175,7 @@ export default {
},
addStrategy() {
this.formStrategies.push({ name: '', parameters: {}, scopes: [] });
this.formStrategies.push({ name: ROLLOUT_STRATEGY_ALL_USERS, parameters: {}, scopes: [] });
},
deleteStrategy(s) {
......
......@@ -3,7 +3,12 @@ import { createNamespacedHelpers } from 'vuex';
import { GlAlert } from '@gitlab/ui';
import store from '../store/index';
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 featureFlagsMixin from '~/vue_shared/mixins/gl_feature_flags_mixin';
......@@ -58,7 +63,7 @@ export default {
return this.glFeatures.featureFlagsNewVersion;
},
strategies() {
return [{ name: '', parameters: {}, scopes: [] }];
return [{ name: ROLLOUT_STRATEGY_ALL_USERS, parameters: {}, scopes: [] }];
},
},
created() {
......
---
title: Default new feature flag strategies to all users
merge_request: 35883
author:
type: changed
......@@ -14,7 +14,7 @@ import {
NEW_VERSION_FLAG,
} from 'ee/feature_flags/constants';
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';
jest.mock('ee/api.js');
......@@ -454,9 +454,15 @@ describe('feature flag form', () => {
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');
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', () => {
......
......@@ -9,6 +9,7 @@ import {
DEFAULT_PERCENT_ROLLOUT,
NEW_FLAG_ALERT,
} from 'ee/feature_flags/constants';
import { allUsersStrategy } from '../mock_data';
describe('New feature flag form', () => {
let wrapper;
......@@ -74,6 +75,7 @@ describe('New feature flag form', () => {
expect(wrapper.find(Form).props('scopes')).toContainEqual(defaultScope);
});
it('should alert users that feature flags are changing soon', () => {
expect(wrapper.find(GlAlert).text()).toBe(NEW_FLAG_ALERT);
});
......@@ -81,4 +83,10 @@ describe('New feature flag form', () => {
it('should pass in the project ID', () => {
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 = {
updated_at: '2020-02-04T08:13:10.507Z',
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