From e0a0a13a91d3a4438fba73dfd8b2b49112283d85 Mon Sep 17 00:00:00 2001 From: Ted Johansson Date: Mon, 30 Sep 2024 13:27:25 +0800 Subject: [PATCH] FIX: Fix broken client-side review actions (#29025) After #28603, the options "agree and suspend" and "agree and silence" in the review queue weren't working. This was happening because the optionalService, when used as a decorator, needs a name argument to work properly. We were also lacking tests for this. --- .../discourse/app/components/reviewable-item.js | 2 +- spec/fabricators/reviewable_fabricator.rb | 1 + spec/system/reviewables_spec.rb | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/assets/javascripts/discourse/app/components/reviewable-item.js b/app/assets/javascripts/discourse/app/components/reviewable-item.js index cf7ee8e5776..235e4953631 100644 --- a/app/assets/javascripts/discourse/app/components/reviewable-item.js +++ b/app/assets/javascripts/discourse/app/components/reviewable-item.js @@ -49,7 +49,7 @@ export default class ReviewableItem extends Component { @service siteSettings; @service currentUser; @service composer; - @optionalService adminTools; + @optionalService("admin-tools") adminTools; updating = null; editing = false; diff --git a/spec/fabricators/reviewable_fabricator.rb b/spec/fabricators/reviewable_fabricator.rb index 25d7c7eb5db..f3a11cc7673 100644 --- a/spec/fabricators/reviewable_fabricator.rb +++ b/spec/fabricators/reviewable_fabricator.rb @@ -96,6 +96,7 @@ Fabricator(:reviewable_flagged_post) do reviewable_by_moderator true type "ReviewableFlaggedPost" created_by { Fabricate(:user) } + target_created_by { Fabricate(:user) } topic target_type "Post" target { Fabricate(:post) } diff --git a/spec/system/reviewables_spec.rb b/spec/system/reviewables_spec.rb index 7ab0072ab34..203dcb74b99 100644 --- a/spec/system/reviewables_spec.rb +++ b/spec/system/reviewables_spec.rb @@ -54,6 +54,21 @@ describe "Reviewables", type: :system do expect(composer).to be_opened expect(composer.composer_input.value).to eq(post.raw) end + + it "should open a modal when suspending a user" do + visit("/review") + + select_kit = + PageObjects::Components::SelectKit.new(".dropdown-select-box.post-agree-and-hide") + select_kit.expand + + select_kit.select_row_by_value("post-agree_and_suspend") + + expect(review_page).to have_css( + "#discourse-modal-title", + text: I18n.t("js.flagging.take_action_options.suspend.title"), + ) + end end end