casper: Improve `toggle_star_last_message`.

We now look for the actual message directly,
and we make assertions about things we are
clicking on.
This commit is contained in:
Steve Howell 2020-03-25 22:34:36 +00:00 committed by showell
parent d604814347
commit 162396cfe3
1 changed files with 25 additions and 5 deletions

View File

@ -6,10 +6,30 @@ function star_count() {
}); });
} }
function toggle_last_star() { function toggle_test_star_message() {
casper.evaluate(function () { var error = casper.evaluate(function () {
$("#zhome .star").last().click(); 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();
}); });
if (error) {
casper.test.info('\n\nERROR: ' + error);
}
casper.test.assert(!error);
} }
common.start_and_log_in(); common.start_and_log_in();
@ -36,7 +56,7 @@ casper.then(function () {
"Got expected empty star count."); "Got expected empty star count.");
// Clicking on a message star stars it. // Clicking on a message star stars it.
toggle_last_star(); toggle_test_star_message();
}); });
casper.then(function () { casper.then(function () {
@ -56,7 +76,7 @@ casper.waitUntilVisible('#zfilt', function () {
casper.then(function () { casper.then(function () {
// Clicking on a starred message unstars it. // Clicking on a starred message unstars it.
toggle_last_star(); toggle_test_star_message();
casper.test.assertEquals(star_count(), 0, casper.test.assertEquals(star_count(), 0,
"Got expected re-empty star count."); "Got expected re-empty star count.");
}); });