|
@@ -49,21 +49,26 @@ describe("The nickname autocomplete feature", function () {
|
|
message_form.onKeyUp(at_event);
|
|
message_form.onKeyUp(at_event);
|
|
|
|
|
|
await u.waitUntil(() => view.querySelectorAll('.suggestion-box__results li').length === 4);
|
|
await u.waitUntil(() => view.querySelectorAll('.suggestion-box__results li').length === 4);
|
|
- const first_child = view.querySelector('.suggestion-box__results li:first-child converse-avatar');
|
|
|
|
- expect(first_child.textContent).toBe('D');
|
|
|
|
- expect(first_child.nextSibling.textContent).toBe('dick');
|
|
|
|
|
|
|
|
- const second_child = view.querySelector('.suggestion-box__results li:nth-child(2) converse-avatar');
|
|
|
|
- expect(second_child.textContent).toBe('H');
|
|
|
|
- expect(second_child.nextSibling.textContent).toBe('harry');
|
|
|
|
-
|
|
|
|
- const third_child = view.querySelector('.suggestion-box__results li:nth-child(3) converse-avatar');
|
|
|
|
- expect(third_child.textContent).toBe('J');
|
|
|
|
- expect(third_child.nextSibling.textContent).toBe('jane');
|
|
|
|
-
|
|
|
|
- const fourth_child = view.querySelector('.suggestion-box__results li:nth-child(4) converse-avatar');
|
|
|
|
- expect(fourth_child.textContent).toBe('T');
|
|
|
|
- expect(fourth_child.nextSibling.textContent).toBe('tom');
|
|
|
|
|
|
+ const first_child = view.querySelector('.suggestion-box__results li:first-child');
|
|
|
|
+ const first_child_avatar = first_child.querySelector('converse-avatar');
|
|
|
|
+ expect(first_child_avatar.textContent).toBe('D');
|
|
|
|
+ expect(first_child.textContent).toBe('D dick');
|
|
|
|
+
|
|
|
|
+ const second_child = view.querySelector('.suggestion-box__results li:nth-child(2)');
|
|
|
|
+ const second_child_avatar = second_child.querySelector('converse-avatar');
|
|
|
|
+ expect(second_child_avatar.textContent).toBe('H');
|
|
|
|
+ expect(second_child.textContent).toBe('H harry');
|
|
|
|
+
|
|
|
|
+ const third_child = view.querySelector('.suggestion-box__results li:nth-child(3)');
|
|
|
|
+ const third_child_avatar = third_child.querySelector('converse-avatar');
|
|
|
|
+ expect(third_child_avatar.textContent).toBe('J');
|
|
|
|
+ expect(third_child.textContent).toBe('J jane');
|
|
|
|
+
|
|
|
|
+ const fourth_child = view.querySelector('.suggestion-box__results li:nth-child(4)');
|
|
|
|
+ const fourth_child_avatar = fourth_child.querySelector('converse-avatar');
|
|
|
|
+ expect(fourth_child_avatar.textContent).toBe('T');
|
|
|
|
+ expect(fourth_child.textContent).toBe('T tom');
|
|
}));
|
|
}));
|
|
|
|
|
|
it("shows all autocompletion options when the user presses @ right after a new line",
|
|
it("shows all autocompletion options when the user presses @ right after a new line",
|
|
@@ -113,21 +118,25 @@ describe("The nickname autocomplete feature", function () {
|
|
message_form.onKeyUp(at_event);
|
|
message_form.onKeyUp(at_event);
|
|
|
|
|
|
await u.waitUntil(() => view.querySelectorAll('.suggestion-box__results li').length === 4);
|
|
await u.waitUntil(() => view.querySelectorAll('.suggestion-box__results li').length === 4);
|
|
- const first_child = view.querySelector('.suggestion-box__results li:first-child converse-avatar');
|
|
|
|
- expect(first_child.textContent).toBe('D');
|
|
|
|
- expect(first_child.nextSibling.textContent).toBe('dick');
|
|
|
|
-
|
|
|
|
- const second_child = view.querySelector('.suggestion-box__results li:nth-child(2) converse-avatar');
|
|
|
|
- expect(second_child.textContent).toBe('H');
|
|
|
|
- expect(second_child.nextSibling.textContent).toBe('harry');
|
|
|
|
-
|
|
|
|
- const third_child = view.querySelector('.suggestion-box__results li:nth-child(3) converse-avatar');
|
|
|
|
- expect(third_child.textContent).toBe('J');
|
|
|
|
- expect(third_child.nextSibling.textContent).toBe('jane');
|
|
|
|
-
|
|
|
|
- const fourth_child = view.querySelector('.suggestion-box__results li:nth-child(4) converse-avatar');
|
|
|
|
- expect(fourth_child.textContent).toBe('T');
|
|
|
|
- expect(fourth_child.nextSibling.textContent).toBe('tom');
|
|
|
|
|
|
+ const first_child = view.querySelector('.suggestion-box__results li:first-child');
|
|
|
|
+ const first_child_avatar = first_child.querySelector('converse-avatar');
|
|
|
|
+ expect(first_child_avatar.textContent).toBe('D');
|
|
|
|
+ expect(first_child.textContent).toBe('D dick');
|
|
|
|
+
|
|
|
|
+ const second_child = view.querySelector('.suggestion-box__results li:nth-child(2)');
|
|
|
|
+ const second_child_avatar = second_child.querySelector('converse-avatar');
|
|
|
|
+ expect(second_child_avatar.textContent).toBe('H');
|
|
|
|
+ expect(second_child.textContent).toBe('H harry');
|
|
|
|
+
|
|
|
|
+ const third_child = view.querySelector('.suggestion-box__results li:nth-child(3)');
|
|
|
|
+ const third_child_avatar = third_child.querySelector('converse-avatar');
|
|
|
|
+ expect(third_child_avatar.textContent).toBe('J');
|
|
|
|
+ expect(third_child.textContent).toBe('J jane');
|
|
|
|
+
|
|
|
|
+ const fourth_child = view.querySelector('.suggestion-box__results li:nth-child(4)');
|
|
|
|
+ const fourth_child_avatar = fourth_child.querySelector('converse-avatar');
|
|
|
|
+ expect(fourth_child_avatar.textContent).toBe('T');
|
|
|
|
+ expect(fourth_child.textContent).toBe('T tom');
|
|
}));
|
|
}));
|
|
|
|
|
|
it("shows all autocompletion options when the user presses @ right after an allowed character",
|
|
it("shows all autocompletion options when the user presses @ right after an allowed character",
|
|
@@ -179,21 +188,25 @@ describe("The nickname autocomplete feature", function () {
|
|
message_form.onKeyUp(at_event);
|
|
message_form.onKeyUp(at_event);
|
|
|
|
|
|
await u.waitUntil(() => view.querySelectorAll('.suggestion-box__results li').length === 4);
|
|
await u.waitUntil(() => view.querySelectorAll('.suggestion-box__results li').length === 4);
|
|
- const first_child = view.querySelector('.suggestion-box__results li:first-child converse-avatar');
|
|
|
|
- expect(first_child.textContent).toBe('D');
|
|
|
|
- expect(first_child.nextSibling.textContent).toBe('dick');
|
|
|
|
-
|
|
|
|
- const second_child = view.querySelector('.suggestion-box__results li:nth-child(2) converse-avatar');
|
|
|
|
- expect(second_child.textContent).toBe('H');
|
|
|
|
- expect(second_child.nextSibling.textContent).toBe('harry');
|
|
|
|
-
|
|
|
|
- const third_child = view.querySelector('.suggestion-box__results li:nth-child(3) converse-avatar');
|
|
|
|
- expect(third_child.textContent).toBe('J');
|
|
|
|
- expect(third_child.nextSibling.textContent).toBe('jane');
|
|
|
|
-
|
|
|
|
- const fourth_child = view.querySelector('.suggestion-box__results li:nth-child(4) converse-avatar');
|
|
|
|
- expect(fourth_child.textContent).toBe('T');
|
|
|
|
- expect(fourth_child.nextSibling.textContent).toBe('tom');
|
|
|
|
|
|
+ const first_child = view.querySelector('.suggestion-box__results li:first-child');
|
|
|
|
+ const first_child_avatar = first_child.querySelector('converse-avatar');
|
|
|
|
+ expect(first_child_avatar.textContent).toBe('D');
|
|
|
|
+ expect(first_child.textContent).toBe('D dick');
|
|
|
|
+
|
|
|
|
+ const second_child = view.querySelector('.suggestion-box__results li:nth-child(2)');
|
|
|
|
+ const second_child_avatar = second_child.querySelector('converse-avatar');
|
|
|
|
+ expect(second_child_avatar.textContent).toBe('H');
|
|
|
|
+ expect(second_child.textContent).toBe('H harry');
|
|
|
|
+
|
|
|
|
+ const third_child = view.querySelector('.suggestion-box__results li:nth-child(3)');
|
|
|
|
+ const third_child_avatar = third_child.querySelector('converse-avatar');
|
|
|
|
+ expect(third_child_avatar.textContent).toBe('J');
|
|
|
|
+ expect(third_child.textContent).toBe('J jane');
|
|
|
|
+
|
|
|
|
+ const fourth_child = view.querySelector('.suggestion-box__results li:nth-child(4)');
|
|
|
|
+ const fourth_child_avatar = fourth_child.querySelector('converse-avatar');
|
|
|
|
+ expect(fourth_child_avatar.textContent).toBe('T');
|
|
|
|
+ expect(fourth_child.textContent).toBe('T tom');
|
|
}));
|
|
}));
|
|
|
|
|
|
it("should order by query index position and length", mock.initConverse(
|
|
it("should order by query index position and length", mock.initConverse(
|
|
@@ -232,21 +245,27 @@ describe("The nickname autocomplete feature", function () {
|
|
message_form.onKeyUp(at_event);
|
|
message_form.onKeyUp(at_event);
|
|
await u.waitUntil(() => view.querySelectorAll('.suggestion-box__results li').length === 3);
|
|
await u.waitUntil(() => view.querySelectorAll('.suggestion-box__results li').length === 3);
|
|
|
|
|
|
- const first_child = view.querySelector('.suggestion-box__results li:first-child converse-avatar');
|
|
|
|
- expect(first_child.textContent).toBe('B');
|
|
|
|
- expect(first_child.nextElementSibling.textContent).toBe('ber');
|
|
|
|
- expect(first_child.nextElementSibling.nextSibling.textContent).toBe('nard');
|
|
|
|
|
|
+ const first_child = view.querySelector('.suggestion-box__results li:first-child');
|
|
|
|
+ expect(first_child.textContent).toBe('B bernard');
|
|
|
|
+ const first_child_avatar = first_child.querySelector('converse-avatar');
|
|
|
|
+ expect(first_child_avatar.textContent).toBe('B');
|
|
|
|
+ const first_child_mark = first_child.querySelector('mark');
|
|
|
|
+ expect(first_child_mark.textContent).toBe('ber');
|
|
|
|
+
|
|
|
|
+ const second_child = view.querySelector('.suggestion-box__results li:nth-child(2)');
|
|
|
|
+ expect(second_child.textContent).toBe('N naber');
|
|
|
|
+ const second_child_avatar = second_child.querySelector('converse-avatar');
|
|
|
|
+ expect(second_child_avatar.textContent).toBe('N');
|
|
|
|
+ const second_child_mark = second_child.querySelector('mark');
|
|
|
|
+ expect(second_child_mark.textContent).toBe('ber');
|
|
|
|
|
|
- const second_child = view.querySelector('.suggestion-box__results li:nth-child(2) converse-avatar');
|
|
|
|
- expect(second_child.textContent).toBe('N');
|
|
|
|
- expect(second_child.nextSibling.textContent).toBe('na');
|
|
|
|
- expect(second_child.nextElementSibling.textContent).toBe('ber');
|
|
|
|
|
|
+ const third_child = view.querySelector('.suggestion-box__results li:nth-child(3)');
|
|
|
|
+ expect(third_child.textContent).toBe('H helberlo');
|
|
|
|
+ const third_child_avatar = third_child.querySelector('converse-avatar');
|
|
|
|
+ expect(third_child_avatar.textContent).toBe('H');
|
|
|
|
+ const third_child_mark = third_child.querySelector('mark');
|
|
|
|
+ expect(third_child_mark.textContent).toBe('ber');
|
|
|
|
|
|
- const third_child = view.querySelector('.suggestion-box__results li:nth-child(3) converse-avatar');
|
|
|
|
- expect(third_child.textContent).toBe('H');
|
|
|
|
- expect(third_child.nextSibling.textContent).toBe('hel');
|
|
|
|
- expect(third_child.nextSibling.nextSibling.textContent).toBe('ber');
|
|
|
|
- expect(third_child.nextSibling.nextSibling.nextSibling.textContent).toBe('lo');
|
|
|
|
|
|
|
|
// Test that when the query index is equal, results should be sorted by length
|
|
// Test that when the query index is equal, results should be sorted by length
|
|
textarea.value = '@jo';
|
|
textarea.value = '@jo';
|
|
@@ -254,8 +273,8 @@ describe("The nickname autocomplete feature", function () {
|
|
await u.waitUntil(() => view.querySelectorAll('.suggestion-box__results li').length === 2);
|
|
await u.waitUntil(() => view.querySelectorAll('.suggestion-box__results li').length === 2);
|
|
|
|
|
|
// First char is the avatar initial
|
|
// First char is the avatar initial
|
|
- expect(view.querySelector('.suggestion-box__results li:first-child').textContent).toBe('Jjohn');
|
|
|
|
- expect(view.querySelector('.suggestion-box__results li:nth-child(2)').textContent).toBe('Jjones');
|
|
|
|
|
|
+ expect(view.querySelector('.suggestion-box__results li:first-child').textContent).toBe('J john');
|
|
|
|
+ expect(view.querySelector('.suggestion-box__results li:nth-child(2)').textContent).toBe('J jones');
|
|
}));
|
|
}));
|
|
|
|
|
|
it("autocompletes when the user presses tab",
|
|
it("autocompletes when the user presses tab",
|
|
@@ -294,7 +313,7 @@ describe("The nickname autocomplete feature", function () {
|
|
expect(view.querySelectorAll('.suggestion-box__results li').length).toBe(1);
|
|
expect(view.querySelectorAll('.suggestion-box__results li').length).toBe(1);
|
|
|
|
|
|
// First char is the avatar initial
|
|
// First char is the avatar initial
|
|
- expect(view.querySelector('.suggestion-box__results li').textContent).toBe('Ssome1');
|
|
|
|
|
|
+ expect(view.querySelector('.suggestion-box__results li').textContent).toBe('S some1');
|
|
|
|
|
|
const backspace_event = {
|
|
const backspace_event = {
|
|
'target': textarea,
|
|
'target': textarea,
|
|
@@ -336,8 +355,8 @@ describe("The nickname autocomplete feature", function () {
|
|
message_form.onKeyUp(up_arrow_event);
|
|
message_form.onKeyUp(up_arrow_event);
|
|
expect(view.querySelectorAll('.suggestion-box__results li').length).toBe(2);
|
|
expect(view.querySelectorAll('.suggestion-box__results li').length).toBe(2);
|
|
// First char is the avatar initial
|
|
// First char is the avatar initial
|
|
- expect(view.querySelector('.suggestion-box__results li[aria-selected="false"]').textContent).toBe('Ssome1');
|
|
|
|
- expect(view.querySelector('.suggestion-box__results li[aria-selected="true"]').textContent).toBe('Ssome2');
|
|
|
|
|
|
+ expect(view.querySelector('.suggestion-box__results li[aria-selected="false"]').textContent).toBe('S some1');
|
|
|
|
+ expect(view.querySelector('.suggestion-box__results li[aria-selected="true"]').textContent).toBe('S some2');
|
|
|
|
|
|
message_form.onKeyDown({
|
|
message_form.onKeyDown({
|
|
'target': textarea,
|
|
'target': textarea,
|
|
@@ -404,6 +423,6 @@ describe("The nickname autocomplete feature", function () {
|
|
await u.waitUntil(() => view.querySelector('.suggestion-box__results').hidden === false);
|
|
await u.waitUntil(() => view.querySelector('.suggestion-box__results').hidden === false);
|
|
expect(view.querySelectorAll('.suggestion-box__results li').length).toBe(1);
|
|
expect(view.querySelectorAll('.suggestion-box__results li').length).toBe(1);
|
|
// First char is the avatar initial
|
|
// First char is the avatar initial
|
|
- expect(view.querySelector('.suggestion-box__results li').textContent).toBe('Ssome1');
|
|
|
|
|
|
+ expect(view.querySelector('.suggestion-box__results li').textContent).toBe('S some1');
|
|
}));
|
|
}));
|
|
});
|
|
});
|