mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-12 03:22:02 +08:00
Replaced legacy assignment updates with `@tracked` properties for reactive state management in `Discourse Assign` plugin. Updated methods for modifying assignment-related properties (`assigned_to_user`, `assigned_to_group`, etc.) and ensured compatibility with Glimmer's reactive model. Also, improved test coverage by parameterizing tests to run with `glimmer_post_stream_mode` both enabled and disabled, ensuring consistent behavior across configurations.
55 lines
1.7 KiB
JavaScript
55 lines
1.7 KiB
JavaScript
import { click, visit } from "@ember/test-helpers";
|
|
import { test } from "qunit";
|
|
import {
|
|
acceptance,
|
|
publishToMessageBus,
|
|
updateCurrentUser,
|
|
} from "discourse/tests/helpers/qunit-helpers";
|
|
import topicWithAssignedPosts from "../fixtures/topic-with-assigned-posts";
|
|
|
|
const topic = topicWithAssignedPosts();
|
|
const post = topic.post_stream.posts[1];
|
|
|
|
["enabled", "disabled"].forEach((postStreamMode) => {
|
|
acceptance(
|
|
`Discourse Assign | Topic level assign menu (glimmer_post_stream_mode = ${postStreamMode})`,
|
|
function (needs) {
|
|
needs.user();
|
|
needs.settings({
|
|
assign_enabled: true,
|
|
glimmer_post_stream_mode: postStreamMode,
|
|
});
|
|
|
|
needs.pretender((server, helper) => {
|
|
server.get("/t/44.json", () => helper.response(topic));
|
|
server.put("/assign/unassign", () => {
|
|
return helper.response({ success: true });
|
|
});
|
|
});
|
|
|
|
needs.hooks.beforeEach(() => {
|
|
updateCurrentUser({ can_assign: true });
|
|
});
|
|
|
|
test("Unassign button unassigns the post", async function (assert) {
|
|
await visit("/t/assignment-topic/44");
|
|
|
|
await click("#topic-footer-dropdown-reassign .btn");
|
|
await click(`li[data-value='unassign-from-post-${post.id}']`);
|
|
await publishToMessageBus("/staff/topic-assignment", {
|
|
type: "unassigned",
|
|
topic_id: topic.id,
|
|
post_id: post.id,
|
|
assigned_type: "User",
|
|
});
|
|
|
|
assert
|
|
.dom("#topic-footer-dropdown-reassign-body ul[role='menu']")
|
|
.doesNotExist("The menu is closed");
|
|
assert
|
|
.dom(".post-stream article#post_2 .assigned-to")
|
|
.doesNotExist("The post is unassigned");
|
|
});
|
|
}
|
|
);
|
|
});
|