summaryrefslogtreecommitdiff
path: root/qa/qa/page/dashboard/projects.rb
blob: c0108d85365f1e6217c108df98c40e88eaf2a44c (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
# frozen_string_literal: true

module QA
  module Page
    module Dashboard
      class Projects < Page::Base
        view 'app/views/shared/projects/_search_form.html.haml' do
          element :project_filter_form, required: true
        end

        view 'app/views/shared/projects/_project.html.haml' do
          element :project_content
          element :user_role_content
        end

        view 'app/views/dashboard/_projects_head.html.haml' do
          element :new_project_button
        end

        def has_project_with_access_role?(project_name, access_role)
          within_element(:project_content, text: project_name) do
            has_element?(:user_role_content, text: access_role)
          end
        end

        def go_to_project(name)
          filter_by_name(name)

          find_link(text: name).click
        end

        def click_new_project_button
          click_element(:new_project_button, Page::Project::New)
        end

        def self.path
          '/'
        end

        def clear_project_filter
          fill_element(:project_filter_form, "")
        end

        private

        def filter_by_name(name)
          within_element(:project_filter_form) do
            fill_in :name, with: name
          end
        end
      end
    end
  end
end

QA::Page::Dashboard::Projects.prepend_mod_with('Page::Dashboard::Projects', namespace: QA)