diff options
Diffstat (limited to 'spec/features/projects/feature_flags')
4 files changed, 47 insertions, 22 deletions
diff --git a/spec/features/projects/feature_flags/user_creates_feature_flag_spec.rb b/spec/features/projects/feature_flags/user_creates_feature_flag_spec.rb index eaafc7e607b..4af5c91479a 100644 --- a/spec/features/projects/feature_flags/user_creates_feature_flag_spec.rb +++ b/spec/features/projects/feature_flags/user_creates_feature_flag_spec.rb @@ -10,7 +10,6 @@ RSpec.describe 'User creates feature flag', :js do before do project.add_developer(user) - stub_feature_flags(feature_flag_permissions: false) sign_in(user) end diff --git a/spec/features/projects/feature_flags/user_deletes_feature_flag_spec.rb b/spec/features/projects/feature_flags/user_deletes_feature_flag_spec.rb index 581709aacee..43540dc4522 100644 --- a/spec/features/projects/feature_flags/user_deletes_feature_flag_spec.rb +++ b/spec/features/projects/feature_flags/user_deletes_feature_flag_spec.rb @@ -15,7 +15,6 @@ RSpec.describe 'User deletes feature flag', :js do before do project.add_developer(user) - stub_feature_flags(feature_flag_permissions: false) sign_in(user) visit(project_feature_flags_path(project)) diff --git a/spec/features/projects/feature_flags/user_sees_feature_flag_list_spec.rb b/spec/features/projects/feature_flags/user_sees_feature_flag_list_spec.rb index d922bc1f4a0..30bfcb645f4 100644 --- a/spec/features/projects/feature_flags/user_sees_feature_flag_list_spec.rb +++ b/spec/features/projects/feature_flags/user_sees_feature_flag_list_spec.rb @@ -16,33 +16,63 @@ RSpec.describe 'User sees feature flag list', :js do sign_in(user) end - context 'with legacy feature flags' do + context 'with feature flags' do before do - create_flag(project, 'ci_live_trace', false, version: :legacy_flag).tap do |feature_flag| - create_scope(feature_flag, 'review/*', true) + create_flag(project, 'ci_live_trace', false).tap do |feature_flag| + create_strategy(feature_flag).tap do |strat| + create(:operations_scope, strategy: strat, environment_scope: '*') + create(:operations_scope, strategy: strat, environment_scope: 'review/*') + end end - create_flag(project, 'drop_legacy_artifacts', false, version: :legacy_flag) - create_flag(project, 'mr_train', true, version: :legacy_flag).tap do |feature_flag| - create_scope(feature_flag, 'production', false) + create_flag(project, 'drop_legacy_artifacts', false) + create_flag(project, 'mr_train', true).tap do |feature_flag| + create_strategy(feature_flag).tap do |strat| + create(:operations_scope, strategy: strat, environment_scope: 'production') + end end + create(:operations_feature_flag, :new_version_flag, project: project, + name: 'my_flag', active: false) end - it 'shows empty page' do + it 'shows the user the first flag' do visit(project_feature_flags_path(project)) - expect(page).to have_text 'Get started with feature flags' - expect(page).to have_selector('.btn-confirm', text: 'New feature flag') - expect(page).to have_selector('[data-qa-selector="configure_feature_flags_button"]', text: 'Configure') + within_feature_flag_row(1) do + expect(page.find('.js-feature-flag-id')).to have_content('^1') + expect(page.find('.feature-flag-name')).to have_content('ci_live_trace') + expect_status_toggle_button_not_to_be_checked + + within_feature_flag_scopes do + expect(page.find('[data-testid="strategy-badge"]')).to have_content('All Users: All Environments, review/*') + end + end end - end - context 'with new version flags' do - before do - create(:operations_feature_flag, :new_version_flag, project: project, - name: 'my_flag', active: false) + it 'shows the user the second flag' do + visit(project_feature_flags_path(project)) + + within_feature_flag_row(2) do + expect(page.find('.js-feature-flag-id')).to have_content('^2') + expect(page.find('.feature-flag-name')).to have_content('drop_legacy_artifacts') + expect_status_toggle_button_not_to_be_checked + end + end + + it 'shows the user the third flag' do + visit(project_feature_flags_path(project)) + + within_feature_flag_row(3) do + expect(page.find('.js-feature-flag-id')).to have_content('^3') + expect(page.find('.feature-flag-name')).to have_content('mr_train') + expect_status_toggle_button_to_be_checked + + within_feature_flag_scopes do + expect(page.find('[data-testid="strategy-badge"]')).to have_content('All Users: production') + end + end end - it 'user updates the status toggle' do + it 'allows the user to update the status toggle' do visit(project_feature_flags_path(project)) within_feature_flag_row(1) do @@ -58,7 +88,7 @@ RSpec.describe 'User sees feature flag list', :js do visit(project_feature_flags_path(project)) end - it 'shows empty page' do + it 'shows the empty page' do expect(page).to have_text 'Get started with feature flags' expect(page).to have_selector('.btn-confirm', text: 'New feature flag') expect(page).to have_selector('[data-qa-selector="configure_feature_flags_button"]', text: 'Configure') diff --git a/spec/features/projects/feature_flags/user_updates_feature_flag_spec.rb b/spec/features/projects/feature_flags/user_updates_feature_flag_spec.rb index 9c03a26abc8..f6330491886 100644 --- a/spec/features/projects/feature_flags/user_updates_feature_flag_spec.rb +++ b/spec/features/projects/feature_flags/user_updates_feature_flag_spec.rb @@ -13,9 +13,6 @@ RSpec.describe 'User updates feature flag', :js do end before do - stub_feature_flags( - feature_flag_permissions: false - ) sign_in(user) end |