From aa54421216068baf84a8526d09d0bf424ee11d43 Mon Sep 17 00:00:00 2001 From: Veiko Aasa Date: Tue, 29 Dec 2020 20:10:13 +0200 Subject: [PATCH] ejabberd: functional tests: Wait until the jsxc buddy list is loaded Fixes #1894 Tests performed: - All the ejabberd tests pass on both Debian testing and stable Signed-off-by: Veiko Aasa Reviewed-by: Sunil Mohan Adapa --- plinth/modules/ejabberd/tests/test_functional.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/plinth/modules/ejabberd/tests/test_functional.py b/plinth/modules/ejabberd/tests/test_functional.py index 8fcae0d89..b970b2bfa 100644 --- a/plinth/modules/ejabberd/tests/test_functional.py +++ b/plinth/modules/ejabberd/tests/test_functional.py @@ -49,6 +49,18 @@ def _disable_message_archive_management(browser): 'disabled') +def _is_jsxc_buddy_list_loaded(browser): + """Return whether the jsxc buddy list has been loaded.""" + if browser.find_by_text('new contact'): + # no contacts + return True + + buddy_list = browser.find_by_id('jsxc_buddylist').first + contacts = buddy_list.find_by_css('.jsxc_rosteritem') + + return len(contacts) > 0 + + def _jsxc_login(browser): """Login to JSXC.""" username = functional.config['DEFAULT']['username'] @@ -71,6 +83,7 @@ def _jsxc_add_contact(browser): functional.set_domain_name(browser, 'localhost') functional.install(browser, 'jsxc') _jsxc_login(browser) + functional.eventually(_is_jsxc_buddy_list_loaded, args=[browser]) new = browser.find_by_text('new contact') if new: # roster is empty new.first.click()