1 require 'integration_helper'
2 require 'selenium-webdriver'
5 class CollectionsTest < ActionDispatch::IntegrationTest
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}']"
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'
25 # Refresh page and make sure the change was committed.
27 within "tr[data-object-uuid='#{uuid}']" do
28 change_persist 'persistent', 'cache'
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'
39 change_persist 'persistent', 'cache'