tests: add frontend tests for starring.

(imported from commit 6a35286cf4a1e3db9adbc14f8d6c0aa0a05b24db)
This commit is contained in:
Jessica McKellar 2013-03-27 16:45:21 -04:00
parent f050f28e05
commit 39602a4437
1 changed files with 52 additions and 0 deletions

View File

@ -122,6 +122,18 @@ function un_narrow() {
keypress(27); // Esc
}
function star_count() {
return casper.evaluate(function () {
return $("#zhome .icon-star").length;
});
}
function toggle_last_star() {
casper.evaluate(function () {
$("#zhome .star").last().click();
});
}
common.log_in();
casper.then(function () {
@ -323,6 +335,46 @@ casper.then(function() {
casper.test.assertExists('#settings.tab-pane.active', 'Settings page is active');
});
// Star tests
casper.then(function() {
casper.test.info("Stars");
send_message('stream', {
stream: 'Verona',
subject: 'stars',
content: 'test star'
});
casper.waitForText("test star");
});
casper.then(function() {
casper.test.info("Stars");
casper.click('a[href^="#home"]');
un_narrow();
// 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"]');
});
casper.then(function() {
// You can narrow to your starred messages.
expected_messages('zfilt', ['Verona > stars'], ['<p>test star</p>']);
un_narrow();
});
casper.then(function() {
// Clicking on a starred message unstars it.
toggle_last_star();
casper.test.assertEquals(star_count(), 0,
"Got expected re-empty star count.");
});
common.log_out();