@@ -184,13 +184,28 @@ const makeServiceResponse = (name: string, teamName: string, overrides: Record<s
184184 ...overrides ,
185185 } ) as unknown as AplServiceResponse
186186
187- const makeHTTPRoute = ( conditions : { type : string ; status : string } [ ] ) => ( {
187+ const makeHTTPRoute = (
188+ conditions : { type : string ; status : string } [ ] ,
189+ options : { parentGatewayName ?: string ; visibility ?: string } = { } ,
190+ ) => ( {
191+ metadata : {
192+ labels : {
193+ 'networking.knative.dev/visibility' : options . visibility ?? '' ,
194+ } ,
195+ } ,
196+ spec : {
197+ parentRefs : [ { name : options . parentGatewayName ?? 'platform' } ] ,
198+ } ,
188199 status : {
189200 parents : [
190201 {
191202 conditions,
192203 controllerName : 'istio.io/gateway-controller' ,
193- parentRef : { group : 'gateway.networking.k8s.io' , kind : 'Gateway' , name : 'knative-local-gateway' } ,
204+ parentRef : {
205+ group : 'gateway.networking.k8s.io' ,
206+ kind : 'Gateway' ,
207+ name : options . parentGatewayName ?? 'platform' ,
208+ } ,
194209 } ,
195210 ] ,
196211 } ,
@@ -252,6 +267,20 @@ describe('getServiceStatus', () => {
252267 expect ( result ) . toBe ( 'NotFound' )
253268 } )
254269
270+ test ( 'returns NotFound when only local HTTPRoutes exist' , async ( ) => {
271+ mockList ( [
272+ makeHTTPRoute (
273+ [
274+ { type : 'Accepted' , status : 'True' } ,
275+ { type : 'ResolvedRefs' , status : 'True' } ,
276+ ] ,
277+ { parentGatewayName : 'knative-local-gateway' , visibility : 'cluster-local' } ,
278+ ) ,
279+ ] )
280+ const result = await getServiceStatus ( makeServiceResponse ( 'web' , 'alpha' ) )
281+ expect ( result ) . toBe ( 'NotFound' )
282+ } )
283+
255284 test ( 'returns Unknown when multiple HTTPRoutes are found' , async ( ) => {
256285 mockList ( [ makeHTTPRoute ( [ ] ) , makeHTTPRoute ( [ ] ) ] )
257286 const result = await getServiceStatus ( makeServiceResponse ( 'web' , 'alpha' ) )
@@ -269,6 +298,24 @@ describe('getServiceStatus', () => {
269298 expect ( result ) . toBe ( 'Succeeded' )
270299 } )
271300
301+ test ( 'returns Succeeded when local and public routes exist and public is accepted' , async ( ) => {
302+ mockList ( [
303+ makeHTTPRoute (
304+ [
305+ { type : 'Accepted' , status : 'True' } ,
306+ { type : 'ResolvedRefs' , status : 'True' } ,
307+ ] ,
308+ { parentGatewayName : 'knative-local-gateway' , visibility : 'cluster-local' } ,
309+ ) ,
310+ makeHTTPRoute ( [
311+ { type : 'Accepted' , status : 'True' } ,
312+ { type : 'ResolvedRefs' , status : 'True' } ,
313+ ] ) ,
314+ ] )
315+ const result = await getServiceStatus ( makeServiceResponse ( 'web' , 'alpha' ) )
316+ expect ( result ) . toBe ( 'Succeeded' )
317+ } )
318+
272319 test ( 'returns Unknown when single HTTPRoute is not accepted' , async ( ) => {
273320 mockList ( [
274321 makeHTTPRoute ( [
0 commit comments