0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-09 18:01:48 +08:00
discourse/plugins/discourse-reactions/test/javascripts/acceptance/discourse-reactions-archived-topic-test.js
Jarek Radosz 893fcf714b
DEV: Remove plugin names from test titles (#39418)
Those are now automatically included in testem's output.
2026-04-21 19:19:52 +02:00

60 lines
2 KiB
JavaScript
Vendored

import { click, visit } from "@ember/test-helpers";
import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import ReactionsTopics from "../fixtures/reactions-topic-fixtures";
acceptance("Archived topic", function (needs) {
needs.user();
needs.settings({
discourse_reactions_enabled: true,
discourse_reactions_enabled_reactions: "otter|open_mouth",
discourse_reactions_reaction_for_like: "heart",
discourse_reactions_like_icon: "heart",
});
needs.pretender((server, helper) => {
const topicPath = "/t/374.json";
const topicData = structuredClone(ReactionsTopics[topicPath]);
// Make topic archived
topicData.archived = true;
// Ensure post_2 (id 1076) has no like action and no reactions
const post2 = topicData.post_stream.posts.find((p) => p.id === 1076);
post2.actions_summary = post2.actions_summary.filter((a) => a.id !== 2);
post2.reactions = [];
post2.current_user_reaction = null;
post2.reaction_users_count = 0;
post2.current_user_used_main_reaction = false;
server.get(topicPath, () => helper.response(topicData));
server.put(
"/discourse-reactions/posts/:post_id/custom-reactions/:reaction/toggle.json",
() => helper.response(403, { errors: ["forbidden"] })
);
});
test("Cannot toggle reaction on post with no likes in archived topic", async function (assert) {
await visit("/t/topic_with_reactions_and_likes/374");
assert
.dom("#post_2 .discourse-reactions-actions.can-toggle-reaction")
.doesNotExist("reaction button is not toggleable");
assert
.dom("#post_2 .discourse-reactions-reaction-button")
.exists("reaction button is rendered");
await click("#post_2 .discourse-reactions-reaction-button");
assert
.dom(".dialog-body")
.doesNotExist("no error dialog is shown after clicking");
assert
.dom("#post_2 .discourse-reactions-actions.has-reacted")
.doesNotExist("no reaction was applied optimistically");
});
});