2017-07-11 23:51:53 +08:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
import { IMAGE_VERSION as v } from 'pretty-text/emoji';
|
2017-07-21 20:27:18 +08:00
|
|
|
import { resetCache } from 'discourse/components/emoji-picker';
|
2017-07-11 23:51:53 +08:00
|
|
|
|
|
|
|
acceptance("EmojiPicker", {
|
|
|
|
loggedIn: true,
|
2017-07-21 20:27:18 +08:00
|
|
|
beforeEach() { resetCache(); }
|
2017-07-11 23:51:53 +08:00
|
|
|
});
|
|
|
|
|
2017-07-21 19:35:29 +08:00
|
|
|
QUnit.test("emoji picker can be opened/closed", assert => {
|
2017-07-11 23:51:53 +08:00
|
|
|
visit("/t/internationalization-localization/280");
|
|
|
|
click("#topic-footer-buttons .btn.create");
|
|
|
|
|
|
|
|
click("button.emoji.btn");
|
|
|
|
andThen(() => {
|
|
|
|
assert.notEqual(
|
|
|
|
find('.emoji-picker').html().trim(),
|
|
|
|
"",
|
|
|
|
"it opens the picker"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
click("button.emoji.btn");
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(
|
|
|
|
find('.emoji-picker').html().trim(),
|
|
|
|
"",
|
|
|
|
"it closes the picker"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-07-21 19:35:29 +08:00
|
|
|
QUnit.test("emojis can be hovered to display info", assert => {
|
2017-07-11 23:51:53 +08:00
|
|
|
visit("/t/internationalization-localization/280");
|
|
|
|
click("#topic-footer-buttons .btn.create");
|
|
|
|
|
|
|
|
click("button.emoji.btn");
|
|
|
|
andThen(() => {
|
2017-07-22 01:42:46 +08:00
|
|
|
$(".emoji-picker button[title='grinning']").trigger('mouseover');
|
2017-07-11 23:51:53 +08:00
|
|
|
andThen(() => {
|
|
|
|
assert.equal(
|
|
|
|
find('.emoji-picker .info').html().trim(),
|
|
|
|
`<img src=\"/images/emoji/emoji_one/grinning.png?v=${v}\" class=\"emoji\"> <span>:grinning:<span></span></span>`,
|
|
|
|
"it displays emoji info when hovering emoji"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-07-25 18:22:47 +08:00
|
|
|
QUnit.test("emoji picker triggers event when picking emoji", assert => {
|
2017-07-11 23:51:53 +08:00
|
|
|
visit("/t/internationalization-localization/280");
|
|
|
|
click("#topic-footer-buttons .btn.create");
|
|
|
|
click("button.emoji.btn");
|
|
|
|
|
2017-07-22 01:42:46 +08:00
|
|
|
click(".emoji-picker button[title='grinning']");
|
2017-07-11 23:51:53 +08:00
|
|
|
andThen(() => {
|
|
|
|
assert.equal(
|
|
|
|
find('.d-editor-input').val(),
|
|
|
|
":grinning:",
|
|
|
|
"it adds the emoji code in the editor when selected"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-07-21 19:35:29 +08:00
|
|
|
QUnit.test("emoji picker has a list of recently used emojis", assert => {
|
2017-07-11 23:51:53 +08:00
|
|
|
visit("/t/internationalization-localization/280");
|
|
|
|
click("#topic-footer-buttons .btn.create");
|
|
|
|
click("button.emoji.btn");
|
|
|
|
|
2017-07-22 01:42:46 +08:00
|
|
|
click(".emoji-picker .section[data-section='people'] button.emoji[title='grinning']");
|
2017-07-11 23:51:53 +08:00
|
|
|
andThen(() => {
|
|
|
|
assert.equal(
|
2017-07-22 01:42:46 +08:00
|
|
|
find('.emoji-picker .section[data-section="recent"]').css("display"),
|
2017-07-11 23:51:53 +08:00
|
|
|
"block",
|
|
|
|
"it shows recent section"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
2017-07-22 01:42:46 +08:00
|
|
|
find('.emoji-picker .section[data-section="recent"] .section-group button.emoji').length,
|
2017-07-11 23:51:53 +08:00
|
|
|
1,
|
|
|
|
"it adds the emoji code to the recently used emojis list"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2017-07-19 19:15:18 +08:00
|
|
|
click(".emoji-picker .clear-recent");
|
2017-07-11 23:51:53 +08:00
|
|
|
andThen(() => {
|
|
|
|
assert.equal(
|
2017-07-22 01:42:46 +08:00
|
|
|
find('.emoji-picker .section[data-section="recent"] .section-group button.emoji').length,
|
2017-07-19 19:15:18 +08:00
|
|
|
0,
|
|
|
|
"it has cleared recent emojis"
|
2017-07-11 23:51:53 +08:00
|
|
|
);
|
|
|
|
|
2017-07-19 19:15:18 +08:00
|
|
|
assert.equal(
|
2017-07-22 01:42:46 +08:00
|
|
|
find('.emoji-picker .section[data-section="recent"]').css("display"),
|
2017-07-19 19:15:18 +08:00
|
|
|
"none",
|
|
|
|
"it hides recent section"
|
|
|
|
);
|
2017-07-11 23:51:53 +08:00
|
|
|
|
2017-07-19 19:15:18 +08:00
|
|
|
assert.equal(
|
2017-07-22 01:42:46 +08:00
|
|
|
find('.emoji-picker .category-icon button.emoji[data-section="recent"]').parent().css("display"),
|
2017-07-19 19:15:18 +08:00
|
|
|
"none",
|
|
|
|
"it hides recent category icon"
|
|
|
|
);
|
2017-07-11 23:51:53 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-07-25 18:22:47 +08:00
|
|
|
QUnit.test("emoji picker correctly orders recently used emojis", assert => {
|
2017-07-11 23:51:53 +08:00
|
|
|
visit("/t/internationalization-localization/280");
|
|
|
|
click("#topic-footer-buttons .btn.create");
|
|
|
|
|
2017-07-25 18:22:47 +08:00
|
|
|
click("button.emoji.btn");
|
2017-07-11 23:51:53 +08:00
|
|
|
andThen(() => {
|
2017-07-25 18:22:47 +08:00
|
|
|
click(".emoji-picker button[title='sunglasses']");
|
|
|
|
click(".emoji-picker button[title='grinning']");
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(
|
|
|
|
find('.section[data-section="recent"] .section-group button.emoji').length,
|
|
|
|
2,
|
|
|
|
"it has multiple recent emojis"
|
|
|
|
);
|
2017-07-11 23:51:53 +08:00
|
|
|
|
2017-07-25 18:22:47 +08:00
|
|
|
assert.equal(
|
|
|
|
/grinning/.test(find('.section[data-section="recent"] .section-group button.emoji').first().css('background-image')),
|
|
|
|
true,
|
|
|
|
"it puts the last used emoji in first"
|
|
|
|
);
|
|
|
|
});
|
2017-07-11 23:51:53 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-07-25 18:22:47 +08:00
|
|
|
QUnit.test("emoji picker lazy loads emojis", assert => {
|
2017-07-11 23:51:53 +08:00
|
|
|
visit("/t/internationalization-localization/280");
|
|
|
|
click("#topic-footer-buttons .btn.create");
|
|
|
|
|
|
|
|
click("button.emoji.btn");
|
|
|
|
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(
|
2017-07-25 18:22:47 +08:00
|
|
|
find('.emoji-picker button[title="massage_woman"]').css("background-image"),
|
|
|
|
"none",
|
2017-07-11 23:51:53 +08:00
|
|
|
"it doesn't load invisible emojis"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-07-25 18:22:47 +08:00
|
|
|
QUnit.test("emoji picker persists state", assert => {
|
2017-07-11 23:51:53 +08:00
|
|
|
visit("/t/internationalization-localization/280");
|
|
|
|
click("#topic-footer-buttons .btn.create");
|
|
|
|
|
|
|
|
click("button.emoji.btn");
|
|
|
|
andThen(() => {
|
|
|
|
click('.emoji-picker a.diversity-scale.medium-dark');
|
|
|
|
});
|
|
|
|
click("button.emoji.btn");
|
|
|
|
|
|
|
|
click("button.emoji.btn");
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(
|
|
|
|
find('.emoji-picker .diversity-scale.medium-dark').hasClass('selected'),
|
|
|
|
true,
|
|
|
|
"it stores diversity scale"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|