Welcome to mirror list, hosted at ThFree Co, Russian Federation.

source_editor_spec_helpers.rb « features « helpers « support « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 57057b47fbbf1b69476f94e60b36a06dcf1992a4 (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
# frozen_string_literal: true

# These helpers help you interact within the Source Editor (single-file editor, snippets, etc.).
#
module Spec
  module Support
    module Helpers
      module Features
        module SourceEditorSpecHelpers
          include ActionView::Helpers::JavaScriptHelper

          def editor_set_value(value)
            editor = find('.monaco-editor')
            uri = editor['data-uri']

            execute_script("monaco.editor.getModel('#{uri}').setValue('#{escape_javascript(value)}')")
          end

          def editor_get_value
            editor = find('.monaco-editor')
            uri = editor['data-uri']

            evaluate_script("monaco.editor.getModel('#{uri}').getValue()")
          end
        end
      end
    end
  end
end