3654: add integration and funtional tests for combining collections and collection...
authorradhika <radhika@curoverse.com>
Fri, 5 Sep 2014 18:03:11 +0000 (14:03 -0400)
committerradhika <radhika@curoverse.com>
Fri, 5 Sep 2014 18:03:11 +0000 (14:03 -0400)
apps/workbench/test/functional/actions_controller_test.rb
apps/workbench/test/integration/collections_test.rb
apps/workbench/test/integration/projects_test.rb

index 965453841f7417b60d79860d4e070fc2447b5069..d152a003a157cdba9e35bd8c4592c3a3163e0cce 100644 (file)
@@ -16,4 +16,34 @@ class ActionsControllerTest < ActionController::TestCase
     assert_equal true, found_email, 'Expected email after issue reported'
   end
 
+  test "combine files into new collection" do
+    post(:combine_selected_files_into_collection, {
+           selection: ['zzzzz-4zz18-znfnqtbbv4spc3w/foo',
+                       'zzzzz-4zz18-ehbhgtheo8909or/bar',
+                       'zzzzz-4zz18-y9vne9npefyxh8g/baz',
+                       '1fd08fc162a5c6413070a8bd0bffc818+150'],
+           format: "json"},
+         session_for(:active))
+
+    assert_response 302   # collection created and redirected to new collection page
+    new_collection_uuid = response.headers['Location'].split('/')[-1]
+
+    @controller = CollectionsController.new
+
+    get :show, {
+      id: new_collection_uuid
+    }
+    assert_response :success
+
+    collection = assigns(:object)
+    manifest_text = collection['manifest_text']
+    assert manifest_text.include?('foo'), 'Not found foo in new collection manifest text'
+    assert manifest_text.include?('bar'), 'Not found bar in new collection manifest text'
+    assert manifest_text.include?('baz'), 'Not found baz in new collection manifest text'
+    assert manifest_text.include?('0:0:file1 0:0:file2 0:0:file3'),
+                'Not found 0:0:file1 0:0:file2 0:0:file3 in new collection manifest text'
+    assert manifest_text.include?('dir1/subdir'), 'Not found dir1/subdir in new collection manifest text'
+    assert manifest_text.include?('dir2'), 'Not found dir2 in new collection manifest text'
+  end
+
 end
index ac2625aaeaca6204b327cff6874d188516a57ded..a5ce8fd3eb33bb087e04be2a381ff7e399aa93f3 100644 (file)
@@ -46,4 +46,58 @@ class CollectionsTest < ActionDispatch::IntegrationTest
     visit page_with_token('active', "/collections/#{uuid}")
     assert page.has_text?('This collection is empty')
   end
+
+  test "combine selected collections into new collection" do
+    foo_collection_uuid = api_fixture('collections')['foo_file']['uuid']
+    bar_collection_uuid = api_fixture('collections')['bar_file']['uuid']
+
+    visit page_with_token('active', "/collections")
+
+    assert(page.has_text?(foo_collection_uuid), "Collection page did not include foo file")
+    assert(page.has_text?(bar_collection_uuid), "Collection page did not include bar file")
+
+    within('tr', text: foo_collection_uuid) do
+      find('input[type=checkbox]').click
+    end
+
+    within('tr', text: bar_collection_uuid) do
+      find('input[type=checkbox]').click
+    end
+
+    click_button 'Selection...'
+    within('.selection-action-container') do
+      click_link 'Combine selections into a new collection'
+    end
+
+    # back in collections page
+    assert(page.has_text?(foo_collection_uuid), "Collection page did not include foo file")
+    assert(page.has_text?(bar_collection_uuid), "Collection page did not include bar file")
+  end
+
+  test "combine selected collection contents into new collection" do
+    foo_collection = api_fixture('collections')['foo_file']
+   # bar_collection = api_fixture('collections')['bar_file']
+   # pdh_collection = api_fixture('collections')['multilevel_collection_1']
+
+    visit page_with_token('active', "/collections")
+
+    # choose file from foo collection
+    within('tr', text: foo_collection['uuid']) do
+      click_link 'Show'
+    end
+
+    # now in collection page
+    within('tr', text: foo_collection['name'].split('_')[0]) do
+      find('input[type=checkbox]').click
+    end
+
+    click_button 'Selection...'
+    within('.selection-action-container') do
+      click_link 'Combine selections into a new collection'
+    end
+
+    # go back to collections page
+    visit page_with_token('active', "/collections")
+    assert(page.has_text?('sdfsdfsdfsdfsdfsdfsdf'), "Collection page did not include foo file link")
+  end
 end
index 100f3bbf2b19ab52a40266cfc986560a4cdd6bce..4fa95671647d3f9e47f71d654419712b1caea722 100644 (file)
@@ -339,6 +339,7 @@ class ProjectsTest < ActionDispatch::IntegrationTest
 
     click_button 'Selection...'
     within('.selection-action-container') do
+      page.assert_selector 'li.disabled', text: 'Combine selections into a new collection'
       page.assert_selector 'li.disabled', text: 'Compare selected'
       page.assert_selector 'li.disabled', text: 'Copy selected'
       page.assert_selector 'li.disabled', text: 'Move selected'
@@ -356,6 +357,8 @@ class ProjectsTest < ActionDispatch::IntegrationTest
 
     click_button 'Selection...'
     within('.selection-action-container') do
+      page.assert_no_selector 'li.disabled', text: 'Combine selections into a new collection'
+      page.assert_selector 'li', text: 'Combine selections into a new collection'
       page.assert_selector 'li.disabled', text: 'Compare selected'
       page.assert_no_selector 'li.disabled', text: 'Copy selected'
       page.assert_selector 'li', text: 'Copy selected'
@@ -378,6 +381,7 @@ class ProjectsTest < ActionDispatch::IntegrationTest
 
     click_button 'Selection...'
     within('.selection-action-container') do
+      page.assert_selector 'li.disabled', text: 'Combine selections into a new collection'
       page.assert_selector 'li.disabled', text: 'Compare selected'
       page.assert_selector 'li.disabled', text: 'Copy selected'
       page.assert_no_selector 'li.disabled', text: 'Move selected'
@@ -406,6 +410,7 @@ class ProjectsTest < ActionDispatch::IntegrationTest
 
     click_button 'Selection...'
     within('.selection-action-container') do
+      page.assert_selector 'li.disabled', text: 'Combine selections into a new collection'
       page.assert_selector 'li.disabled', text: 'Compare selected'
       page.assert_selector 'li.disabled', text: 'Copy selected'
       page.assert_no_selector 'li.disabled', text: 'Move selected'
@@ -415,4 +420,26 @@ class ProjectsTest < ActionDispatch::IntegrationTest
     end
   end
 
+  test "combine selections into new collection" do
+    my_project = api_fixture('groups')['aproject']
+    my_collection = api_fixture('collections')['collection_to_move_around_in_aproject']
+
+    visit page_with_token 'active', '/'
+    find('.arv-project-list a,button', text: my_project['name']).click
+    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
+
+    click_button 'Selection...'
+    within('.selection-action-container') do
+      click_link 'Combine selections into a new collection'
+    end
+
+    # back in project page
+    assert page.has_text?(my_collection['name']), 'Collection not found in project'
+    assert page.has_link?('Jobs and pipelines'), 'Jobs and pipelines link not found in project'
+  end
+
 end