Merge branch '1968-monitor-disk-usage'
[arvados.git] / apps / workbench / test / integration / collections_test.rb
1 require 'integration_helper'
2 require 'selenium-webdriver'
3 require 'headless'
4
5 class CollectionsTest < ActionDispatch::IntegrationTest
6
7   def change_persist oldstate, newstate
8     find "div[data-persistent-state='#{oldstate}']"
9     page.assert_no_selector "div[data-persistent-state='#{newstate}']"
10     find('.btn', text: oldstate.capitalize).click
11     find '.btn', text: newstate.capitalize
12     page.assert_no_selector '.btn', text: oldstate.capitalize
13     find "div[data-persistent-state='#{newstate}']"
14     page.assert_no_selector "div[data-persistent-state='#{oldstate}']"
15   end
16
17   ['/collections', '/'].each do |path|
18     test "Flip persistent switch at #{path}" do
19       Capybara.current_driver = Capybara.javascript_driver
20       uuid = api_fixture('collections')['foo_file']['uuid']
21       visit page_with_token('active', path)
22       within "tr[data-object-uuid='#{uuid}']" do
23         change_persist 'cache', 'persistent'
24       end
25       # Refresh page and make sure the change was committed.
26       visit current_path
27       within "tr[data-object-uuid='#{uuid}']" do
28         change_persist 'persistent', 'cache'
29       end
30     end
31   end
32
33   test 'Flip persistent switch on collection#show' do
34     Capybara.current_driver = Capybara.javascript_driver
35     uuid = api_fixture('collections')['foo_file']['uuid']
36     visit page_with_token('active', "/collections/#{uuid}")
37     change_persist 'cache', 'persistent'
38     visit current_path
39     change_persist 'persistent', 'cache'
40   end
41
42   test "Collection page renders default name links" do
43     uuid = api_fixture('collections')['foo_file']['uuid']
44     coll_name = api_fixture('links')['foo_collection_name_in_afolder']['name']
45     visit page_with_token('active', "/collections/#{uuid}")
46     assert(page.has_text?(coll_name), "Collection page did not include name")
47     # Now check that the page is otherwise normal, and the collection name
48     # isn't only showing up in an error message.
49     assert(page.has_link?('foo'), "Collection page did not include file link")
50   end
51 end