debian-mirror-gitlab/spec/support/helpers/features/snippet_helpers.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

90 lines
2.7 KiB
Ruby
Raw Normal View History

2020-11-24 15:15:51 +05:30
# frozen_string_literal: true
2021-09-30 23:02:18 +05:30
# These helpers help you interact within the Source Editor (single-file editor, snippets, etc.).
2020-11-24 15:15:51 +05:30
#
2021-09-30 23:02:18 +05:30
require Rails.root.join("spec/support/helpers/features/source_editor_spec_helpers.rb")
2020-11-24 15:15:51 +05:30
module Spec
module Support
module Helpers
module Features
module SnippetSpecHelpers
include ActionView::Helpers::JavaScriptHelper
2021-09-30 23:02:18 +05:30
include Spec::Support::Helpers::Features::SourceEditorSpecHelpers
2020-11-24 15:15:51 +05:30
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-09-30 23:02:18 +05:30
page.find('.gl-source-editor', 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)
2021-09-30 23:02:18 +05:30
page.within('.gl-source-editor') 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)
2022-07-16 23:28:13 +05:30
if content
snippet_fill_in_content(content)
# It takes some time after sending keys for the vue component to
# update so let Capybara wait for the content before proceeding
expect(page).to have_content(content)
end
2021-01-03 14:25:43 +05:30
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_visibility(visibility) if visibility
2020-11-24 15:15:51 +05:30
end
end
end
end
end
end