summaryrefslogtreecommitdiff
path: root/spec/features/projects/branches_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/projects/branches_spec.rb')
-rw-r--r--spec/features/projects/branches_spec.rb67
1 files changed, 49 insertions, 18 deletions
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