Skip to content

Commit a0421ff

Browse files
author
shrey
committed
first attempt at testing error popup
1 parent 25617d4 commit a0421ff

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

tests/tests_tui/test_tui_create_folders.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -599,6 +599,40 @@ async def test_get_next_sub_and_ses_central_no_template(
599599
include_central=True,
600600
)
601601

602+
@pytest.mark.asyncio
603+
async def test_get_next_sub_and_ses_error_popup(self, setup_project_paths):
604+
"""
605+
Test the modal error dialog display on encountering an error
606+
while suggesting next sub/ses. Since getting the suggestion happens
607+
in a thread, the `dismiss_popup_and_show_modal_error_dialog_from_thread`
608+
function which is used to display the modal error dialog from main thread
609+
is being tested. It is done by trying to get next session suggestion without
610+
inputting a subject.
611+
"""
612+
tmp_config_path, tmp_path, project_name = setup_project_paths.values()
613+
614+
app = TuiApp()
615+
async with app.run_test(size=self.tui_size()) as pilot:
616+
await self.setup_existing_project_create_tab_filled_sub_and_ses(
617+
pilot, project_name, create_folders=True
618+
)
619+
620+
# Clear the inputs
621+
await self.fill_input(pilot, "#create_folders_subject_input", "")
622+
await self.fill_input(pilot, "#create_folders_session_input", "")
623+
624+
await self.double_click(pilot, "#create_folders_session_input")
625+
await test_utils.await_task_by_name_if_present(
626+
"suggest_next_ses_async_task"
627+
)
628+
629+
assert (
630+
"Must input a subject number before suggesting next session number."
631+
in pilot.app.screen.query_one(
632+
"#messagebox_message_label"
633+
).renderable
634+
)
635+
602636
# -------------------------------------------------------------------------
603637
# Test Top Level Folders
604638
# -------------------------------------------------------------------------

0 commit comments

Comments
 (0)