summaryrefslogtreecommitdiff
path: root/qa/qa/page/file/form.rb
blob: f6e502f500b55262f5c7bd06f7003c9cf06bb14d (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
module QA
  module Page
    module File
      class Form < Page::Base
        include Shared::CommitMessage

        view 'app/views/projects/blob/_editor.html.haml' do
          element :file_name, "text_field_tag 'file_name'"
          element :editor, '#editor'
        end

        view 'app/views/projects/_commit_button.html.haml' do
          element :commit_changes, "button_tag 'Commit changes'"
        end

        def add_name(name)
          fill_in 'file_name', with: name
        end

        def add_content(content)
          text_area.set content
        end

        def remove_content
          text_area.send_keys([:command, 'a'], :backspace)
        end

        def commit_changes
          click_on 'Commit changes'
        end

        private

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