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

copy_snippet_file_contents_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: 667601b7bcab0eb9153e67695b1c50906111062a (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
# frozen_string_literal: true

module QA
  RSpec.describe 'Create', :reliable, product_group: :source_code 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
        create(:snippet,
          title: 'Personal snippet to copy file contents from',
          file_name: 'First file name',
          file_content: first_file_content,
          files: [
            { name: 'Second file name', content: second_file_content },
            { name: 'Third file name', content: third_file_content }
          ])
      end

      let(:project_snippet) do
        create(:project_snippet,
          title: 'Project snippet to copy file contents from',
          file_name: 'First file name',
          file_content: first_file_content,
          files: [
            { name: 'Second file name', content: second_file_content },
            { name: 'Third file name', content: third_file_content }
          ])
      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, testcase|
        it "copies file contents of a multi-file #{snippet_type} to a comment and verifies them", testcase: testcase 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, 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347849'
      it_behaves_like 'copying snippet file contents', :project_snippet, 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347848'
    end
  end
end