summaryrefslogtreecommitdiff
path: root/qa/qa/specs/features/browser_ui/3_create/snippet/add_comment_to_snippet_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'qa/qa/specs/features/browser_ui/3_create/snippet/add_comment_to_snippet_spec.rb')
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/snippet/add_comment_to_snippet_spec.rb81
1 files changed, 81 insertions, 0 deletions
diff --git a/qa/qa/specs/features/browser_ui/3_create/snippet/add_comment_to_snippet_spec.rb b/qa/qa/specs/features/browser_ui/3_create/snippet/add_comment_to_snippet_spec.rb
new file mode 100644
index 00000000000..a867d9cb973
--- /dev/null
+++ b/qa/qa/specs/features/browser_ui/3_create/snippet/add_comment_to_snippet_spec.rb
@@ -0,0 +1,81 @@
+# frozen_string_literal: true
+
+module QA
+ RSpec.describe 'Create' do
+ describe 'Adding comments on snippets' do
+ let(:comment_author) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1) }
+ let(:comment_content) { 'Comment 123' }
+ let(:edited_comment_content) { 'Nice snippet!' }
+
+ let(:personal_snippet) do
+ Resource::Snippet.fabricate! do |snippet|
+ snippet.title = 'Personal snippet with a comment'
+ end
+ end
+
+ let(:project_snippet) do
+ Resource::ProjectSnippet.fabricate! do |snippet|
+ snippet.title = 'Project snippet with a comment'
+ end
+ end
+
+ before do
+ Flow::Login.sign_in
+ end
+
+ shared_examples 'comments on snippets' do |snippet_type|
+ it "adds, edits, and deletes a comment on a #{snippet_type}" do
+ send(snippet_type)
+
+ Page::Main::Menu.perform(&:sign_out)
+
+ Flow::Login.sign_in(as: comment_author)
+
+ send(snippet_type).visit!
+
+ create_comment
+ verify_comment_content(comment_author.username, comment_content)
+
+ edit_comment
+ verify_comment_content(comment_author.username, edited_comment_content)
+
+ delete_comment
+ verify_comment_deleted
+ end
+ end
+
+ it_behaves_like 'comments on snippets', :personal_snippet
+ it_behaves_like 'comments on snippets', :project_snippet
+
+ def create_comment
+ Page::Dashboard::Snippet::Show.perform do |snippet|
+ snippet.add_comment(comment_content)
+ end
+ end
+
+ def edit_comment
+ Page::Dashboard::Snippet::Show.perform do |snippet|
+ snippet.edit_comment(edited_comment_content)
+ end
+ end
+
+ def delete_comment
+ Page::Dashboard::Snippet::Show.perform do |snippet|
+ snippet.delete_comment(edited_comment_content)
+ end
+ end
+
+ def verify_comment_content(author, comment_content)
+ Page::Dashboard::Snippet::Show.perform do |comment|
+ expect(comment).to have_comment_author(author)
+ expect(comment).to have_comment_content(comment_content)
+ end
+ end
+
+ def verify_comment_deleted
+ expect(page).not_to have_content(comment_author.username)
+ expect(page).not_to have_content(edited_comment_content)
+ end
+ end
+ end
+end