mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 12:03:46 +00:00 
			
		
		
		
	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:
		| @@ -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 () { | ||||
|     var menu_selector = '#settings-dropdown'; | ||||
|     var logout_selector = 'a[href="#logout"]'; | ||||
|   | ||||
| @@ -95,10 +95,8 @@ casper.then(function () { | ||||
| // }); | ||||
|  | ||||
| // go to admin page | ||||
| casper.then(function () { | ||||
|     casper.click('#settings-dropdown'); | ||||
|     casper.click('a[href^="#organization"]'); | ||||
| }); | ||||
| common.then_click('#settings-dropdown'); | ||||
| common.then_click('a[href^="#organization"]'); | ||||
|  | ||||
| casper.then(function () { | ||||
|     casper.waitForSelector('#settings_overlay_container.show', function () { | ||||
| @@ -107,13 +105,10 @@ casper.then(function () { | ||||
|     }); | ||||
| }); | ||||
|  | ||||
| casper.then(function () { | ||||
|     casper.click("li[data-section='organization-settings']"); | ||||
|     // deactivate "allow message editing" | ||||
|     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'); | ||||
|     }); | ||||
| }); | ||||
| common.then_click("li[data-section='organization-settings']"); | ||||
|  | ||||
| // deactivate "allow message editing" | ||||
| common.then_click('input[type="checkbox"][id="id_realm_allow_message_editing"] + span'); | ||||
|  | ||||
| submit_unchecked(); | ||||
|  | ||||
| @@ -176,23 +171,10 @@ casper.then(function () { | ||||
| }); | ||||
|  | ||||
| // go back to admin page, and reactivate "allow message editing" | ||||
| casper.then(function () { | ||||
|     casper.click('#settings-dropdown'); | ||||
|     casper.click('a[href^="#organization"]'); | ||||
| }); | ||||
|  | ||||
| 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'); | ||||
|     }); | ||||
| }); | ||||
|  | ||||
| common.then_click('#settings-dropdown'); | ||||
| common.then_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'); | ||||
| submit_checked(); | ||||
|  | ||||
| casper.then(function () { | ||||
| @@ -257,10 +239,10 @@ casper.then(function () { | ||||
|         casper.evaluate(function () { | ||||
|             $('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(); | ||||
|  | ||||
| casper.then(function () { | ||||
| @@ -275,13 +257,7 @@ casper.then(function () { | ||||
|     }); | ||||
| }); | ||||
|  | ||||
| casper.then(function () { | ||||
|     // 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'); | ||||
|     }); | ||||
| }); | ||||
|  | ||||
| common.then_click('input[type="checkbox"][id="id_realm_allow_message_editing"] + span'); | ||||
| submit_checked(); | ||||
|  | ||||
| casper.then(function () { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user