From 6ee08e0602fe1c943e4e48c9dba661aa99671993 Mon Sep 17 00:00:00 2001 From: Umair Khan Date: Wed, 31 May 2017 10:07:49 +0500 Subject: [PATCH] casper: Fix waiting condition in message deletion tests. We now specifically wait for the length to decrease by one. This seems like a more deterministic condition to wait on. Previously we were waiting till the id of the deleted message remained visible; intuitively, this should have worked but it seems that there is some race condition that was causing the test to fail sporadically. --- frontend_tests/casper_tests/15-delete-message.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend_tests/casper_tests/15-delete-message.js b/frontend_tests/casper_tests/15-delete-message.js index ae6969122d..da57bb80c8 100644 --- a/frontend_tests/casper_tests/15-delete-message.js +++ b/frontend_tests/casper_tests/15-delete-message.js @@ -29,15 +29,17 @@ casper.then(function () { }); casper.then(function () { - casper.waitWhileVisible(last_message_id, function () { - var msgs_after_deleting = casper.evaluate(function () { - return $('#zhome .message_row').length; - }); - casper.test.assertEquals(msgs_qty - 1, msgs_after_deleting); - casper.test.assertDoesntExist(last_message_id); + casper.waitFor(function check_length() { + return casper.evaluate(function (expected_length) { + return $('#zhome .message_row').length === expected_length; + }, msgs_qty - 1); }); }); +casper.then(function () { + casper.test.assertDoesntExist(last_message_id); +}); + casper.run(function () { casper.test.done(); });