2020-11-24 15:15:51 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
# These helpers help you interact within the Editor Lite (single-file editor, snippets, etc.).
|
|
|
|
#
|
|
|
|
module Spec
|
|
|
|
module Support
|
|
|
|
module Helpers
|
|
|
|
module Features
|
|
|
|
module SnippetSpecHelpers
|
|
|
|
include ActionView::Helpers::JavaScriptHelper
|
|
|
|
include Spec::Support::Helpers::Features::EditorLiteSpecHelpers
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
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
|
|
|
|
|
2020-11-24 15:15:51 +05:30
|
|
|
def snippet_get_first_blob_path
|
2021-01-03 14:25:43 +05:30
|
|
|
page.find_field('snippet_file_name', match: :first).value
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def snippet_get_first_blob_value
|
2021-01-03 14:25:43 +05:30
|
|
|
page.find('.gl-editor-lite', match: :first)
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def snippet_description_value
|
2021-01-03 14:25:43 +05:30
|
|
|
page.find_field(snippet_description_locator).value
|
|
|
|
end
|
|
|
|
|
|
|
|
def snippet_fill_in_visibility(text)
|
|
|
|
page.find('#visibility-level-setting').choose(text)
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
def snippet_fill_in_title(value)
|
|
|
|
fill_in 'snippet-title', with: value
|
|
|
|
end
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
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
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
def snippet_fill_in_content(value)
|
|
|
|
page.within('.gl-editor-lite') do
|
2020-11-24 15:15:51 +05:30
|
|
|
el = find('.inputarea')
|
2021-01-03 14:25:43 +05:30
|
|
|
el.send_keys value
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
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
|
2020-11-24 15:15:51 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
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
|
2020-11-24 15:15:51 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|