1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
5 require 'integration_helper'
7 class TrashTest < ActionDispatch::IntegrationTest
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']
18 visit page_with_token('active', "/trash")
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
27 # Un-trash one item using selection dropdown
28 within('tr', text: deleted['name']) do
32 click_button 'Selection...'
33 within('.selection-action-container') do
34 click_link 'Un-trash selected items'
39 assert_text expired1['name'] # this should still be there
40 assert_no_text deleted['name'] # this should no longer be here
42 # Un-trash another item using the recycle button
43 within('tr', text: expired1['name']) do
44 first('.fa-recycle').click
49 assert_no_text expired1['name']
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']
58 test "trashed projects" do
59 deleted = api_fixture('groups')['trashed_project']
61 # verify that the un-trashed item are missing in /groups page
62 visit page_with_token('active', "/groups")
63 assert_no_text deleted['uuid']
66 visit page_with_token('active', "/trash")
67 click_on "Trashed projects"
69 assert_text deleted['name']
70 assert_text deleted['uuid']
72 # Un-trash item using the recycle button
73 within('tr', text: deleted['name']) do
74 first('.fa-recycle').click
79 assert_no_text deleted['uuid']
81 # verify that the un-trashed item are now shown in /groups page
82 visit page_with_token('active', "/groups")
83 assert_text deleted['uuid']
86 test "trash page with search" do
87 deleted = api_fixture('collections')['deleted_on_next_sweep']
88 expired = api_fixture('collections')['unique_expired_collection']
90 visit page_with_token('active', "/trash")
92 assert_text deleted['name']
93 assert_text deleted['uuid']
94 assert_text deleted['portable_data_hash']
95 assert_text expired['name']
97 page.find_field('Search trash').set 'expired'
99 assert_no_text deleted['name']
100 assert_text expired['name']
102 page.find_field('Search trash').set deleted['portable_data_hash'][0..9]
104 assert_no_text expired['name']
105 assert_text deleted['name']
106 assert_text deleted['uuid']
107 assert_text deleted['portable_data_hash']
109 click_button 'Selection...'
110 within('.selection-action-container') do
111 assert_selector 'li.disabled', text: 'Un-trash selected items'
116 click_button 'Selection...'
117 within('.selection-action-container') do
118 assert_selector 'li', text: 'Un-trash selected items'
119 assert_selector 'li.disabled', text: 'Un-trash selected items'