mirror of
https://github.com/hanzoai/forum.git
synced 2026-09-30 21:51:19 +00:00
The chat emoji picker is renamed emoji-picker, and the old emoji-picker is removed. This commit doesn't attempt to fully rework a new emoji-picker but instead tries to migrate everything to one picker (the chat one) and add small changes. Other notable changes: - all the favorite emojis code has been mixed into one service which is able to store one state per context, favorites emojis will be stored for all topics, and for each chat channel. Meaning that if you always use a specific emoji in a channel, it will only show as favorite emoji in this channel. - a lot of static code has been removed which should improve initial load perf of discourse. Initially this code was around to improve the performance of the emoji picker rendering. - the emojis are now stored, once the full list has been loaded, if you close and reopen the picker it won't have to load them again. List of components: - `<EmojiPicker />` will render a button which will open a dropdown - `<EmojiPickerContent />` represents the content of the dropdown alone, it's useful when you want to render a picker from an action which is not the default picker button - `<EmojiPickerDetached />` just a simple wrapper over `<EmojiPickerContent />` to make it easier to use it with `this.menu.show(...)` --------- Co-authored-by: Renato Atilio <[email protected]>
114 lines
3.7 KiB
JavaScript
114 lines
3.7 KiB
JavaScript
import { click, fillIn, visit } from "@ember/test-helpers";
|
|
import { test } from "qunit";
|
|
import emojiPicker from "discourse/tests/helpers/emoji-picker-helper";
|
|
import {
|
|
acceptance,
|
|
updateCurrentUser,
|
|
} from "discourse/tests/helpers/qunit-helpers";
|
|
|
|
async function openUserStatusModal() {
|
|
await click(".pref-user-status .btn-default");
|
|
}
|
|
|
|
async function setStatus(status) {
|
|
await openUserStatusModal();
|
|
await click(".btn-emoji");
|
|
await emojiPicker().fill(status.emoji);
|
|
await emojiPicker().select(status.emoji);
|
|
await fillIn(".user-status-description", status.description);
|
|
await click(".d-modal__footer .btn-primary"); // save and close modal
|
|
}
|
|
|
|
acceptance("User Profile - Account - User Status", function (needs) {
|
|
const username = "eviltrout";
|
|
const status = {
|
|
emoji: "grinning",
|
|
description: "off to dentist",
|
|
};
|
|
|
|
needs.user({ username, status });
|
|
|
|
test("doesn't render status block if status is disabled in site settings", async function (assert) {
|
|
this.siteSettings.enable_user_status = false;
|
|
await visit(`/u/${username}/preferences/account`);
|
|
assert.dom(".pref-user-status").doesNotExist();
|
|
});
|
|
|
|
test("renders status block if status is enabled in site settings", async function (assert) {
|
|
this.siteSettings.enable_user_status = true;
|
|
|
|
await visit(`/u/${username}/preferences/account`);
|
|
|
|
assert
|
|
.dom(".pref-user-status .user-status-message")
|
|
.exists("status is shown");
|
|
assert
|
|
.dom(`.pref-user-status .emoji[alt='${status.emoji}']`)
|
|
.exists("status emoji is correct");
|
|
assert
|
|
.dom(`.pref-user-status .user-status-message-description`)
|
|
.hasText(status.description, "status description is correct");
|
|
});
|
|
|
|
test("doesn't show the pause notifications control group on the user status modal", async function (assert) {
|
|
this.siteSettings.enable_user_status = true;
|
|
|
|
await visit(`/u/${username}/preferences/account`);
|
|
await openUserStatusModal();
|
|
|
|
assert.dom(".pause-notifications").doesNotExist();
|
|
});
|
|
|
|
test("the status modal sets status", async function (assert) {
|
|
this.siteSettings.enable_user_status = true;
|
|
updateCurrentUser({ status: null });
|
|
|
|
await visit(`/u/${username}/preferences/account`);
|
|
assert
|
|
.dom(".pref-user-status .user-status-message")
|
|
.doesNotExist("status isn't shown");
|
|
|
|
await setStatus(status);
|
|
|
|
assert
|
|
.dom(".pref-user-status .user-status-message")
|
|
.exists("status is shown");
|
|
assert
|
|
.dom(`.pref-user-status .emoji[alt='${status.emoji}']`)
|
|
.exists("status emoji is correct");
|
|
assert
|
|
.dom(`.pref-user-status .user-status-message-description`)
|
|
.hasText(status.description, "status description is correct");
|
|
});
|
|
|
|
test("the status modal updates status", async function (assert) {
|
|
this.siteSettings.enable_user_status = true;
|
|
|
|
await visit(`/u/${username}/preferences/account`);
|
|
const newStatus = { emoji: "womans_clothes", description: "shopping" };
|
|
await setStatus(newStatus);
|
|
|
|
assert
|
|
.dom(".pref-user-status .user-status-message")
|
|
.exists("status is shown");
|
|
assert
|
|
.dom(`.pref-user-status .emoji[alt='${newStatus.emoji}']`)
|
|
.exists("status emoji is correct");
|
|
assert
|
|
.dom(`.pref-user-status .user-status-message-description`)
|
|
.hasText(newStatus.description, "status description is correct");
|
|
});
|
|
|
|
test("the status modal clears status", async function (assert) {
|
|
this.siteSettings.enable_user_status = true;
|
|
|
|
await visit(`/u/${username}/preferences/account`);
|
|
await openUserStatusModal();
|
|
await click(".btn.delete-status");
|
|
|
|
assert
|
|
.dom(".pref-user-status .user-status-message")
|
|
.doesNotExist("status isn't shown");
|
|
});
|
|
});
|