summaryrefslogtreecommitdiff
path: root/qa/qa/specs/features/browser_ui/3_create/snippet/copy_snippet_file_contents_spec.rb
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
committerRobert Speicher <rspeicher@gmail.com>2021-01-20 13:34:23 -0600
commit6438df3a1e0fb944485cebf07976160184697d72 (patch)
tree00b09bfd170e77ae9391b1a2f5a93ef6839f2597 /qa/qa/specs/features/browser_ui/3_create/snippet/copy_snippet_file_contents_spec.rb
parent42bcd54d971da7ef2854b896a7b34f4ef8601067 (diff)
downloadgitlab-ce-6438df3a1e0fb944485cebf07976160184697d72.tar.gz
Add latest changes from gitlab-org/gitlab@13-8-stable-eev13.8.0-rc42
Diffstat (limited to 'qa/qa/specs/features/browser_ui/3_create/snippet/copy_snippet_file_contents_spec.rb')
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/snippet/copy_snippet_file_contents_spec.rb75
1 files changed, 75 insertions, 0 deletions
diff --git a/qa/qa/specs/features/browser_ui/3_create/snippet/copy_snippet_file_contents_spec.rb b/qa/qa/specs/features/browser_ui/3_create/snippet/copy_snippet_file_contents_spec.rb
new file mode 100644
index 00000000000..1670ba56064
--- /dev/null
+++ b/qa/qa/specs/features/browser_ui/3_create/snippet/copy_snippet_file_contents_spec.rb
@@ -0,0 +1,75 @@
+# frozen_string_literal: true
+
+module QA
+ RSpec.describe 'Create' do
+ describe 'Multiple file snippet' do
+ let(:first_file_content) { 'First file content' }
+ let(:second_file_content) { 'Second file content' }
+ let(:third_file_content) { 'Third file content' }
+
+ let(:personal_snippet) do
+ Resource::Snippet.fabricate_via_api! do |snippet|
+ snippet.title = 'Personal snippet to copy file contents from'
+ snippet.file_name = 'First file name'
+ snippet.file_content = first_file_content
+
+ snippet.add_files do |files|
+ files.append(name: 'Second file name', content: second_file_content)
+ files.append(name: 'Third file name', content: third_file_content)
+ end
+ end
+ end
+
+ let(:project_snippet) do
+ Resource::ProjectSnippet.fabricate_via_api! do |snippet|
+ snippet.title = 'Project snippet to copy file contents from'
+ snippet.file_name = 'First file name'
+ snippet.file_content = first_file_content
+
+ snippet.add_files do |files|
+ files.append(name: 'Second file name', content: second_file_content)
+ files.append(name: 'Third file name', content: third_file_content)
+ end
+ end
+ end
+
+ let(:files) do
+ [
+ {
+ number: 1,
+ content: first_file_content
+ },
+ {
+ number: 2,
+ content: second_file_content
+ },
+ {
+ number: 3,
+ content: third_file_content
+ }
+ ]
+ end
+
+ before do
+ Flow::Login.sign_in
+ end
+
+ shared_examples 'copying snippet file contents' do |snippet_type|
+ it "copies file contents of a multi-file #{snippet_type} to a comment and verifies them" do
+ send(snippet_type).visit!
+
+ files.each do |files|
+ Page::Dashboard::Snippet::Show.perform do |snippet|
+ snippet.copy_file_contents_to_comment(files[:number])
+ expect(snippet).to have_comment_content(files[:content])
+ snippet.delete_comment(files[:content])
+ end
+ end
+ end
+ end
+
+ it_behaves_like 'copying snippet file contents', :personal_snippet
+ it_behaves_like 'copying snippet file contents', :project_snippet
+ end
+ end
+end