mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +00:00
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 <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
f768840165
commit
ae73b296de
@ -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])
|
||||
|
||||
|
||||
@ -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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user