summaryrefslogtreecommitdiff
path: root/qa/qa/page/project/branches/show.rb
blob: 7163bc7464d120c832552e507b14f93cb62aa9da (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
59
60
61
62
63
64
65
66
# frozen_string_literal: true

module QA
  module Page
    module Project
      module Branches
        class Show < Page::Base
          view 'app/assets/javascripts/branches/components/delete_branch_button.vue' do
            element :delete_branch_button
          end

          view 'app/assets/javascripts/branches/components/delete_branch_modal.vue' do
            element :delete_branch_confirmation_button
          end

          view 'app/views/projects/branches/_branch.html.haml' do
            element :badge_content
            element :branch_container
            element :branch_link
          end

          view 'app/views/projects/branches/_panel.html.haml' do
            element :all_branches_container
          end

          view 'app/assets/javascripts/branches/components/delete_merged_branches.vue' do
            element :delete_merged_branches_button
            element :delete_merged_branches_input
            element :delete_merged_branches_confirmation_button
          end

          def delete_branch(branch_name)
            within_element(:branch_container, name: branch_name) do
              click_element(:delete_branch_button)
            end

            click_element(:delete_branch_confirmation_button)

            finished_loading?
          end

          def has_no_branch?(branch_name, reload: false)
            wait_until(reload: reload) do
              within_element(:all_branches_container) do
                has_no_element?(:branch_link, text: branch_name)
              end
            end
          end

          def has_branch_with_badge?(branch_name, badge)
            within_element(:branch_container, name: branch_name) do
              has_element?(:badge_content, text: badge)
            end
          end

          def delete_merged_branches(branches_length)
            click_element(:delete_merged_branches_button)
            fill_element(:delete_merged_branches_input, branches_length)
            click_element(:delete_merged_branches_confirmation_button)
            finished_loading?
          end
        end
      end
    end
  end
end