Commit 6f57c0af authored by Anastasia McDonald's avatar Anastasia McDonald Committed by Mark Lapierre

Add E2E to create project snippet with multiple files

See https://gitlab.com/gitlab-org/quality/testcases/-/issues/1024
parent 7d523a37
......@@ -21,6 +21,13 @@ module QA
new_snippet.set_visibility(@visibility)
new_snippet.fill_file_name(@file_name)
new_snippet.fill_file_content(@file_content)
@files.each.with_index(2) do |file, i|
new_snippet.click_add_file
new_snippet.fill_file_name(file[:name], i)
new_snippet.fill_file_content(file[:content], i)
end
new_snippet.click_create_snippet_button
end
end
......
# frozen_string_literal: true
module QA
RSpec.describe 'Create' do
describe 'Multiple file snippet' do
it 'creates a project snippet with multiple files', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1024' do
Flow::Login.sign_in
Resource::ProjectSnippet.fabricate_via_browser_ui! do |snippet|
snippet.title = 'Project snippet with multiple files'
snippet.description = 'Snippet description'
snippet.visibility = 'Private'
snippet.file_name = '01 file name'
snippet.file_content = '1 file content'
# Ten is the limit of files you can have under one snippet at the moment
snippet.add_files do |files|
(2..10).each do |i|
files.append(name: file_name(i), content: file_content(i))
end
end
end
Page::Dashboard::Snippet::Show.perform do |snippet|
aggregate_failures 'file content verification' do
expect(snippet).to have_snippet_title('Project snippet with multiple files')
expect(snippet).to have_snippet_description('Snippet description')
expect(snippet).to have_visibility_type(/private/i)
(1..10).each do |i|
expect(snippet).to have_file_name(file_name(i), i)
expect(snippet).to have_file_content(file_content(i), i)
end
end
end
end
# Currently the files are returned in alphabetical order and not in the order they are created.
# However, it might soon change - see https://gitlab.com/gitlab-org/gitlab/-/issues/250836.
# By using a leading "0" we make sure the test works with either implementation.
def file_name(index)
"#{index.to_s.rjust(2, '0')} file name"
end
def file_content(index)
"#{index} file content"
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment