Skip to content

Commit d204026

Browse files
committed
Add tests.
1 parent 8f7ba63 commit d204026

1 file changed

Lines changed: 68 additions & 14 deletions

File tree

tests/tests_tui/test_tui_datatypes.py

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -218,42 +218,96 @@ async def test_select_displayed_datatypes_transfer(
218218
async def test_transfer_displayed_datatypes_widgets_hide_after_mode_switch(
219219
self, setup_project_paths
220220
):
221-
"""Test that after editing the displayed datatypes in custom transfer, the
222-
widgets are properly hidden. This test was added after a bug in which the
223-
old, deleted widgets were still persistent on the other tabs.
221+
"""Check refreshed transfer widgets hide correctly and still drive transfer.
222+
223+
Covers the bug where the deleted custom widgets persisted after
224+
switching transfer type, then verifies a newly displayed narrow
225+
datatype can still be selected and transferred correctly.
224226
"""
225227
tmp_config_path, tmp_path, project_name = setup_project_paths.values()
228+
subs, sessions = test_utils.get_default_sub_sessions_to_test()
229+
sub_to_transfer, ses_to_transfer = "sub-002", "ses-003"
230+
231+
refreshed_widgets = [
232+
"#transfer_custom_datatype_checkboxes",
233+
"#transfer_tab_displayed_datatypes_button",
234+
]
235+
236+
def assert_refreshed_widgets_display(pilot, expected):
237+
for id in refreshed_widgets:
238+
assert pilot.app.screen.query_one(id).display is expected
226239

227240
app = TuiApp()
228241
async with app.run_test(size=self.tui_size()) as pilot:
229242
await self.check_and_click_onto_existing_project(
230243
pilot, project_name
231244
)
232-
233245
await self.switch_tab(pilot, "transfer")
234246
await self.scroll_to_click_pause(
235247
pilot, "#transfer_custom_radiobutton"
236248
)
249+
250+
# Set up a project containing only the (narrow) "conf" datatype.
251+
project = pilot.app.screen.interface.project
252+
folders_used = test_utils.get_all_broad_folders_used(value=False)
253+
folders_used["conf"] = True
254+
255+
test_utils.make_and_check_local_project_folders(
256+
project,
257+
"rawdata",
258+
subs,
259+
sessions,
260+
["conf"],
261+
datatypes_used=folders_used,
262+
)
263+
_, base_path_to_check = test_utils.handle_upload_or_download(
264+
project, "upload", transfer_method=None
265+
)
266+
267+
# Display the narrow datatypes, refreshing the custom widgets.
237268
await self.scroll_to_click_pause(
238-
pilot,
239-
"#transfer_tab_displayed_datatypes_button",
269+
pilot, "#transfer_tab_displayed_datatypes_button"
240270
)
271+
pilot.app.screen.query_one(
272+
"#displayed_datatypes_selection_list"
273+
).toggle_all()
241274
await self.scroll_to_click_pause(
242-
pilot, "#displayed_datatypes_close_button"
275+
pilot, "#displayed_datatypes_save_button"
243276
)
277+
278+
# The refreshed widgets must hide / show with the transfer mode.
244279
await self.scroll_to_click_pause(
245280
pilot, "#transfer_toplevel_radiobutton"
246281
)
282+
assert_refreshed_widgets_display(pilot, False)
283+
284+
await self.scroll_to_click_pause(
285+
pilot, "#transfer_custom_radiobutton"
286+
)
287+
assert_refreshed_widgets_display(pilot, True)
288+
289+
# Select the newly displayed "conf" datatype and transfer.
290+
await self.fill_input(
291+
pilot, "#transfer_subject_input", sub_to_transfer
292+
)
293+
await self.fill_input(
294+
pilot, "#transfer_session_input", ses_to_transfer
295+
)
296+
await self.change_checkbox(pilot, "#transfer_conf_checkbox")
247297

248298
assert (
249299
pilot.app.screen.query_one(
250300
"#transfer_custom_datatype_checkboxes"
251-
).display
252-
is False
301+
).datatype_config["conf"]["on"]
302+
is True
253303
)
254-
assert (
255-
pilot.app.screen.query_one(
256-
"#transfer_tab_displayed_datatypes_button"
257-
).display
258-
is False
304+
305+
await self.click_and_await_transfer(pilot)
306+
307+
test_utils.check_working_top_level_folder_only_exists(
308+
"rawdata",
309+
base_path_to_check / "rawdata",
310+
[sub_to_transfer],
311+
[ses_to_transfer],
312+
folders_used,
259313
)

0 commit comments

Comments
 (0)