@@ -33,13 +33,16 @@ Cypress.Commands.add('assertValueCopiedToClipboard', value => {
3333} )
3434
3535Cypress . Commands . add ( 'interceptAll' , ( ) => {
36+ // console.log('Intercepted:', req.method, req.url)
3637 cy . intercept ( 'GET' , / h t t p s .* j s o n $ / ) . as ( 'jsonLink' )
3738 cy . intercept ( 'GET' , / ^ \/ \w * \. j s o n $ / ) . as ( 'jsonLocal' )
3839 cy . intercept ( 'GET' , '**/api/resources/find-resources-in-batch*' , ( req ) => {
3940 const url = new URL ( req . url ) ;
4041 const ids = url . searchParams . getAll ( 'id' ) ;
4142 const versions = url . searchParams . getAll ( 'resource_version' ) ;
42-
43+ console . log ( "in find" , url )
44+ console . log ( ids )
45+ console . log ( versions )
4346 // Check for specific resource requests
4447 if ( ids . includes ( 'arm64-ubuntu-20.04-boot' ) ) {
4548 const versionIndex = ids . indexOf ( 'arm64-ubuntu-20.04-boot' ) ;
@@ -54,33 +57,22 @@ Cypress.Commands.add('interceptAll', () => {
5457 fixture : 'getResource.json'
5558 } )
5659 } else {
57- req . reply ( {
58- documents : [ ] ,
59- } )
60+ req . reply ( [ ] )
6061 }
6162 } else {
62- req . reply ( {
63- documents : [ ] ,
64- } )
63+ req . reply ( [ ] )
6564 }
6665 } ) . as ( 'find' )
67- cy . intercept ( 'GET' , '**/api/resources/search*' , ( req ) => {
66+ cy . intercept ( 'GET' , '**/api/resources/search*' , ( req ) => {
6867 const url = new URL ( req . url ) ;
6968 const containsStr = url . searchParams . get ( 'contains-str' ) ;
7069 const mustInclude = url . searchParams . get ( 'must-include' ) ;
7170 const pageSize = parseInt ( url . searchParams . get ( 'page-size' ) ) || 10 ;
7271 const page = parseInt ( url . searchParams . get ( 'page' ) ) || 1 ;
73-
72+ console . log ( "in cypress" )
7473 console . log ( 'Search params:' , { containsStr, mustInclude, pageSize, page } ) ;
7574
76- // Handle different search scenarios based on your old pipeline logic
77- if ( ! containsStr && ! mustInclude ) {
78- // Empty search - equivalent to pipeline length 5
79- req . reply ( {
80- documents : [ ] ,
81- totalCount : 0
82- } )
83- } else if ( mustInclude ) {
75+ if ( mustInclude ) {
8476 // Parse must-include filters
8577 const filters = mustInclude . split ( ';' ) . reduce ( ( acc , filter ) => {
8678 const [ field , ...values ] = filter . split ( ',' ) ;
@@ -89,36 +81,46 @@ Cypress.Commands.add('interceptAll', () => {
8981 } , { } ) ;
9082
9183 if ( filters . category ) {
84+ console . log ( "category" )
9285 req . reply ( {
9386 fixture : 'searchDiskimage.json'
9487 } )
9588 } else if ( filters . architecture ) {
89+ console . log ( "architecture" )
9690 req . reply ( {
9791 fixture : 'searchArchitecture.json'
9892 } )
93+ } else if ( filters . tags ) {
94+ req . reply ( {
95+ fixture : 'searchTags.json'
96+ } )
9997 } else {
98+ console . log ( "exact" )
10099 req . reply ( {
101100 fixture : 'searchExact.json'
102101 } )
103102 }
104- } else if ( containsStr ) {
103+ } else if ( pageSize ) {
105104 // Basic search with different page sizes
106105 if ( pageSize === 25 ) {
106+ console . log ( "page 25" )
107107 req . reply ( {
108108 fixture : 'search25.json'
109109 } )
110110 } else {
111+ console . log ( "default page exact" )
111112 req . reply ( {
112113 fixture : 'searchExact.json'
113114 } )
114115 }
115116 } else {
117+ console . log ( "else" )
116118 req . reply ( {
117119 documents : [ ] ,
118120 totalCount : 0
119121 } )
120122 }
121- } ) . as ( 'search ' )
123+ } ) . as ( 'mongo ' )
122124
123125 // Intercept filters request (replaces old MongoDB aggregate for filters)
124126 cy . intercept ( 'GET' , '**/api/resources/filters*' , {
@@ -129,19 +131,19 @@ Cypress.Commands.add('interceptAll', () => {
129131Cypress . Commands . add ( 'waitFirst' , ( ) => {
130132 const resource = Object . keys ( Cypress . env ( 'SOURCES' ) ) [ 0 ]
131133 if ( Cypress . env ( 'SOURCES' ) [ resource ] . isMongo ) {
132- cy . wait ( [ '@search ' ] )
134+ // cy.wait(['@mongo '])
133135 } else {
134136 cy . waitJSON ( Cypress . env ( 'SOURCES' ) [ resource ] . url . includes ( 'http' ) )
135137 }
136138 return cy . wrap ( Cypress . env ( 'SOURCES' ) [ resource ] . isMongo )
137139} )
138140
139141Cypress . Commands . add ( 'waitAll' , value => {
140- cy . wait ( [ '@kiwi' , '@resources' , '@search' , '@ filters'] )
142+ cy . wait ( [ '@kiwi' , '@resources' , '@filters' ] )
141143} )
142144
143145Cypress . Commands . add ( 'waitMongo' , ( ) => {
144- cy . wait ( [ '@search' , '@ filters'] )
146+ cy . wait ( [ '@filters' ] )
145147} )
146148
147149Cypress . Commands . add ( 'waitJSON' , ( isUrl ) => {
@@ -154,9 +156,10 @@ Cypress.Commands.add('waitJSON', (isUrl) => {
154156
155157Cypress . Commands . add ( 'waitAuto' , ( ) => {
156158 const resources = Cypress . env ( 'SOURCES' )
159+ console . log ( "resouces" , resources )
157160 Object . keys ( resources ) . forEach ( ( i ) => {
158161 if ( resources [ i ] . isMongo ) {
159- cy . wait ( [ '@search ' ] )
162+ cy . wait ( [ '@mongo ' ] )
160163 } else {
161164 cy . waitJSON ( resources [ i ] . url . includes ( 'http' ) )
162165 }
0 commit comments