@@ -131,4 +131,153 @@ describe('My DSpace page', () => {
131131 testA11y ( 'ds-submission-import-external' ) ;
132132 } ) ;
133133
134+ it ( 'should let you filter to only archived items' , ( ) => {
135+ cy . visit ( '/mydspace' ) ;
136+
137+ //To wait filter be ready
138+ cy . intercept ( {
139+ method : 'GET' ,
140+ url : '/server/api/discover/facets/namedresourcetype**' ,
141+ } ) . as ( 'facetNamedResourceType' ) ;
142+
143+ //This page is restricted, so we will be shown the login form. Fill it in and submit it
144+ cy . loginViaForm ( Cypress . env ( 'DSPACE_TEST_ADMIN_USER' ) , Cypress . env ( 'DSPACE_TEST_ADMIN_PASSWORD' ) ) ;
145+
146+ //Wait for the page to display
147+ cy . wait ( '@facetNamedResourceType' ) ;
148+
149+ //Open all filters
150+ cy . get ( '.filter-toggle' ) . click ( { multiple : true } ) ;
151+
152+ //The authority filter should be visible.
153+ cy . get ( 'ds-search-authority-filter' ) . scrollIntoView ( ) . should ( 'be.visible' ) ;
154+
155+ //Intercept the request to filter and the request of filter.
156+ cy . intercept ( {
157+ method : 'GET' ,
158+ url : '/server/api/discover/search/objects**' ,
159+ } ) . as ( 'filterByItem' ) ;
160+
161+ //Apply the filter to the “archived” items.
162+ cy . get ( 'ds-search-authority-filter a[href*="f.namedresourcetype=item,authority"]' ) . find ( 'input[type="checkbox"]' ) . click ( ) ;
163+
164+ //Wait for the response.
165+ cy . wait ( '@filterByItem' ) ;
166+
167+ //Check that we have at least one item and that they all have the archived badge.
168+ cy . get ( 'ds-item-search-result-list-element-submission' ) . should ( 'exist' ) ;
169+ cy . get ( 'ds-item-search-result-list-element-submission' )
170+ . each ( ( $item ) => {
171+ cy . wrap ( $item )
172+ . find ( '.badge-archived' )
173+ . should ( 'exist' ) ;
174+ } ) ;
175+ } ) ;
176+
177+ //This test also generate an item to validate workflow task section
178+ it ( 'should upload a file via drag & drop, display it in the UI and submit the item' , ( ) => {
179+ const fileName = 'example.pdf' ;
180+ const currentYear = new Date ( ) . getFullYear ( ) ;
181+
182+ cy . visit ( '/mydspace' ) ;
183+
184+ //This page is restricted, so we will be shown the login form. Fill it in and submit it
185+ cy . loginViaForm ( Cypress . env ( 'DSPACE_TEST_SUBMIT_USER' ) , Cypress . env ( 'DSPACE_TEST_SUBMIT_USER_PASSWORD' ) ) ;
186+
187+ //Wait for the page to display
188+ cy . get ( 'ds-my-dspace-page' ) . should ( 'be.visible' ) ;
189+
190+ cy . wait ( 500 ) ;
191+
192+ //Select the uploader and perform the drag-and-drop action.
193+ cy . get ( 'ds-uploader .well' ) . selectFile ( `cypress/fixtures/${ fileName } ` , { action : 'drag-drop' } ) ;
194+
195+ //Validate that the file appears in the UI
196+ cy . get ( 'ds-uploader .filename' ) . should ( 'exist' ) . and ( 'contain.text' , fileName ) ;
197+
198+ //Validate that there is now exactly 1 file in the queue
199+ cy . get ( 'ds-uploader .upload-item-top' ) . should ( 'have.length' , 1 ) ;
200+
201+ // This should display the <ds-collection-dropdown> (popup window)
202+ cy . get ( 'ds-collection-dropdown' ) . should ( 'be.visible' ) ;
203+
204+ // Type in a known Collection name in the search box
205+ cy . get ( 'ds-collection-dropdown input[type="search"]' ) . type ( Cypress . env ( 'DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME' ) ) ;
206+
207+ // Click on the button matching that known Collection name
208+ cy . get ( 'ds-collection-dropdown li[title="' . concat ( Cypress . env ( 'DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME' ) ) . concat ( '"]' ) ) . click ( ) ;
209+
210+ // New URL should include /workspaceitems, as we've started a new submission
211+ cy . url ( ) . should ( 'include' , '/workspaceitems' ) ;
212+
213+ //Fill required fields
214+ cy . get ( '#dc_title' ) . type ( 'Workflow test item' ) ;
215+ cy . get ( '#dc_date_issued_year' ) . type ( currentYear . toString ( ) ) ;
216+ cy . get ( 'input[name="dc.type"]' ) . click ( ) ;
217+ cy . get ( '.dropdown-menu' ) . should ( 'be.visible' ) . contains ( 'button' , 'Other' ) . click ( ) ;
218+ cy . get ( '#granted' ) . check ( ) ;
219+
220+ //Press deposit button
221+ cy . get ( 'button[data-test="deposit"]' ) . click ( ) ;
222+
223+ //validate that URL is /mydspace
224+ cy . url ( ) . should ( 'include' , '/mydspace' ) ;
225+
226+ } ) ;
227+
228+ it ( 'should let you take task from workflow' , ( ) => {
229+ cy . visit ( '/mydspace' ) ;
230+
231+ //This page is restricted, so we will be shown the login form. Fill it in and submit it
232+ cy . loginViaForm ( Cypress . env ( 'DSPACE_TEST_ADMIN_USER' ) , Cypress . env ( 'DSPACE_TEST_ADMIN_PASSWORD' ) ) ;
233+
234+ //Wait for the page to display
235+ cy . get ( 'ds-my-dspace-page' ) . should ( 'be.visible' ) ;
236+
237+ //And wait to list is ready
238+ cy . get ( '[data-test="objects"]' ) . should ( 'be.visible' ) ;
239+
240+ //Intercept to await backend response
241+ cy . intercept ( {
242+ method : 'GET' ,
243+ url : '/server/api/discover/search/objects**' ,
244+ } ) . as ( 'workflowSearch' ) ;
245+
246+ //Change view to see workflow tasks
247+ cy . get ( 'ds-search-switch-configuration select option[data-test="workflow"]' )
248+ . should ( 'exist' )
249+ . invoke ( 'attr' , 'value' )
250+ . then ( value => {
251+ cy . get ( 'ds-search-switch-configuration select' ) . select ( value ) ;
252+ } ) ;
253+
254+ //Await backend search response
255+ cy . wait ( '@workflowSearch' ) ;
256+
257+ //Validate URL
258+ cy . url ( ) . should ( 'include' , 'configuration=workflow' ) ;
259+
260+ //Wait to render the list and at leat one item
261+ cy . get ( '[data-test="list-object"]' ) . should ( 'have.length.greaterThan' , 0 ) ;
262+ cy . get ( '[data-test="claim-button"]' ) . should ( 'exist' ) ;
263+
264+ //Check that we have at least one item in worflow search, the item have claim-button and can click in it.
265+ cy . get ( '[data-test="list-object"]' )
266+ . then ( ( $items ) => {
267+ const itemWithClaim = [ ...$items ] . find ( item =>
268+ item . querySelector ( '[data-test="claim-button"]' ) ,
269+ ) ;
270+ cy . wrap ( itemWithClaim ) . should ( 'exist' ) ;
271+ cy . wrap ( itemWithClaim ) . as ( 'selectedItem' ) ;
272+ cy . wrap ( itemWithClaim ) . within ( ( ) => {
273+ cy . get ( 'ds-pool-task-actions' ) . should ( 'exist' ) ;
274+ cy . get ( '[data-test="claim-button"]' ) . click ( ) ;
275+ } ) ;
276+ } ) ;
277+
278+ //Finally, when you click the ‘Claim’ button, the actions for the selected item change
279+ cy . get ( '@selectedItem' ) . within ( ( ) => {
280+ cy . get ( 'ds-claimed-task-actions' ) . should ( 'exist' ) ;
281+ } ) ;
282+ } ) ;
134283} ) ;
0 commit comments