summaryrefslogtreecommitdiff
path: root/qa/qa/page/dashboard/groups.rb
blob: 3d098ac60cc56ce5691d665c5ec8b863a118baa0 (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
module QA
  module Page
    module Dashboard
      class Groups < Page::Base
        def prepare_sandbox
          sandbox_name = Runtime::Namespace.sandbox_name

          fill_in 'Filter by name...', with: sandbox_name

          if page.has_content?(sandbox_name)
            return click_link(sandbox_name)
          else
            click_on 'New group'

            populate_group_form(sandbox_name, "QA sandbox")
          end
        end

        def prepare_test_namespace
          namespace_name = Runtime::Namespace.name

          if page.has_content?('Subgroups')
            click_link 'Subgroups'

            if page.has_content?(namespace_name)
              return click_link(namespace_name)
            end

            # NOTE: Inconsistent capitalization here in the UI
            click_on 'New Subgroup'
          else
            click_on 'New group'
          end

          populate_group_form(
            namespace_name,
            "QA test run at #{Runtime::Namespace.time}"
          )
        end

        private

        def populate_group_form(name, description)
          fill_in 'group_path', with: name
          fill_in 'group_description', with: description
          choose 'Private'

          click_button 'Create group'
        end
      end
    end
  end
end