2020-07-15 01:29:15 +02:00
|
|
|
var common = require("../casper_lib/common.js");
|
2013-03-29 00:03:11 +01:00
|
|
|
|
|
|
|
function star_count() {
|
|
|
|
return casper.evaluate(function () {
|
2018-07-04 01:42:24 +02:00
|
|
|
return $("#zhome .fa-star:not(.empty-star)").length;
|
2013-03-29 00:03:11 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-03-25 23:34:36 +01:00
|
|
|
function toggle_test_star_message() {
|
|
|
|
var error = casper.evaluate(function () {
|
|
|
|
var msg = $('.message_content:contains("test star"):visible').last();
|
|
|
|
|
|
|
|
if (msg.length !== 1) {
|
2020-07-15 01:29:15 +02:00
|
|
|
return "cannot find test star message";
|
2020-03-25 23:34:36 +01:00
|
|
|
}
|
|
|
|
|
2020-07-15 00:34:28 +02:00
|
|
|
var star_icon = msg.closest(".messagebox").find(".star");
|
2020-03-25 23:34:36 +01:00
|
|
|
|
|
|
|
if (star_icon.length !== 1) {
|
2020-07-15 01:29:15 +02:00
|
|
|
return "cannot find star icon";
|
2020-03-25 23:34:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
star_icon.click();
|
2013-03-29 00:03:11 +01:00
|
|
|
});
|
2020-03-25 23:34:36 +01:00
|
|
|
|
|
|
|
if (error) {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.test.info("\n\nERROR: " + error);
|
2020-03-25 23:34:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
casper.test.assert(!error);
|
2013-03-29 00:03:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
common.start_and_log_in();
|
|
|
|
|
2013-07-05 17:43:56 +02:00
|
|
|
casper.then(function () {
|
2013-03-29 00:03:11 +01:00
|
|
|
casper.test.info("Sending test message");
|
2014-03-07 20:58:18 +01:00
|
|
|
});
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
common.then_send_message("stream", {
|
|
|
|
stream: "Verona",
|
|
|
|
subject: "stars",
|
|
|
|
content: "test star",
|
2013-03-29 00:03:11 +01:00
|
|
|
});
|
|
|
|
|
2017-06-07 09:55:08 +02:00
|
|
|
casper.then(function () {
|
2020-03-31 14:39:19 +02:00
|
|
|
common.wait_for_text("#zhome .message_row", "test star");
|
2017-06-07 09:55:08 +02:00
|
|
|
});
|
2014-03-07 20:58:18 +01:00
|
|
|
|
2013-07-05 17:43:56 +02:00
|
|
|
casper.then(function () {
|
2013-03-29 00:03:11 +01:00
|
|
|
casper.test.info("Checking star counts");
|
|
|
|
|
|
|
|
// Initially, no messages are starred.
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertEquals(star_count(), 0, "Got expected empty star count.");
|
2013-03-29 00:03:11 +01:00
|
|
|
|
|
|
|
// Clicking on a message star stars it.
|
2020-03-25 23:34:36 +01:00
|
|
|
toggle_test_star_message();
|
2018-04-23 18:14:22 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#zhome .fa-star", function () {
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertEquals(star_count(), 1, "Got expected single star count.");
|
2013-03-29 00:03:11 +01:00
|
|
|
|
2018-04-23 18:14:22 +02:00
|
|
|
casper.click('a[href^="#narrow/is/starred"]');
|
|
|
|
});
|
2013-03-29 00:03:11 +01:00
|
|
|
});
|
|
|
|
|
2020-07-15 01:29:15 +02:00
|
|
|
casper.waitUntilVisible("#zfilt", function () {
|
2013-03-29 00:03:11 +01:00
|
|
|
// You can narrow to your starred messages.
|
2020-07-15 01:29:15 +02:00
|
|
|
common.expected_messages("zfilt", ["Verona > stars"], ["<p>test star</p>"]);
|
2013-03-29 00:03:11 +01:00
|
|
|
common.un_narrow();
|
|
|
|
});
|
|
|
|
|
2013-07-05 17:43:56 +02:00
|
|
|
casper.then(function () {
|
2013-03-29 00:03:11 +01:00
|
|
|
// Clicking on a starred message unstars it.
|
2020-03-25 23:34:36 +01:00
|
|
|
toggle_test_star_message();
|
2020-07-15 00:34:28 +02:00
|
|
|
casper.test.assertEquals(star_count(), 0, "Got expected re-empty star count.");
|
2013-03-29 00:03:11 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
common.then_log_out();
|
|
|
|
|
|
|
|
casper.run(function () {
|
|
|
|
casper.test.done();
|
|
|
|
});
|