diff options
Diffstat (limited to 'spec/features/protected_branches_spec.rb')
-rw-r--r-- | spec/features/protected_branches_spec.rb | 52 |
1 files changed, 47 insertions, 5 deletions
diff --git a/spec/features/protected_branches_spec.rb b/spec/features/protected_branches_spec.rb index 207b74c990a..6fbed21acdb 100644 --- a/spec/features/protected_branches_spec.rb +++ b/spec/features/protected_branches_spec.rb @@ -21,13 +21,28 @@ RSpec.describe 'Protected Branches', :js do expect(ProtectedBranch.count).to eq(1) end - it 'does not allow developer to removes protected branch' do + 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_css('.btn-danger.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 |