2017-07-11 23:51:53 +08:00
|
|
|
import { acceptance } from "helpers/qunit-helpers";
|
|
|
|
import { IMAGE_VERSION as v } from 'pretty-text/emoji';
|
|
|
|
import {
|
|
|
|
keyValueStore,
|
|
|
|
EMOJI_USAGE,
|
|
|
|
EMOJI_SCROLL_Y,
|
|
|
|
EMOJI_SELECTED_DIVERSITY
|
|
|
|
} from 'discourse/components/emoji-picker';
|
|
|
|
|
|
|
|
acceptance("EmojiPicker", {
|
|
|
|
loggedIn: true,
|
|
|
|
beforeEach() {
|
|
|
|
keyValueStore.setObject({ key: EMOJI_USAGE, value: {} });
|
|
|
|
keyValueStore.setObject({ key: EMOJI_SCROLL_Y, value: 0 });
|
|
|
|
keyValueStore.setObject({ key: EMOJI_SELECTED_DIVERSITY, value: 1 });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-07-19 23:07:53 +08:00
|
|
|
QUnit.skip("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-19 23:07:53 +08:00
|
|
|
QUnit.skip("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(() => {
|
|
|
|
$(".emoji-picker a[title='grinning']").trigger('mouseover');
|
|
|
|
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-19 22:26:21 +08:00
|
|
|
QUnit.skip("emoji picker has sections", assert => {
|
2017-07-11 23:51:53 +08:00
|
|
|
visit("/t/internationalization-localization/280");
|
|
|
|
click("#topic-footer-buttons .btn.create");
|
|
|
|
click("button.emoji.btn");
|
|
|
|
|
|
|
|
click(".emoji-picker .categories-column a[title='travel']");
|
|
|
|
andThen(() => {
|
|
|
|
assert.notEqual(
|
|
|
|
find('.emoji-picker .list').scrollTop(),
|
|
|
|
0,
|
|
|
|
"it scrolls to section"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find(".emoji-picker .categories-column a[title='travel']").parent().hasClass('current'),
|
|
|
|
true,
|
|
|
|
"it highlights section icon"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-07-19 23:07:53 +08:00
|
|
|
QUnit.skip("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");
|
|
|
|
|
|
|
|
click(".emoji-picker a[title='grinning']");
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(
|
|
|
|
find('.d-editor-input').val(),
|
|
|
|
":grinning:",
|
|
|
|
"it adds the emoji code in the editor when selected"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-07-19 23:07:53 +08:00
|
|
|
QUnit.skip("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");
|
|
|
|
click(".emoji-picker .clear-recent");
|
|
|
|
|
|
|
|
click(".emoji-picker a[title='grinning']");
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(
|
|
|
|
find('.section[data-section="recent"]').css("display"),
|
|
|
|
"block",
|
|
|
|
"it shows recent section"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find('.section[data-section="recent"] .section-group img.emoji').length,
|
|
|
|
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(
|
|
|
|
find('.section[data-section="recent"] .section-group img.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(
|
|
|
|
find('.section[data-section="recent"]').css("display"),
|
|
|
|
"none",
|
|
|
|
"it hides recent section"
|
|
|
|
);
|
2017-07-11 23:51:53 +08:00
|
|
|
|
2017-07-19 19:15:18 +08:00
|
|
|
assert.equal(
|
|
|
|
find('.category-icon a[title="recent"]').parent().css("display"),
|
|
|
|
"none",
|
|
|
|
"it hides recent category icon"
|
|
|
|
);
|
2017-07-11 23:51:53 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-07-19 23:07:53 +08:00
|
|
|
QUnit.skip("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");
|
|
|
|
click("button.emoji.btn");
|
|
|
|
click(".emoji-picker .clear-recent");
|
|
|
|
|
|
|
|
click(".emoji-picker a[title='grinning']");
|
|
|
|
click(".emoji-picker a[title='sunglasses']");
|
|
|
|
click(".emoji-picker a[title='sunglasses']");
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(
|
|
|
|
find('.section[data-section="recent"] .section-group img.emoji').length,
|
|
|
|
2,
|
|
|
|
"it has multiple recent emojis"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find('.section[data-section="recent"] .section-group img.emoji').first().attr('src'),
|
|
|
|
`/images/emoji/emoji_one/sunglasses.png?v=${v}`,
|
|
|
|
"it puts the most used emoji in first"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-07-19 23:07:53 +08:00
|
|
|
QUnit.skip("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(() => {
|
|
|
|
const $emoji = $('.emoji-picker a[title="massage_woman"] img');
|
|
|
|
assert.equal(
|
|
|
|
$emoji.attr('src'),
|
|
|
|
"",
|
|
|
|
"it doesn't load invisible emojis"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-07-19 22:26:21 +08:00
|
|
|
QUnit.skip("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(() => {
|
|
|
|
$('.emoji-picker .list').scrollTop(2600);
|
|
|
|
click('.emoji-picker a.diversity-scale.medium-dark');
|
|
|
|
});
|
|
|
|
|
|
|
|
click("button.emoji.btn");
|
|
|
|
|
|
|
|
click("button.emoji.btn");
|
|
|
|
andThen(() => {
|
|
|
|
assert.equal(
|
|
|
|
find('.emoji-picker .list').scrollTop() > 2500,
|
|
|
|
true,
|
|
|
|
"it stores scroll position"
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.equal(
|
|
|
|
find('.emoji-picker .diversity-scale.medium-dark').hasClass('selected'),
|
|
|
|
true,
|
|
|
|
"it stores diversity scale"
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|