mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Improvements to library testing.
- Add tests for creating a collection from a library. - Add more class names to library GUI to improve selectors for tests. - Automatically select whichever radio box makes sense in library collection builder dialog based on whether there is a selection or not.
This commit is contained in:
@@ -1382,12 +1382,12 @@ var FolderToolbarView = Backbone.View.extend({
|
||||
"</label>",
|
||||
"</div>",
|
||||
// create new folder button
|
||||
'<button style="display:none;" data-toggle="tooltip" data-placement="top" title="Create New Folder" class="btn btn-default primary-button toolbtn-create-folder add-library-items toolbar-item" type="button">',
|
||||
'<button style="display:none;" data-toggle="tooltip" data-placement="top" title="Create New Folder" class="btn btn-default primary-button toolbtn-create-folder add-library-items add-library-items-folder toolbar-item" type="button">',
|
||||
'<span class="fa fa-plus"></span><span class="fa fa-folder"></span> Create Folder ',
|
||||
"</button>",
|
||||
// add datasets button
|
||||
"<% if(mutiple_add_dataset_options) { %>",
|
||||
'<div class="btn-group add-library-items toolbar-item" style="display:none;">',
|
||||
'<div class="btn-group add-library-items add-library-items-datasets toolbar-item" style="display:none;">',
|
||||
'<button title="Add Datasets to Current Folder" id="" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">',
|
||||
'<span class="fa fa-plus"></span><span class="fa fa-file"></span> Add Datasets <span class="caret"></span>',
|
||||
"</button>",
|
||||
@@ -1415,12 +1415,12 @@ var FolderToolbarView = Backbone.View.extend({
|
||||
"<% } %>",
|
||||
// import to history button
|
||||
'<div class="btn-group toolbar-item">',
|
||||
'<button title="Import to history" type="button" class="primary-button dropdown-toggle" data-toggle="dropdown">',
|
||||
'<button title="Import to history" type="button" class="primary-button dropdown-toggle add-to-history" data-toggle="dropdown">',
|
||||
'<span class="fa fa-book"></span> To History <span class="caret"></span>',
|
||||
"</button>",
|
||||
'<ul class="dropdown-menu" role="menu">',
|
||||
'<li><a href="" class="toolbtn-bulk-import">as Datasets</a></li>',
|
||||
'<li><a href="" class="toolbtn-collection-import">as a Collection</a></li>',
|
||||
'<li><a href="" class="toolbtn-bulk-import add-to-history-datasets">as Datasets</a></li>',
|
||||
'<li><a href="" class="toolbtn-collection-import add-to-history-collection">as a Collection</a></li>',
|
||||
"</ul>",
|
||||
"</div>",
|
||||
// download button
|
||||
@@ -1828,13 +1828,13 @@ var FolderToolbarView = Backbone.View.extend({
|
||||
"<h4>Which datasets?</h4>",
|
||||
'<form class="form-inline">',
|
||||
'<label class="radio-inline">',
|
||||
'<input type="radio" name="radio_elements" id="selection_radio" value="selection" <% if (!selected_datasets) { %> disabled <% } %> > current selection',
|
||||
'<input type="radio" name="radio_elements" id="selection_radio" value="selection" <% if (!selected_datasets) { %> disabled <% } else { %> checked <% } %> > current selection',
|
||||
"<% if (selected_datasets) { %>",
|
||||
" (<%- selected_datasets %>)",
|
||||
"<% } %>",
|
||||
"</label>",
|
||||
'<label class="radio-inline">',
|
||||
'<input type="radio" name="radio_elements" id="folder_radio" value="folder"> all datasets in current folder',
|
||||
'<input type="radio" name="radio_elements" id="folder_radio" value="folder" <% if (!selected_datasets) { %> checked <% } %> > all datasets in current folder',
|
||||
"</label>",
|
||||
"</form>",
|
||||
"</div>",
|
||||
|
||||
@@ -612,6 +612,11 @@ class NavigatesGalaxy(HasDriver):
|
||||
self.components.masthead.libraries.wait_for_and_click()
|
||||
self.components.libraries.selector.wait_for_visible()
|
||||
|
||||
def libraries_open_with_name(self, name):
|
||||
self.libraries_open()
|
||||
self.libraries_index_search_for(name)
|
||||
self.libraries_index_table_elements()[0].find_element_by_css_selector("td a").click()
|
||||
|
||||
@retry_during_transitions
|
||||
def libraries_index_table_elements(self):
|
||||
container = self.wait_for_selector_visible(".library_container")
|
||||
@@ -681,6 +686,26 @@ class NavigatesGalaxy(HasDriver):
|
||||
self.wait_for_visible(self.navigation.libraries.folder.selectors.add_items_menu)
|
||||
self.wait_for_and_click(self.navigation.libraries.folder.labels.from_path)
|
||||
|
||||
def libraries_dataset_import_from_history_select(self, to_select_items):
|
||||
self.wait_for_visible(self.navigation.libraries.folder.selectors.import_history_content)
|
||||
history_elements = self.find_elements(self.navigation.libraries.folder.selectors.import_history_contents_items)
|
||||
for to_select_item in to_select_items:
|
||||
found = False
|
||||
for history_element in history_elements:
|
||||
if to_select_item in history_element.text:
|
||||
history_element.find_element_by_css_selector("input").click()
|
||||
found = True
|
||||
break
|
||||
|
||||
if not found:
|
||||
raise Exception("Failed to find history item [%s] to select" % to_select_item)
|
||||
|
||||
def libraries_dataset_import_from_history_click_ok(self, wait=True):
|
||||
self.wait_for_and_click(self.navigation.libraries.folder.selectors.import_datasets_ok_button)
|
||||
if wait:
|
||||
# Let the progress bar disappear...
|
||||
self.wait_for_absent_or_hidden(self.navigation.libraries.folder.selectors.import_progress_bar)
|
||||
|
||||
def libraries_table_elements(self):
|
||||
tbody_element = self.wait_for_selector_visible("#folder_list_body")
|
||||
return tbody_element.find_elements_by_css_selector("tr")[1:]
|
||||
|
||||
@@ -236,14 +236,14 @@ libraries:
|
||||
|
||||
folder:
|
||||
selectors:
|
||||
# There needs to a different class or ID on the dataset button, this isn't
|
||||
# a good selector for that button since .add-library-items also applies to
|
||||
# folder (but it is a button.add-library-items instead).
|
||||
add_items_button: 'div.add-library-items'
|
||||
add_items_menu: 'div.add-library-items .dropdown-menu'
|
||||
add_items_options: 'div.add-library-items .dropdown-menu li a'
|
||||
add_items_button: '.add-library-items-datasets'
|
||||
add_items_menu: '.add-library-items-datasets .dropdown-menu'
|
||||
add_items_options: '.add-library-items-datasets .dropdown-menu li a'
|
||||
|
||||
# TODO: Most of these are very good selectors but the same DOM elements
|
||||
add_to_history: '.add-to-history'
|
||||
add_to_history_datasets: '.add-to-history-datasets'
|
||||
add_to_history_collection: '.add-to-history-collection'
|
||||
# TODO: Most of these aren't very good selectors but the same DOM elements
|
||||
# are reused without adding specific classes, IDs, or roles to anything.
|
||||
import_modal: '.modal'
|
||||
import_datasets_ok_button: '.modal-footer .buttons #button-0'
|
||||
@@ -252,6 +252,7 @@ libraries:
|
||||
import_history_content: '.library_selected_history_content'
|
||||
import_history_contents_items: '.library_selected_history_content ul li'
|
||||
import_from_path_textarea: '#import_paths'
|
||||
select_all: '#select-all-checkboxes'
|
||||
|
||||
labels:
|
||||
from_history: 'from History'
|
||||
|
||||
@@ -31,16 +31,11 @@ class LibraryContentsTestCase(SeleniumTestCase):
|
||||
self.wait_for_absent_or_hidden(self.navigation.libraries.folder.selectors.import_modal)
|
||||
|
||||
self.libraries_dataset_import_from_history()
|
||||
self.wait_for_visible(self.navigation.libraries.folder.selectors.import_history_content)
|
||||
history_elements = self.find_elements(self.navigation.libraries.folder.selectors.import_history_contents_items)
|
||||
assert "1.txt" in history_elements[0].text
|
||||
history_elements[0].find_element_by_css_selector("input").click()
|
||||
self.libraries_dataset_import_from_history_select(["1.txt"])
|
||||
# Add
|
||||
self.sleep_for(self.wait_types.UX_RENDER)
|
||||
self.screenshot("libraries_dataset_import")
|
||||
self.wait_for_and_click(self.navigation.libraries.folder.selectors.import_datasets_ok_button)
|
||||
# Let the progress bar disappear...
|
||||
self.wait_for_absent_or_hidden(self.navigation.libraries.folder.selectors.import_progress_bar)
|
||||
self.libraries_dataset_import_from_history_click_ok()
|
||||
self._assert_num_displayed_items_is(1)
|
||||
|
||||
# Fine test locally but the upload doesn't work in Docker compose. I'd think
|
||||
@@ -103,6 +98,4 @@ class LibraryContentsTestCase(SeleniumTestCase):
|
||||
self.libraries_open()
|
||||
self.name = self._get_random_name(prefix="testcontents")
|
||||
self.libraries_index_create(self.name)
|
||||
self.wait_for_overlays_cleared()
|
||||
self.libraries_index_search_for(self.name)
|
||||
self.libraries_index_table_elements()[0].find_element_by_css_selector("td a").click()
|
||||
self.libraries_open_with_name(self.name)
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
from .framework import (
|
||||
selenium_test,
|
||||
SharedStateSeleniumTestCase,
|
||||
)
|
||||
|
||||
|
||||
class LibraryToCollectionsTestCase(SharedStateSeleniumTestCase):
|
||||
|
||||
requires_admin = True
|
||||
|
||||
@selenium_test
|
||||
def test_list_creation(self):
|
||||
self.admin_login()
|
||||
self.history_panel_create_new_with_name("new_history_for_library_list")
|
||||
self.libraries_open_with_name(self.name)
|
||||
self.sleep_for(self.wait_types.UX_RENDER)
|
||||
self.components.libraries.folder.select_all.wait_for_and_click()
|
||||
self.components.libraries.folder.add_to_history.wait_for_and_click()
|
||||
self.screenshot("libraries_add_to_history_menu")
|
||||
self.components.libraries.folder.add_to_history_collection.wait_for_and_click()
|
||||
self.sleep_for(self.wait_types.UX_RENDER)
|
||||
self.screenshot("libraries_to_collection_landing")
|
||||
self.components.libraries.folder.import_datasets_ok_button.wait_for_and_click()
|
||||
|
||||
self.collection_builder_set_name("my cool list")
|
||||
self.collection_builder_create()
|
||||
self.home()
|
||||
self.history_panel_wait_for_hid_ok(3)
|
||||
|
||||
def setup_shared_state(self):
|
||||
self.admin_login()
|
||||
self.perform_upload(self.get_filename("1.bed"))
|
||||
self.wait_for_history()
|
||||
self.perform_upload(self.get_filename("2.bed"))
|
||||
self.wait_for_history()
|
||||
|
||||
self.name = self._get_random_name(prefix="testcontents")
|
||||
|
||||
self.libraries_open()
|
||||
self.libraries_index_create(self.name)
|
||||
self.libraries_open_with_name(self.name)
|
||||
|
||||
self.libraries_dataset_import_from_history()
|
||||
self.libraries_dataset_import_from_history_select(["1.bed", "2.bed"])
|
||||
self.sleep_for(self.wait_types.UX_RENDER)
|
||||
self.libraries_dataset_import_from_history_click_ok()
|
||||
Reference in New Issue
Block a user