mirror of
https://github.com/discourse/discourse.git
synced 2026-08-04 10:23:17 -05:00
DEV: Fix flaky assign spec (#34734)
This commit is contained in:
@@ -3,19 +3,18 @@
|
||||
describe "Assign | Assigning topics", type: :system do
|
||||
let(:topic_page) { PageObjects::Pages::Topic.new }
|
||||
let(:assign_modal) { PageObjects::Modals::Assign.new }
|
||||
fab!(:staff_user) { Fabricate(:user, groups: [Group[:staff]]) }
|
||||
fab!(:admin)
|
||||
fab!(:admin1) { Fabricate(:admin) }
|
||||
fab!(:admin2) { Fabricate(:admin) }
|
||||
fab!(:topic)
|
||||
fab!(:post) { Fabricate(:post, topic: topic) }
|
||||
|
||||
before do
|
||||
SiteSetting.assign_enabled = true
|
||||
SiteSetting.prioritize_full_name_in_ux = false
|
||||
# The system tests in this file are flaky and auth token related so turning this on
|
||||
SiteSetting.verbose_auth_token_logging = true
|
||||
SiteSetting.whispers_allowed_groups = [Group[:staff].id]
|
||||
SiteSetting.whispers_allowed_groups = "#{Group::AUTO_GROUPS[:staff]}"
|
||||
SiteSetting.assign_allowed_on_groups = "#{Group::AUTO_GROUPS[:staff]}"
|
||||
|
||||
sign_in(admin)
|
||||
sign_in(admin1)
|
||||
end
|
||||
|
||||
%w[enabled disabled].each do |value|
|
||||
@@ -27,16 +26,17 @@ describe "Assign | Assigning topics", type: :system do
|
||||
visit "/t/#{topic.id}"
|
||||
|
||||
topic_page.click_assign_topic
|
||||
assign_modal.assignee = staff_user
|
||||
assign_modal.assignee = admin2
|
||||
assign_modal.confirm
|
||||
|
||||
expect(assign_modal).to be_closed
|
||||
expect(topic_page).to have_assigned(user: staff_user, at_post: 2)
|
||||
expect(find("#topic .assigned-to")).to have_content(staff_user.username)
|
||||
|
||||
expect(topic_page).to have_assigned(user: admin2, at_post: 2)
|
||||
expect(find("#topic .assigned-to")).to have_content(admin2.username)
|
||||
|
||||
topic_page.click_unassign_topic
|
||||
|
||||
expect(topic_page).to have_unassigned(user: staff_user, at_post: 3)
|
||||
expect(topic_page).to have_unassigned(user: admin2, at_post: 3)
|
||||
expect(page).to have_no_css("#topic .assigned-to")
|
||||
end
|
||||
|
||||
@@ -44,14 +44,15 @@ describe "Assign | Assigning topics", type: :system do
|
||||
visit "/t/#{topic.id}"
|
||||
|
||||
topic_page.click_assign_topic
|
||||
assign_modal.assignee = staff_user
|
||||
assign_modal.assignee = admin2
|
||||
|
||||
find("body").send_keys(:tab)
|
||||
find("body").send_keys(:control, :enter)
|
||||
|
||||
expect(assign_modal).to be_closed
|
||||
expect(topic_page).to have_assigned(user: staff_user, at_post: 2)
|
||||
expect(find("#topic .assigned-to")).to have_content(staff_user.username)
|
||||
|
||||
expect(topic_page).to have_assigned(user: admin2, at_post: 2)
|
||||
expect(find("#topic .assigned-to")).to have_content(admin2.username)
|
||||
end
|
||||
|
||||
context "when prioritize_full_name_in_ux setting is enabled" do
|
||||
@@ -61,21 +62,21 @@ describe "Assign | Assigning topics", type: :system do
|
||||
visit "/t/#{topic.id}"
|
||||
|
||||
topic_page.click_assign_topic
|
||||
assign_modal.assignee = staff_user
|
||||
assign_modal.assignee = admin2
|
||||
assign_modal.confirm
|
||||
expect(find("#topic .assigned-to")).to have_content(staff_user.name)
|
||||
expect(find("#topic .assigned-to")).to have_content(admin2.name)
|
||||
end
|
||||
|
||||
it "show the user's username if there is no name" do
|
||||
visit "/t/#{topic.id}"
|
||||
staff_user.name = nil
|
||||
staff_user.save!
|
||||
staff_user.reload
|
||||
admin2.name = nil
|
||||
admin2.save!
|
||||
admin2.reload
|
||||
|
||||
topic_page.click_assign_topic
|
||||
assign_modal.assignee = staff_user
|
||||
assign_modal.assignee = admin2
|
||||
assign_modal.confirm
|
||||
expect(find("#topic .assigned-to")).to have_content(staff_user.username)
|
||||
expect(find("#topic .assigned-to")).to have_content(admin2.username)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -86,12 +87,12 @@ describe "Assign | Assigning topics", type: :system do
|
||||
visit "/t/#{topic.id}"
|
||||
|
||||
topic_page.click_assign_topic
|
||||
assign_modal.assignee = staff_user
|
||||
assign_modal.assignee = admin2
|
||||
assign_modal.confirm
|
||||
|
||||
expect(assign_modal).to be_closed
|
||||
expect(topic_page).to have_assigned(
|
||||
user: staff_user,
|
||||
user: admin2,
|
||||
at_post: 2,
|
||||
class_attribute: ".private-assign",
|
||||
)
|
||||
@@ -105,11 +106,11 @@ describe "Assign | Assigning topics", type: :system do
|
||||
visit "/t/#{topic.id}"
|
||||
|
||||
topic_page.click_assign_topic
|
||||
assign_modal.assignee = staff_user
|
||||
assign_modal.assignee = admin2
|
||||
assign_modal.confirm
|
||||
|
||||
expect(assign_modal).to be_closed
|
||||
expect(topic_page).to have_assigned(user: staff_user, at_post: 2)
|
||||
expect(topic_page).to have_assigned(user: admin2, at_post: 2)
|
||||
|
||||
find(".timeline-controls .toggle-admin-menu").click
|
||||
find(".topic-admin-close").click
|
||||
@@ -125,11 +126,11 @@ describe "Assign | Assigning topics", type: :system do
|
||||
visit "/t/#{topic.id}"
|
||||
|
||||
topic_page.click_assign_topic
|
||||
assign_modal.assignee = staff_user
|
||||
assign_modal.assignee = admin2
|
||||
assign_modal.confirm
|
||||
|
||||
expect(assign_modal).to be_closed
|
||||
expect(topic_page).to have_assigned(user: staff_user, at_post: 2)
|
||||
expect(topic_page).to have_assigned(user: admin2, at_post: 2)
|
||||
|
||||
find(".timeline-controls .toggle-admin-menu").click
|
||||
find(".topic-admin-close").click
|
||||
@@ -141,11 +142,12 @@ describe "Assign | Assigning topics", type: :system do
|
||||
expect(page).to have_no_css("#topic .assigned-to")
|
||||
|
||||
topic_page.click_assign_topic
|
||||
assign_modal.assignee = staff_user
|
||||
assign_modal.assignee = admin2
|
||||
assign_modal.confirm
|
||||
|
||||
expect(page).to have_no_css("#post_4")
|
||||
expect(find("#topic .assigned-to")).to have_content(staff_user.username)
|
||||
|
||||
expect(find("#topic .assigned-to")).to have_content(admin2.username)
|
||||
end
|
||||
|
||||
context "when reassign_on_open is set to true" do
|
||||
@@ -155,11 +157,11 @@ describe "Assign | Assigning topics", type: :system do
|
||||
visit "/t/#{topic.id}"
|
||||
|
||||
topic_page.click_assign_topic
|
||||
assign_modal.assignee = staff_user
|
||||
assign_modal.assignee = admin2
|
||||
assign_modal.confirm
|
||||
|
||||
expect(assign_modal).to be_closed
|
||||
expect(topic_page).to have_assigned(user: staff_user, at_post: 2)
|
||||
expect(topic_page).to have_assigned(user: admin2)
|
||||
|
||||
find(".timeline-controls .toggle-admin-menu").click
|
||||
find(".topic-admin-close").click
|
||||
@@ -177,7 +179,9 @@ describe "Assign | Assigning topics", type: :system do
|
||||
I18n.t("js.action_codes.closed.disabled", when: "just now"),
|
||||
)
|
||||
expect(page).to have_no_css("#post_5")
|
||||
expect(find("#topic .assigned-to")).to have_content(staff_user.username)
|
||||
try_until_success do
|
||||
expect(find("#topic .assigned-to")).to have_content(admin2.username)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user