From 4bc13f063f055dd54c0f39fe88eba827fc605021 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Thu, 10 Oct 2024 15:48:30 -0700 Subject: [PATCH] calibre: tests: functional: Fix occasional failure in add book test - When a library is added to using the FreedomBox interface and immediately Calibre interface is loaded, the library does not immediately get listed in the list of libraries. We will have to fresh the page to see the new library. Do this. Tests: - Run functional tests for calibre on Testing distribution multiple times without failures. Signed-off-by: Sunil Mohan Adapa Reviewed-by: Veiko Aasa --- plinth/modules/calibre/tests/test_functional.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/plinth/modules/calibre/tests/test_functional.py b/plinth/modules/calibre/tests/test_functional.py index 6ddd7049f..d658ceecf 100644 --- a/plinth/modules/calibre/tests/test_functional.py +++ b/plinth/modules/calibre/tests/test_functional.py @@ -105,8 +105,17 @@ def _visit_library(browser, name): functional.eventually(_service_available) - functional.eventually(browser.find_by_css, - args=[f'.calibre-push-button[data-lid="{name}"]']) + def _library_available(): + """Refresh until the expected library is available.""" + available = browser.find_by_css( + f'.calibre-push-button[data-lid="{name}"]') + if not available: + time.sleep(0.5) + functional.visit(browser, '/calibre') + + return available + + functional.eventually(_library_available) link = browser.find_by_css(f'.calibre-push-button[data-lid="{name}"]') if not link: raise ValueError('Library not found')