Skip to content

A platform for community discussion. Free, open, simple.

FIX: Handle assign edge-cases and restore skipped specs (#39232)

Jarek Radosz50e9e0e45930
diff --git a/plugins/discourse-assign/assets/javascripts/discourse/components/assigned-to-first-post.gjs b/plugins/discourse-assign/assets/javascripts/discourse/components/assigned-to-first-post.gjs
index 64ccfd82e80..e8693e344d8 100644
--- a/plugins/discourse-assign/assets/javascripts/discourse/components/assigned-to-first-post.gjs
+++ b/plugins/discourse-assign/assets/javascripts/discourse/components/assigned-to-first-post.gjs
@@ -45,11 +45,17 @@ export default class AssignedToFirstPost extends Component {
});
}
+ get hasIndirectAssignments() {
+ return this.indirectlyAssignedTo
+ ? Object.keys(this.indirectlyAssignedTo).length > 0
+ : false;
+ }
+
get isAssigned() {
return !!(
this.assignedToUser ||
this.assignedToGroup ||
- this.args.post?.topic?.indirectly_assigned_to
+ this.hasIndirectAssignments
);
}
@@ -112,7 +118,7 @@ export default class AssignedToFirstPost extends Component {
{{i18n "discourse_assign.assigned"}}
</span>
{{/if}}
- {{#if this.indirectlyAssignedTo}}
+ {{#if this.hasIndirectAssignments}}
{{#each
this.indirectAssignments key="postId"
as |indirectAssignment|
diff --git a/plugins/discourse-assign/assets/javascripts/discourse/initializers/extend-for-assigns.js b/plugins/discourse-assign/assets/javascripts/discourse/initializers/extend-for-assigns.js
index 2ae757d27c9..9997e8d1138 100644
--- a/plugins/discourse-assign/assets/javascripts/discourse/initializers/extend-for-assigns.js
+++ b/plugins/discourse-assign/assets/javascripts/discourse/initializers/extend-for-assigns.js
@@ -490,7 +490,9 @@ function initialize(api) {
}
if (data.post_id) {
+ topic.indirectly_assigned_to ||= {};
if (data.type === "assigned") {
+ topic.indirectly_assigned_to[data.post_id] ||= {};
topic.indirectly_assigned_to[data.post_id].assigned_to =
data.assigned_to;
} else if (data.type === "unassigned") {
diff --git a/plugins/discourse-assign/spec/system/assign_post_spec.rb b/plugins/discourse-assign/spec/system/assign_post_spec.rb
index 2a3054ac6e0..dece8221eb0 100644
--- a/plugins/discourse-assign/spec/system/assign_post_spec.rb
+++ b/plugins/discourse-assign/spec/system/assign_post_spec.rb
@@ -10,8 +10,8 @@ describe "Assign | Assigning posts" do
fab!(:post2) { Fabricate(:post, topic: topic) }
before do
- skip "Tests are broken and need to be fixed. See https://github.com/discourse/discourse/actions/runs/13890376408/job/38861216842"
SiteSetting.assign_enabled = true
+ SiteSetting.whispers_allowed_groups = "#{Group::AUTO_GROUPS[:staff]}"
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
diff --git a/plugins/discourse-assign/spec/system/page_objects/pages/topic.rb b/plugins/discourse-assign/spec/system/page_objects/pages/topic.rb
index 1622e7dcd7d..aeefe4b3ee1 100644
--- a/plugins/discourse-assign/spec/system/page_objects/pages/topic.rb
+++ b/plugins/discourse-assign/spec/system/page_objects/pages/topic.rb
@@ -19,9 +19,12 @@ module PageObjects
end
def click_assign_post(post)
- find_post_action_button(post, :show_more).click
- assign_post = within_post(post) { find(".post-action-menu__assign-post") }
- assign_post.click
+ within_post(post) do
+ if has_css?(".post-controls .post-action-menu__show-more", wait: 0)
+ find(".post-controls .post-action-menu__show-more").click
+ end
+ find(".post-action-menu__assign-post").click
+ end
end
def click_edit_topic_assignment