3821: add an integration test to rename a file in a collection
authorradhika <radhika@curoverse.com>
Tue, 28 Mar 2017 15:25:35 +0000 (11:25 -0400)
committerradhika <radhika@curoverse.com>
Tue, 28 Mar 2017 15:25:35 +0000 (11:25 -0400)
apps/workbench/test/integration/collections_test.rb

index 3d2767aecddaf25eca35882ef4c309d0d809d870..2685e521f18f2a7bc29b17b50f011af30d846c71 100644 (file)
@@ -299,13 +299,11 @@ class CollectionsTest < ActionDispatch::IntegrationTest
     refute_match(%r{/collections/#{col['uuid']}}, page.current_url)
   end
 
-  test "remove selected collection files using checkboxes and dropdown option" do
+  test "remove a file from collection using checkbox 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
+    # remove first file
     input_files = page.all('input[type=checkbox]')
     input_files[0].click
 
@@ -314,26 +312,32 @@ class CollectionsTest < ActionDispatch::IntegrationTest
       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_no_text?('file1'), 'file found - file')
     assert(page.has_text?('file2'), 'file not found - file2')
   end
 
-  test "remove a collection file using trash icon" do
+  test "remove a file in collection 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
+    page.driver.browser.switch_to.alert.accept
 
-    # now in the newly created collection page
-    assert(page.has_no_text?('file1'), 'file not found - file')
+    assert(page.has_no_text?('file1'), 'file found - file')
     assert(page.has_text?('file2'), 'file not found - file2')
   end
+
+  test "rename a file in collection" do
+    visit page_with_token('active', '/collections/zzzzz-4zz18-a21ux3541sxa8sf')
+
+    within('.collection_files') do
+      first('.fa-pencil').click
+      find('.editable-input input').set('file1renamed')
+      find('.editable-submit').click
+    end
+
+    assert(page.has_text?('file1renamed'), 'file not found - file1renamed')
+  end
 end