From a5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Wed, 16 Jun 2021 18:25:58 +0000 Subject: Add latest changes from gitlab-org/gitlab@14-0-stable-ee --- spec/features/projects/branches_spec.rb | 67 ++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 18 deletions(-) (limited to 'spec/features/projects/branches_spec.rb') diff --git a/spec/features/projects/branches_spec.rb b/spec/features/projects/branches_spec.rb index f805416b03d..0a79719f14a 100644 --- a/spec/features/projects/branches_spec.rb +++ b/spec/features/projects/branches_spec.rb @@ -88,10 +88,7 @@ RSpec.describe 'Branches' do it 'shows filtered branches', :js do visit project_branches_path(project) - branch_search = find('input[data-testid="branch-search"]') - - branch_search.set('fix') - branch_search.native.send_keys(:enter) + search_for_branch('fix') expect(page).to have_content('fix') expect(find('.all-branches')).to have_selector('li', count: 1) @@ -99,13 +96,14 @@ RSpec.describe 'Branches' do end describe 'Delete unprotected branch on Overview' do - it 'removes branch after confirmation', :js, quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/239019' do + it 'removes branch after confirmation', :js do visit project_branches_filtered_path(project, state: 'all') expect(all('.all-branches').last).to have_selector('li', count: 20) - accept_confirm { first('.js-branch-item .btn-danger').click } - expect(all('.all-branches').last).to have_selector('li', count: 19) + delete_branch_and_confirm + + expect(page).to have_content('Branch was deleted') end end @@ -151,10 +149,7 @@ RSpec.describe 'Branches' do it 'shows filtered branches', :js do visit project_branches_filtered_path(project, state: 'all') - branch_search = find('input[data-testid="branch-search"]') - - branch_search.set('fix') - branch_search.native.send_keys(:enter) + search_for_branch('fix') expect(page).to have_content('fix') expect(find('.all-branches')).to have_selector('li', count: 1) @@ -165,17 +160,39 @@ RSpec.describe 'Branches' do it 'removes branch after confirmation', :js do visit project_branches_filtered_path(project, state: 'all') - branch_search = find('input[data-testid="branch-search"]') + search_for_branch('fix') - branch_search.set('fix') - branch_search.native.send_keys(:enter) + expect(all('.all-branches').last).to have_selector('li', count: 1) - expect(page).to have_content('fix') - expect(find('.all-branches')).to have_selector('li', count: 1) - accept_confirm { find('.js-branch-fix .btn-danger').click } + delete_branch_and_confirm + + expect(page).to have_content('Branch was deleted') + + page.refresh + + search_for_branch('fix') expect(page).not_to have_content('fix') - expect(find('.all-branches')).to have_selector('li', count: 0) + expect(all('.all-branches').last).to have_selector('li', count: 0) + end + + context 'when the delete_branch_confirmation_modals feature flag is disabled' do + it 'removes branch after confirmation', :js do + stub_feature_flags(delete_branch_confirmation_modals: false) + + visit project_branches_filtered_path(project, state: 'all') + + search_for_branch('fix') + + expect(page).to have_content('fix') + expect(find('.all-branches')).to have_selector('li', count: 1) + accept_confirm do + within('.js-branch-item', match: :first) { click_link(title: 'Delete branch') } + end + + expect(page).not_to have_content('fix') + expect(find('.all-branches')).to have_selector('li', count: 0) + end end end @@ -323,4 +340,18 @@ RSpec.describe 'Branches' do def create_file(message: 'message', branch_name:) repository.create_file(user, generate(:branch), 'content', message: message, branch_name: branch_name) end + + def search_for_branch(name) + branch_search = find('input[data-testid="branch-search"]') + branch_search.set(name) + branch_search.native.send_keys(:enter) + end + + def delete_branch_and_confirm + find('.js-delete-branch-button', match: :first).click + + within '.modal-footer' do + click_button 'Yes, delete branch' + end + end end -- cgit v1.2.3