From 3efb377d1c6d6cce0d1153e5dfeea424af992b93 Mon Sep 17 00:00:00 2001 From: Jesse Zoldak Date: Thu, 8 Jan 2015 16:52:55 -0500 Subject: [PATCH] Fix flaky textbook upload lettuce tests --- cms/djangoapps/contentstore/features/common.py | 12 +++++++++++- .../contentstore/features/textbooks.feature | 1 - 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/features/common.py b/cms/djangoapps/contentstore/features/common.py index b0681433b0..41c6b7cffd 100644 --- a/cms/djangoapps/contentstore/features/common.py +++ b/cms/djangoapps/contentstore/features/common.py @@ -348,10 +348,20 @@ def attach_file(filename, sub_path): def upload_file(filename, sub_path=''): + # The file upload dialog is a faux modal, a div that takes over the display attach_file(filename, sub_path) - button_css = '.wrapper-modal-window-assetupload .action-upload' + modal_css = 'div.wrapper-modal-window-assetupload' + button_css = '{} .action-upload'.format(modal_css) world.css_click(button_css) + # Clicking the Upload button triggers an AJAX POST. + world.wait_for_ajax_complete() + + # The modal stays up with a "File uploaded succeeded" confirmation message, then goes away. + # It should take under 2 seconds, so wait up to 10. + # Note that is_css_not_present will return as soon as the element is gone. + assert world.is_css_not_present(modal_css, wait_time=10) + @step(u'"([^"]*)" logs in$') def other_user_login(step, name): diff --git a/cms/djangoapps/contentstore/features/textbooks.feature b/cms/djangoapps/contentstore/features/textbooks.feature index 79b6c66d52..ac07a7affc 100644 --- a/cms/djangoapps/contentstore/features/textbooks.feature +++ b/cms/djangoapps/contentstore/features/textbooks.feature @@ -17,7 +17,6 @@ Feature: CMS.Textbooks And I name the first chapter "Chapter 1" And I click the Upload Asset link for the first chapter And I upload the textbook "textbook.pdf" - And I wait for "2" seconds And I save the textbook Then I should see a textbook named "Economics" with a chapter path containing "/static/textbook.pdf" And I reload the page