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_text "The collection with UUID #{expired1['uuid']} is in the trash"
51 click_on "Click here to untrash '#{expired1['name']}'"
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']
60 ["button","selection"].each do |method|
61 test "trashed projects using #{method}" do
62 deleted = api_fixture('groups')['trashed_project']
63 aproject = api_fixture('groups')['aproject']
65 # verify that the un-trashed item are missing in /groups page
66 visit page_with_token('active', "/projects/zzzzz-tpzed-xurymjxw79nv3jz")
67 click_on "Subprojects"
68 assert_no_text deleted['name']
71 visit page_with_token('active', "/trash")
72 click_on "Trashed projects"
74 assert_text deleted['name']
75 assert_text deleted['uuid']
76 assert_no_text aproject['name']
77 assert_no_text aproject['uuid']
81 within('tr', text: deleted['uuid']) do
82 first('.fa-recycle').click
84 assert_text "The group with UUID #{deleted['uuid']} is in the trash"
85 click_on "Click here to untrash '#{deleted['name']}'"
87 within('tr', text: deleted['uuid']) do
90 click_button 'Selection...'
91 within('.selection-action-container') do
92 click_link 'Un-trash selected items'
95 assert_no_text deleted['uuid']
98 # check that the un-trashed item are now shown on parent project page
99 visit page_with_token('active', "/projects/zzzzz-tpzed-xurymjxw79nv3jz")
100 click_on "Subprojects"
101 assert_text deleted['name']
102 assert_text aproject['name']
105 if method == "button"
106 within('tr', text: aproject['name']) do
107 first('.fa-trash-o').click
110 within('tr', text: aproject['name']) do
113 click_button 'Selection'
114 within('.selection-action-container') do
115 click_link 'Remove selected'
120 assert_no_text aproject['name']
122 assert_no_text aproject['name']
125 visit page_with_token('active', "/trash")
126 click_on "Trashed projects"
128 assert_text aproject['name']
129 assert_text aproject['uuid']
133 test "trash page with search" do
134 deleted = api_fixture('collections')['deleted_on_next_sweep']
135 expired = api_fixture('collections')['unique_expired_collection']
137 visit page_with_token('active', "/trash")
139 assert_text deleted['name']
140 assert_text deleted['uuid']
141 assert_text deleted['portable_data_hash']
142 assert_text expired['name']
144 page.find_field('Search trash').set 'expired'
146 assert_no_text deleted['name']
147 assert_text expired['name']
149 page.find_field('Search trash').set deleted['portable_data_hash'][0..9]
151 assert_no_text expired['name']
152 assert_text deleted['name']
153 assert_text deleted['uuid']
154 assert_text deleted['portable_data_hash']
156 click_button 'Selection...'
157 within('.selection-action-container') do
158 assert_selector 'li.disabled', text: 'Un-trash selected items'
163 click_button 'Selection...'
164 within('.selection-action-container') do
165 assert_selector 'li', text: 'Un-trash selected items'
166 assert_selector 'li.disabled', text: 'Un-trash selected items'