@@ -43,6 +43,8 @@ function extractInfoFromInterceptedResponse(interception: Interception) {
4343}
4444
4545describe ( 'Collection Items Panel' , ( ) => {
46+ let collectionId : string
47+
4648 beforeEach ( ( ) => {
4749 TestsUtils . login ( ) . then ( ( token ) => {
4850 cy . wrap ( TestsUtils . setup ( token ) ) . then ( async ( ) => {
@@ -52,6 +54,7 @@ describe('Collection Items Panel', () => {
5254
5355 const collectionName = 'ItemsTestCollection'
5456 const collection = await CollectionHelper . create ( `${ collectionName } -${ Date . now ( ) } ` )
57+ collectionId = collection . id
5558 // Creates 8 datasets with 1 file each
5659 for ( const _number of numbersOfDatasetsToCreate ) {
5760 await DatasetHelper . createWithFileAndTitle (
@@ -71,7 +74,7 @@ describe('Collection Items Panel', () => {
7174 } )
7275
7376 it ( 'performs different search, filtering and respond to back and forward navigation' , ( ) => {
74- cy . visit ( `/spa/collections` )
77+ cy . visit ( `/spa/collections/ ${ collectionId } ` )
7578
7679 cy . wait ( '@getCollectionItems' ) . then ( ( interception ) => {
7780 const { totalItemsInResponse, collectionsInResponse, datasetsInResponse, filesInResponse } =
@@ -121,7 +124,7 @@ describe('Collection Items Panel', () => {
121124 ] . join ( ',' )
122125 } ) . toString ( )
123126
124- cy . url ( ) . should ( 'include' , `/collections?${ firstExpectedURL } ` )
127+ cy . url ( ) . should ( 'include' , `/collections/ ${ collectionId } ?${ firstExpectedURL } ` )
125128 } )
126129
127130 // 2 - Now perform a search in the input
@@ -154,7 +157,7 @@ describe('Collection Items Panel', () => {
154157 [ CollectionItemsQueryParams . QUERY ] : 'Darwin'
155158 } ) . toString ( )
156159
157- cy . url ( ) . should ( 'include' , `/collections?${ secondExpectedURL } ` )
160+ cy . url ( ) . should ( 'include' , `/collections/ ${ collectionId } ?${ secondExpectedURL } ` )
158161 } )
159162
160163 // 3 - Clear the search and assert that the search is performed correctly and the url is updated correctly
@@ -187,7 +190,7 @@ describe('Collection Items Panel', () => {
187190 ] . join ( ',' )
188191 } ) . toString ( )
189192
190- cy . url ( ) . should ( 'include' , `/collections?${ thirdExpectedURL } ` )
193+ cy . url ( ) . should ( 'include' , `/collections/ ${ collectionId } ?${ thirdExpectedURL } ` )
191194 } )
192195
193196 // 4 - Uncheck the Collections checkbox
@@ -219,7 +222,7 @@ describe('Collection Items Panel', () => {
219222 ] . join ( ',' )
220223 } ) . toString ( )
221224
222- cy . url ( ) . should ( 'include' , `/collections?${ fourthExpectedURL } ` )
225+ cy . url ( ) . should ( 'include' , `/collections/ ${ collectionId } ?${ fourthExpectedURL } ` )
223226 } )
224227
225228 // 5 - Uncheck the Dataset checkbox
@@ -247,7 +250,7 @@ describe('Collection Items Panel', () => {
247250 [ CollectionItemsQueryParams . TYPES ] : [ CollectionItemType . FILE ] . join ( ',' )
248251 } ) . toString ( )
249252
250- cy . url ( ) . should ( 'include' , `/collections?${ fifthExpectedURL } ` )
253+ cy . url ( ) . should ( 'include' , `/collections/ ${ collectionId } ?${ fifthExpectedURL } ` )
251254 } )
252255
253256 // 6 - Navigate back with the browser and assert that the url is updated correctly and the items are displayed correctly as in step 4
@@ -278,7 +281,7 @@ describe('Collection Items Panel', () => {
278281 ] . join ( ',' )
279282 } ) . toString ( )
280283
281- cy . url ( ) . should ( 'include' , `/collections?${ fourthExpectedURL } ` )
284+ cy . url ( ) . should ( 'include' , `/collections/ ${ collectionId } ?${ fourthExpectedURL } ` )
282285 } )
283286
284287 // 7 - Selects a facet filter
@@ -312,15 +315,15 @@ describe('Collection Items Panel', () => {
312315 ] . join ( ',' )
313316 } ) . toString ( )
314317
315- cy . url ( ) . should ( 'include' , `/collections?${ expectedURL } ` )
318+ cy . url ( ) . should ( 'include' , `/collections/ ${ collectionId } ?${ expectedURL } ` )
316319
317320 // Assert that the selected facet filter is displayed
318321 cy . findAllByRole ( 'button' , { name : / F i n c h , F i o n a / } )
319322 . should ( 'exist' )
320323 . should ( 'have.length' , 2 )
321324 } )
322325 // 8 Sort by Name (Z-A)
323- cy . visit ( `/spa/collections` )
326+ cy . visit ( `/spa/collections/ ${ collectionId } ` )
324327 cy . findByRole ( 'button' , { name : / S o r t / } ) . click ( { force : true } )
325328 cy . contains ( 'Name (Z-A)' ) . click ( { force : true } )
326329 cy . wait ( '@getCollectionItems' )
@@ -329,7 +332,7 @@ describe('Collection Items Panel', () => {
329332 [ CollectionItemsQueryParams . SORT ] : 'name' ,
330333 [ CollectionItemsQueryParams . ORDER ] : 'desc'
331334 } ) . toString ( )
332- cy . url ( ) . should ( 'include' , `/collections?${ sortExpectedUrl } ` )
335+ cy . url ( ) . should ( 'include' , `/collections/ ${ collectionId } ?${ sortExpectedUrl } ` )
333336 cy . findAllByTestId ( 'dataset-card' ) . first ( ) . should ( 'contain.text' , 'Volta' )
334337 } )
335338} )
0 commit comments