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'
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")