from .framework import (
managed_history,
selenium_only,
selenium_test,
SeleniumTestCase,
)
[docs]
class TestCollectionBuilders(SeleniumTestCase):
ensure_registered = True
[docs]
@selenium_only("Not yet migrated to support Playwright backend")
@selenium_test
@managed_history
def test_build_list_simple_hidden(self):
self.perform_upload(self.get_filename("1.fasta"))
self._wait_for_and_select([1])
self.history_panel_build_list_auto()
self.collection_builder_set_name("my cool list")
self.screenshot("collection_builder_wizard_list")
self.collection_builder_create()
self._wait_for_hid_visible(3)
self._assert_selection_cleared()
[docs]
@selenium_test
@managed_history
def test_build_list_open_keeps_selection(self):
self.perform_upload(self.get_filename("1.fasta"))
self._wait_for_and_select([1])
self.history_panel_build_list_auto()
self.components.collection_builders.name.wait_for_visible()
multi_operations = self.navigation.history_panel.multi_operations.selectors
self.wait_for_visible(multi_operations.selected_content_menu)
self.wait_for_visible(multi_operations.item_selector)
[docs]
@selenium_only("Not yet migrated to support Playwright backend")
@selenium_test
@managed_history
def test_build_list_and_show_items(self):
self.perform_upload(self.get_filename("1.fasta"))
self._wait_for_and_select([1])
self.history_panel_build_list_auto()
# this toggles the checkbox to not hide originals
self.collection_builder_hide_originals()
self.collection_builder_set_name("my cool list")
self.collection_builder_create()
self._wait_for_hid_visible(3)
[docs]
@selenium_test
def test_build_list_in_viewed_history(self):
target_history_id = self.dataset_populator.new_history(name=self._get_random_name())
self.dataset_populator.new_dataset(target_history_id, content="1\n", wait=True)
self.history_panel_create_new()
other_history_id = self.current_history_id()
self.get(f"histories/view?id={target_history_id}")
center_panel = self.components._.center_panel
self.wait_for_and_click(center_panel.descendant(self.components.history_panel.multi_operations.show_button))
self.history_panel_muli_operation_select_hid(1, history_id=target_history_id)
self.history_panel_build_list_auto(scope=center_panel.selector)
self.collection_builder_set_name("viewed history list")
self.screenshot("collection_builder_wizard_list_viewed_history")
self.collection_builder_create()
created_alert = self.components.collection_builders.list_wizard.created_alert
assert "history it was built from" in created_alert.wait_for_text()
self.screenshot("collection_builder_wizard_list_created")
self._wait_on(
lambda: "viewed history list" in self.history_collection_names(target_history_id),
"the list in the viewed history",
)
assert self.history_collection_names(other_history_id) == []
[docs]
@selenium_only("Not yet migrated to support Playwright backend")
@selenium_test
@managed_history
def test_build_paired_list_auto_matched(self):
self.perform_upload_of_pasted_content(
{
"basename_1.fasta": "forward content",
"basename_2.fasta": "reverse content",
}
)
self._wait_for_and_select([1, 2])
self.history_panel_build_list_of_pairs()
self.collection_builder_set_name("my awesome paired list")
self.screenshot("collection_builder_paired_list")
self.collection_builder_create()
self._wait_for_hid_visible(5)
self._assert_selection_cleared()
# switch to hidden filters to see the hidden datasets appear
self._show_hidden_content()
self._wait_for_hid_visible(1)
self._wait_for_hid_visible(2)
self._wait_for_hid_visible(3)
self._wait_for_hid_visible(4)
[docs]
@selenium_only("Not yet migrated to support Playwright backend")
@selenium_test
@managed_history
def test_build_paired_list_manual_matched(self):
self.perform_upload_of_pasted_content(
{
"thisdoesnotmatch.fasta": "forward content",
"becausethenamesarentalike.fasta": "reverse content",
}
)
self._wait_for_and_select([1, 2])
self.history_panel_build_list_of_pairs()
self.collection_builder_pair_rows(0, 1)
row0 = self.components.collection_builders.list_wizard.row._(index=0)
row0.unlink_button.wait_for_present()
row0.link_button.assert_absent()
self.collection_builder_set_name("my awesome paired list manual match")
self.screenshot("collection_builder_paired_list_manual_match")
self.collection_builder_create()
self._wait_for_hid_visible(5)
# switch to hidden filters to see the hidden datasets appear
self._show_hidden_content()
self._wait_for_hid_visible(1)
self._wait_for_hid_visible(2)
self._wait_for_hid_visible(3)
self._wait_for_hid_visible(4)
[docs]
@selenium_only("Not yet migrated to support Playwright backend")
@selenium_test
@managed_history
def test_build_paired_unpaired_list(self):
self.perform_upload_of_pasted_content(
{
"commonprefix_1.fasta": "forward content",
"commonprefix_2.fasta": "reverse content",
"unmatched.fasta": "unmatched",
}
)
self._wait_for_and_select([1, 2, 3])
self.history_panel_build_list_of_paired_or_unpaireds()
self.collection_builder_set_name("mix of paired and unpaired data")
self.screenshot("collection_builder_paired_or_unpaired_list")
self.collection_builder_create()
self._wait_for_hid_visible(7)
[docs]
@selenium_only("Not yet migrated to support Playwright backend")
@selenium_test
@managed_history
def test_build_list_of_lists(self):
self.perform_upload_of_pasted_content(
{
"foo1.txt": "forward content 1",
"bar1.txt": "reverse content 1",
"foo2.txt": "forward content 2",
"bar2.txt": "forward content 2",
}
)
self._wait_for_and_select([1, 2, 3, 4])
self.history_panel_build_list_of_lists()
self.list_wizard_click_cell_and_send_keys("outerIdentifier", 2, "outer1")
self.list_wizard_click_cell_and_send_keys("outerIdentifier", 3, "outer1")
self.list_wizard_click_cell_and_send_keys("outerIdentifier", 4, "outer2")
self.list_wizard_click_cell_and_send_keys("outerIdentifier", 5, "outer2")
self.collection_builder_set_name("nested list")
self.screenshot("collection_builder_list_list")
self.collection_builder_create()
self._wait_for_hid_visible(9)
[docs]
@selenium_only("Not yet migrated to support Playwright backend")
@selenium_test
@managed_history
def test_build_paired_list_show_original(self):
self.perform_upload_of_pasted_content(
{
"thisdoesnotmatch.fasta": "forward content",
"becausethenamesarentalike.fasta": "reverse content",
}
)
self._wait_for_and_select([1, 2])
self.history_panel_build_list_of_pairs()
self.collection_builder_pair_rows(0, 1)
row0 = self.components.collection_builders.list_wizard.row._(index=0)
row0.unlink_button.wait_for_present()
row0.link_button.assert_absent()
self.collection_builder_hide_originals()
self.collection_builder_set_name("my awesome paired list shown originals")
self.collection_builder_create()
self._wait_for_hid_visible(5)
self._wait_for_hid_visible(1)
self._wait_for_hid_visible(2)
self._show_hidden_content()
self._wait_for_hid_visible(3)
self._wait_for_hid_visible(4)
[docs]
@selenium_only("Not yet migrated to support Playwright backend")
@selenium_test
@managed_history
def test_build_simple_list_via_rules_hidden(self):
self.perform_upload_of_pasted_content(
{
"1.fasta": "fasta content",
}
)
self._wait_for_and_select([1])
self.history_panel_build_rule_builder_for_selection()
self.collection_builder_set_name("my cool list from rules originals hidden")
self.screenshot("collection_builder_rules_list")
self.collection_builder_create()
self._wait_for_hid_visible(3)
self._show_hidden_content()
self._wait_for_hid_visible(1)
self._wait_for_hid_visible(2)
def _wait_for_hid_visible(self, hid, state="ok"):
# takes a little while for these things to upload and end up in the history
timeout = self.wait_length(self.wait_types.JOB_COMPLETION)
row_selector = self.content_item_by_attributes(hid=hid, state=state)
self.wait_for_visible(row_selector, timeout=timeout)
def _assert_selection_cleared(self):
multi_operations = self.navigation.history_panel.multi_operations.selectors
self.wait_for_absent(multi_operations.selected_content_menu)
self.wait_for_absent(multi_operations.item_selector)
def _collection_dropdown(self, option_description):
return self.use_bootstrap_dropdown(option=option_description, menu="selected content menu")
def _wait_for_and_select(self, hids):
self.history_panel_wait_for_and_select(hids)
def _show_hidden_content(self):
"""Switches the hidden filter toggle on"""
self.sleep_for(self.wait_types.UX_RENDER)
filter_element = self.history_element(
attribute_value="filter text input", scope=".content-operations-filters"
).wait_for_and_click()
filter_element.send_keys("visible:false")
self.sleep_for(self.wait_types.UX_RENDER)