summaryrefslogtreecommitdiff
path: root/qa/qa/page/project/show.rb
blob: fcc4bb79c10325505a3a8c35bbdd4a28220e8e06 (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# frozen_string_literal: true

module QA
  module Page
    module Project
      class Show < Page::Base
        include Page::Component::ClonePanel

        view 'app/views/projects/_last_push.html.haml' do
          element :create_merge_request
        end

        view 'app/views/projects/_home_panel.html.haml' do
          element :project_name
        end

        view 'app/views/layouts/header/_new_dropdown.haml' do
          element :new_menu_toggle
          element :new_issue_link, "link_to _('New issue'), new_project_issue_path(@project)" # rubocop:disable QA/ElementWithPattern
        end

        view 'app/views/shared/_ref_switcher.html.haml' do
          element :branches_select
          element :branches_dropdown
        end

        view 'app/views/projects/buttons/_fork.html.haml' do
          element :fork_label, "%span= s_('ProjectOverview|Fork')" # rubocop:disable QA/ElementWithPattern
          element :fork_link, "link_to new_project_fork_path(@project)" # rubocop:disable QA/ElementWithPattern
        end

        view 'app/views/projects/_files.html.haml' do
          element :tree_holder, '.tree-holder' # rubocop:disable QA/ElementWithPattern
        end

        view 'app/views/projects/buttons/_dropdown.html.haml' do
          element :create_new_dropdown
          element :new_file_option
        end

        view 'app/views/projects/tree/_tree_header.html.haml' do
          element :web_ide_button
        end

        def project_name
          find('.qa-project-name').text
        end

        def create_new_file!
          click_element :create_new_dropdown
          click_element :new_file_option
        end

        def switch_to_branch(branch_name)
          find_element(:branches_select).click

          within_element(:branches_dropdown) do
            click_on branch_name
          end
        end

        def last_commit_content
          find_element(:commit_content).text
        end

        def new_merge_request
          wait(reload: true) do
            has_css?(element_selector_css(:create_merge_request))
          end

          click_element :create_merge_request
        end

        def wait_for_import
          wait(reload: true) do
            has_css?('.tree-holder')
          end
        end

        def go_to_new_issue
          click_element :new_menu_toggle

          click_link 'New issue'
        end

        def fork_project
          click_on 'Fork'
        end

        def open_web_ide!
          click_element :web_ide_button
        end
      end
    end
  end
end