@@ -56,7 +56,11 @@ describe('getDevframeRpcClient — connection meta base', () => {
5656
5757 it ( 'publishes the meta annotated with the absolute base it resolved from' , async ( ) => {
5858 const served : ConnectionMeta = { backend : 'websocket' , websocket : { path : '__ws' } }
59- vi . stubGlobal ( 'fetch' , vi . fn ( async ( ) => ( { json : async ( ) => served } ) as any ) )
59+ vi . stubGlobal ( 'fetch' , vi . fn ( async ( ) => ( {
60+ ok : true ,
61+ status : 200 ,
62+ json : async ( ) => served ,
63+ } ) as any ) )
6064
6165 await getDevframeRpcClient ( { baseURL : '/__foo/' , otpParam : false } )
6266
@@ -66,6 +70,31 @@ describe('getDevframeRpcClient — connection meta base', () => {
6670 expect ( lastWsUrl ( ) ) . toBe ( 'ws://localhost:5173/__foo/__ws' )
6771 } )
6872
73+ it ( 'falls back when a base returns a non-successful JSON response' , async ( ) => {
74+ const served : ConnectionMeta = { backend : 'websocket' , websocket : { path : '__ws' } }
75+ const fetchSpy = vi . fn ( )
76+ . mockResolvedValueOnce ( {
77+ ok : false ,
78+ status : 404 ,
79+ json : async ( ) => ( { status : 404 , error : 'Not Found' } ) ,
80+ } )
81+ . mockResolvedValueOnce ( {
82+ ok : true ,
83+ status : 200 ,
84+ json : async ( ) => served ,
85+ } )
86+ vi . stubGlobal ( 'fetch' , fetchSpy )
87+
88+ await getDevframeRpcClient ( {
89+ baseURL : [ '/__missing/' , '/__foo/' ] ,
90+ otpParam : false ,
91+ } )
92+
93+ expect ( fetchSpy ) . toHaveBeenNthCalledWith ( 1 , '/__missing/__connection.json' )
94+ expect ( fetchSpy ) . toHaveBeenNthCalledWith ( 2 , '/__foo/__connection.json' )
95+ expect ( lastWsUrl ( ) ) . toBe ( 'ws://localhost:5173/__foo/__ws' )
96+ } )
97+
6998 it ( 'inherits the publisher base so a child at another base dials the shared endpoint' , async ( ) => {
7099 // A same-origin parent already published its meta, carrying the base it was
71100 // resolved against (`/__devtools/`), not this child's base (`/__foo/`).
0 commit comments