Warning

This document is for an in-development version of Galaxy. You can alternatively view this page in the latest release if it exists or view the top of the latest release's documentation.

Source code for galaxy_test.selenium.test_collection_builders

from .framework import (
    managed_history,
    selenium_test,
    SeleniumTestCase,
)
from .upload_activity_helpers import UsesUploadActivity


[docs] class TestCollectionBuilders(SeleniumTestCase, UsesUploadActivity): ensure_registered = True
[docs] @selenium_test @managed_history def test_build_list_simple_hidden(self): self.upload_context("local-file").stage_local_file(self.get_filename("1.fasta")).start() 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.upload_context("local-file").stage_local_file(self.get_filename("1.fasta")).start() 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_test @managed_history def test_build_list_and_show_items(self): self.upload_context("local-file").stage_local_file(self.get_filename("1.fasta")).start() 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_test @managed_history def test_build_list_keep_extensions(self): self._upload_and_select_sample_fastas() self.history_panel_build_list_auto() self.collection_builder_toggle_remove_extensions() self.collection_builder_set_name("list keeping extensions") self.collection_builder_create() self._wait_for_hid_visible(5) identifiers = self._collection_identifiers(5) assert identifiers == ["sample1.fasta", "sample2.fasta"]
[docs] @selenium_test @managed_history def test_build_list_advanced_rename_element(self): self._upload_and_select_sample_fastas() self.history_panel_build_list_advanced_and_select_builder("list") self.collection_builder_rename_element(1, "first") self.collection_builder_set_name("list with a renamed element") self.screenshot("collection_builder_advanced_list") self.collection_builder_create() self._wait_for_hid_visible(5) identifiers = self._collection_identifiers(5) assert identifiers == ["first", "sample2"]
[docs] @selenium_test @managed_history def test_build_paired_list_auto_matched(self): uploader = self.upload_context("paste-content") uploader.stage_paste_content("forward content", {"name": "basename_1.fasta"}) uploader.stage_paste_content("reverse content", {"name": "basename_2.fasta"}) uploader.start() self._wait_for_and_select([1, 2]) self.history_panel_build_list_of_pairs() list_wizard = self.components.collection_builders.list_wizard self.ag_grid_edit_cell(list_wizard, "identifier", 2, "renamed", clear=True) 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) collection = self.dataset_populator.get_history_collection_details(self.current_history_id(), hid=5) (element,) = collection["elements"] assert element["element_identifier"] == "renamed", element["element_identifier"] pair = element["object"]["elements"] assert [e["element_identifier"] for e in pair] == ["forward", "reverse"] assert [e["object"]["name"] for e in pair] == ["basename_1.fasta", "basename_2.fasta"], pair 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_test @managed_history def test_build_paired_list_manual_matched(self): uploader = self.upload_context("paste-content") uploader.stage_paste_content("forward content", {"name": "thisdoesnotmatch.fasta"}) uploader.stage_paste_content("reverse content", {"name": "becausethenamesarentalike.fasta"}) uploader.start() 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_test @managed_history def test_build_paired_unpaired_list(self): uploader = self.upload_context("paste-content") uploader.stage_paste_content("forward content", {"name": "commonprefix_1.fasta"}) uploader.stage_paste_content("reverse content", {"name": "commonprefix_2.fasta"}) uploader.stage_paste_content("unmatched", {"name": "unmatched.fasta"}) uploader.start() 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_test @managed_history def test_build_list_of_lists(self): uploader = self.upload_context("paste-content") uploader.stage_paste_content("forward content 1", {"name": "foo1.txt"}) uploader.stage_paste_content("reverse content 1", {"name": "bar1.txt"}) uploader.stage_paste_content("forward content 2", {"name": "foo2.txt"}) uploader.stage_paste_content("forward content 2", {"name": "bar2.txt"}) uploader.start() self._wait_for_and_select([1, 2, 3, 4]) self.history_panel_build_list_of_lists(screenshot_name="collection_builder_which_builder_list_list") 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_test @managed_history def test_build_paired_list_show_original(self): uploader = self.upload_context("paste-content") uploader.stage_paste_content("forward content", {"name": "thisdoesnotmatch.fasta"}) uploader.stage_paste_content("reverse content", {"name": "becausethenamesarentalike.fasta"}) uploader.start() 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_test @managed_history def test_build_simple_list_via_rules_hidden(self): self.upload_context("paste-content").stage_paste_content("fasta content", {"name": "1.fasta"}).start() 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 _upload_and_select_sample_fastas(self): """Paste ``sample1.fasta`` and ``sample2.fasta`` (hids 1, 2) and select both.""" uploader = self.upload_context("paste-content") uploader.stage_paste_content("content 1", {"name": "sample1.fasta"}) uploader.stage_paste_content("content 2", {"name": "sample2.fasta"}) uploader.start() self._wait_for_and_select([1, 2]) def _collection_identifiers(self, hid): """Sorted element identifiers of collection ``hid``, via the API.""" collection = self.dataset_populator.get_history_collection_details(self.current_history_id(), hid=hid) return sorted(e["element_identifier"] for e in collection["elements"]) def _show_hidden_content(self): """Filter the history panel to hidden items.""" self.history_panel_filter("visible:false")