casper: Extract user_checkbox() helper.

This sets the stage to eliminate the data-email
markup.
This commit is contained in:
Steve Howell 2020-01-27 16:40:59 +00:00
parent 8e7ad57131
commit a0bd93d720
1 changed files with 10 additions and 6 deletions

View File

@ -1,5 +1,9 @@
var common = require('../casper_lib/common.js');
function user_checkbox(email) {
return '#user-checkboxes [data-email="' + email + '"]';
}
common.start_and_log_in();
casper.then(function () {
@ -27,8 +31,8 @@ casper.waitUntilVisible('.sub_unsub_button.checked', function () {
});
casper.then(function () {
casper.test.assertExists('#user-checkboxes [data-email="cordelia@zulip.com"]', 'Original user list contains Cordelia');
casper.test.assertExists('#user-checkboxes [data-email="othello@zulip.com"]', 'Original user list contains Othello');
casper.test.assertExists(user_checkbox('cordelia@zulip.com'), 'Original user list contains Cordelia');
casper.test.assertExists(user_checkbox('othello@zulip.com'), 'Original user list contains Othello');
});
casper.waitUntilVisible("#copy-from-stream-expand-collapse", function () {
@ -45,10 +49,10 @@ casper.waitUntilVisible("form#stream_creation_form", function () {
casper.fill('form#stream_creation_form', {user_list_filter: 'ot'});
});
casper.waitUntilVisible("#user-checkboxes", function () {
casper.test.assertEquals(casper.visible('#user-checkboxes [data-email="cordelia@zulip.com"]'),
casper.test.assertEquals(casper.visible(user_checkbox('cordelia@zulip.com')),
false,
"Cordelia is not visible");
casper.test.assertEquals(casper.visible('#user-checkboxes [data-email="othello@zulip.com"]'),
casper.test.assertEquals(casper.visible(user_checkbox('othello@zulip.com')),
true,
"Othello is visible");
@ -86,10 +90,10 @@ casper.then(function () {
casper.fill('form#stream_creation_form', {user_list_filter: ''});
});
casper.then(function () {
casper.test.assertEquals(casper.visible('#user-checkboxes [data-email="cordelia@zulip.com"]'),
casper.test.assertEquals(casper.visible(user_checkbox('cordelia@zulip.com')),
true,
"Cordelia is visible again");
casper.test.assertEquals(casper.visible('#user-checkboxes [data-email="othello@zulip.com"]'),
casper.test.assertEquals(casper.visible(user_checkbox('othello@zulip.com')),
true,
"Othello is visible again");
casper.test.assertEquals(casper.visible('#stream-checkboxes [data-stream-name="Scotland"]'),