diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-28 18:10:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-28 18:10:28 +0300 |
commit | fcfd395a4b4d60f017a4512418a3a9e12cdc5e3a (patch) | |
tree | 6fe7879f93d1cbe3b93007911787caec92a90cde /spec/features/protected_branches_spec.rb | |
parent | 0d8df625a2ee3562cf1b2bdac46a429f69b06daf (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features/protected_branches_spec.rb')
-rw-r--r-- | spec/features/protected_branches_spec.rb | 50 |
1 files changed, 46 insertions, 4 deletions
diff --git a/spec/features/protected_branches_spec.rb b/spec/features/protected_branches_spec.rb index 2436132297e..6fbed21acdb 100644 --- a/spec/features/protected_branches_spec.rb +++ b/spec/features/protected_branches_spec.rb @@ -27,7 +27,22 @@ RSpec.describe 'Protected Branches', :js do find('input[data-testid="branch-search"]').set('fix') find('input[data-testid="branch-search"]').native.send_keys(:enter) - expect(page).to have_selector('button[data-testid="remove-protected-branch"][disabled]') + expect(page).to have_button('Only a project maintainer or owner can delete a protected branch', disabled: true) + end + + context 'when feature flag :delete_branch_confirmation_modals is disabled' do + before do + stub_feature_flags(delete_branch_confirmation_modals: false) + end + + it 'does not allow developer to remove protected branch' do + visit project_branches_path(project) + + find('input[data-testid="branch-search"]').set('fix') + find('input[data-testid="branch-search"]').native.send_keys(:enter) + + expect(page).to have_selector('button[data-testid="remove-protected-branch"][disabled]') + end end end end @@ -52,17 +67,44 @@ RSpec.describe 'Protected Branches', :js do expect(page).to have_content('fix') expect(find('.all-branches')).to have_selector('li', count: 1) - page.find('[data-target="#modal-delete-branch"]').click - expect(page).to have_css('.js-delete-branch[disabled]') + expect(page).to have_button('Delete protected branch', disabled: false) + + page.find('.js-delete-branch-button').click fill_in 'delete_branch_input', with: 'fix' - click_link 'Delete protected branch' + click_button 'Yes, delete protected branch' find('input[data-testid="branch-search"]').set('fix') find('input[data-testid="branch-search"]').native.send_keys(:enter) expect(page).to have_content('No branches to show') end + + context 'when the feature flag :delete_branch_confirmation_modals is disabled' do + before do + stub_feature_flags(delete_branch_confirmation_modals: false) + end + + it 'removes branch after modal confirmation' do + visit project_branches_path(project) + + find('input[data-testid="branch-search"]').set('fix') + find('input[data-testid="branch-search"]').native.send_keys(:enter) + + expect(page).to have_content('fix') + expect(find('.all-branches')).to have_selector('li', count: 1) + page.find('[data-target="#modal-delete-branch"]').click + + expect(page).to have_css('.js-delete-branch[disabled]') + fill_in 'delete_branch_input', with: 'fix' + click_link 'Delete protected branch' + + find('input[data-testid="branch-search"]').set('fix') + find('input[data-testid="branch-search"]').native.send_keys(:enter) + + expect(page).to have_content('No branches to show') + end + end end end |