2013-03-29 00:03:11 +01:00
|
|
|
var common = require('../common.js').common;
|
|
|
|
|
|
|
|
function star_count() {
|
|
|
|
return casper.evaluate(function () {
|
2013-05-21 17:47:44 +02:00
|
|
|
return $("#zhome .icon-vector-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', {
|
2013-03-29 00:03:11 +01:00
|
|
|
stream: 'Verona',
|
|
|
|
subject: 'stars',
|
|
|
|
content: 'test star'
|
|
|
|
});
|
|
|
|
|
2014-03-07 20:58:18 +01:00
|
|
|
casper.waitForText("test star");
|
|
|
|
|
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();
|
|
|
|
casper.test.assertEquals(star_count(), 1,
|
|
|
|
"Got expected single star count.");
|
|
|
|
|
|
|
|
casper.click('a[href^="#narrow/is/starred"]');
|
|
|
|
});
|
|
|
|
|
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();
|
|
|
|
});
|