diff --git a/bmds_ui/desktop/components/database_form.py b/bmds_ui/desktop/components/database_form.py index 0cea7adc..8ff891c9 100644 --- a/bmds_ui/desktop/components/database_form.py +++ b/bmds_ui/desktop/components/database_form.py @@ -146,9 +146,6 @@ def compose(self) -> ComposeResult: @on(Button.Pressed, "#db-create") async def on_db_create(self) -> None: - await self.create_db() - - async def create_db(self) -> None: name = self.query_one("#name").value path = self.query_one("#path").value db = self.query_one("#filename").value @@ -163,6 +160,7 @@ async def create_db(self) -> None: @work(exclusive=True) async def _create_django_db(self, config, db): + # sleeps are required for loading indicator to show/hide properly actions = self.get_widget_by_id("actions-row") actions.loading = True await sleep(0.1) diff --git a/tests/desktop/test_app.py b/tests/desktop/test_app.py index 358aa8d6..46354809 100644 --- a/tests/desktop/test_app.py +++ b/tests/desktop/test_app.py @@ -148,7 +148,13 @@ async def test_db_form(self, rollback_get_app): # create a new db app.query_one("#path").value = resolved_temp_dir await pilot.click("#db-create") - await pilot.pause(delay=1) # delay for thread worker to finish + # wait for db creation to finish or max of 60 seconds + max = 1 + while max < 60 and isinstance( + app.screen, components.database_form.DatabaseFormModel + ): + await pilot.pause(delay=1) + max += 1 assert app.screen.name == "main" # make sure a new one appears on the list page