From ae73b296de9fd2a3575dbaff2f1a3bfc37a8ef82 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Thu, 28 May 2020 09:22:18 -0700 Subject: [PATCH] ttrss: tests: functional: Fix to wait properly - When subscribe button is clicked in subscribe dialog, the dialog does not close immediately. Wait until it closes or error appears. - When a feed is added, the feed list refreshes and during that time, it is not possible to click on the feed expand button. Wait until it can be clicked. Extend the eventually() method to wait on exceptions and not just false values. Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/ttrss/tests/test_functional.py | 13 +++++++++++-- plinth/tests/functional/__init__.py | 7 +++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/plinth/modules/ttrss/tests/test_functional.py b/plinth/modules/ttrss/tests/test_functional.py index 89009f9bc..c67d99f52 100644 --- a/plinth/modules/ttrss/tests/test_functional.py +++ b/plinth/modules/ttrss/tests/test_functional.py @@ -49,18 +49,27 @@ def _click_main_menu_item(browser, text): def _subscribe(browser): """Subscribe to a feed in TT-RSS.""" + + def _already_subscribed_message(): + return browser.is_text_present( + 'You are already subscribed to this feed.') + _ttrss_load_main_interface(browser) _click_main_menu_item(browser, 'Subscribe to feed...') browser.find_by_id('feedDlg_feedUrl').fill( 'https://planet.debian.org/atom.xml') browser.find_by_text('Subscribe').click() - if browser.is_text_present('You are already subscribed to this feed.'): + add_dialog = browser.find_by_css('#feedAddDlg') + functional.eventually( + lambda: not add_dialog.visible or _already_subscribed_message()) + if _already_subscribed_message(): browser.find_by_text('Cancel').click() + functional.eventually(lambda: not add_dialog.visible) expand = browser.find_by_css('span.dijitTreeExpandoClosed') if expand: - expand.first.click() + functional.eventually(expand.first.click) assert functional.eventually(_is_feed_shown, [browser]) diff --git a/plinth/tests/functional/__init__.py b/plinth/tests/functional/__init__.py index 9ea5bc4bb..5a75812d9 100644 --- a/plinth/tests/functional/__init__.py +++ b/plinth/tests/functional/__init__.py @@ -64,8 +64,11 @@ def eventually(function, args=[], timeout=30): end_time = time.time() + timeout current_time = time.time() while current_time < end_time: - if function(*args): - return True + try: + if function(*args): + return True + except Exception: + pass time.sleep(0.1) current_time = time.time()