@@ -134,19 +134,25 @@ describe('My DSpace page', () => {
134134 it ( 'should let you filter to only archived items' , ( ) => {
135135 cy . visit ( '/mydspace' ) ;
136136
137+ //To wait filter be ready
138+ cy . intercept ( {
139+ method : 'GET' ,
140+ url : '/server/api/discover/facets/namedresourcetype**' ,
141+ } ) . as ( 'facetNamedResourceType' ) ;
142+
137143 //This page is restricted, so we will be shown the login form. Fill it in and submit it
138144 cy . loginViaForm ( Cypress . env ( 'DSPACE_TEST_ADMIN_USER' ) , Cypress . env ( 'DSPACE_TEST_ADMIN_PASSWORD' ) ) ;
139145
140146 //Wait for the page to display
141- cy . get ( 'ds-my-dspace-page' ) . should ( 'be.visible ') ;
147+ cy . wait ( '@facetNamedResourceType ') ;
142148
143149 //Open all filters
144150 cy . get ( '.filter-toggle' ) . click ( { multiple : true } ) ;
145151
146152 //The authority filter should be visible.
147- cy . get ( 'ds-search-authority-filter' ) . should ( 'be.visible' ) ;
153+ cy . get ( 'ds-search-authority-filter' ) . scrollIntoView ( ) . should ( 'be.visible' ) ;
148154
149- //Intercept the request to filter.
155+ //Intercept the request to filter and the request of filter .
150156 cy . intercept ( {
151157 method : 'GET' ,
152158 url : '/server/api/discover/search/objects**' ,
@@ -168,8 +174,10 @@ describe('My DSpace page', () => {
168174 } ) ;
169175 } ) ;
170176
171- it ( 'should upload a file via drag & drop and display it in the UI' , ( ) => {
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' , ( ) => {
172179 const fileName = 'example.pdf' ;
180+ const currentYear = new Date ( ) . getFullYear ( ) ;
173181
174182 cy . visit ( '/mydspace' ) ;
175183
@@ -192,13 +200,27 @@ describe('My DSpace page', () => {
192200 cy . get ( 'ds-collection-dropdown' ) . should ( 'be.visible' ) ;
193201
194202 // Type in a known Collection name in the search box
195- cy . get ( 'ds-collection-dropdown input[type="search"]' ) . type ( Cypress . env ( 'DSPACE_TEST_SUBMIT_COLLECTION_NAME ' ) ) ;
203+ cy . get ( 'ds-collection-dropdown input[type="search"]' ) . type ( Cypress . env ( 'DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME ' ) ) ;
196204
197205 // Click on the button matching that known Collection name
198- cy . get ( 'ds-collection-dropdown li[title="' . concat ( Cypress . env ( 'DSPACE_TEST_SUBMIT_COLLECTION_NAME ' ) ) . concat ( '"]' ) ) . click ( ) ;
206+ cy . get ( 'ds-collection-dropdown li[title="' . concat ( Cypress . env ( 'DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME ' ) ) . concat ( '"]' ) ) . click ( ) ;
199207
200208 // New URL should include /workspaceitems, as we've started a new submission
201209 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+
202224 } ) ;
203225
204226 it ( 'should let you take task from workflow' , ( ) => {
@@ -222,20 +244,30 @@ describe('My DSpace page', () => {
222244 //Await backend search response
223245 cy . wait ( '@workflowSearch' ) ;
224246
225- //Check that we have at least one item and that they all have the archived badge.
226- cy . get ( '[data-test="objects"]' )
227- . find ( '[data-test="list-object"]' )
228- . each ( ( $item ) => {
229- cy . wrap ( $item )
230- . find ( 'ds-claimed-task-actions, ds-pool-task-actions' ) . should ( 'exist' )
231- . within ( ( ) => {
232- cy . get ( 'button, a.btn' ) . each ( ( $btn ) => {
233- cy . wrap ( $btn )
234- . should ( 'exist' )
235- . and ( 'be.visible' )
236- . and ( 'not.be.disabled' ) ;
237- } ) ;
238- } ) ;
247+ //Validate URL
248+ cy . url ( ) . should ( 'include' , 'configuration=workflow' ) ;
249+
250+ //Wait to render the list and at leat one item
251+ cy . get ( '[data-test="list-object"]' ) . should ( 'have.length.greaterThan' , 0 ) ;
252+ cy . get ( '[data-test="claim-button"]' ) . should ( 'exist' ) ;
253+
254+ //Check that we have at least one item in worflow search, the item have claim-button and can click in it.
255+ cy . get ( '[data-test="list-object"]' )
256+ . then ( ( $items ) => {
257+ const itemWithClaim = [ ...$items ] . find ( item =>
258+ item . querySelector ( '[data-test="claim-button"]' )
259+ ) ;
260+ expect ( itemWithClaim , 'item with claim button' ) . to . exist ;
261+ cy . wrap ( itemWithClaim ) . as ( 'selectedItem' ) ;
262+ cy . wrap ( itemWithClaim ) . within ( ( ) => {
263+ cy . get ( 'ds-pool-task-actions' ) . should ( 'exist' ) ;
264+ cy . get ( '[data-test="claim-button"]' ) . click ( ) ;
265+ } ) ;
239266 } ) ;
267+
268+ //Finally, when you click the ‘Claim’ button, the actions for the selected item change
269+ cy . get ( '@selectedItem' ) . within ( ( ) => {
270+ cy . get ( 'ds-claimed-task-actions' ) . should ( 'exist' ) ;
271+ } ) ;
240272 } ) ;
241273} ) ;
0 commit comments