summaryrefslogtreecommitdiff
path: root/spec/features/projects/branches/user_deletes_branch_spec.rb
blob: 3b8f49accc5d61e11e766f5e7cea764b69af36ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# frozen_string_literal: true

require "spec_helper"

RSpec.describe "User deletes branch", :js do
  let_it_be(:user) { create(:user) }

  let(:project) { create(:project, :repository) }

  before do
    project.add_developer(user)
    sign_in(user)
  end

  it "deletes branch", :js do
    visit(project_branches_path(project))

    branch_search = find('input[data-testid="branch-search"]')

    branch_search.set('improve/awesome')
    branch_search.native.send_keys(:enter)

    page.within(".js-branch-improve\\/awesome") do
      find('.js-delete-branch-button').click
    end

    page.within '.modal-footer' do
      click_button 'Yes, delete branch'
    end

    wait_for_requests

    expect(page).to have_content('Branch was deleted')
  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 "deletes branch" do
      visit(project_branches_path(project))

      branch_search = find('input[data-testid="branch-search"]')

      branch_search.set('improve/awesome')
      branch_search.native.send_keys(:enter)

      page.within(".js-branch-improve\\/awesome") do
        accept_alert { click_link(title: 'Delete branch') }
      end

      wait_for_requests

      expect(page).to have_css(".js-branch-improve\\/awesome", visible: :hidden)
    end
  end
end