diff --git a/app/assets/javascripts/feature_flags/store/helpers.js b/app/assets/javascripts/feature_flags/store/helpers.js index 300709f2771403496fcf4ca2da4095c8920facd6..a7231f90be52ed41b77cd6427456a37da42f857d 100644 --- a/app/assets/javascripts/feature_flags/store/helpers.js +++ b/app/assets/javascripts/feature_flags/store/helpers.js @@ -52,7 +52,7 @@ const mapStrategyToRails = (strategy) => { }; if (strategy.name === ROLLOUT_STRATEGY_GITLAB_USER_LIST) { - mappedStrategy.user_list_id = strategy.userList.id; + mappedStrategy.user_list_id = strategy.userList?.id; } return mappedStrategy; }; diff --git a/app/assets/javascripts/feature_flags/utils.js b/app/assets/javascripts/feature_flags/utils.js index 47deeab05714cfdb3d9de6c7f304fb4f63b78c09..f2eff68c6388370f29bdd8f9175d23d0096d1dd6 100644 --- a/app/assets/javascripts/feature_flags/utils.js +++ b/app/assets/javascripts/feature_flags/utils.js @@ -41,7 +41,7 @@ const badgeTextByType = { }, [ROLLOUT_STRATEGY_GITLAB_USER_LIST]: { name: s__('FeatureFlags|User List'), - parameters: ({ user_list: { name } }) => name, + parameters: (data) => data?.user_list?.name || '', }, }; 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 7f01a510001fa22164789757c31130cd127ea55c..688b374f66af2ec8d519b80710b93d08b5b2bc85 100644 --- a/spec/frontend/feature_flags/components/feature_flags_table_spec.js +++ b/spec/frontend/feature_flags/components/feature_flags_table_spec.js @@ -54,6 +54,20 @@ const getDefaultProps = () => ({ name: 'flag without description', description: '', }, + { + id: 3, + iid: 3, + active: true, + name: 'flag with invalid strategy', + scopes: [], + strategies: [ + { + name: ROLLOUT_STRATEGY_GITLAB_USER_LIST, + parameters: {}, + scopes: [{ environment_scope: '*' }], + }, + ], + }, ], }); @@ -220,7 +234,11 @@ describe('Feature flag table', () => { }); it('shows the name of a user list for user list', () => { - expect(labels.at(3).text()).toContain('User List - test list'); + expect(labels.at(3).text()).toBe('User List - test list: All Environments'); + }); + + it('shows the empty name of a user list if it is not provided', () => { + expect(labels.at(4).text()).toBe('User List: All Environments'); }); it('renders a feature flag without an iid', () => {