@@ -230,6 +230,80 @@ describe('Home integration tests:', () => {
230230 expect ( typeof item . message ) . toBe ( 'string' ) ;
231231 } ) ;
232232 } ) ;
233+
234+ test ( 'should report ok status when config values are properly set' , async ( ) => {
235+ const mailer = ( await import ( '../../../lib/helpers/mailer/index.js' ) ) . default ;
236+ const origDomain = config . domain ;
237+ const origJwt = config . jwt . secret ;
238+ const origOAuth = config . oAuth ;
239+ const origStripe = config . stripe ;
240+ const origPosthog = config . posthog ;
241+ const origSentry = config . sentry ;
242+ const mailerSpy = jest . spyOn ( mailer , 'isConfigured' ) . mockReturnValue ( true ) ;
243+
244+ config . domain = 'example.com' ;
245+ config . jwt . secret = 'a-real-custom-secret-key' ;
246+ config . oAuth = { google : { clientID : 'google-id' } , apple : { clientID : 'apple-id' } } ;
247+ config . stripe = { secretKey : 'sk_test_123' } ;
248+ config . posthog = { apiKey : 'phk_123' } ;
249+ config . sentry = { dsn : 'https://sentry.io/123' } ;
250+
251+ const result = await agent . get ( '/api/admin/readiness' ) . set ( 'Cookie' , `TOKEN=${ adminToken } ` ) . expect ( 200 ) ;
252+ result . body . data . forEach ( ( item ) => {
253+ expect ( item . status ) . toBe ( 'ok' ) ;
254+ } ) ;
255+ // Verify OAuth message includes both providers
256+ const authCheck = result . body . data . find ( ( c ) => c . category === 'auth' ) ;
257+ expect ( authCheck . message ) . toContain ( 'Google' ) ;
258+ expect ( authCheck . message ) . toContain ( 'Apple' ) ;
259+
260+ config . domain = origDomain ;
261+ config . jwt . secret = origJwt ;
262+ config . oAuth = origOAuth ;
263+ config . stripe = origStripe ;
264+ config . posthog = origPosthog ;
265+ config . sentry = origSentry ;
266+ mailerSpy . mockRestore ( ) ;
267+ } ) ;
268+
269+ test ( 'should report warning when JWT secret is the default value' , async ( ) => {
270+ const origJwt = config . jwt . secret ;
271+ config . jwt . secret = 'WaosSecretKeyExampleToChnageAbsolutely' ;
272+ const result = await agent . get ( '/api/admin/readiness' ) . set ( 'Cookie' , `TOKEN=${ adminToken } ` ) . expect ( 200 ) ;
273+ const secCheck = result . body . data . find ( ( c ) => c . category === 'security' ) ;
274+ expect ( secCheck . status ) . toBe ( 'warning' ) ;
275+ expect ( secCheck . message ) . toContain ( 'default' ) ;
276+ config . jwt . secret = origJwt ;
277+ } ) ;
278+
279+ test ( 'should report warning when domain is a DEVKIT placeholder' , async ( ) => {
280+ const origDomain = config . domain ;
281+ config . domain = 'DEVKIT_NODE_DOMAIN' ;
282+ const result = await agent . get ( '/api/admin/readiness' ) . set ( 'Cookie' , `TOKEN=${ adminToken } ` ) . expect ( 200 ) ;
283+ const cfgCheck = result . body . data . find ( ( c ) => c . category === 'config' ) ;
284+ expect ( cfgCheck . status ) . toBe ( 'warning' ) ;
285+ config . domain = origDomain ;
286+ } ) ;
287+
288+ test ( 'should handle only Google OAuth configured' , async ( ) => {
289+ const origOAuth = config . oAuth ;
290+ config . oAuth = { google : { clientID : 'google-id' } , apple : { } } ;
291+ const result = await agent . get ( '/api/admin/readiness' ) . set ( 'Cookie' , `TOKEN=${ adminToken } ` ) . expect ( 200 ) ;
292+ const authCheck = result . body . data . find ( ( c ) => c . category === 'auth' ) ;
293+ expect ( authCheck . status ) . toBe ( 'ok' ) ;
294+ expect ( authCheck . message ) . toContain ( 'Google' ) ;
295+ expect ( authCheck . message ) . not . toContain ( 'Apple' ) ;
296+ config . oAuth = origOAuth ;
297+ } ) ;
298+
299+ test ( 'should return 422 when readiness service throws' , async ( ) => {
300+ jest . spyOn ( HomeService , 'getReadinessStatus' ) . mockImplementationOnce ( ( ) => {
301+ throw new Error ( 'config error' ) ;
302+ } ) ;
303+ const result = await agent . get ( '/api/admin/readiness' ) . set ( 'Cookie' , `TOKEN=${ adminToken } ` ) . expect ( 422 ) ;
304+ expect ( result . body . type ) . toBe ( 'error' ) ;
305+ expect ( result . body . description ) . toBe ( 'config error.' ) ;
306+ } ) ;
233307 } ) ;
234308
235309 describe ( 'Errors' , ( ) => {
0 commit comments