@@ -131,4 +131,151 @@ 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+ //Select the uploader and perform the drag-and-drop action.
191+ cy . get ( 'ds-uploader .well' ) . selectFile ( `cypress/fixtures/${ fileName } ` , { action : 'drag-drop' } ) ;
192+
193+ //Validate that the file appears in the UI
194+ cy . get ( 'ds-uploader .filename' ) . should ( 'exist' ) . and ( 'contain.text' , fileName ) ;
195+
196+ //Validate that there is now exactly 1 file in the queue
197+ cy . get ( 'ds-uploader .upload-item-top' ) . should ( 'have.length' , 1 ) ;
198+
199+ // This should display the <ds-collection-dropdown> (popup window)
200+ cy . get ( 'ds-collection-dropdown' ) . should ( 'be.visible' ) ;
201+
202+ // Type in a known Collection name in the search box
203+ cy . get ( 'ds-collection-dropdown input[type="search"]' ) . type ( Cypress . env ( 'DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME' ) ) ;
204+
205+ // Click on the button matching that known Collection name
206+ cy . get ( 'ds-collection-dropdown li[title="' . concat ( Cypress . env ( 'DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME' ) ) . concat ( '"]' ) ) . click ( ) ;
207+
208+ // New URL should include /workspaceitems, as we've started a new submission
209+ cy . url ( ) . should ( 'include' , '/workspaceitems' ) ;
210+
211+ //Fill required fields
212+ cy . get ( '#dc_title' ) . type ( 'Workflow test item' ) ;
213+ cy . get ( '#dc_date_issued_year' ) . type ( currentYear . toString ( ) ) ;
214+ cy . get ( 'input[name="dc.type"]' ) . click ( ) ;
215+ cy . get ( '.dropdown-menu' ) . should ( 'be.visible' ) . contains ( 'button' , 'Other' ) . click ( ) ;
216+ cy . get ( '#granted' ) . check ( ) ;
217+
218+ //Press deposit button
219+ cy . get ( 'button[data-test="deposit"]' ) . click ( ) ;
220+
221+ //validate that URL is /mydspace
222+ cy . url ( ) . should ( 'include' , '/mydspace' ) ;
223+
224+ } ) ;
225+
226+ it ( 'should let you take task from workflow' , ( ) => {
227+ cy . visit ( '/mydspace' ) ;
228+
229+ //This page is restricted, so we will be shown the login form. Fill it in and submit it
230+ cy . loginViaForm ( Cypress . env ( 'DSPACE_TEST_ADMIN_USER' ) , Cypress . env ( 'DSPACE_TEST_ADMIN_PASSWORD' ) ) ;
231+
232+ //Wait for the page to display
233+ cy . get ( 'ds-my-dspace-page' ) . should ( 'be.visible' ) ;
234+
235+ //And wait to list is ready
236+ cy . get ( '[data-test="objects"]' ) . should ( 'be.visible' ) ;
237+
238+ //Intercept to await backend response
239+ cy . intercept ( {
240+ method : 'GET' ,
241+ url : '/server/api/discover/search/objects**' ,
242+ } ) . as ( 'workflowSearch' ) ;
243+
244+ //Change view to see workflow tasks
245+ cy . get ( 'ds-search-switch-configuration select option[data-test="workflow"]' )
246+ . should ( 'exist' )
247+ . invoke ( 'attr' , 'value' )
248+ . then ( value => {
249+ cy . get ( 'ds-search-switch-configuration select' ) . select ( value ) ;
250+ } ) ;
251+
252+ //Await backend search response
253+ cy . wait ( '@workflowSearch' ) ;
254+
255+ //Validate URL
256+ cy . url ( ) . should ( 'include' , 'configuration=workflow' ) ;
257+
258+ //Wait to render the list and at leat one item
259+ cy . get ( '[data-test="list-object"]' ) . should ( 'have.length.greaterThan' , 0 ) ;
260+ cy . get ( '[data-test="claim-button"]' ) . should ( 'exist' ) ;
261+
262+ //Check that we have at least one item in worflow search, the item have claim-button and can click in it.
263+ cy . get ( '[data-test="list-object"]' )
264+ . then ( ( $items ) => {
265+ const itemWithClaim = [ ...$items ] . find ( item =>
266+ item . querySelector ( '[data-test="claim-button"]' ) ,
267+ ) ;
268+ cy . wrap ( itemWithClaim ) . should ( 'exist' ) ;
269+ cy . wrap ( itemWithClaim ) . as ( 'selectedItem' ) ;
270+ cy . wrap ( itemWithClaim ) . within ( ( ) => {
271+ cy . get ( 'ds-pool-task-actions' ) . should ( 'exist' ) ;
272+ cy . get ( '[data-test="claim-button"]' ) . click ( ) ;
273+ } ) ;
274+ } ) ;
275+
276+ //Finally, when you click the ‘Claim’ button, the actions for the selected item change
277+ cy . get ( '@selectedItem' ) . within ( ( ) => {
278+ cy . get ( 'ds-claimed-task-actions' ) . should ( 'exist' ) ;
279+ } ) ;
280+ } ) ;
134281} ) ;
0 commit comments