9587: test /trash page
[arvados.git] / apps / workbench / test / integration / trash_test.rb
1 require 'integration_helper'
2
3 class TrashTest < ActionDispatch::IntegrationTest
4   setup do
5     need_javascript
6   end
7
8   test "trash page" do
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']
12
13     # visit trash page
14     visit page_with_token('active', "/trash")
15
16     assert_text deleted['name']
17     assert_text expired1['name']
18     assert_text expired2['name']
19     assert_no_text 'foo_file'
20
21     # Un-trash one item using selection dropdown
22     within('tr', text: deleted['name']) do
23       first('input').click
24     end
25
26     click_button 'Selection...'
27     within('.selection-action-container') do
28       click_link 'Un-trash selected items'
29     end
30
31     wait_for_ajax
32
33     assert_text expired1['name']      # this should still be there
34     assert_no_text deleted['name']    # this should no longer be here
35
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')
40     end
41
42     # Un-trash another item using the recycle button
43     within('tr', text: expired1['name']) do
44       first('.fa-recycle').click
45       accept_alert
46     end
47
48     wait_for_ajax
49
50     assert_text expired2['name']
51     assert_no_text expired1['name']
52
53     # verify that the two un-trashed items are now shown in /collections page
54     visit page_with_token('active', "/collections")
55     assert_text deleted['uuid']
56     assert_text expired1['uuid']
57     assert_no_text expired2['uuid']
58   end
59
60   test "trash page with search" do
61     deleted = api_fixture('collections')['deleted_on_next_sweep']
62     expired = api_fixture('collections')['unique_expired_collection2']
63
64     visit page_with_token('active', "/trash")
65
66     assert_text deleted['name']
67     assert_text expired['name']
68
69     page.find_field('Search trash').set 'expired'
70
71     assert_text expired['name']
72     assert_no_text deleted['name']
73
74     click_button 'Selection...'
75     within('.selection-action-container') do
76       assert_selector 'li.disabled', text: 'Un-trash selected items'
77     end
78
79     first('input').click
80
81     click_button 'Selection...'
82     within('.selection-action-container') do
83       assert_selector 'li', text: 'Un-trash selected items'
84       assert_selector 'li.disabled', text: 'Un-trash selected items'
85     end
86   end
87 end