Merge branch '0000-ruby-client-config'
[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 end