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

snippet_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: dc718b1b212d9586c6d61338a42dc66f455c08c6 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# frozen_string_literal: true

# These helpers help you interact within the Source Editor (single-file editor, snippets, etc.).
#

require Rails.root.join("spec/support/helpers/features/source_editor_spec_helpers.rb")

module Spec
  module Support
    module Helpers
      module Features
        module SnippetSpecHelpers
          include ActionView::Helpers::JavaScriptHelper
          include Spec::Support::Helpers::Features::SourceEditorSpecHelpers

          def snippet_description_locator
            'snippet-description'
          end

          def snippet_blob_path_locator
            'snippet_file_name'
          end

          def snippet_description_view_selector
            '.snippet-header .snippet-description'
          end

          def snippet_description_field_collapsed
            find('.js-description-input').find('input,textarea')
          end

          def snippet_get_first_blob_path
            page.find_field('snippet_file_name', match: :first).value
          end

          def snippet_get_first_blob_value
            page.find('.gl-source-editor', match: :first)
          end

          def snippet_description_value
            page.find_field(snippet_description_locator).value
          end

          def snippet_fill_in_visibility(text)
            page.find('#visibility-level-setting').choose(text)
          end

          def snippet_fill_in_title(value)
            fill_in 'snippet-title', with: value
          end

          def snippet_fill_in_description(value)
            # Click placeholder first to expand full description field
            snippet_description_field_collapsed.click
            fill_in snippet_description_locator, with: value
          end

          def snippet_fill_in_content(value)
            page.within('.gl-source-editor') do
              el = find('.inputarea')
              el.send_keys value
            end
          end

          def snippet_fill_in_file_name(value)
            fill_in(snippet_blob_path_locator, match: :first, with: value)
          end

          def snippet_fill_in_form(title: nil, content: nil, file_name: nil, description: nil, visibility: nil)
            snippet_fill_in_title(title) if title

            snippet_fill_in_description(description) if description

            snippet_fill_in_file_name(file_name) if file_name

            snippet_fill_in_content(content) if content

            snippet_fill_in_visibility(visibility) if visibility
          end
        end
      end
    end
  end
end