summaryrefslogtreecommitdiff
path: root/qa/qa/page/file/shared/editor.rb
blob: f392d52747e4af9890045b0bbc9274dcea038842 (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
# frozen_string_literal: true

module QA
  module Page
    module File
      module Shared
        module Editor
          extend QA::Page::PageConcern

          def self.included(base)
            super

            base.view 'app/views/projects/blob/_editor.html.haml' do
              element :source_editor_preview_container
            end
          end

          def add_content(content)
            text_area.set content
          end

          def remove_content
            if page.driver.browser.capabilities.platform.include? "mac"
              text_area.send_keys([:command, 'a'], :backspace)
            else
              text_area.send_keys([:control, 'a'], :backspace)
            end
          end

          private

          def text_area
            within_element :source_editor_preview_container do
              find('textarea', visible: false)
            end
          end
        end
      end
    end
  end
end