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 <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
This commit is contained in:
Sunil Mohan Adapa 2024-10-10 15:48:30 -07:00 committed by Veiko Aasa
parent fc86f3e507
commit 4bc13f063f
No known key found for this signature in database
GPG Key ID: 478539CAE680674E

View File

@ -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')