discourse/plugins/discourse-reactions/test/javascripts/acceptance/discourse-reactions-post-test.js
Jarek Radosz 21e9733f27
DEV: Fix various lint issues (#33811)
…mostly in recently bundled plugins.
2025-07-24 15:27:04 +02:00

102 lines
3.5 KiB
JavaScript
Vendored
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import ReactionsTopics from "../fixtures/reactions-topic-fixtures";
["enabled", "disabled"].forEach((postStreamMode) => {
acceptance(
`Discourse Reactions - Post (glimmer_post_stream_mode = ${postStreamMode})`,
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",
glimmer_post_stream_mode: postStreamMode,
});
needs.pretender((server, helper) => {
const topicPath = "/t/374.json";
server.get(topicPath, () =>
helper.response(ReactionsTopics[topicPath])
);
});
test("Reactions count", async function (assert) {
await visit("/t/topic_with_reactions_and_likes/374");
assert
.dom("#post_1 .discourse-reactions-counter .reactions-counter")
.hasText("209", "displays the correct count");
});
test("Other user post", async function (assert) {
await visit("/t/topic_with_reactions_and_likes/374");
assert
.dom("#post_2 .discourse-reactions-reaction-button")
.exists("displays the reaction button");
});
test("Post is yours", async function (assert) {
await visit("/t/topic_with_reactions_and_likes/374");
assert
.dom("#post_1 .discourse-reactions-reaction-button")
.doesNotExist("does not display the reaction button");
});
test("Post has only likes (no reactions)", async function (assert) {
await visit("/t/topic_with_reactions_and_likes/374");
assert
.dom("#post_3 .discourse-reactions-double-button")
.exists("displays the reaction count beside the reaction button");
});
test("Post has likes and reactions", async function (assert) {
await visit("/t/topic_with_reactions_and_likes/374");
assert
.dom("#post_1 .discourse-reactions-double-button")
.doesNotExist(
"does not display the reaction count beside the reaction button"
);
});
test("Current user has no reaction on post and can toggle", async function (assert) {
await visit("/t/topic_with_reactions_and_likes/374");
assert
.dom("#post_2 .discourse-reactions-actions.can-toggle-reaction")
.exists("allows to toggle the reaction");
});
test("Current user has no reaction on post and can toggle", async function (assert) {
await visit("/t/topic_with_reactions_and_likes/374");
assert
.dom("#post_2 .discourse-reactions-actions.can-toggle-reaction")
.exists("allows to toggle the reaction");
});
test("Current user can undo on post and can toggle", async function (assert) {
await visit("/t/topic_with_reactions_and_likes/374");
assert
.dom("#post_3 .discourse-reactions-actions.can-toggle-reaction")
.exists("allows to toggle the reaction");
});
test("Current user can't toggle", async function (assert) {
await visit("/t/topic_with_reactions_and_likes/374");
assert
.dom("#post_1 .discourse-reactions-actions.can-toggle-reaction")
.doesNotExist("doesnt allow to toggle the reaction");
});
}
);
});