Welcome to mirror list, hosted at ThFree Co, Russian Federation.

add_comment_to_snippet_spec.rb « snippet « 3_create « browser_ui « features « specs « qa « qa - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1a7c64a363fd0b40d677d9f5236a6ebd3759788d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# 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

      after do
        personal_snippet&.remove_via_api!
        project_snippet&.remove_via_api!
      end

      shared_examples 'comments on snippets' do |snippet_type, testcase|
        it "adds, edits, and deletes a comment on a #{snippet_type}", testcase: testcase 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, 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347816'
      it_behaves_like 'comments on snippets', :project_snippet, 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347817'

      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