-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
Copy pathassignee_board_spec.rb
216 lines (175 loc) · 7.24 KB
/
assignee_board_spec.rb
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See COPYRIGHT and LICENSE files for more details.
#++
require "spec_helper"
require_relative "../support/board_index_page"
require_relative "../support/board_page"
RSpec.describe "Assignee action board",
:js,
:selenium,
with_ee: %i[board_view] do
let(:bobself_user) do
create(:user,
firstname: "Bob",
lastname: "Self",
member_with_roles: { project => role })
end
let(:admin) { create(:admin) }
let(:type) { create(:type_standard) }
let(:project) { create(:project, types: [type], enabled_module_names: %i[work_package_tracking board_view]) }
let(:project_without_members) { create(:project, enabled_module_names: %i[work_package_tracking board_view]) }
let(:role) { create(:project_role, permissions:) }
let(:board_index) { Pages::BoardIndex.new(project) }
let(:other_board_index) { Pages::BoardIndex.new(project_without_members) }
let(:permissions) do
%i[show_board_views manage_board_views add_work_packages
edit_work_packages view_work_packages manage_public_queries work_package_assigned]
end
let!(:priority) { create(:default_priority) }
# Set up other assignees
let!(:foobar_user) do
create(:user,
firstname: "Foo",
lastname: "Bar",
member_with_roles: { project => role })
end
let!(:group) do
create(:group, name: "Grouped").tap do |group|
create(:member,
principal: group,
project:,
roles: [role])
end
end
let!(:work_package) do
create(:work_package,
project:,
assigned_to: bobself_user,
subject: "Some Task")
end
context "in a project with members" do
before do
login_as(bobself_user)
end
it "allows to move a task between two assignees" do
# Move to the board index page
board_index.visit!
# Create new board
board_page = board_index.create_board title: "My Assignee Board",
action: "Assignee",
expect_empty: true
# Expect no assignees to be present
board_page.expect_empty
# Add myself to the board list
board_page.add_list option: "Bob Self"
board_page.expect_list "Bob Self"
# Add the other user to the board list
board_page.add_list option: "Foo Bar"
board_page.expect_list "Foo Bar"
# Add grouped list
board_page.add_list option: "Grouped"
board_page.expect_list "Grouped"
# There is now only the none option left
board_page.expect_list_option "(none)"
board_page.board(reload: true) do |board|
expect(board.name).to eq "My Assignee Board"
queries = board.contained_queries
expect(queries.count).to eq(3)
bob = queries.first
foo = queries.second
grouped = queries.last
expect(bob.name).to eq "Bob Self"
expect(foo.name).to eq "Foo Bar"
expect(grouped.name).to eq "Grouped"
expect(bob.filters.first.name).to eq :assigned_to_id
expect(bob.filters.first.values).to eq [bobself_user.id.to_s]
expect(foo.filters.first.name).to eq :assigned_to_id
expect(foo.filters.first.values).to eq [foobar_user.id.to_s]
expect(grouped.filters.first.name).to eq :assigned_to_id
expect(grouped.filters.first.values).to eq [group.id.to_s]
end
# First, expect work package to be assigned to "Bob self"
# For this, test the Bob self column to contain the work package
board_page.expect_card "Bob Self", "Some Task"
# Then, move the work package from one column to the next one
board_page.move_card(0, from: "Bob Self", to: "Foo Bar")
# Then, the work package should be in the other column
# and assigned to "Foo Bar" user
board_page.expect_card "Foo Bar", "Some Task"
board_page.expect_card "Bob Self", "Some Task", present: false
# Expect to have changed the avatar
within_test_selector("op-wp-single-card--content-assignee") do
expect(page).to have_css(".op-avatar_mini", text: "FB", wait: 10)
end
work_package.reload
expect(work_package.assigned_to).to eq(foobar_user)
# Move to group column
board_page.move_card(0, from: "Foo Bar", to: "Grouped")
board_page.expect_card "Grouped", "Some Task"
board_page.expect_card "Foo Bar", "Some Task", present: false
board_page.expect_card "Bob Self", "Some Task", present: false
# Expect to have changed the avatar
within_test_selector("op-wp-single-card--content-assignee") do
expect(page).to have_css(".op-avatar_mini", text: "G", wait: 10)
end
work_package.reload
expect(work_package.assigned_to).to eq(group)
# Open remaining in split view
card = board_page.card_for(work_package)
split_view = card.open_details_view
split_view.expect_subject
split_view.edit_field(:assignee).update("Foo Bar")
split_view.expect_and_dismiss_toaster message: "Successful update."
work_package.reload
expect(work_package.assigned_to).to eq(foobar_user)
board_page.expect_card("Foo Bar", "Some Task", present: true)
board_page.expect_card("Grouped", "Some Task", present: false)
# Reassign to grouped
board_page.reference "Grouped", work_package
board_page.expect_card("Grouped", "Some Task", present: true)
board_page.expect_card("Foo Bar", "Some Task", present: false)
end
end
context "in a project without members" do
before do
login_as(admin)
end
it "shows a warning when there are no members to add as a list with a link to add a new member" do
# Move to the board index page
other_board_index.visit!
# Create new board
board_page = other_board_index.create_board action: :Assignee, expect_empty: true
# Expect no assignees to be present
board_page.expect_empty
# Add none to the list
board_page.add_list option: "(none)"
board_page.expect_list "(none)"
board_page.open_add_list_modal
board_page.add_list_modal_shows_warning true, with_link: true
end
end
end