Merge branch 'master' into 12197-show-pdh-in-trash
[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 deleted['uuid']
22     assert_text deleted['portable_data_hash']
23     assert_text expired1['name']
24     assert_no_text expired2['name']   # not readable by this user
25     assert_no_text 'foo_file'         # not trash
26
27     # Un-trash one item using selection dropdown
28     within('tr', text: deleted['name']) do
29       first('input').click
30     end
31
32     click_button 'Selection...'
33     within('.selection-action-container') do
34       click_link 'Un-trash selected items'
35     end
36
37     wait_for_ajax
38
39     assert_text expired1['name']      # this should still be there
40     assert_no_text deleted['name']    # this should no longer be here
41
42     # Un-trash another item using the recycle button
43     within('tr', text: expired1['name']) do
44       first('.fa-recycle').click
45     end
46
47     wait_for_ajax
48
49     assert_no_text expired1['name']
50
51     # verify that the two un-trashed items are now shown in /collections page
52     visit page_with_token('active', "/collections")
53     assert_text deleted['uuid']
54     assert_text expired1['uuid']
55     assert_no_text expired2['uuid']
56   end
57
58   test "trash page with search" do
59     deleted = api_fixture('collections')['deleted_on_next_sweep']
60     expired = api_fixture('collections')['unique_expired_collection']
61
62     visit page_with_token('active', "/trash")
63
64     assert_text deleted['name']
65     assert_text deleted['uuid']
66     assert_text deleted['portable_data_hash']
67     assert_text expired['name']
68
69     page.find_field('Search trash').set 'expired'
70
71     assert_no_text deleted['name']
72     assert_text expired['name']
73
74     page.find_field('Search trash').set deleted['portable_data_hash'][0..9]
75
76     assert_no_text expired['name']
77     assert_text deleted['name']
78     assert_text deleted['uuid']
79     assert_text deleted['portable_data_hash']
80
81     click_button 'Selection...'
82     within('.selection-action-container') do
83       assert_selector 'li.disabled', text: 'Un-trash selected items'
84     end
85
86     first('input').click
87
88     click_button 'Selection...'
89     within('.selection-action-container') do
90       assert_selector 'li', text: 'Un-trash selected items'
91       assert_selector 'li.disabled', text: 'Un-trash selected items'
92     end
93   end
94 end