summaryrefslogtreecommitdiff
path: root/qa/qa/page/dashboard/snippet/new.rb
blob: 4a8e65e20afe86ca7343016ed8bc7275c5b0b33f (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
# frozen_string_literal: true

module QA
  module Page
    module Dashboard
      module Snippet
        class New < Page::Base
          view 'app/views/shared/form_elements/_description.html.haml' do
            element :issuable_form_description
          end

          view 'app/views/shared/snippets/_form.html.haml' do
            element :snippet_title
            element :snippet_file_name
            element :create_snippet_button
          end

          def fill_title(title)
            fill_element :snippet_title, title
          end

          def fill_description(description)
            fill_element :issuable_form_description, description
          end

          def set_visibility(visibility)
            choose visibility
          end

          def fill_file_name(name)
            finished_loading?
            fill_element :snippet_file_name, name
          end

          def fill_file_content(content)
            finished_loading?
            text_area.set content
          end

          def click_create_snippet_button
            click_element :create_snippet_button
          end

          private

          def text_area
            find('#editor>textarea', visible: false)
          end
        end
      end
    end
  end
end