3821: integration test to remove files from a collection
authorradhika <radhika@curoverse.com>
Mon, 27 Mar 2017 23:37:45 +0000 (19:37 -0400)
committerradhika <radhika@curoverse.com>
Mon, 27 Mar 2017 23:37:45 +0000 (19:37 -0400)
apps/workbench/app/controllers/collections_controller.rb
apps/workbench/test/integration/collections_test.rb
services/api/test/fixtures/collections.yml

index bac3f8eae59b2c80b224666f01f46dc06860ea20..02b204f18cbec2dc0d2e0a03bfd17c6ec042c8b6 100644 (file)
@@ -334,7 +334,7 @@ class CollectionsController < ApplicationController
         self.render_error status: 422
       end
     else
-      # Non a file rename; use default
+      # Not a file rename; use default
       super
     end
   end
index 8190b35f00747627c198af7bdd296d2e61d23377..3d2767aecddaf25eca35882ef4c309d0d809d870 100644 (file)
@@ -298,4 +298,42 @@ class CollectionsTest < ActionDispatch::IntegrationTest
     # Make sure we're not still on the old collection page.
     refute_match(%r{/collections/#{col['uuid']}}, page.current_url)
   end
+
+  test "remove selected collection files using checkboxes and dropdown option" do
+    visit page_with_token('active', '/collections/zzzzz-4zz18-a21ux3541sxa8sf')
+    assert(page.has_text?('file1'), 'file not found - file1')
+    assert(page.has_text?('file2'), 'file not found - file2')
+
+    # now in collection page
+    # remove first file from both subdirs
+    input_files = page.all('input[type=checkbox]')
+    input_files[0].click
+
+    click_button 'Selection...'
+    within('.selection-action-container') do
+      click_link 'Remove selected files'
+    end
+
+    # now in the newly created collection page
+    assert(page.has_no_text?('file1'), 'file not found - file')
+    assert(page.has_text?('file2'), 'file not found - file2')
+  end
+
+  test "remove a collection file using trash icon" do
+    need_selenium 'to confirm remove'
+
+    visit page_with_token('active', '/collections/zzzzz-4zz18-a21ux3541sxa8sf')
+    assert(page.has_text?('file1'), 'file not found - file1')
+    assert(page.has_text?('file2'), 'file not found - file2')
+
+    # now in collection page
+    first('.fa-trash-o').click
+    alert = page.driver.browser.switch_to.alert
+    alert.accept
+    wait_for_ajax
+
+    # now in the newly created collection page
+    assert(page.has_no_text?('file1'), 'file not found - file')
+    assert(page.has_text?('file2'), 'file not found - file2')
+  end
 end
index 5f7bad8abe2ed94d14986045290076d56e671e10..7f5e1f8c69ef1c2c28ccd21f8cfb55fad3602bae 100644 (file)
@@ -645,6 +645,18 @@ collection_not_readable_by_active:
   manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:bar\n"
   name: collection_not_readable_by_active
 
+collection_to_remove_and_rename_files:
+  uuid: zzzzz-4zz18-a21ux3541sxa8sf
+  portable_data_hash: 80cf6dd2cf079dd13f272ec4245cb4a8+48
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  created_at: 2014-02-03T17:22:54Z
+  modified_by_client_uuid: zzzzz-ozdt8-brczlopd8u8d0jr
+  modified_by_user_uuid: zzzzz-tpzed-d9tiejq69daie8f
+  modified_at: 2014-02-03T17:22:54Z
+  updated_at: 2014-02-03T17:22:54Z
+  manifest_text: ". d41d8cd98f00b204e9800998ecf8427e+0 0:0:file1 0:0:file2\n"
+  name: collection to remove and rename files
+
 
 # Test Helper trims the rest of the file