mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
casper: Use casper.then() more consistently in editing tests.
Hopefully, this will fix the test flake problems we've been having with this test since upgrading Casper.
This commit is contained in:
@@ -25,11 +25,13 @@ casper.then(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// wait for message to be sent
|
// wait for message to be sent
|
||||||
|
casper.then(function () {
|
||||||
casper.waitFor(function () {
|
casper.waitFor(function () {
|
||||||
return casper.evaluate(function () {
|
return casper.evaluate(function () {
|
||||||
return !current_msg_list.last().locally_echoed;
|
return !current_msg_list.last().locally_echoed;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// edit the last message just sent
|
// edit the last message just sent
|
||||||
casper.then(function () {
|
casper.then(function () {
|
||||||
@@ -42,6 +44,7 @@ casper.then(function () {
|
|||||||
|
|
||||||
var edited_value = 'admin tests: test edit';
|
var edited_value = 'admin tests: test edit';
|
||||||
|
|
||||||
|
casper.then(function () {
|
||||||
casper.waitUntilVisible(".message_edit_content", function () {
|
casper.waitUntilVisible(".message_edit_content", function () {
|
||||||
casper.evaluate(function (edited_value) {
|
casper.evaluate(function (edited_value) {
|
||||||
var msg = $('#zhome .message_row:last');
|
var msg = $('#zhome .message_row:last');
|
||||||
@@ -49,6 +52,7 @@ casper.waitUntilVisible(".message_edit_content", function () {
|
|||||||
msg.find('.message_edit_save').click();
|
msg.find('.message_edit_save').click();
|
||||||
}, edited_value);
|
}, edited_value);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
casper.then(function () {
|
casper.then(function () {
|
||||||
// check that the message was indeed edited
|
// check that the message was indeed edited
|
||||||
@@ -79,20 +83,21 @@ casper.then(function () {
|
|||||||
casper.click('a[href^="#organization"]');
|
casper.click('a[href^="#organization"]');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
casper.then(function () {
|
||||||
casper.waitForSelector('#settings_overlay_container.show', function () {
|
casper.waitForSelector('#settings_overlay_container.show', function () {
|
||||||
casper.test.info('Organization page is active');
|
casper.test.info('Organization page is active');
|
||||||
casper.test.assertUrlMatch(/^http:\/\/[^/]+\/#organization/, 'URL suggests we are on organization page');
|
casper.test.assertUrlMatch(/^http:\/\/[^/]+\/#organization/, 'URL suggests we are on organization page');
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
casper.then(function () {
|
casper.then(function () {
|
||||||
casper.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 () {
|
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');
|
casper.click('input[type="checkbox"][id="id_realm_allow_message_editing"] + span');
|
||||||
casper.click('form.org-settings-form button.button');
|
casper.click('form.org-settings-form button.button');
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
casper.then(function () {
|
casper.then(function () {
|
||||||
casper.waitUntilVisible('#admin-realm-message-editing-status', function () {
|
casper.waitUntilVisible('#admin-realm-message-editing-status', function () {
|
||||||
@@ -152,10 +157,13 @@ casper.then(function () {
|
|||||||
casper.click('a[href^="#organization"]');
|
casper.click('a[href^="#organization"]');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
casper.then(function () {
|
||||||
casper.waitUntilVisible("li[data-section='organization-settings']", function () {
|
casper.waitUntilVisible("li[data-section='organization-settings']", function () {
|
||||||
casper.click("li[data-section='organization-settings']");
|
casper.click("li[data-section='organization-settings']");
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.then(function () {
|
||||||
casper.waitUntilVisible('input[type="checkbox"][id="id_realm_allow_message_editing"] + span', 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');
|
casper.click('input[type="checkbox"][id="id_realm_allow_message_editing"] + span');
|
||||||
casper.click('form.org-settings-form button.button');
|
casper.click('form.org-settings-form button.button');
|
||||||
@@ -166,6 +174,7 @@ casper.waitUntilVisible('input[type="checkbox"][id="id_realm_allow_message_editi
|
|||||||
}, 'Allow message editing Setting re-activated');
|
}, 'Allow message editing Setting re-activated');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Commented out due to Issue #1243
|
// Commented out due to Issue #1243
|
||||||
// go back home
|
// go back home
|
||||||
@@ -210,9 +219,12 @@ casper.then(function () {
|
|||||||
casper.test.assertExists('#settings_overlay_container.show', 'Organization page is active');
|
casper.test.assertExists('#settings_overlay_container.show', 'Organization page is active');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
casper.then(function () {
|
||||||
casper.waitUntilVisible('form.admin-realm-form button.button');
|
casper.waitUntilVisible('form.admin-realm-form button.button');
|
||||||
|
});
|
||||||
|
|
||||||
// deactivate message editing
|
// deactivate message editing
|
||||||
|
casper.then(function () {
|
||||||
casper.waitUntilVisible('input[type="checkbox"][id="id_realm_allow_message_editing"] + span', function () {
|
casper.waitUntilVisible('input[type="checkbox"][id="id_realm_allow_message_editing"] + span', 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');
|
||||||
@@ -220,6 +232,7 @@ casper.waitUntilVisible('input[type="checkbox"][id="id_realm_allow_message_editi
|
|||||||
casper.click('input[type="checkbox"][id="id_realm_allow_message_editing"] + span');
|
casper.click('input[type="checkbox"][id="id_realm_allow_message_editing"] + span');
|
||||||
casper.click('form.org-settings-form button.button');
|
casper.click('form.org-settings-form button.button');
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
casper.then(function () {
|
casper.then(function () {
|
||||||
casper.waitUntilVisible('#admin-realm-message-editing-status', function () {
|
casper.waitUntilVisible('#admin-realm-message-editing-status', function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user