FIX: Prepends whitespace when inserting via emoji picker

This commit is contained in:
Gerhard Schlager
2019-12-02 17:31:05 +01:00
parent ee2473d7d5
commit e7c3c10829
3 changed files with 37 additions and 4 deletions
@@ -4,7 +4,7 @@ import { IMAGE_VERSION as v } from "pretty-text/emoji/version";
acceptance("EmojiPicker", {
loggedIn: true,
beforeEach() {
const store = Discourse.__container__.lookup("service:emojis-store");
const store = Discourse.__container__.lookup("service:emoji-store");
store.reset();
}
});
@@ -60,6 +60,36 @@ QUnit.skip("emoji picker triggers event when picking emoji", async assert => {
);
});
QUnit.test(
"emoji picker adds leading whitespace before emoji",
async assert => {
await visit("/t/internationalization-localization/280");
await click("#topic-footer-buttons .btn.create");
// Whitespace should be added on text
await fillIn(".d-editor-input", "This is a test input");
await click("button.emoji.btn");
await click(".emoji-picker button[title='grinning']");
assert.equal(
find(".d-editor-input").val(),
"This is a test input :grinning:",
"it adds the emoji code and a leading whitespace when there is text"
);
await click("button.emoji.btn");
// Whitespace should not be added on whitespace
await fillIn(".d-editor-input", "This is a test input ");
await click("button.emoji.btn");
await click(".emoji-picker button[title='grinning']");
assert.equal(
find(".d-editor-input").val(),
"This is a test input :grinning:",
"it adds the emoji code and no leading whitespace when user already entered whitespace"
);
await click("button.emoji.btn");
}
);
QUnit.skip("emoji picker has a list of recently used emojis", async assert => {
await visit("/t/internationalization-localization/280");
await click("#topic-footer-buttons .btn.create");