+ assert_selector 'li.disabled', text: 'Create new collection with selected collections'
+ assert_selector 'li.disabled', text: 'Compare selected'
+ assert_selector 'li.disabled', text: 'Copy selected'
+ assert_no_selector 'li.disabled', text: 'Move selected'
+ assert_selector 'li', text: 'Move selected'
+ assert_no_selector 'li.disabled', text: 'Remove selected'
+ assert_selector 'li', text: 'Remove selected'
+ end
+ end
+
+ # When project tabs are switched, only options applicable to the current tab's selections are enabled.
+ test "verify selection options when tabs are switched" do
+ my_project = api_fixture('groups')['aproject']
+ my_collection = api_fixture('collections')['collection_to_move_around_in_aproject']
+ my_subproject = api_fixture('groups')['asubproject']
+
+ # select subproject and a collection and verify that copy action is still disabled
+ visit page_with_token 'active', '/'
+ find("#projects-menu").click
+ find(".dropdown-menu a", text: my_project['name']).click
+
+ # Select a sub-project
+ click_link 'Subprojects'
+ assert page.has_text?(my_subproject['name']), 'Subproject not found in project'
+
+ within('tr', text: my_subproject['name']) do
+ find('input[type=checkbox]').click
+ end
+
+ # Select a collection
+ click_link 'Data collections'
+ assert page.has_text?(my_collection['name']), 'Collection not found in project'
+
+ within('tr', text: my_collection['name']) do
+ find('input[type=checkbox]').click
+ end
+
+ # Go back to Subprojects tab
+ click_link 'Subprojects'
+ click_button 'Selection'
+ within('.selection-action-container') do
+ assert_selector 'li.disabled', text: 'Create new collection with selected collections'
+ assert_selector 'li.disabled', text: 'Compare selected'
+ assert_selector 'li.disabled', text: 'Copy selected'
+ assert_no_selector 'li.disabled', text: 'Move selected'
+ assert_selector 'li', text: 'Move selected'
+ assert_no_selector 'li.disabled', text: 'Remove selected'
+ assert_selector 'li', text: 'Remove selected'
+ end
+
+ # Close the dropdown by clicking outside it.
+ find('.dropdown-toggle', text: 'Selection').find(:xpath, '..').click
+
+ # Go back to Data collections tab
+ find('.nav-tabs a', text: 'Data collections').click
+ click_button 'Selection'
+ within('.selection-action-container') do
+ assert_no_selector 'li.disabled', text: 'Create new collection with selected collections'
+ assert_selector 'li', text: 'Create new collection with selected collections'
+ assert_selector 'li.disabled', text: 'Compare selected'
+ assert_no_selector 'li.disabled', text: 'Copy selected'
+ assert_selector 'li', text: 'Copy selected'
+ assert_no_selector 'li.disabled', text: 'Move selected'
+ assert_selector 'li', text: 'Move selected'
+ assert_no_selector 'li.disabled', text: 'Remove selected'
+ assert_selector 'li', text: 'Remove selected'
+ end
+ end
+
+ # "Move selected" and "Remove selected" options should not be
+ # available when current user cannot write to the project
+ test "move selected and remove selected actions not available when current user cannot write to project" do
+ my_project = api_fixture('groups')['anonymously_accessible_project']
+ visit page_with_token 'active', "/projects/#{my_project['uuid']}"
+
+ click_link 'Data collections'
+ click_button 'Selection'
+ within('.selection-action-container') do
+ assert_selector 'li', text: 'Create new collection with selected collections'
+ assert_selector 'li', text: 'Compare selected'
+ assert_selector 'li', text: 'Copy selected'
+ assert_no_selector 'li', text: 'Move selected'
+ assert_no_selector 'li', text: 'Remove selected'