discourse/spec/system/pm_user_removal_spec.rb
2026-03-20 00:39:52 +01:00

63 lines
1.6 KiB
Ruby

# frozen_string_literal: true
describe "PM user removal" do
fab!(:current_user, :admin)
fab!(:other_user, :user)
let(:topic_page) { PageObjects::Pages::Topic.new }
let(:dialog) { PageObjects::Components::Dialog.new }
before { sign_in(current_user) }
it "removes a user from the PM list" do
pm =
create_post(
user: current_user,
target_usernames: [other_user.username],
archetype: Archetype.private_message,
).topic
topic_page.visit_topic(pm)
find(".user[data-id='#{other_user.id}'] .remove-invited").click
expect(page).to have_selector(
".small-action-contents",
text: "Removed @#{other_user.username} just now",
)
end
it "removes yourself from the PM list" do
pm =
create_post(
user: current_user,
target_usernames: [other_user.username],
archetype: Archetype.private_message,
).topic
topic_page.visit_topic(pm)
find(".user[data-id='#{current_user.id}'] .remove-invited").click
dialog.click_yes
expect(page).to have_current_path("/u/#{current_user.username}/messages")
end
it "removes a group from the PM list" do
group =
Fabricate(:group, messageable_level: Group::ALIAS_LEVELS[:everyone]).tap do |g|
g.add(other_user)
end
pm =
create_post(
user: current_user,
target_group_names: [group.name],
archetype: Archetype.private_message,
).topic
topic_page.visit_topic(pm)
find(".group[data-id='#{group.id}'] .remove-invited").click
expect(page).to have_selector(".small-action-contents", text: "Removed @#{group.name} just now")
end
end