@@ -245,10 +245,24 @@ describe.each([
245245 } )
246246 describe ( 'Test on base routes' , ( ) => {
247247 test ( `${ permission } key: get health` , async ( ) => {
248+ await client . health ( ) . then ( ( response : Types . Health ) => {
249+ expect ( response ) . toHaveProperty (
250+ 'status' ,
251+ expect . stringMatching ( 'available' )
252+ )
253+ } )
254+ } )
255+ test ( `${ permission } key: is server healthy` , async ( ) => {
248256 await client . isHealthy ( ) . then ( ( response : boolean ) => {
249257 expect ( response ) . toBe ( true )
250258 } )
251259 } )
260+ test ( `${ permission } key: is healthy return false on bad host` , async ( ) => {
261+ const client = new MeiliSearch ( { host : 'http://localhost:9345' } )
262+ await client . isHealthy ( ) . then ( ( response : boolean ) => {
263+ expect ( response ) . toBe ( false )
264+ } )
265+ } )
252266 test ( `${ permission } key: get version` , async ( ) => {
253267 await client . version ( ) . then ( ( response : Types . Version ) => {
254268 expect ( response ) . toHaveProperty ( 'commitSha' , expect . any ( String ) )
@@ -263,11 +277,19 @@ describe.each([
263277 expect ( response ) . toHaveProperty ( 'indexes' , expect . any ( Object ) )
264278 } )
265279 } )
280+ test ( `${ permission } key: bad host raise CommunicationError on health route` , async ( ) => {
281+ const client = new MeiliSearch ( { host : 'http://localhost:9345' } )
282+ try {
283+ await client . health ( )
284+ } catch ( e ) {
285+ expect ( e . type ) . toEqual ( 'MeiliSearchCommunicationError' )
286+ }
287+ } )
266288 } )
267289} )
268290
269291describe . each ( [ { client : publicClient , permission : 'Public' } ] ) (
270- 'Test on routes where public key should not have access ' ,
292+ 'Test on routes with public key' ,
271293 ( { client, permission } ) => {
272294 describe ( 'Test on indexes' , ( ) => {
273295 test ( `${ permission } key: try to get all indexes and be denied` , async ( ) => {
@@ -322,6 +344,14 @@ describe.each([{ client: publicClient, permission: 'Public' }])(
322344 } )
323345 } )
324346 describe ( 'Test on base routes' , ( ) => {
347+ test ( `${ permission } key: get health` , async ( ) => {
348+ await client . health ( ) . then ( ( response : Types . Health ) => {
349+ expect ( response ) . toHaveProperty (
350+ 'status' ,
351+ expect . stringMatching ( 'available' )
352+ )
353+ } )
354+ } )
325355 test ( `${ permission } key: try to get version and be denied` , async ( ) => {
326356 await expect ( client . version ( ) ) . rejects . toHaveProperty (
327357 'errorCode' ,
@@ -339,7 +369,7 @@ describe.each([{ client: publicClient, permission: 'Public' }])(
339369)
340370
341371describe . each ( [ { client : anonymousClient , permission : 'No' } ] ) (
342- 'Test on routes where client without api key should not have access ' ,
372+ 'Test on routes without an API key ' ,
343373 ( { client, permission } ) => {
344374 describe ( 'Test on indexes' , ( ) => {
345375 test ( `${ permission } key: try to get all indexes and be denied` , async ( ) => {
@@ -394,6 +424,14 @@ describe.each([{ client: anonymousClient, permission: 'No' }])(
394424 } )
395425 } )
396426 describe ( 'Test on base routes' , ( ) => {
427+ test ( `${ permission } key: get health` , async ( ) => {
428+ await client . health ( ) . then ( ( response : Types . Health ) => {
429+ expect ( response ) . toHaveProperty (
430+ 'status' ,
431+ expect . stringMatching ( 'available' )
432+ )
433+ } )
434+ } )
397435 test ( `${ permission } key: try to get version and be denied` , async ( ) => {
398436 await expect ( client . version ( ) ) . rejects . toHaveProperty (
399437 'errorCode' ,
0 commit comments