@@ -73,22 +73,28 @@ describe("msalConfig", () => {
7373 expect ( global . fetch ) . toHaveBeenCalledWith ( "/api/auth/config" ) ;
7474 } ) ;
7575
76- it ( "returns empty config when response is not ok" , async ( ) => {
77- ( global . fetch as jest . Mock ) . mockResolvedValue ( { ok : false } ) ;
76+ it ( "throws when response is not ok (transient failure is not auth-disabled)" , async ( ) => {
77+ ( global . fetch as jest . Mock ) . mockResolvedValue ( {
78+ ok : false ,
79+ status : 503 ,
80+ statusText : "Service Unavailable" ,
81+ } ) ;
7882
7983 const { fetchAuthConfig } = await import ( "./msalConfig" ) ;
80- const result = await fetchAuthConfig ( ) ;
8184
82- expect ( result ) . toEqual ( { clientId : "" , tenantId : "" , allowedGroupIds : "" } ) ;
85+ await expect ( fetchAuthConfig ( ) ) . rejects . toThrow ( "/api/auth/config returned 503 Service Unavailable" ) ;
8386 } ) ;
8487
85- it ( "returns empty config on network error" , async ( ) => {
86- ( global . fetch as jest . Mock ) . mockRejectedValue ( new Error ( "Network error" ) ) ;
88+ it ( "throws on network error (transient failure is not auth-disabled)" , async ( ) => {
89+ const networkError = new Error ( "Network error" ) ;
90+ ( global . fetch as jest . Mock ) . mockRejectedValue ( networkError ) ;
8791
8892 const { fetchAuthConfig } = await import ( "./msalConfig" ) ;
89- const result = await fetchAuthConfig ( ) ;
9093
91- expect ( result ) . toEqual ( { clientId : "" , tenantId : "" , allowedGroupIds : "" } ) ;
94+ await expect ( fetchAuthConfig ( ) ) . rejects . toMatchObject ( {
95+ message : "Failed to reach /api/auth/config: Network error" ,
96+ cause : networkError ,
97+ } ) ;
9298 } ) ;
9399 } ) ;
94100} ) ;
0 commit comments