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