summaryrefslogtreecommitdiff
path: root/qa/qa/specs/features/browser_ui/2_plan/issue/create_issue_spec.rb
blob: 45c3c26483732821934818350865a6ae9959fe0a (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
87
# frozen_string_literal: true

module QA
  RSpec.describe 'Plan', :smoke, product_group: :project_management do
    describe 'Issue creation' do
      let(:project) do
        Resource::Project.fabricate_via_api_unless_fips! do |project|
          project.name = "project-create-issue-#{SecureRandom.hex(8)}"
          project.personal_namespace = Runtime::User.username
          project.description = nil
        end
      end

      let(:closed_issue) do
        Resource::Issue.fabricate_via_api_unless_fips! { |issue| issue.project = project }
      end

      before do
        Flow::Login.sign_in
      end

      it(
        'creates an issue',
        :mobile,
        testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347989'
      ) do
        issue = Resource::Issue.fabricate_via_browser_ui! { |issue| issue.project = project }

        Page::Project::Menu.perform(&:click_issues)

        Page::Project::Issue::Index.perform do |index|
          expect(index).to have_issue(issue)
        end
      end

      it(
        'closes an issue',
        :mobile,
        testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347967'
      ) do
        closed_issue.visit!

        Page::Project::Issue::Show.perform do |issue_page|
          issue_page.click_close_issue_button

          expect(issue_page).to have_reopen_issue_button
        end

        Page::Project::Menu.perform(&:click_issues)

        Page::Project::Issue::Index.perform do |index|
          expect(index).not_to have_issue(closed_issue)

          index.click_closed_issues_tab

          expect(index).to have_issue(closed_issue)
        end
      end

      context 'when using attachments in comments', :object_storage do
        let(:png_file_name) { 'testfile.png' }
        let(:file_to_attach) do
          File.absolute_path(File.join('qa', 'fixtures', 'designs', png_file_name))
        end

        before do
          Resource::Issue.fabricate_via_api_unless_fips! { |issue| issue.project = project }.visit!
        end

        # The following example is excluded from running in `review-qa-smoke` job
        # as it proved to be flaky when running against Review App
        # See https://gitlab.com/gitlab-com/www-gitlab-com/-/issues/11568#note_621999351
        it(
          'comments on an issue with an attachment',
          testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347946',
          except: { job: 'review-qa-*' }
        ) do
          Page::Project::Issue::Show.perform do |show|
            show.comment('See attached image for scale', attachment: file_to_attach)

            expect(show.noteable_note_item.find("img[src$='#{png_file_name}']")).to be_visible
          end
        end
      end
    end
  end
end