@@ -89,13 +89,27 @@ describe.each([
8989 } )
9090 } )
9191
92+ test ( `${ permission } key: Get raw index that exists` , async ( ) => {
93+ await client . createIndex ( indexPk . uid )
94+ await client . getRawIndex ( indexPk . uid ) . then ( ( response ) => {
95+ expect ( response ) . toHaveProperty ( 'uid' , indexPk . uid )
96+ } )
97+ } )
98+
9299 test ( `${ permission } key: Get index that does not exist` , async ( ) => {
93100 await expect ( client . getIndex ( 'does_not_exist' ) ) . rejects . toHaveProperty (
94101 'errorCode' ,
95102 ErrorStatusCode . INDEX_NOT_FOUND
96103 )
97104 } )
98105
106+ test ( `${ permission } key: Get raw index that does not exist` , async ( ) => {
107+ await expect ( client . getRawIndex ( 'does_not_exist' ) ) . rejects . toHaveProperty (
108+ 'errorCode' ,
109+ ErrorStatusCode . INDEX_NOT_FOUND
110+ )
111+ } )
112+
99113 test ( `${ permission } key: Get index info with primary key` , async ( ) => {
100114 const index = await client . createIndex ( indexPk . uid , {
101115 primaryKey : indexPk . primaryKey ,
@@ -106,6 +120,16 @@ describe.each([
106120 } )
107121 } )
108122
123+ test ( `${ permission } key: Get raw index info with primary key` , async ( ) => {
124+ await client . createIndex ( indexPk . uid , {
125+ primaryKey : indexPk . primaryKey ,
126+ } )
127+ await client . getRawIndex ( indexPk . uid ) . then ( ( response : IndexResponse ) => {
128+ expect ( response ) . toHaveProperty ( 'uid' , indexPk . uid )
129+ expect ( response ) . toHaveProperty ( 'primaryKey' , indexPk . primaryKey )
130+ } )
131+ } )
132+
109133 test ( `${ permission } key: Get index info with NO primary key` , async ( ) => {
110134 const index = await client . createIndex ( indexNoPk . uid )
111135 await index . getRawInfo ( ) . then ( ( response : IndexResponse ) => {
@@ -114,6 +138,14 @@ describe.each([
114138 } )
115139 } )
116140
141+ test ( `${ permission } key: Get raw index info with NO primary key` , async ( ) => {
142+ await client . createIndex ( indexNoPk . uid )
143+ await client . getRawIndex ( indexNoPk . uid ) . then ( ( response : IndexResponse ) => {
144+ expect ( response ) . toHaveProperty ( 'uid' , indexNoPk . uid )
145+ expect ( response ) . toHaveProperty ( 'primaryKey' , null )
146+ } )
147+ } )
148+
117149 test ( `${ permission } key: fetch index with primary key` , async ( ) => {
118150 const index = await client . createIndex ( indexPk . uid , {
119151 primaryKey : indexPk . primaryKey ,
@@ -198,6 +230,13 @@ describe.each([
198230 )
199231 } )
200232
233+ test ( `${ permission } key: get deleted raw index should fail` , async ( ) => {
234+ await expect ( client . getRawIndex ( indexNoPk . uid ) ) . rejects . toHaveProperty (
235+ 'errorCode' ,
236+ ErrorStatusCode . INDEX_NOT_FOUND
237+ )
238+ } )
239+
201240 test ( `${ permission } key: delete index with uid that does not exist should fail` , async ( ) => {
202241 const index = client . index ( indexNoPk . uid )
203242 await expect ( index . delete ( ) ) . rejects . toHaveProperty (
@@ -266,6 +305,13 @@ describe.each([{ client: publicClient, permission: 'Public' }])(
266305 ) . rejects . toHaveProperty ( 'errorCode' , ErrorStatusCode . INVALID_TOKEN )
267306 } )
268307
308+ test ( `${ permission } key: try to get raw index and be denied` , async ( ) => {
309+ await expect ( client . getRawIndex ( indexNoPk . uid ) ) . rejects . toHaveProperty (
310+ 'errorCode' ,
311+ ErrorStatusCode . INVALID_TOKEN
312+ )
313+ } )
314+
269315 test ( `${ permission } key: try to delete index and be denied` , async ( ) => {
270316 await expect ( client . index ( indexPk . uid ) . delete ( ) ) . rejects . toHaveProperty (
271317 'errorCode' ,
@@ -311,6 +357,13 @@ describe.each([{ client: anonymousClient, permission: 'No' }])(
311357 )
312358 } )
313359
360+ test ( `${ permission } key: try to get raw index and be denied` , async ( ) => {
361+ await expect ( client . getRawIndex ( indexNoPk . uid ) ) . rejects . toHaveProperty (
362+ 'errorCode' ,
363+ ErrorStatusCode . MISSING_AUTHORIZATION_HEADER
364+ )
365+ } )
366+
314367 test ( `${ permission } key: try to delete index and be denied` , async ( ) => {
315368 await expect ( client . index ( indexPk . uid ) . delete ( ) ) . rejects . toHaveProperty (
316369 'errorCode' ,
@@ -364,6 +417,23 @@ describe.each([
364417 )
365418 } )
366419
420+ test ( `Test getRawIndex route` , async ( ) => {
421+ const route = `indexes/${ indexPk . uid } `
422+ const client = new MeiliSearch ( { host } )
423+ const strippedHost = trailing ? host . slice ( 0 , - 1 ) : host
424+ await expect ( client . getRawIndex ( indexPk . uid ) ) . rejects . toHaveProperty (
425+ 'message' ,
426+ `request to ${ strippedHost } /${ route } failed, reason: connect ECONNREFUSED ${ BAD_HOST . replace (
427+ 'http://' ,
428+ ''
429+ ) } `
430+ )
431+ await expect ( client . getRawIndex ( indexPk . uid ) ) . rejects . toHaveProperty (
432+ 'type' ,
433+ 'MeiliSearchCommunicationError'
434+ )
435+ } )
436+
367437 test ( `Test updateIndex route` , async ( ) => {
368438 const route = `indexes/${ indexPk . uid } `
369439 const client = new MeiliSearch ( { host } )
0 commit comments