From 90b94a46bcdb5c65b6e47ddf6e6bb14c49d29a4e Mon Sep 17 00:00:00 2001 From: Eric Fischer Date: Thu, 20 Aug 2015 11:21:29 -0400 Subject: [PATCH] Potential fix for flaky TeamDiscussionView js tests Adding waitsFor check in the beforeEach method. The condition I'm waiting for here is shamelessly borrowed from bok-choy's wait_for_ajax._is_ajax_finished() method: https://github.com/edx/bok-choy/blob/master/bok_choy/page_object.py#L431 This seems to fix the errors I was able to generate with the set_timeout, which themselves looked ver similar to the failing master tests, so I *think* this will fix our woes, but since I was never able to get the tests to fail exactly the same way I can't be sure. Since there don't seem to be any drawbacks, this is going into mainline as-is and we'll monitor for the sporadic failures over the next few weeks. --- .../js/spec/views/team_discussion_spec.js | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lms/djangoapps/teams/static/teams/js/spec/views/team_discussion_spec.js b/lms/djangoapps/teams/static/teams/js/spec/views/team_discussion_spec.js index 889577224b..a8bc9d888f 100644 --- a/lms/djangoapps/teams/static/teams/js/spec/views/team_discussion_spec.js +++ b/lms/djangoapps/teams/static/teams/js/spec/views/team_discussion_spec.js @@ -8,12 +8,20 @@ define([ var discussionView, createDiscussionView, createPost, expandReplies, postReply; beforeEach(function() { - setFixtures('
'); - $('.discussion-module').data('course-id', TeamSpecHelpers.testCourseID); - $('.discussion-module').data('discussion-id', TeamSpecHelpers.testTeamDiscussionID); - $('.discussion-module').data('user-create-comment', true); - $('.discussion-module').data('user-create-subcomment', true); - DiscussionSpecHelper.setUnderscoreFixtures(); + runs(function() { + setFixtures('
'); + $('.discussion-module').data('course-id', TeamSpecHelpers.testCourseID); + $('.discussion-module').data('discussion-id', TeamSpecHelpers.testTeamDiscussionID); + $('.discussion-module').data('user-create-comment', true); + $('.discussion-module').data('user-create-subcomment', true); + DiscussionSpecHelper.setUnderscoreFixtures(); + }); + + waitsFor( + function() {return typeof(jQuery)!='undefined' && jQuery.active==0;}, + "Ajax did not finish", + 10000 + }) }); createDiscussionView = function(requests, threads) {