Revert "DEV: Refactor composer-/topic-presence-display (#29262)" (#29368)

This reverts commit 38ab3f23493e314b3658c4b1392688fdad2447ba.
This commit is contained in:
Jarek Radosz
2024-10-23 16:26:08 +02:00
committed by GitHub
parent 38ab3f2349
commit a59c07fc45
12 changed files with 311 additions and 271 deletions

View File

@ -6,7 +6,12 @@ import {
leaveChannel,
presentUserIds,
} from "discourse/tests/helpers/presence-pretender";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import {
acceptance,
count,
exists,
query,
} from "discourse/tests/helpers/qunit-helpers";
import selectKit from "discourse/tests/helpers/select-kit-helper";
acceptance("Discourse Presence Plugin", function (needs) {
@ -28,7 +33,7 @@ acceptance("Discourse Presence Plugin", function (needs) {
assert.strictEqual(
currentURL(),
"/t/internationalization-localization/280",
"transitions to the newly created topic URL"
"it transitions to the newly created topic URL"
);
});
@ -36,7 +41,7 @@ acceptance("Discourse Presence Plugin", function (needs) {
await visit("/t/internationalization-localization/280");
await click("#topic-footer-buttons .btn.create");
assert.dom(".d-editor-input").exists("the composer input is visible");
assert.ok(exists(".d-editor-input"), "the composer input is visible");
assert.deepEqual(
presentUserIds("/discourse-presence/reply/280"),
@ -65,7 +70,7 @@ acceptance("Discourse Presence Plugin", function (needs) {
await visit("/t/internationalization-localization/280");
await click("#topic-footer-buttons .btn.create");
assert.dom(".d-editor-input").exists("the composer input is visible");
assert.ok(exists(".d-editor-input"), "the composer input is visible");
await fillIn(".d-editor-input", "this is the content of my reply");
@ -79,9 +84,11 @@ acceptance("Discourse Presence Plugin", function (needs) {
await menu.expand();
await menu.selectRowByName("toggle-whisper");
assert
.dom(".composer-actions svg.d-icon-far-eye-slash")
.exists("sets the post type to whisper");
assert.strictEqual(
count(".composer-actions svg.d-icon-far-eye-slash"),
1,
"it sets the post type to whisper"
);
assert.deepEqual(
presentUserIds("/discourse-presence/reply/280"),
@ -110,13 +117,11 @@ acceptance("Discourse Presence Plugin", function (needs) {
await click(".topic-post:nth-of-type(1) button.show-more-actions");
await click(".topic-post:nth-of-type(1) button.edit");
assert
.dom(".d-editor-input")
.hasValue(
document.querySelector(".topic-post:nth-of-type(1) .cooked > p")
.innerText,
"composer has contents of post to be edited"
);
assert.strictEqual(
query(".d-editor-input").value,
query(".topic-post:nth-of-type(1) .cooked > p").innerText,
"composer has contents of post to be edited"
);
assert.deepEqual(
presentUserIds("/discourse-presence/edit/398"),
@ -153,7 +158,7 @@ acceptance("Discourse Presence Plugin", function (needs) {
assert
.dom(".topic-above-footer-buttons-outlet.presence")
.exists("includes the presence component");
assert.dom(avatarSelector).doesNotExist("no avatars displayed");
assert.strictEqual(count(avatarSelector), 0, "no avatars displayed");
await joinChannel("/discourse-presence/reply/280", {
id: 123,
@ -161,7 +166,7 @@ acceptance("Discourse Presence Plugin", function (needs) {
username: "my-username",
});
assert.dom(avatarSelector).exists({ count: 1 }, "avatar displayed");
assert.strictEqual(count(avatarSelector), 1, "avatar displayed");
await joinChannel("/discourse-presence/whisper/280", {
id: 124,
@ -169,28 +174,28 @@ acceptance("Discourse Presence Plugin", function (needs) {
username: "my-username2",
});
assert.dom(avatarSelector).exists({ count: 2 }, "whisper avatar displayed");
assert.strictEqual(count(avatarSelector), 2, "whisper avatar displayed");
await leaveChannel("/discourse-presence/reply/280", {
id: 123,
});
assert.dom(avatarSelector).exists({ count: 1 }, "reply avatar removed");
assert.strictEqual(count(avatarSelector), 1, "reply avatar removed");
await leaveChannel("/discourse-presence/whisper/280", {
id: 124,
});
assert.dom(avatarSelector).doesNotExist("whisper avatar removed");
assert.strictEqual(count(avatarSelector), 0, "whisper avatar removed");
});
test("Displays replying and whispering presence in composer", async function (assert) {
await visit("/t/internationalization-localization/280");
await click("#topic-footer-buttons .btn.create");
assert.dom(".d-editor-input").exists("the composer input is visible");
assert.ok(exists(".d-editor-input"), "the composer input is visible");
const avatarSelector = ".reply-to .presence-avatars .avatar";
assert.dom(avatarSelector).doesNotExist("no avatars displayed");
assert.strictEqual(count(avatarSelector), 0, "no avatars displayed");
await joinChannel("/discourse-presence/reply/280", {
id: 123,
@ -198,7 +203,7 @@ acceptance("Discourse Presence Plugin", function (needs) {
username: "my-username",
});
assert.dom(avatarSelector).exists({ count: 1 }, "avatar displayed");
assert.strictEqual(count(avatarSelector), 1, "avatar displayed");
await joinChannel("/discourse-presence/whisper/280", {
id: 124,
@ -206,18 +211,18 @@ acceptance("Discourse Presence Plugin", function (needs) {
username: "my-username2",
});
assert.dom(avatarSelector).exists({ count: 2 }, "whisper avatar displayed");
assert.strictEqual(count(avatarSelector), 2, "whisper avatar displayed");
await leaveChannel("/discourse-presence/reply/280", {
id: 123,
});
assert.dom(avatarSelector).exists({ count: 1 }, "reply avatar removed");
assert.strictEqual(count(avatarSelector), 1, "reply avatar removed");
await leaveChannel("/discourse-presence/whisper/280", {
id: 124,
});
assert.dom(avatarSelector).doesNotExist("whisper avatar removed");
assert.strictEqual(count(avatarSelector), 0, "whisper avatar removed");
});
});