File: work_item_spec.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (170 lines) | stat: -rw-r--r-- 5,130 bytes parent folder | download
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe 'Work item', :js, feature_category: :team_planning do
  before do
    stub_feature_flags(notifications_todos_buttons: false)
  end

  include ListboxHelpers

  let_it_be_with_reload(:user) { create(:user) }
  let_it_be_with_reload(:user2) { create(:user, name: 'John') }

  let_it_be(:group) { create(:group) }
  let_it_be(:project) { create(:project, :public, group: group) }
  let_it_be(:label) { create(:label, project: project, title: "testing-label") }
  let_it_be(:label2) { create(:label, project: project, title: "another-label") }
  let_it_be(:work_item) { create(:work_item, project: project, labels: [label]) }
  let_it_be(:task) { create(:work_item, :task, project: project) }
  let_it_be(:emoji_upvote) { create(:award_emoji, :upvote, awardable: work_item, user: user2) }
  let_it_be(:milestone) { create(:milestone, project: project) }
  let_it_be(:milestones) { create_list(:milestone, 25, project: project) }
  let_it_be(:note) { create(:note, noteable: work_item, project: work_item.project) }
  let(:work_items_path) { project_work_item_path(project, work_item.iid) }
  let_it_be(:contact) { create(:contact, group: group) }
  let(:contact_name) { "#{contact.first_name} #{contact.last_name}" }

  context 'for signed in user' do
    before do
      stub_feature_flags(notifications_todos_buttons: false)
      stub_const("AutocompleteSources::ExpiresIn::AUTOCOMPLETE_EXPIRES_IN", 0)
      group.add_developer(user)
      sign_in(user)
      visit work_items_path
    end

    it 'shows breadcrumb links', :aggregate_failures do
      within_testid('breadcrumb-links') do
        expect(page).to have_link(project.name, href: project_path(project))
        expect(page).to have_link('Issues', href: project_issues_path(project))
        expect(find('nav:last-of-type li:last-of-type')).to have_link("##{work_item.iid}", href: work_items_path)
      end
    end

    it 'actions dropdown is displayed' do
      expect(page).to have_button _('More actions')
    end

    context 'when work_items_beta is enabled' do
      before do
        stub_feature_flags(work_items_beta: true)
        stub_feature_flags(notifications_todos_buttons: false)

        page.refresh
        wait_for_all_requests
      end

      it 'reassigns to another user',
        quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/413074' do
        within_testid('work-item-assignees') do
          click_button 'Edit'
        end

        select_listbox_item(user.username)

        wait_for_requests

        within_testid('work-item-assignees') do
          click_button 'Edit'
        end

        select_listbox_item(user2.username)

        wait_for_requests

        expect(work_item.reload.assignees).to include(user2)
      end
    end

    it_behaves_like 'work items title'
    it_behaves_like 'work items description'
    it_behaves_like 'work items award emoji'
    it_behaves_like 'work items comments', :issue
    it_behaves_like 'work items toggle status button'

    it_behaves_like 'work items todos'
    it_behaves_like 'work items lock discussion'
    it_behaves_like 'work items confidentiality'
    it_behaves_like 'work items notifications'

    it_behaves_like 'work items assignees'
    it_behaves_like 'work items labels'
    it_behaves_like 'work items milestone'
    it_behaves_like 'work items time tracking'
    it_behaves_like 'work items crm contacts'
  end

  context 'for signed in owner' do
    before do
      project.add_owner(user)
      sign_in(user)
      visit work_items_path
    end

    it_behaves_like 'work items invite members'
  end

  context 'for guest users' do
    before do
      project.add_guest(user)
      sign_in(user)
      visit work_items_path
    end

    it_behaves_like 'work items comment actions for guest users'
  end

  context 'when item is a task' do
    before do
      project.add_developer(user)
      sign_in(user)
      visit project_work_item_path(project, task.iid)
    end

    it_behaves_like 'work items parent', :issue
  end

  context 'for user not signed in' do
    before do
      visit work_items_path
    end

    it 'todos action is not displayed' do
      expect(page).not_to have_button s_('WorkItem|Add a to-do item')
    end

    it 'award button is disabled and add reaction is not displayed' do
      expect(page).not_to have_button _('Add reaction')
      expect(page).to have_selector('[data-testid="award-button"].disabled')
    end

    it 'renders note' do
      wait_for_all_requests

      expect(page).to have_content(note.note)
    end

    context 'when work_items_beta is enabled' do
      before do
        stub_feature_flags(work_items_beta: true)

        page.refresh
        wait_for_all_requests
      end

      it 'hides the assignees edit button' do
        within_testid('work-item-assignees') do
          expect(page).not_to have_button('Edit')
        end
      end

      it 'hides the labels edit button' do
        within_testid('work-item-labels') do
          expect(page).not_to have_button('Edit')
        end
      end
    end
  end
end