1 require 'integration_helper'
3 class TrashTest < ActionDispatch::IntegrationTest
9 deleted = api_fixture('collections')['deleted_on_next_sweep']
10 expired1 = api_fixture('collections')['unique_expired_collection']
11 expired2 = api_fixture('collections')['unique_expired_collection2']
14 visit page_with_token('active', "/trash")
16 assert_text deleted['name']
17 assert_text expired1['name']
18 assert_text expired2['name']
19 assert_no_text 'foo_file'
21 # Un-trash one item using selection dropdown
22 within('tr', text: deleted['name']) do
26 click_button 'Selection...'
27 within('.selection-action-container') do
28 click_link 'Un-trash selected items'
33 assert_text expired1['name'] # this should still be there
34 assert_no_text deleted['name'] # this should no longer be here
36 # expired2 is not editable by me; checkbox and recycle button shouldn't be offered
37 within('tr', text: expired2['name']) do
38 assert_nil first('input')
39 assert_nil first('.fa-recycle')
42 # Un-trash another item using the recycle button
43 within('tr', text: expired1['name']) do
44 first('.fa-recycle').click
49 assert_text expired2['name']
50 assert_no_text expired1['name']
52 # verify that the two un-trashed items are now shown in /collections page
53 visit page_with_token('active', "/collections")
54 assert_text deleted['uuid']
55 assert_text expired1['uuid']
56 assert_no_text expired2['uuid']
59 test "trash page with search" do
60 deleted = api_fixture('collections')['deleted_on_next_sweep']
61 expired = api_fixture('collections')['unique_expired_collection2']
63 visit page_with_token('active', "/trash")
65 assert_text deleted['name']
66 assert_text expired['name']
68 page.find_field('Search trash').set 'expired'
70 assert_text expired['name']
71 assert_no_text deleted['name']
73 click_button 'Selection...'
74 within('.selection-action-container') do
75 assert_selector 'li.disabled', text: 'Un-trash selected items'
80 click_button 'Selection...'
81 within('.selection-action-container') do
82 assert_selector 'li', text: 'Un-trash selected items'
83 assert_selector 'li.disabled', text: 'Un-trash selected items'