discourse/spec/system/page_objects/pages/group.rb
Régis Hanol 23982658b2
FIX: Improve error message when updating group notification settings (#37184)
When updating a group's notification defaults (like
watching_category_ids) via API, if existing members would be affected,
the server returns a 422 asking the caller to specify whether to apply
changes to existing users.

The previous error message was confusing: "You supplied invalid
parameters to the request: update_existing_users" - even though the
caller hadn't supplied that parameter at all. The new message clearly
explains what's happening and what to do:

"This change affects X existing group members. You must specify the
'update_existing_users' parameter (true or false) to indicate whether to
apply the new notification defaults to existing members."

Also fixed a bug where the confirmation modal state wasn't being reset
when navigating between groups, causing the modal to not appear on
subsequent group edits. The modal now returns its result directly
instead of storing it in component state.

Ref - https://meta.discourse.org/t/-/393572
2026-01-19 15:08:38 +11:00

68 lines
1.8 KiB
Ruby
Vendored

# frozen_string_literal: true
module PageObjects
module Pages
class Group < PageObjects::Pages::Base
def visit(group)
page.visit("/g/#{group.name}")
self
end
def find(selector)
page.find(".group #{selector}")
end
def add_users
find(".group-members-manage button.group-members-add").click
self
end
def delete_group
page.find("[data-test-selector='delete-group-button']").click
page.find(".dialog-footer .btn-danger").click
end
def select_user_and_add(user)
page.find(
".modal-container .user-chooser .multi-select-header .select-kit-header-wrapper",
).click
page.find(".modal-container .user-chooser .filter-input").set(user.username)
page.find(
".modal-container li.email-group-user-chooser-row[data-value='#{user.username}']",
).click
page.find(".modal-container button.add.btn-primary").click
self
end
def click_manage
page.find(".user-primary-navigation .manage").click
end
def click_membership
page.find(".user-secondary-navigation li", text: "Membership").click
end
def click_interaction
page.find(
".user-secondary-navigation li",
text: I18n.t("js.groups.manage.interaction.title"),
).click
end
def click_save
page.find(".group-manage-save").click
end
def has_saved?
page.has_css?(".group-manage-save-button span", text: I18n.t("js.saved"))
end
def select_default_notification_level(level)
select_kit =
PageObjects::Components::SelectKit.new(".groups-form-default-notification-level")
select_kit.expand
select_kit.select_row_by_value(level)
end
end
end
end