2019-10-25 09:45:13 +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
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function toggle_last_star() {
|
|
|
|
casper.evaluate(function () {
|
|
|
|
$("#zhome .star").last().click();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
});
|
|
|
|
|
2014-03-07 20:59:30 +01:00
|
|
|
common.then_send_message('stream', {
|
2018-12-18 19:34:45 +01:00
|
|
|
stream: 'Verona',
|
2018-05-07 01:42:17 +02:00
|
|
|
subject: 'stars',
|
|
|
|
content: 'test star',
|
2013-03-29 00:03:11 +01:00
|
|
|
});
|
|
|
|
|
2017-06-07 09:55:08 +02:00
|
|
|
casper.then(function () {
|
|
|
|
casper.waitForSelectorText("#zhome .message_row", "test star");
|
|
|
|
});
|
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.
|
|
|
|
casper.test.assertEquals(star_count(), 0,
|
|
|
|
"Got expected empty star count.");
|
|
|
|
|
|
|
|
// Clicking on a message star stars it.
|
|
|
|
toggle_last_star();
|
2018-04-23 18:14:22 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
casper.then(function () {
|
2018-07-04 01:42:24 +02:00
|
|
|
casper.waitUntilVisible('#zhome .fa-star', function () {
|
2018-04-23 18:14:22 +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
|
|
|
});
|
|
|
|
|
2013-06-13 22:31:19 +02:00
|
|
|
casper.waitUntilVisible('#zfilt', function () {
|
2013-03-29 00:03:11 +01:00
|
|
|
// You can narrow to your starred messages.
|
2013-07-17 22:53:07 +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.
|
|
|
|
toggle_last_star();
|
|
|
|
casper.test.assertEquals(star_count(), 0,
|
|
|
|
"Got expected re-empty star count.");
|
|
|
|
});
|
|
|
|
|
|
|
|
common.then_log_out();
|
|
|
|
|
|
|
|
casper.run(function () {
|
|
|
|
casper.test.done();
|
|
|
|
});
|