X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/964ab3dd90ff1508efc0c77378cde2b3a4da1029..e59c1d365d9b6e1eff9b5cb030a8b1a3aaf14353:/apps/workbench/test/integration/collection_upload_test.rb diff --git a/apps/workbench/test/integration/collection_upload_test.rb b/apps/workbench/test/integration/collection_upload_test.rb index a2405765b0..f2a638f316 100644 --- a/apps/workbench/test/integration/collection_upload_test.rb +++ b/apps/workbench/test/integration/collection_upload_test.rb @@ -7,9 +7,19 @@ class CollectionUploadTest < ActionDispatch::IntegrationTest io.write content end end + # Database reset doesn't restore KeepServices; we have to + # save/restore manually. + use_token :admin do + @keep_services = KeepService.all.to_a + end end teardown do + use_token :admin do + @keep_services.each do |ks| + KeepService.find(ks.uuid).update_attributes(ks.attributes) + end + end testfiles.each do |filename, _| File.unlink(testfile_path filename) end @@ -22,21 +32,18 @@ class CollectionUploadTest < ActionDispatch::IntegrationTest click_link 'Upload files from my computer' # Should be looking at a new empty collection. assert_text 'New collection' - assert_text 'd41d8cd98f00b204e9800998ecf8427e+0' + assert_text ' 0 files' + assert_text ' 0 bytes' # The "Upload" tab should be active and loaded. assert_selector 'div#Upload.active div.panel' end - test "No Upload tab on non-writable collection" do - need_javascript - visit(page_with_token 'active', - '/collections/'+api_fixture('collections')['user_agreement']['uuid']) - assert_no_selector '.nav-tabs Upload' - end - test "Upload two empty files with the same name" do need_selenium "to make file uploads work" visit page_with_token 'active', sandbox_path + + unlock_collection + find('.nav-tabs a', text: 'Upload').click attach_file 'file_selector', testfile_path('empty.txt') assert_selector 'div', text: 'empty.txt' @@ -48,22 +55,59 @@ class CollectionUploadTest < ActionDispatch::IntegrationTest assert_match /_text":"\. d41d8\S+ 0:0:empty.txt\\n\. d41d8\S+ 0:0:empty\\\\040\(1\).txt\\n"/, body end - test "Upload non-empty files, report errors" do + test "Upload non-empty files" do need_selenium "to make file uploads work" visit page_with_token 'active', sandbox_path + + unlock_collection + find('.nav-tabs a', text: 'Upload').click attach_file 'file_selector', testfile_path('a') attach_file 'file_selector', testfile_path('foo.txt') assert_selector 'button:not([disabled])', text: 'Start' click_button 'Start' - if "test environment does not have a keepproxy yet, see #4534" != "fixed" - using_wait_time 20 do - assert_text :visible, 'error' - end - else - assert_text :visible, 'Done!' - visit sandbox_path+'.json' - assert_match /_text":"\. 0cc1\S+ 0:1:a\\n\. acbd\S+ 0:3:foo.txt\\n"/, body + assert_text :visible, 'Done!' + visit sandbox_path+'.json' + assert_match /_text":"\. 0cc1\S+ 0:1:a\\n\. acbd\S+ 0:3:foo.txt\\n"/, body + end + + test "Report mixed-content error" do + skip 'Test suite does not use TLS' + need_selenium "to make file uploads work" + use_token :admin do + KeepService.where(service_type: 'proxy').first. + update_attributes(service_ssl_flag: false) + end + visit page_with_token 'active', sandbox_path + find('.nav-tabs a', text: 'Upload').click + attach_file 'file_selector', testfile_path('foo.txt') + assert_selector 'button:not([disabled])', text: 'Start' + click_button 'Start' + using_wait_time 5 do + assert_text :visible, 'server setup problem' + assert_text :visible, 'cannot be used from origin' + end + end + + test "Report network error" do + need_selenium "to make file uploads work" + use_token :admin do + # Even if port 0 is a thing, surely nx.example.net won't + # respond + KeepService.where(service_type: 'proxy').first. + update_attributes(service_host: 'nx.example.net', + service_port: 0) + end + visit page_with_token 'active', sandbox_path + + unlock_collection + + find('.nav-tabs a', text: 'Upload').click + attach_file 'file_selector', testfile_path('foo.txt') + assert_selector 'button:not([disabled])', text: 'Start' + click_button 'Start' + using_wait_time 5 do + assert_text :visible, 'network error' end end @@ -93,4 +137,9 @@ class CollectionUploadTest < ActionDispatch::IntegrationTest # Must be an absolute path. https://github.com/jnicklas/capybara/issues/621 File.join Dir.getwd, 'tmp', filename end + + def unlock_collection + first('.lock-collection-btn').click + accept_alert + end end