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
|
|
|
});
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
return 'cannot find test star message';
|
|
|
|
}
|
|
|
|
|
|
|
|
var star_icon = msg
|
|
|
|
.closest('.messagebox')
|
|
|
|
.find('.star');
|
|
|
|
|
|
|
|
if (star_icon.length !== 1) {
|
|
|
|
return 'cannot find star icon';
|
|
|
|
}
|
|
|
|
|
|
|
|
star_icon.click();
|
2013-03-29 00:03:11 +01:00
|
|
|
});
|
2020-03-25 23:34:36 +01:00
|
|
|
|
|
|
|
if (error) {
|
|
|
|
casper.test.info('\n\nERROR: ' + error);
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
});
|
|
|
|
|
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 () {
|
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.
|
|
|
|
casper.test.assertEquals(star_count(), 0,
|
|
|
|
"Got expected empty star count.");
|
|
|
|
|
|
|
|
// 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 () {
|
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.
|
2020-03-25 23:34:36 +01:00
|
|
|
toggle_test_star_message();
|
2013-03-29 00:03:11 +01:00
|
|
|
casper.test.assertEquals(star_count(), 0,
|
|
|
|
"Got expected re-empty star count.");
|
|
|
|
});
|
|
|
|
|
|
|
|
common.then_log_out();
|
|
|
|
|
|
|
|
casper.run(function () {
|
|
|
|
casper.test.done();
|
|
|
|
});
|