diff --git a/package.json b/package.json index 44f47ed8..67c090e1 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "url": "https://github.com/meilisearch/instant-meilisearch.git" }, "dependencies": { - "meilisearch": "^0.23.0" + "meilisearch": "0.24.0-beta.0" }, "devDependencies": { "@babel/cli": "^7.16.0", diff --git a/tests/configure.attributes-to-retrieve.tests.ts b/tests/configure.attributes-to-retrieve.tests.ts index f17a3403..ef8cec8e 100644 --- a/tests/configure.attributes-to-retrieve.tests.ts +++ b/tests/configure.attributes-to-retrieve.tests.ts @@ -2,16 +2,16 @@ import { searchClient, dataset, Movies } from './assets/utils' describe('Instant MeiliSearch Browser test', () => { beforeAll(async () => { - try { - await searchClient.MeiliSearchClient.deleteIndex('movies') - } catch (e) { - // movies does not exist - } - const moviesUpdate = await searchClient.MeiliSearchClient.index( + const deleteTask = await searchClient.MeiliSearchClient.deleteIndex( + 'movies' + ) + await searchClient.MeiliSearchClient.waitForTask(deleteTask.uid) + + const documentsTask = await searchClient.MeiliSearchClient.index( 'movies' ).addDocuments(dataset) - await searchClient.MeiliSearchClient.index('movies').waitForPendingUpdate( - moviesUpdate.updateId + await searchClient.MeiliSearchClient.index('movies').waitForTask( + documentsTask.uid ) }) @@ -43,18 +43,14 @@ describe('Instant MeiliSearch Browser test', () => { }, }, ]) - const notRetrieved = [ - 'id', - 'overview', - 'genres', - 'poster', - 'release_date', - 'title', - ] + const hit = response.results[0].hits[0] - notRetrieved.map((attribute: string) => - expect(hit[attribute]).not.toBeDefined() - ) + expect(hit.id).not.toBeDefined() + expect(hit.overview).not.toBeDefined() + expect(hit.genres).not.toBeDefined() + expect(hit.poster).not.toBeDefined() + expect(hit.release_date).not.toBeDefined() + expect(hit.title).not.toBeDefined() }) test('Test attributesToRetrieve on one non existing attribute', async () => { @@ -67,20 +63,15 @@ describe('Instant MeiliSearch Browser test', () => { }, }, ]) - const notRetrieved = [ - 'id', - 'overview', - 'genres', - 'poster', - 'release_date', - 'title', - ] + const hit = response.results[0].hits[0] - notRetrieved.map( - (attribute: string) => - hit._highlightResult && - expect(hit._highlightResult[attribute]).toBeDefined() - ) + + expect(hit._highlightResult?.id).toBeDefined() + expect(hit._highlightResult?.overview).toBeDefined() + expect(hit._highlightResult?.genres).toBeDefined() + expect(hit._highlightResult?.poster).toBeDefined() + expect(hit._highlightResult?.release_date).toBeDefined() + expect(hit._highlightResult?.title).toBeDefined() }) test('Test attributesToRetrieve on one existing attribute', async () => { @@ -93,12 +84,14 @@ describe('Instant MeiliSearch Browser test', () => { }, }, ]) - const notRetrieved = ['id', 'overview', 'genres', 'poster', 'release_date'] const hit = response.results[0].hits[0] expect(hit.title).toEqual('Ariel') - notRetrieved.map((attribute: string) => - expect(hit[attribute]).not.toBeDefined() - ) + expect(hit.id).not.toBeDefined() + expect(hit.overview).not.toBeDefined() + expect(hit.genres).not.toBeDefined() + expect(hit.poster).not.toBeDefined() + expect(hit.release_date).not.toBeDefined() + expect(hit.title).toBeDefined() }) test('Test attributesToRetrieve on default value', async () => { @@ -110,18 +103,24 @@ describe('Instant MeiliSearch Browser test', () => { }, }, ]) - const notRetrieved = ['id', 'overview', 'genres', 'poster', 'release_date'] + const hit = response.results[0].hits[0] expect(hit.title).toEqual('Ariel') expect(hit._highlightResult).toBeDefined() - notRetrieved.map((attribute: string) => - expect(hit[attribute]).toBeDefined() - ) - notRetrieved.map( - (attribute: string) => - hit._highlightResult && - expect(hit._highlightResult[attribute]).toBeDefined() - ) + + expect(hit.id).toBeDefined() + expect(hit.overview).toBeDefined() + expect(hit.genres).toBeDefined() + expect(hit.poster).toBeDefined() + expect(hit.release_date).toBeDefined() + expect(hit.title).toBeDefined() + + expect(hit._highlightResult?.id).toBeDefined() + expect(hit._highlightResult?.overview).toBeDefined() + expect(hit._highlightResult?.genres).toBeDefined() + expect(hit._highlightResult?.poster).toBeDefined() + expect(hit._highlightResult?.release_date).toBeDefined() + expect(hit._highlightResult?.title).toBeDefined() }) test('Test attributesToRetrieve on wild card', async () => { @@ -134,21 +133,14 @@ describe('Instant MeiliSearch Browser test', () => { }, }, ]) - const retrieved = [ - 'id', - 'overview', - 'genres', - 'poster', - 'release_date', - 'title', - ] + const hit = response.results[0].hits[0] expect(hit.title).toEqual('Ariel') - retrieved.map((attribute: string) => expect(hit[attribute]).toBeDefined()) - retrieved.map( - (attribute: string) => - hit._highlightResult && - expect(hit._highlightResult[attribute]).toBeDefined() - ) + expect(hit._highlightResult?.id).toBeDefined() + expect(hit._highlightResult?.overview).toBeDefined() + expect(hit._highlightResult?.genres).toBeDefined() + expect(hit._highlightResult?.poster).toBeDefined() + expect(hit._highlightResult?.release_date).toBeDefined() + expect(hit._highlightResult?.title).toBeDefined() }) }) diff --git a/tests/facets-distribution.tests.ts b/tests/facets-distribution.tests.ts index 7e3c5025..3a68cdd3 100644 --- a/tests/facets-distribution.tests.ts +++ b/tests/facets-distribution.tests.ts @@ -2,19 +2,18 @@ import { searchClient, dataset } from './assets/utils' describe('Instant MeiliSearch Browser test', () => { beforeAll(async () => { - try { - await searchClient.MeiliSearchClient.deleteIndex('movies') - } catch (e) { - // movies does not exist - } + const deleteTask = await searchClient.MeiliSearchClient.deleteIndex( + 'movies' + ) + await searchClient.MeiliSearchClient.waitForTask(deleteTask.uid) await searchClient.MeiliSearchClient.index( 'movies' ).updateFilterableAttributes(['genres']) - const moviesUpdate = await searchClient.MeiliSearchClient.index( + const documentsTask = await searchClient.MeiliSearchClient.index( 'movies' ).addDocuments(dataset) - await searchClient.MeiliSearchClient.index('movies').waitForPendingUpdate( - moviesUpdate.updateId + await searchClient.MeiliSearchClient.index('movies').waitForTask( + documentsTask.uid ) }) diff --git a/tests/filter.tests.ts b/tests/filter.tests.ts index 8ba08315..d7851788 100644 --- a/tests/filter.tests.ts +++ b/tests/filter.tests.ts @@ -2,19 +2,18 @@ import { searchClient, dataset, Movies } from './assets/utils' describe('Instant MeiliSearch Browser test', () => { beforeAll(async () => { - try { - await searchClient.MeiliSearchClient.deleteIndex('movies') - } catch (e) { - // movies does not exist - } + const deleteTask = await searchClient.MeiliSearchClient.deleteIndex( + 'movies' + ) + await searchClient.MeiliSearchClient.waitForTask(deleteTask.uid) await searchClient.MeiliSearchClient.index( 'movies' ).updateFilterableAttributes(['genres', 'title']) - const moviesUpdate = await searchClient.MeiliSearchClient.index( + const documentsTask = await searchClient.MeiliSearchClient.index( 'movies' ).addDocuments(dataset) - await searchClient.MeiliSearchClient.index('movies').waitForPendingUpdate( - moviesUpdate.updateId + await searchClient.MeiliSearchClient.index('movies').waitForTask( + documentsTask.uid ) }) diff --git a/tests/geosearch.tests.ts b/tests/geosearch.tests.ts index 43452e50..a97f7bb8 100644 --- a/tests/geosearch.tests.ts +++ b/tests/geosearch.tests.ts @@ -2,22 +2,21 @@ import { searchClient, geoDataset, City } from './assets/utils' describe('Instant MeiliSearch Browser test', () => { beforeAll(async () => { - try { - await searchClient.MeiliSearchClient.deleteIndex('geotest') - } catch (e) { - // geotest does not exist - } + const deleteTask = await searchClient.MeiliSearchClient.deleteIndex( + 'geotest' + ) + await searchClient.MeiliSearchClient.waitForTask(deleteTask.uid) await searchClient.MeiliSearchClient.index( 'geotest' ).updateFilterableAttributes(['_geo']) await searchClient.MeiliSearchClient.index( 'geotest' ).updateSortableAttributes(['_geo']) - const geotestUpdate = await searchClient.MeiliSearchClient.index( + const documentsTask = await searchClient.MeiliSearchClient.index( 'geotest' ).addDocuments(geoDataset) - await searchClient.MeiliSearchClient.index('geotest').waitForPendingUpdate( - geotestUpdate.updateId + await searchClient.MeiliSearchClient.index('movies').waitForTask( + documentsTask.uid ) }) diff --git a/tests/highlight.tests.ts b/tests/highlight.tests.ts index 5c2aae86..5c40fe52 100644 --- a/tests/highlight.tests.ts +++ b/tests/highlight.tests.ts @@ -2,23 +2,18 @@ import { searchClient, dataset, Movies } from './assets/utils' describe('Highlight Browser test', () => { beforeAll(async () => { - try { - await searchClient.MeiliSearchClient.deleteIndex('movies') - } catch (e) { - // movies does not exist - } - const moviesUpdate = await searchClient.MeiliSearchClient.index( - 'movies' - ).addDocuments(dataset) - const settingsUpdate = await searchClient.MeiliSearchClient.index( + const deleteTask = await searchClient.MeiliSearchClient.deleteIndex( 'movies' - ).updateFilterableAttributes(['genres']) // if settings update is put before document addition relevancy is impacted - - await searchClient.MeiliSearchClient.index('movies').waitForPendingUpdate( - moviesUpdate.updateId ) - await searchClient.MeiliSearchClient.index('movies').waitForPendingUpdate( - settingsUpdate.updateId + await searchClient.MeiliSearchClient.waitForTask(deleteTask.uid) + await searchClient.MeiliSearchClient.index( + 'movies' + ).updateFilterableAttributes(['genres']) + const documentsTask = await searchClient.MeiliSearchClient.index( + 'movies' + ).addDocuments(dataset) + await searchClient.MeiliSearchClient.index('movies').waitForTask( + documentsTask.uid ) }) diff --git a/tests/pagination.tests.ts b/tests/pagination.tests.ts index 6f3be88d..1af45871 100644 --- a/tests/pagination.tests.ts +++ b/tests/pagination.tests.ts @@ -3,19 +3,18 @@ import { searchClient, dataset, Movies } from './assets/utils' describe('Pagination browser test', () => { beforeAll(async () => { - try { - await searchClient.MeiliSearchClient.deleteIndex('movies') - } catch (e) { - // movies does not exist - } + const deleteTask = await searchClient.MeiliSearchClient.deleteIndex( + 'movies' + ) + await searchClient.MeiliSearchClient.waitForTask(deleteTask.uid) await searchClient.MeiliSearchClient.index( 'movies' ).updateFilterableAttributes(['genres']) - const moviesUpdate = await searchClient.MeiliSearchClient.index( + const documentsTask = await searchClient.MeiliSearchClient.index( 'movies' ).addDocuments(dataset) - await searchClient.MeiliSearchClient.index('movies').waitForPendingUpdate( - moviesUpdate.updateId + await searchClient.MeiliSearchClient.index('movies').waitForTask( + documentsTask.uid ) }) diff --git a/tests/snippets.tests.ts b/tests/snippets.tests.ts index 9a3ef7df..bb44ffa2 100644 --- a/tests/snippets.tests.ts +++ b/tests/snippets.tests.ts @@ -2,19 +2,18 @@ import { searchClient, dataset, Movies } from './assets/utils' describe('Snippet Browser test', () => { beforeAll(async () => { - try { - await searchClient.MeiliSearchClient.deleteIndex('movies') - } catch (e) { - // movies does not exist - } + const deleteTask = await searchClient.MeiliSearchClient.deleteIndex( + 'movies' + ) + await searchClient.MeiliSearchClient.waitForTask(deleteTask.uid) await searchClient.MeiliSearchClient.index( 'movies' ).updateFilterableAttributes(['genres']) - const moviesUpdate = await searchClient.MeiliSearchClient.index( + const documentsTask = await searchClient.MeiliSearchClient.index( 'movies' ).addDocuments(dataset) - await searchClient.MeiliSearchClient.index('movies').waitForPendingUpdate( - moviesUpdate.updateId + await searchClient.MeiliSearchClient.index('movies').waitForTask( + documentsTask.uid ) }) diff --git a/yarn.lock b/yarn.lock index 464add61..3ab421b9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5067,10 +5067,10 @@ mdn-data@2.0.4: resolved "https://registry.yarnpkg.com/mdn-data/-/mdn-data-2.0.4.tgz#699b3c38ac6f1d728091a64650b65d388502fd5b" integrity sha512-iV3XNKw06j5Q7mi6h+9vbx23Tv7JkjEVgKHW4pimwyDGWm0OIQntJJ+u1C6mg6mK1EaTv42XQ7w76yuzH7M2cA== -meilisearch@^0.23.0: - version "0.23.0" - resolved "https://registry.yarnpkg.com/meilisearch/-/meilisearch-0.23.0.tgz#eed5098bd147c13658c3f92e658df9cbfb9e8953" - integrity sha512-bLNonPJK2pJz2akjwolcc/Eqnz/GKJ7y1I4Flg4zjL+v0yPFyIGFFdfe0dw93JWFJWj/RbLS2Q6dDTobZQ9Ehg== +meilisearch@0.24.0-beta.0: + version "0.24.0-beta.0" + resolved "https://registry.yarnpkg.com/meilisearch/-/meilisearch-0.24.0-beta.0.tgz#ebbc7c59fe7152c4dc0e9e3002a906f1e7c4a89e" + integrity sha512-dQDyTPs1e8Zf+LmGv7gEfWPNuv1+3OeFjRCVqSkUsTFEApD2zZtOPstXYSIgksqxyt9XTe38CCQO0m4DVVrP3A== dependencies: cross-fetch "^3.1.4"