2020-08-01 03:43:15 +02:00
|
|
|
"use strict";
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
var common = require("../casper_lib/common.js");
|
2013-03-21 18:18:28 +01:00
|
|
|
|
|
|
|
common.start_and_log_in();
|
|
|
|
|
2020-01-29 14:12:24 +01:00
|
|
|
function get_stream_li(stream_name) {
|
2020-01-29 14:13:12 +01:00
|
|
|
var stream_id = common.get_stream_id(stream_name);
|
|
|
|
return '#stream_filters [data-stream-id="' + stream_id + '"]';
|
2020-01-29 14:12:24 +01:00
|
|
|
}
|
|
|
|
|
2016-06-25 01:41:07 +02:00
|
|
|
// We could use the messages sent by 02-site.js, but we want to
|
2013-03-21 18:18:28 +01:00
|
|
|
// make sure each test file can be run individually (which the
|
|
|
|
// 'run' script provides for).
|
|
|
|
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.info("Sending messages");
|
2013-03-21 18:18:28 +01:00
|
|
|
});
|
|
|
|
|
2014-03-07 20:59:30 +01:00
|
|
|
common.then_send_many([
|
2020-07-15 00:34:28 +02:00
|
|
|
{stream: "Verona", subject: "frontend test", content: "test message A"},
|
2013-03-21 18:18:28 +01:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
{stream: "Verona", subject: "frontend test", content: "test message B"},
|
2013-03-21 18:18:28 +01:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
{stream: "Verona", subject: "other subject", content: "test message C"},
|
2013-03-21 18:18:28 +01:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
{stream: "Denmark", subject: "frontend test", content: "other message"},
|
2013-03-22 01:42:46 +01:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
{recipient: "cordelia@zulip.com, hamlet@zulip.com", content: "personal A"},
|
2013-03-21 18:18:28 +01:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
{recipient: "cordelia@zulip.com, hamlet@zulip.com", content: "personal B"},
|
2013-03-21 18:18:28 +01:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
{recipient: "cordelia@zulip.com", content: "personal C"},
|
2013-03-21 18:18:28 +01:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
{stream: "Verona", subject: "frontend test", content: "test message D"},
|
2013-03-21 18:18:28 +01:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
{recipient: "cordelia@zulip.com, hamlet@zulip.com", content: "personal D"},
|
2013-03-22 01:42:46 +01:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
{recipient: "cordelia@zulip.com", content: "personal E"},
|
2013-03-21 18:18:28 +01:00
|
|
|
]);
|
|
|
|
|
2013-03-21 19:38:18 +01:00
|
|
|
// Define the messages we expect to see when narrowed.
|
2013-03-21 18:18:28 +01:00
|
|
|
|
2013-03-21 19:38:18 +01:00
|
|
|
function expect_home() {
|
2016-09-20 12:43:06 +02:00
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#zhome", function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
common.expected_messages(
|
|
|
|
"zhome",
|
|
|
|
[
|
|
|
|
"Verona > frontend test",
|
|
|
|
"You and Cordelia Lear, King Hamlet",
|
|
|
|
"You and Cordelia Lear",
|
|
|
|
],
|
|
|
|
["<p>test message D</p>", "<p>personal D</p>", "<p>personal E</p>"]
|
|
|
|
);
|
2016-09-20 12:43:06 +02:00
|
|
|
});
|
|
|
|
});
|
2013-03-21 19:38:18 +01:00
|
|
|
}
|
2013-03-21 18:18:28 +01:00
|
|
|
|
2013-03-21 19:38:18 +01:00
|
|
|
function expect_stream() {
|
2016-09-20 12:43:06 +02:00
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#zfilt", function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
common.expected_messages(
|
|
|
|
"zfilt",
|
|
|
|
["Verona > frontend test", "Verona > other subject", "Verona > frontend test"],
|
|
|
|
[
|
|
|
|
"<p>test message A</p>",
|
|
|
|
"<p>test message B</p>",
|
|
|
|
"<p>test message C</p>",
|
|
|
|
"<p>test message D</p>",
|
|
|
|
]
|
|
|
|
);
|
2016-09-20 12:43:06 +02:00
|
|
|
});
|
|
|
|
});
|
2013-03-21 19:38:18 +01:00
|
|
|
}
|
2013-03-21 18:18:28 +01:00
|
|
|
|
2013-03-21 19:38:18 +01:00
|
|
|
function expect_stream_subject() {
|
2016-09-20 12:43:06 +02:00
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#zfilt", function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
common.expected_messages(
|
|
|
|
"zfilt",
|
|
|
|
["Verona > frontend test"],
|
|
|
|
["<p>test message A</p>", "<p>test message B</p>", "<p>test message D</p>"]
|
|
|
|
);
|
|
|
|
|
|
|
|
casper.test.assertEquals(
|
|
|
|
casper.fetchText("#left_bar_compose_stream_button_big"),
|
|
|
|
"New topic"
|
|
|
|
);
|
2016-09-20 12:43:06 +02:00
|
|
|
});
|
|
|
|
});
|
2013-03-21 19:38:18 +01:00
|
|
|
}
|
2013-03-21 18:18:28 +01:00
|
|
|
|
2013-03-22 01:42:46 +01:00
|
|
|
function expect_subject() {
|
2016-09-20 12:43:06 +02:00
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#zfilt", function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
common.expected_messages(
|
|
|
|
"zfilt",
|
|
|
|
["Verona > frontend test", "Denmark > frontend test", "Verona > frontend test"],
|
|
|
|
[
|
|
|
|
"<p>test message A</p>",
|
|
|
|
"<p>test message B</p>",
|
|
|
|
"<p>other message</p>",
|
|
|
|
"<p>test message D</p>",
|
|
|
|
]
|
|
|
|
);
|
2016-09-20 12:43:06 +02:00
|
|
|
});
|
|
|
|
});
|
2013-03-22 01:42:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function expect_huddle() {
|
2016-09-20 12:43:06 +02:00
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#zfilt", function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
common.expected_messages(
|
|
|
|
"zfilt",
|
|
|
|
["You and Cordelia Lear, King Hamlet"],
|
|
|
|
["<p>personal A</p>", "<p>personal B</p>", "<p>personal D</p>"]
|
|
|
|
);
|
2016-09-20 12:43:06 +02:00
|
|
|
});
|
|
|
|
});
|
2013-03-21 19:38:18 +01:00
|
|
|
}
|
|
|
|
|
2013-03-22 01:42:46 +01:00
|
|
|
function expect_1on1() {
|
2016-09-20 12:43:06 +02:00
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#zfilt", function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
common.expected_messages(
|
|
|
|
"zfilt",
|
|
|
|
["You and Cordelia Lear"],
|
|
|
|
["<p>personal C</p>", "<p>personal E</p>"]
|
|
|
|
);
|
2016-09-20 12:43:06 +02:00
|
|
|
});
|
|
|
|
});
|
2013-03-22 01:42:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function expect_all_pm() {
|
2016-09-20 12:43:06 +02:00
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#zfilt", function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
common.expected_messages(
|
|
|
|
"zfilt",
|
|
|
|
["You and Cordelia Lear, King Hamlet", "You and Cordelia Lear"],
|
|
|
|
[
|
|
|
|
"<p>personal A</p>",
|
|
|
|
"<p>personal B</p>",
|
|
|
|
"<p>personal C</p>",
|
|
|
|
"<p>personal D</p>",
|
|
|
|
"<p>personal E</p>",
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
casper.test.assertEquals(
|
|
|
|
casper.fetchText("#left_bar_compose_stream_button_big"),
|
|
|
|
"New stream message"
|
|
|
|
);
|
2016-09-20 12:43:06 +02:00
|
|
|
});
|
|
|
|
});
|
2013-03-22 01:42:46 +01:00
|
|
|
}
|
|
|
|
|
2019-06-28 02:02:43 +02:00
|
|
|
function expect_non_existing_user() {
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#non_existing_user", function () {
|
2019-06-28 02:02:43 +02:00
|
|
|
casper.test.info("Empty feed for non existing user visible.");
|
2020-07-15 00:34:28 +02:00
|
|
|
var expected_message = "\n This user does not exist!" + "\n ";
|
2020-07-15 01:29:15 +02:00
|
|
|
this.test.assertEquals(casper.fetchText("#non_existing_user"), expected_message);
|
2019-06-28 02:02:43 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-06-28 02:17:43 +02:00
|
|
|
function expect_non_existing_users() {
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#non_existing_users", function () {
|
2019-06-28 02:17:43 +02:00
|
|
|
casper.test.info("Empty feed for non existing user visible.");
|
2020-07-15 00:34:28 +02:00
|
|
|
var expected_message = "\n One or more of these users do not exist!" + "\n ";
|
2020-07-15 01:29:15 +02:00
|
|
|
this.test.assertEquals(casper.fetchText("#non_existing_users"), expected_message);
|
2019-06-28 02:17:43 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2015-12-10 20:37:01 +01:00
|
|
|
function check_narrow_title(title) {
|
|
|
|
return function () {
|
|
|
|
// need to get title tag from HTML
|
|
|
|
// test if it's equal to some string passed in to function
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.assertSelectorHasText("title", title, "Got expected narrow title");
|
2015-12-10 20:37:01 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-03-22 01:42:46 +01:00
|
|
|
function un_narrow() {
|
2013-03-29 00:03:11 +01:00
|
|
|
casper.then(common.un_narrow);
|
2016-09-20 12:43:06 +02:00
|
|
|
expect_home();
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.then(check_narrow_title("home - Zulip Dev - Zulip"));
|
2013-03-22 01:42:46 +01:00
|
|
|
}
|
|
|
|
|
2015-12-10 20:37:01 +01:00
|
|
|
function search_and_check(str, item, check, narrow_title) {
|
2020-07-15 01:29:15 +02:00
|
|
|
common.select_item_via_typeahead("#search_query", str, item);
|
2016-09-20 12:43:06 +02:00
|
|
|
check();
|
2015-12-10 20:37:01 +01:00
|
|
|
casper.then(check_narrow_title(narrow_title));
|
2013-03-22 01:42:46 +01:00
|
|
|
un_narrow();
|
|
|
|
}
|
|
|
|
|
2016-07-29 16:15:50 +02:00
|
|
|
function search_silent_user(str, item) {
|
2020-07-15 01:29:15 +02:00
|
|
|
common.select_item_via_typeahead("#search_query", str, item);
|
2016-09-08 14:10:41 +02:00
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#silent_user", function () {
|
2016-09-08 14:10:41 +02:00
|
|
|
casper.test.info("Empty feed for silent user visible.");
|
2020-07-15 00:34:28 +02:00
|
|
|
var expected_message =
|
|
|
|
"\n You haven't received any messages sent by this user yet!" + "\n ";
|
2020-07-15 01:29:15 +02:00
|
|
|
this.test.assertEquals(casper.fetchText("#silent_user"), expected_message);
|
2016-09-08 14:10:41 +02:00
|
|
|
});
|
2016-07-29 16:15:50 +02:00
|
|
|
});
|
|
|
|
un_narrow();
|
|
|
|
}
|
|
|
|
|
|
|
|
function search_non_existing_user(str, item) {
|
2020-07-15 01:29:15 +02:00
|
|
|
common.select_item_via_typeahead("#search_query", str, item);
|
2019-06-28 02:02:43 +02:00
|
|
|
expect_non_existing_user();
|
2016-07-29 16:15:50 +02:00
|
|
|
un_narrow();
|
|
|
|
}
|
|
|
|
|
2016-09-20 12:43:06 +02:00
|
|
|
// Narrow by clicking links.
|
|
|
|
|
2016-09-08 14:10:41 +02:00
|
|
|
casper.then(function () {
|
2016-09-20 12:43:06 +02:00
|
|
|
common.wait_for_receive(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.info("Narrowing by clicking stream");
|
2016-12-06 19:57:46 +01:00
|
|
|
casper.click('*[title="Narrow to stream \\"Verona\\""]');
|
2016-09-20 12:43:06 +02:00
|
|
|
});
|
2016-09-08 14:10:41 +02:00
|
|
|
});
|
2013-03-22 01:42:46 +01:00
|
|
|
|
2016-09-20 12:43:06 +02:00
|
|
|
expect_stream();
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.then(check_narrow_title("Verona - Zulip Dev - Zulip"));
|
2016-09-20 12:43:06 +02:00
|
|
|
|
|
|
|
un_narrow();
|
|
|
|
|
|
|
|
expect_home();
|
|
|
|
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.info("Narrowing by clicking subject");
|
2016-12-06 19:57:46 +01:00
|
|
|
casper.click('*[title="Narrow to stream \\"Verona\\", topic \\"frontend test\\""]');
|
2016-09-20 12:43:06 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
expect_stream_subject();
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.then(check_narrow_title("frontend test - Zulip Dev - Zulip"));
|
2016-09-20 12:43:06 +02:00
|
|
|
|
|
|
|
casper.then(function () {
|
2020-02-03 17:01:11 +01:00
|
|
|
// Un-narrow by clicking "Zulip"
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.info("Un-narrowing");
|
|
|
|
casper.click(".brand");
|
2016-09-20 12:43:06 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
expect_home();
|
|
|
|
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.info("Narrowing by clicking personal");
|
2016-09-20 12:43:06 +02:00
|
|
|
casper.click('*[title="Narrow to your private messages with Cordelia Lear, King Hamlet"]');
|
|
|
|
});
|
|
|
|
|
|
|
|
expect_huddle();
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.then(check_narrow_title("Cordelia Lear, King Hamlet - Zulip Dev - Zulip"));
|
2016-09-20 12:43:06 +02:00
|
|
|
|
|
|
|
casper.then(function () {
|
|
|
|
// Un-narrow by clicking "Zulip"
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.info("Un-narrowing");
|
|
|
|
casper.click(".brand");
|
2016-09-20 12:43:06 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
expect_home();
|
|
|
|
|
|
|
|
// Narrow by typing in search strings or operators.
|
2013-03-22 01:42:46 +01:00
|
|
|
// Test stream / recipient autocomplete in the search bar
|
2020-07-15 00:34:28 +02:00
|
|
|
search_and_check("Verona", "Stream", expect_stream, "Verona - Zulip Dev - Zulip");
|
2016-09-20 12:43:06 +02:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
search_and_check("Cordelia", "Private", expect_1on1, "Cordelia Lear - Zulip Dev - Zulip");
|
2013-03-22 01:42:46 +01:00
|
|
|
|
|
|
|
// Test operators
|
2020-07-15 00:34:28 +02:00
|
|
|
search_and_check("stream:Verona", "", expect_stream, "Verona - Zulip Dev - Zulip");
|
2016-09-20 12:43:06 +02:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
search_and_check(
|
|
|
|
"stream:Verona subject:frontend+test",
|
|
|
|
"",
|
|
|
|
expect_stream_subject,
|
|
|
|
"frontend test - Zulip Dev - Zulip"
|
|
|
|
);
|
2016-09-20 12:43:06 +02:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
search_and_check(
|
|
|
|
"stream:Verona topic:frontend+test",
|
|
|
|
"",
|
|
|
|
expect_stream_subject,
|
|
|
|
"frontend test - Zulip Dev - Zulip"
|
|
|
|
);
|
2016-10-16 23:09:45 +02:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
search_and_check("subject:frontend+test", "", expect_subject, "home - Zulip Dev - Zulip");
|
2013-03-22 01:42:46 +01:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
search_silent_user("sender:emailgateway@zulip.com", "");
|
2016-09-20 12:43:06 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
search_non_existing_user("sender:dummyuser@zulip.com", "");
|
2016-07-29 16:15:50 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
search_and_check("pm-with:dummyuser@zulip.com", "", expect_non_existing_user, "Invalid user");
|
2019-06-28 02:17:43 +02:00
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
search_and_check(
|
|
|
|
"pm-with:dummyuser@zulip.com,dummyuser2@zulip.com",
|
|
|
|
"",
|
|
|
|
expect_non_existing_users,
|
|
|
|
"Invalid users"
|
|
|
|
);
|
2019-06-28 02:17:43 +02:00
|
|
|
|
2013-03-22 01:42:46 +01:00
|
|
|
// Narrow by clicking the left sidebar.
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.info("Narrowing with left sidebar");
|
|
|
|
casper.click(get_stream_li("Verona") + " a");
|
2013-03-22 01:42:46 +01:00
|
|
|
});
|
2016-09-20 12:43:06 +02:00
|
|
|
|
|
|
|
expect_stream();
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.then(check_narrow_title("Verona - Zulip Dev - Zulip"));
|
2016-09-20 12:43:06 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.thenClick(".top_left_all_messages a");
|
2016-09-20 12:43:06 +02:00
|
|
|
|
|
|
|
expect_home();
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.then(check_narrow_title("home - Zulip Dev - Zulip"));
|
2016-09-20 12:43:06 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.thenClick(".top_left_private_messages a");
|
2016-09-20 12:43:06 +02:00
|
|
|
|
|
|
|
expect_all_pm();
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.then(check_narrow_title("Private messages - Zulip Dev - Zulip"));
|
2013-03-21 19:38:18 +01:00
|
|
|
|
2016-09-20 12:43:06 +02:00
|
|
|
un_narrow();
|
2013-03-21 18:18:28 +01:00
|
|
|
|
2016-06-13 22:06:12 +02:00
|
|
|
// Make sure stream search filters the stream list
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.info("Search streams using left sidebar");
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertExists(
|
|
|
|
".input-append.notdisplayed",
|
|
|
|
"Stream filter box not visible initially"
|
|
|
|
);
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.click("#streams_header .sidebar-title");
|
2016-06-13 22:06:12 +02:00
|
|
|
});
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitWhileSelector("#streams_list .input-append.notdisplayed", function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertExists(get_stream_li("Denmark"), "Original stream list contains Denmark");
|
2020-07-23 04:32:20 +02:00
|
|
|
casper.test.assertExists(get_stream_li("Venice"), "Original stream list contains Venice");
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertExists(get_stream_li("Verona"), "Original stream list contains Verona");
|
2018-02-12 22:56:37 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// Enter the search box and test highlighted suggestion navigation
|
|
|
|
casper.then(function () {
|
|
|
|
casper.evaluate(function () {
|
2020-07-20 21:24:26 +02:00
|
|
|
$(".stream-list-filter").expectOne().trigger("focus").trigger($.Event("click"));
|
2018-02-12 22:56:37 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitForSelector("#stream_filters .highlighted_stream", function () {
|
|
|
|
casper.test.info("Suggestion highlighting - initial situation");
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertExist(
|
|
|
|
get_stream_li("Denmark") + ".highlighted_stream",
|
|
|
|
"Stream Denmark is highlighted"
|
|
|
|
);
|
|
|
|
casper.test.assertDoesntExist(
|
2020-07-23 04:32:20 +02:00
|
|
|
get_stream_li("Venice") + ".highlighted_stream",
|
|
|
|
"Stream Venice is not highlighted"
|
2020-07-15 00:34:28 +02:00
|
|
|
);
|
|
|
|
casper.test.assertDoesntExist(
|
|
|
|
get_stream_li("Verona") + ".highlighted_stream",
|
|
|
|
"Stream Verona is not highlighted"
|
|
|
|
);
|
2018-02-12 22:56:37 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// Use arrow keys to navigate through suggestions
|
|
|
|
casper.then(function () {
|
2018-04-24 16:59:01 +02:00
|
|
|
function arrow(key) {
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.sendKeys(".stream-list-filter", casper.page.event.key[key], {keepFocus: true});
|
2018-04-24 16:59:01 +02:00
|
|
|
}
|
2020-07-23 04:32:20 +02:00
|
|
|
arrow("Down"); // Denmark -> Venice
|
|
|
|
arrow("Up"); // Venice -> Denmark
|
2020-07-15 01:29:15 +02:00
|
|
|
arrow("Up"); // Denmark -> Denmark
|
2020-07-23 04:32:20 +02:00
|
|
|
arrow("Down"); // Denmark -> Venice
|
2018-02-12 22:56:37 +01:00
|
|
|
});
|
|
|
|
|
2020-01-29 14:13:12 +01:00
|
|
|
casper.then(function () {
|
2020-07-23 04:32:20 +02:00
|
|
|
casper.waitForSelector(get_stream_li("Venice") + ".highlighted_stream", function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.info("Suggestion highlighting - after arrow key navigation");
|
2020-01-29 14:13:12 +01:00
|
|
|
casper.test.assertDoesntExist(
|
2020-07-15 01:29:15 +02:00
|
|
|
get_stream_li("Denmark") + ".highlighted_stream",
|
2020-07-15 00:34:28 +02:00
|
|
|
"Stream Denmark is not highlighted"
|
|
|
|
);
|
2020-01-29 14:13:12 +01:00
|
|
|
casper.test.assertExist(
|
2020-07-23 04:32:20 +02:00
|
|
|
get_stream_li("Venice") + ".highlighted_stream",
|
|
|
|
"Stream Venice is highlighted"
|
2020-07-15 00:34:28 +02:00
|
|
|
);
|
2020-01-29 14:13:12 +01:00
|
|
|
casper.test.assertDoesntExist(
|
2020-07-15 01:29:15 +02:00
|
|
|
get_stream_li("Verona") + ".highlighted_stream",
|
2020-07-15 00:34:28 +02:00
|
|
|
"Stream Verona is not highlighted"
|
|
|
|
);
|
2020-01-29 14:13:12 +01:00
|
|
|
});
|
2016-06-13 22:06:12 +02:00
|
|
|
});
|
|
|
|
|
2020-07-23 04:32:20 +02:00
|
|
|
// We search for the beginning of "Venice", not case sensitive
|
2016-06-13 22:06:12 +02:00
|
|
|
casper.then(function () {
|
|
|
|
casper.evaluate(function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
$(".stream-list-filter")
|
|
|
|
.expectOne()
|
2020-07-20 21:24:26 +02:00
|
|
|
.trigger("focus")
|
2020-07-23 04:32:20 +02:00
|
|
|
.val("vEnI")
|
2020-07-15 01:29:15 +02:00
|
|
|
.trigger($.Event("input"))
|
|
|
|
.trigger($.Event("click"));
|
2016-06-13 22:06:12 +02:00
|
|
|
});
|
|
|
|
});
|
2016-09-20 12:43:06 +02:00
|
|
|
|
|
|
|
// There will be no race condition between these two waits because we
|
|
|
|
// expect them to happen in parallel.
|
2020-01-29 14:12:24 +01:00
|
|
|
casper.waitWhileVisible(get_stream_li("Denmark"), function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.info("Search term entered");
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertDoesntExist(
|
|
|
|
get_stream_li("Denmark"),
|
|
|
|
"Filtered stream list does not contain Denmark"
|
|
|
|
);
|
2016-09-20 12:43:06 +02:00
|
|
|
});
|
2020-01-29 14:12:24 +01:00
|
|
|
casper.waitWhileVisible(get_stream_li("Verona"), function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertDoesntExist(
|
|
|
|
get_stream_li("Verona"),
|
|
|
|
"Filtered stream list does not contain Verona"
|
|
|
|
);
|
2016-09-20 12:43:06 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
2020-07-23 04:32:20 +02:00
|
|
|
casper.test.assertExists(get_stream_li("Venice"), "Filtered stream list does contain Venice");
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertExists(
|
2020-07-23 04:32:20 +02:00
|
|
|
get_stream_li("Venice") + ".highlighted_stream",
|
|
|
|
"Stream Venice is highlighted"
|
2020-07-15 00:34:28 +02:00
|
|
|
);
|
2016-06-13 22:06:12 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
// Clearing the list should give us back all the streams in the list
|
|
|
|
casper.then(function () {
|
|
|
|
casper.evaluate(function () {
|
2020-07-20 21:24:26 +02:00
|
|
|
$(".stream-list-filter").expectOne().trigger("focus").val("").trigger($.Event("input"));
|
2016-06-13 22:06:12 +02:00
|
|
|
});
|
|
|
|
});
|
2016-09-20 12:43:06 +02:00
|
|
|
|
2020-01-29 14:13:12 +01:00
|
|
|
casper.then(function () {
|
|
|
|
casper.waitUntilVisible(get_stream_li("Denmark"), function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertExists(get_stream_li("Denmark"), "Restored stream list contains Denmark");
|
2020-01-29 14:13:12 +01:00
|
|
|
});
|
2020-07-23 04:32:20 +02:00
|
|
|
casper.waitUntilVisible(get_stream_li("Venice"), function () {
|
|
|
|
casper.test.assertExists(get_stream_li("Denmark"), "Restored stream list contains Venice");
|
2020-01-29 14:13:12 +01:00
|
|
|
});
|
|
|
|
casper.waitUntilVisible(get_stream_li("Verona"), function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertExists(get_stream_li("Denmark"), "Restored stream list contains Verona");
|
2020-01-29 14:13:12 +01:00
|
|
|
});
|
2016-06-13 22:06:12 +02:00
|
|
|
});
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.thenClick("#streams_header .sidebar-title");
|
2016-06-13 22:06:12 +02:00
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitForSelector(".input-append.notdisplayed", function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertExists(
|
|
|
|
".input-append.notdisplayed",
|
|
|
|
"Stream filter box not visible after second click"
|
|
|
|
);
|
2016-06-13 22:06:12 +02:00
|
|
|
});
|
|
|
|
|
2018-01-25 20:44:30 +01:00
|
|
|
// We search for the beginning of "Verona", not case sensitive
|
|
|
|
casper.then(function () {
|
|
|
|
casper.evaluate(function () {
|
2020-07-20 21:24:26 +02:00
|
|
|
$(".stream-list-filter").expectOne().trigger("focus").val("ver").trigger($.Event("input"));
|
2018-01-25 20:44:30 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-01-29 14:12:24 +01:00
|
|
|
casper.waitWhileVisible(get_stream_li("Denmark"), function () {
|
2018-01-25 20:44:30 +01:00
|
|
|
// Clicking the narrowed list should clear the search
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.click(get_stream_li("Verona") + " a");
|
2018-01-25 20:44:30 +01:00
|
|
|
expect_stream();
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertEquals(
|
|
|
|
casper.fetchText(".stream-list-filter"),
|
|
|
|
"",
|
|
|
|
"Clicking on a stream clears the search"
|
|
|
|
);
|
2018-01-25 20:44:30 +01:00
|
|
|
});
|
|
|
|
|
2016-06-13 22:06:12 +02:00
|
|
|
un_narrow();
|
|
|
|
|
2018-09-08 17:44:47 +02:00
|
|
|
function assert_in_list(name) {
|
|
|
|
casper.test.assertExists(
|
|
|
|
'#user_presences li [data-name="' + name + '"]',
|
2020-07-15 01:29:15 +02:00
|
|
|
"User " + name + " is IN buddy list"
|
2018-09-08 17:44:47 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function assert_selected(name) {
|
|
|
|
casper.test.assertExists(
|
|
|
|
'#user_presences li.highlighted_user [data-name="' + name + '"]',
|
2020-07-15 01:29:15 +02:00
|
|
|
"User " + name + " is SELECTED IN buddy list"
|
2018-09-08 17:44:47 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function assert_not_selected(name) {
|
|
|
|
assert_in_list(name);
|
|
|
|
casper.test.assertDoesntExist(
|
|
|
|
'#user_presences li.highlighted_user [data-name="' + name + '"]',
|
2020-07-15 01:29:15 +02:00
|
|
|
"User " + name + " is NOT SELECTED buddy list"
|
2018-09-08 17:44:47 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-02-12 23:31:17 +01:00
|
|
|
// User search at the right sidebar
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.info("Search users using right sidebar");
|
2020-07-23 04:32:20 +02:00
|
|
|
assert_in_list("Desdemona");
|
2020-07-15 01:29:15 +02:00
|
|
|
assert_in_list("Cordelia Lear");
|
|
|
|
assert_in_list("King Hamlet");
|
|
|
|
assert_in_list("aaron");
|
2018-02-12 23:31:17 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// Enter the search box and test selected suggestion navigation
|
|
|
|
// Click on search icon
|
|
|
|
casper.then(function () {
|
|
|
|
casper.evaluate(function () {
|
2020-07-20 21:24:26 +02:00
|
|
|
$("#user_filter_icon").expectOne().trigger("focus").trigger($.Event("click"));
|
2018-02-12 23:31:17 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitForSelector("#user_presences .highlighted_user", function () {
|
|
|
|
casper.test.info("Suggestion highlighting - initial situation");
|
2020-07-23 04:32:20 +02:00
|
|
|
assert_selected("Desdemona");
|
2020-07-15 01:29:15 +02:00
|
|
|
assert_not_selected("Cordelia Lear");
|
|
|
|
assert_not_selected("King Hamlet");
|
|
|
|
assert_not_selected("aaron");
|
2018-02-12 23:31:17 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// Use arrow keys to navigate through suggestions
|
|
|
|
casper.then(function () {
|
2018-04-21 14:59:03 +02:00
|
|
|
function arrow(key) {
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.sendKeys(".user-list-filter", casper.page.event.key[key], {keepFocus: true});
|
2018-04-21 14:59:03 +02:00
|
|
|
}
|
2018-09-08 14:41:41 +02:00
|
|
|
|
2020-05-27 05:31:36 +02:00
|
|
|
// go down 2, up 3 (which is really 2), then down 3
|
2018-09-08 14:41:41 +02:00
|
|
|
// Iago
|
|
|
|
// Cordelia
|
2020-05-27 05:31:36 +02:00
|
|
|
// Desdemona
|
2018-09-08 14:41:41 +02:00
|
|
|
// Hamlet
|
2020-07-15 01:29:15 +02:00
|
|
|
arrow("Down");
|
|
|
|
arrow("Down");
|
|
|
|
arrow("Up");
|
|
|
|
arrow("Up");
|
|
|
|
arrow("Up"); // does nothing
|
|
|
|
arrow("Down");
|
|
|
|
arrow("Down");
|
|
|
|
arrow("Down");
|
2018-02-12 23:31:17 +01:00
|
|
|
});
|
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.waitForSelector(
|
|
|
|
'#user_presences li.highlighted_user [data-name="King Hamlet"]',
|
|
|
|
function () {
|
|
|
|
casper.test.info("Suggestion highlighting - after arrow key navigation");
|
|
|
|
assert_not_selected("Iago");
|
|
|
|
assert_not_selected("Cordelia Lear");
|
|
|
|
assert_selected("King Hamlet");
|
|
|
|
}
|
|
|
|
);
|
2018-02-12 23:31:17 +01:00
|
|
|
|
2013-03-21 18:18:28 +01:00
|
|
|
common.then_log_out();
|
|
|
|
|
|
|
|
// Run the above queued actions.
|
|
|
|
casper.run(function () {
|
|
|
|
casper.test.done();
|
|
|
|
});
|