casper: Try to fix clicking flakes for message editing.

The new `common.then_click` should prevent some races and remove
some duplicate code.
This commit is contained in:
Steve Howell
2017-12-27 18:08:58 -05:00
parent 9391f7aa98
commit aae69702fe
2 changed files with 20 additions and 36 deletions

View File

@@ -109,6 +109,14 @@ exports.start_and_log_in = function (credentials, viewport) {
}); });
}; };
exports.then_click = function (selector) {
casper.then(function () {
casper.waitUntilVisible(selector, function () {
casper.click(selector);
});
});
};
exports.then_log_out = function () { exports.then_log_out = function () {
var menu_selector = '#settings-dropdown'; var menu_selector = '#settings-dropdown';
var logout_selector = 'a[href="#logout"]'; var logout_selector = 'a[href="#logout"]';

View File

@@ -95,10 +95,8 @@ casper.then(function () {
// }); // });
// go to admin page // go to admin page
casper.then(function () { common.then_click('#settings-dropdown');
casper.click('#settings-dropdown'); common.then_click('a[href^="#organization"]');
casper.click('a[href^="#organization"]');
});
casper.then(function () { casper.then(function () {
casper.waitForSelector('#settings_overlay_container.show', function () { casper.waitForSelector('#settings_overlay_container.show', function () {
@@ -107,13 +105,10 @@ casper.then(function () {
}); });
}); });
casper.then(function () { common.then_click("li[data-section='organization-settings']");
casper.click("li[data-section='organization-settings']");
// deactivate "allow message editing" // deactivate "allow message editing"
casper.waitUntilVisible('input[type="checkbox"][id="id_realm_allow_message_editing"] + span', function () { common.then_click('input[type="checkbox"][id="id_realm_allow_message_editing"] + span');
casper.click('input[type="checkbox"][id="id_realm_allow_message_editing"] + span');
});
});
submit_unchecked(); submit_unchecked();
@@ -176,23 +171,10 @@ casper.then(function () {
}); });
// go back to admin page, and reactivate "allow message editing" // go back to admin page, and reactivate "allow message editing"
casper.then(function () { common.then_click('#settings-dropdown');
casper.click('#settings-dropdown'); common.then_click('a[href^="#organization"]');
casper.click('a[href^="#organization"]'); common.then_click("li[data-section='organization-settings']");
}); common.then_click('input[type="checkbox"][id="id_realm_allow_message_editing"] + span');
casper.then(function () {
casper.waitUntilVisible("li[data-section='organization-settings']", function () {
casper.click("li[data-section='organization-settings']");
});
});
casper.then(function () {
casper.waitUntilVisible('input[type="checkbox"][id="id_realm_allow_message_editing"] + span', function () {
casper.click('input[type="checkbox"][id="id_realm_allow_message_editing"] + span');
});
});
submit_checked(); submit_checked();
casper.then(function () { casper.then(function () {
@@ -257,10 +239,10 @@ casper.then(function () {
casper.evaluate(function () { casper.evaluate(function () {
$('input[type="text"][id="id_realm_message_content_edit_limit_minutes"]').val('4'); $('input[type="text"][id="id_realm_message_content_edit_limit_minutes"]').val('4');
}); });
casper.click('input[type="checkbox"][id="id_realm_allow_message_editing"] + span');
}); });
}); });
common.then_click('input[type="checkbox"][id="id_realm_allow_message_editing"] + span');
submit_unchecked(); submit_unchecked();
casper.then(function () { casper.then(function () {
@@ -275,13 +257,7 @@ casper.then(function () {
}); });
}); });
casper.then(function () { common.then_click('input[type="checkbox"][id="id_realm_allow_message_editing"] + span');
// allow message editing again, and check that the old edit limit is still there
casper.waitUntilVisible('input[type="checkbox"][id="id_realm_allow_message_editing"] + span', function () {
casper.click('input[type="checkbox"][id="id_realm_allow_message_editing"] + span');
});
});
submit_checked(); submit_checked();
casper.then(function () { casper.then(function () {