From 39602a443743e80bc48d27c75b943a9c655b9cab Mon Sep 17 00:00:00 2001 From: Jessica McKellar Date: Wed, 27 Mar 2013 16:45:21 -0400 Subject: [PATCH] tests: add frontend tests for starring. (imported from commit 6a35286cf4a1e3db9adbc14f8d6c0aa0a05b24db) --- zephyr/tests/frontend/tests/01-site.js | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/zephyr/tests/frontend/tests/01-site.js b/zephyr/tests/frontend/tests/01-site.js index bd07939a27..008eddf067 100644 --- a/zephyr/tests/frontend/tests/01-site.js +++ b/zephyr/tests/frontend/tests/01-site.js @@ -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'], ['

test star

']); + 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();