summaryrefslogtreecommitdiff
path: root/qa/qa/specs/features/browser_ui/2_plan/issue/real_time_assignee_spec.rb
blob: 44a361df34d12127fe45c35e7dfc72d9661f17f5 (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
# frozen_string_literal: true

module QA
  RSpec.describe 'Plan', :requires_admin, :actioncable, :orchestrated do
    describe 'Assignees' do
      let(:user1) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1) }
      let(:user2) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_2, Runtime::Env.gitlab_qa_password_2) }
      let(:project) do
        Resource::Project.fabricate_via_api! do |project|
          project.name = 'project-to-test-assignees'
        end
      end

      before do
        Runtime::Feature.enable('real_time_issue_sidebar', project: project)
        Runtime::Feature.enable('broadcast_issue_updates', project: project)
        Runtime::Feature.enable(:invite_members_group_modal, project: project)

        Flow::Login.sign_in

        project.add_member(user1)
        project.add_member(user2)
      end

      after do
        Runtime::Feature.disable('real_time_issue_sidebar', project: project)
        Runtime::Feature.disable('broadcast_issue_updates', project: project)
        Runtime::Feature.disable(:invite_members_group_modal, project: project)
      end

      it 'update without refresh', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1048' do
        issue = Resource::Issue.fabricate_via_api! do |issue|
          issue.project = project
          issue.assignee_ids = [user1.id]
        end

        issue.visit!

        Page::Project::Issue::Show.perform do |show|
          expect(show).to have_assignee(user1.name)
          # We need to wait 1 second for the page to connect to the websocket to subscribe to updates
          # https://gitlab.com/gitlab-org/gitlab/-/issues/293699#note_583959786
          sleep 1
          issue.set_issue_assignees(assignee_ids: [user2.id])

          expect(show).to have_assignee(user2.name)
          expect(show).not_to have_assignee(user1.name)

          issue.set_issue_assignees(assignee_ids: [])

          expect(show).not_to have_assignee(user1.name)
          expect(show).not_to have_assignee(user2.name)
        end
      end
    end
  end
end