Skip to content

Commit 9065e03

Browse files
committed
[AGILE-361] Cover the viewer who cannot select
Selection consumes Space, the arrows, Home/End and Ctrl/Cmd+A, so a page that offers no selection must not attach anything that swallows them. Nothing covered that, which made the permission gate the least tested of the fixes and the one that reaches the most users. The context re-visits after logging in: `current_user` declared inside a describe registers its login after the outer visit hook, so the first navigation lands before the user exists and the browser sits on the rack-session page. https://community.openproject.org/wp/AGILE-361
1 parent d02ed4e commit 9065e03

2 files changed

Lines changed: 43 additions & 2 deletions

File tree

modules/backlogs/spec/features/work_packages/batch_selection_spec.rb

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@
179179
# Root-wide, not list-scoped: the fixtures span a sprint and a bucket
180180
# precisely so a regression that only selects the focused card's own list
181181
# would leave this short of all six.
182-
it "selects every movable card across the whole root with Ctrl/Cmd+A" do
182+
it "selects every orderable card across the whole root with Ctrl/Cmd+A" do
183183
backlogs_page.send_work_package_card_keys(story1, [:control, "a"])
184184

185185
expect(page).to have_css("[data-batch-selected]", count: 6)
@@ -255,4 +255,35 @@
255255
backlogs_page.expect_work_package_card_not_described(story3)
256256
end
257257
end
258+
259+
# Selection consumes Space, the arrows, Home/End and Ctrl/Cmd+A. On a page
260+
# where the permission makes every card fixed that is pure loss: the keys
261+
# would stop scrolling the page and announce a refusal for a capability the
262+
# page never offers. The root does not opt in at all, so there is nothing
263+
# attached to consume them.
264+
describe "without the permission to manage sprint items" do
265+
let(:view_role) do
266+
create(:project_role, permissions: %i(view_sprints view_work_packages))
267+
end
268+
269+
current_user do
270+
create(:user, member_with_roles: { project => view_role })
271+
end
272+
273+
# The outer `before` visits the page, and `current_user` declared here
274+
# registers its login after that hook — so the first visit lands before
275+
# this user exists. Visit again once they do.
276+
before do
277+
backlogs_page.visit!
278+
end
279+
280+
it "does not enable selection, and leaves its gestures to the browser" do
281+
backlogs_page.expect_batch_selection_disabled
282+
283+
backlogs_page.toggle_card(story1)
284+
backlogs_page.send_work_package_card_keys(story2, [:space])
285+
286+
expect(page).to have_no_css("[data-batch-selected]")
287+
end
288+
end
258289
end

modules/backlogs/spec/support/pages/backlog.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ def expect_and_confirm_backlog_bucket_delete_modal
680680

681681
# Every row now carries `data-sortable-lists--item-id-value` regardless of
682682
# whether the user may move it (a fixed row still anchors a neighbour's
683-
# drop), so the item id is no longer what distinguishes a movable row.
683+
# drop), so the item id is no longer what distinguishes an orderable row.
684684
# `draggable` and the item's `mobility` value are set independently by the
685685
# component and read by separate consumers (the browser's native drag
686686
# start, and the item controller's own drag registration), so both are
@@ -751,6 +751,16 @@ def extend_selection_to(work_package)
751751
modified_click(work_package, :shift)
752752
end
753753

754+
# The root advertises whether it opted into selection at all. Asserted
755+
# directly because the absence of a batch proves nothing on its own: a
756+
# root that opted in and simply refused every gesture looks identical
757+
# from the outside, and the two differ in whether the browser still gets
758+
# the keystroke.
759+
def expect_batch_selection_disabled
760+
expect(page).to have_css("[data-controller~='sortable-lists'][data-sortable-lists-selection-enabled-value='false']",
761+
visible: :all)
762+
end
763+
754764
# Live batch membership, in document order.
755765
def selected_card_ids
756766
all("[data-batch-selected]").pluck("data-sortable-lists--item-id-value")

0 commit comments

Comments
 (0)