diff --git a/eslint.config.js b/eslint.config.js index 37e17297c..c1072689b 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -63,13 +63,7 @@ module.exports = [ { files: ["tests/*.ts"], plugins: { vitest }, - rules: { - ...vitest.configs.recommended.rules, - // @TODO: Remove all of these rules and adapt code! - "vitest/expect-expect": "off", - "vitest/valid-title": "off", - "vitest/valid-expect": "off", - }, + rules: vitest.configs.recommended.rules, }, prettier, ]; diff --git a/tests/client.test.ts b/tests/client.test.ts index e522c0813..09693d124 100644 --- a/tests/client.test.ts +++ b/tests/client.test.ts @@ -724,7 +724,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getIndex route`, async () => { + test(`getIndex route`, async () => { const route = `indexes/${indexPk.uid}`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -734,7 +734,7 @@ describe.each([ ); }); - test(`Test createIndex route`, async () => { + test(`createIndex route`, async () => { const route = `indexes`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -744,7 +744,7 @@ describe.each([ ); }); - test(`Test updateIndex route`, async () => { + test(`updateIndex route`, async () => { const route = `indexes/${indexPk.uid}`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -754,7 +754,7 @@ describe.each([ ); }); - test(`Test deleteIndex route`, async () => { + test(`deleteIndex route`, async () => { const route = `indexes/${indexPk.uid}`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -764,7 +764,7 @@ describe.each([ ); }); - test(`Test get indexes route`, async () => { + test(`get indexes route`, async () => { const route = `indexes`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -774,7 +774,7 @@ describe.each([ ); }); - test(`Test getKeys route`, async () => { + test(`getKeys route`, async () => { const route = `keys`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -784,7 +784,7 @@ describe.each([ ); }); - test(`Test health route`, async () => { + test(`health route`, async () => { const route = `health`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -794,7 +794,7 @@ describe.each([ ); }); - test(`Test stats route`, async () => { + test(`stats route`, async () => { const route = `stats`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -804,7 +804,7 @@ describe.each([ ); }); - test(`Test version route`, async () => { + test(`version route`, async () => { const route = `version`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/dictionary.test.ts b/tests/dictionary.test.ts index 5c352347a..1215eedba 100644 --- a/tests/dictionary.test.ts +++ b/tests/dictionary.test.ts @@ -78,7 +78,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getDictionary route`, async () => { + test(`getDictionary route`, async () => { const route = `indexes/${index.uid}/settings/dictionary`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -90,7 +90,7 @@ describe.each([ ); }); - test(`Test updateDictionary route`, async () => { + test(`updateDictionary route`, async () => { const route = `indexes/${index.uid}/settings/dictionary`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -102,7 +102,7 @@ describe.each([ ); }); - test(`Test resetDictionary route`, async () => { + test(`resetDictionary route`, async () => { const route = `indexes/${index.uid}/settings/dictionary`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/displayed_attributes.test.ts b/tests/displayed_attributes.test.ts index 2939e1732..6837f320d 100644 --- a/tests/displayed_attributes.test.ts +++ b/tests/displayed_attributes.test.ts @@ -153,7 +153,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getDisplayedAttributes route`, async () => { + test(`getDisplayedAttributes route`, async () => { const route = `indexes/${index.uid}/settings/displayed-attributes`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -165,7 +165,7 @@ describe.each([ ); }); - test(`Test updateDisplayedAttributes route`, async () => { + test(`updateDisplayedAttributes route`, async () => { const route = `indexes/${index.uid}/settings/displayed-attributes`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -177,7 +177,7 @@ describe.each([ ); }); - test(`Test resetDisplayedAttributes route`, async () => { + test(`resetDisplayedAttributes route`, async () => { const route = `indexes/${index.uid}/settings/displayed-attributes`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/distinct_attribute.test.ts b/tests/distinct_attribute.test.ts index c64a076c0..911fbc10d 100644 --- a/tests/distinct_attribute.test.ts +++ b/tests/distinct_attribute.test.ts @@ -143,7 +143,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getDistinctAttribute route`, async () => { + test(`getDistinctAttribute route`, async () => { const route = `indexes/${index.uid}/settings/distinct-attribute`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -155,7 +155,7 @@ describe.each([ ); }); - test(`Test updateDistinctAttribute route`, async () => { + test(`updateDistinctAttribute route`, async () => { const route = `indexes/${index.uid}/settings/distinct-attribute`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -167,7 +167,7 @@ describe.each([ ); }); - test(`Test resetDistinctAttribute route`, async () => { + test(`resetDistinctAttribute route`, async () => { const route = `indexes/${index.uid}/settings/distinct-attribute`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/documents.test.ts b/tests/documents.test.ts index 8ebb8ed1a..61f44d033 100644 --- a/tests/documents.test.ts +++ b/tests/documents.test.ts @@ -987,7 +987,7 @@ Hint: It might not be working because maybe you're not up to date with the Meili { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getDocument route`, async () => { + test(`getDocument route`, async () => { const route = `indexes/${indexPk.uid}/documents/1`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -999,7 +999,7 @@ Hint: It might not be working because maybe you're not up to date with the Meili ); }); - test(`Test getDocuments route`, async () => { + test(`getDocuments route`, async () => { const route = `indexes/${indexPk.uid}/documents`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -1011,7 +1011,7 @@ Hint: It might not be working because maybe you're not up to date with the Meili ); }); - test(`Test addDocuments route`, async () => { + test(`addDocuments route`, async () => { const route = `indexes/${indexPk.uid}/documents`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -1023,7 +1023,7 @@ Hint: It might not be working because maybe you're not up to date with the Meili ); }); - test(`Test updateDocuments route`, async () => { + test(`updateDocuments route`, async () => { const route = `indexes/${indexPk.uid}/documents`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -1035,7 +1035,7 @@ Hint: It might not be working because maybe you're not up to date with the Meili ); }); - test(`Test deleteDocument route`, async () => { + test(`deleteDocument route`, async () => { const route = `indexes/${indexPk.uid}/documents/1`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -1047,7 +1047,7 @@ Hint: It might not be working because maybe you're not up to date with the Meili ); }); - test(`Test deleteDocuments route`, async () => { + test(`deleteDocuments route`, async () => { const route = `indexes/${indexPk.uid}/documents/delete-batch`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -1059,7 +1059,7 @@ Hint: It might not be working because maybe you're not up to date with the Meili ); }); - test(`Test deleteAllDocuments route`, async () => { + test(`deleteAllDocuments route`, async () => { const route = `indexes/${indexPk.uid}/documents`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -1071,7 +1071,7 @@ Hint: It might not be working because maybe you're not up to date with the Meili ); }); - test(`Test updateDocumentsByFunction route`, async () => { + test(`updateDocumentsByFunction route`, async () => { const route = `indexes/${indexPk.uid}/documents/edit`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/dump.test.ts b/tests/dump.test.ts index 442b5581b..0a3acd677 100644 --- a/tests/dump.test.ts +++ b/tests/dump.test.ts @@ -1,5 +1,5 @@ import { expect, test, describe, beforeEach } from "vitest"; -import { ErrorStatusCode } from "../src/types"; +import { ErrorStatusCode, TaskStatus } from "../src/types"; import { clearAllIndexes, config, @@ -13,13 +13,15 @@ beforeEach(async () => { }); describe.each([{ permission: "Master" }, { permission: "Admin" }])( - "Test on dump", + "Test on dump should succeed with right permission", ({ permission }) => { test(`${permission} key: create a new dump`, async () => { const client = await getClient(permission); const { taskUid } = await client.createDump(); - await client.waitForTask(taskUid); + const taskResult = await client.waitForTask(taskUid); + + expect(taskResult).toHaveProperty("status", TaskStatus.TASK_SUCCEEDED); }); }, ); @@ -55,7 +57,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test createDump route`, async () => { + test(`createDump route`, async () => { const route = `dumps`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/embedders.test.ts b/tests/embedders.test.ts index 3bbffe265..8258d097a 100644 --- a/tests/embedders.test.ts +++ b/tests/embedders.test.ts @@ -305,7 +305,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getEmbedders route`, async () => { + test(`getEmbedders route`, async () => { const route = `indexes/${index.uid}/settings/embedders`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -315,7 +315,7 @@ describe.each([ ); }); - test(`Test updateEmbedders route`, async () => { + test(`updateEmbedders route`, async () => { const route = `indexes/${index.uid}/settings/embedders`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -327,7 +327,7 @@ describe.each([ ); }); - test(`Test resetEmbedders route`, async () => { + test(`resetEmbedders route`, async () => { const route = `indexes/${index.uid}/settings/embedders`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/faceting.test.ts b/tests/faceting.test.ts index dc5da490a..4e17b7ba0 100644 --- a/tests/faceting.test.ts +++ b/tests/faceting.test.ts @@ -167,7 +167,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getFaceting route`, async () => { + test(`getFaceting route`, async () => { const route = `indexes/${index.uid}/settings/faceting`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -177,7 +177,7 @@ describe.each([ ); }); - test(`Test updateFaceting route`, async () => { + test(`updateFaceting route`, async () => { const route = `indexes/${index.uid}/settings/faceting`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -189,7 +189,7 @@ describe.each([ ); }); - test(`Test resetFaceting route`, async () => { + test(`resetFaceting route`, async () => { const route = `indexes/${index.uid}/settings/faceting`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/filterable_attributes.test.ts b/tests/filterable_attributes.test.ts index d0fbcab09..c396ad31c 100644 --- a/tests/filterable_attributes.test.ts +++ b/tests/filterable_attributes.test.ts @@ -155,7 +155,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getFilterableAttributes route`, async () => { + test(`getFilterableAttributes route`, async () => { const route = `indexes/${index.uid}/settings/filterable-attributes`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -167,7 +167,7 @@ describe.each([ ); }); - test(`Test updateFilterableAttributes route`, async () => { + test(`updateFilterableAttributes route`, async () => { const route = `indexes/${index.uid}/settings/filterable-attributes`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -179,7 +179,7 @@ describe.each([ ); }); - test(`Test resetFilterableAttributes route`, async () => { + test(`resetFilterableAttributes route`, async () => { const route = `indexes/${index.uid}/settings/filterable-attributes`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/get_search.test.ts b/tests/get_search.test.ts index f5834c355..df5bab371 100644 --- a/tests/get_search.test.ts +++ b/tests/get_search.test.ts @@ -590,7 +590,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test get search route`, async () => { + test(`get search route`, async () => { const route = `indexes/${index.uid}/search`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -600,7 +600,7 @@ describe.each([ ); }); - test(`Test post search route`, async () => { + test(`post search route`, async () => { const route = `indexes/${index.uid}/search`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/index.test.ts b/tests/index.test.ts index fdcac2cb0..2bfce281c 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -501,7 +501,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getStats route`, async () => { + test(`getStats route`, async () => { const route = `indexes/${indexPk.uid}/stats`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -511,7 +511,7 @@ describe.each([ ); }); - test(`Test getRawInfo route`, async () => { + test(`getRawInfo route`, async () => { const route = `indexes/${indexPk.uid}`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -525,7 +525,7 @@ describe.each([ ); }); - test(`Test getRawIndex route`, async () => { + test(`getRawIndex route`, async () => { const route = `indexes/${indexPk.uid}`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -539,7 +539,7 @@ describe.each([ ); }); - test(`Test updateIndex route`, async () => { + test(`updateIndex route`, async () => { const route = `indexes/${indexPk.uid}`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -549,7 +549,7 @@ describe.each([ ); }); - test(`Test delete index route`, async () => { + test(`delete index route`, async () => { const route = `indexes/${indexPk.uid}`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/localized_attributes.test.ts b/tests/localized_attributes.test.ts index b55ca3809..8b41f4fd2 100644 --- a/tests/localized_attributes.test.ts +++ b/tests/localized_attributes.test.ts @@ -180,7 +180,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getLocalizedAttributes route`, async () => { + test(`getLocalizedAttributes route`, async () => { const route = `indexes/${index.uid}/settings/localized-attributes`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -192,7 +192,7 @@ describe.each([ ); }); - test(`Test updateLocalizedAttributes route`, async () => { + test(`updateLocalizedAttributes route`, async () => { const route = `indexes/${index.uid}/settings/localized-attributes`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -204,7 +204,7 @@ describe.each([ ); }); - test(`Test resetLocalizedAttributes route`, async () => { + test(`resetLocalizedAttributes route`, async () => { const route = `indexes/${index.uid}/settings/localized-attributes`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/non_separator_tokens.test.ts b/tests/non_separator_tokens.test.ts index 6d601b336..d726075c1 100644 --- a/tests/non_separator_tokens.test.ts +++ b/tests/non_separator_tokens.test.ts @@ -86,7 +86,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getNonSeparatorTokens route`, async () => { + test(`getNonSeparatorTokens route`, async () => { const route = `indexes/${index.uid}/settings/non-separator-tokens`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -98,7 +98,7 @@ describe.each([ ); }); - test(`Test updateNonSeparatorTokens route`, async () => { + test(`updateNonSeparatorTokens route`, async () => { const route = `indexes/${index.uid}/settings/non-separator-tokens`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -110,7 +110,7 @@ describe.each([ ); }); - test(`Test resetNonSeparatorTokens route`, async () => { + test(`resetNonSeparatorTokens route`, async () => { const route = `indexes/${index.uid}/settings/non-separator-tokens`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/pagination.test.ts b/tests/pagination.test.ts index 877520237..e84a43037 100644 --- a/tests/pagination.test.ts +++ b/tests/pagination.test.ts @@ -168,7 +168,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getPagination route`, async () => { + test(`getPagination route`, async () => { const route = `indexes/${index.uid}/settings/pagination`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -180,7 +180,7 @@ describe.each([ ); }); - test(`Test updatePagination route`, async () => { + test(`updatePagination route`, async () => { const route = `indexes/${index.uid}/settings/pagination`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -192,7 +192,7 @@ describe.each([ ); }); - test(`Test resetPagination route`, async () => { + test(`resetPagination route`, async () => { const route = `indexes/${index.uid}/settings/pagination`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/proximity_precision.test.ts b/tests/proximity_precision.test.ts index 7f8ef1a99..c1b49fb29 100644 --- a/tests/proximity_precision.test.ts +++ b/tests/proximity_precision.test.ts @@ -86,7 +86,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getProximityPrecision route`, async () => { + test(`getProximityPrecision route`, async () => { const route = `indexes/${index.uid}/settings/proximity-precision`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -98,7 +98,7 @@ describe.each([ ); }); - test(`Test updateProximityPrecision route`, async () => { + test(`updateProximityPrecision route`, async () => { const route = `indexes/${index.uid}/settings/proximity-precision`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -110,7 +110,7 @@ describe.each([ ); }); - test(`Test resetProximityPrecision route`, async () => { + test(`resetProximityPrecision route`, async () => { const route = `indexes/${index.uid}/settings/proximity-precision`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/ranking_rules.test.ts b/tests/ranking_rules.test.ts index ef9d10073..fa500bba6 100644 --- a/tests/ranking_rules.test.ts +++ b/tests/ranking_rules.test.ts @@ -164,7 +164,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getRankingRules route`, async () => { + test(`getRankingRules route`, async () => { const route = `indexes/${index.uid}/settings/ranking-rules`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -176,7 +176,7 @@ describe.each([ ); }); - test(`Test updateRankingRules route`, async () => { + test(`updateRankingRules route`, async () => { const route = `indexes/${index.uid}/settings/ranking-rules`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -188,7 +188,7 @@ describe.each([ ); }); - test(`Test resetRankingRules route`, async () => { + test(`resetRankingRules route`, async () => { const route = `indexes/${index.uid}/settings/ranking-rules`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/search.test.ts b/tests/search.test.ts index f4cf6658b..7bbc7c573 100644 --- a/tests/search.test.ts +++ b/tests/search.test.ts @@ -1280,7 +1280,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test get search route`, async () => { + test(`get search route`, async () => { const route = `indexes/${index.uid}/search`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -1290,7 +1290,7 @@ describe.each([ ); }); - test(`Test post search route`, async () => { + test(`post search route`, async () => { const route = `indexes/${index.uid}/search`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/search_cutoff_ms.test.ts b/tests/search_cutoff_ms.test.ts index ae6037012..36abbfc44 100644 --- a/tests/search_cutoff_ms.test.ts +++ b/tests/search_cutoff_ms.test.ts @@ -176,7 +176,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getSearchCutoffMs route`, async () => { + test(`getSearchCutoffMs route`, async () => { const route = `indexes/${index.uid}/settings/search-cutoff-ms`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -188,7 +188,7 @@ describe.each([ ); }); - test(`Test updateSearchCutoffMs route`, async () => { + test(`updateSearchCutoffMs route`, async () => { const route = `indexes/${index.uid}/settings/search-cutoff-ms`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -200,7 +200,7 @@ describe.each([ ); }); - test(`Test resetSearchCutoffMs route`, async () => { + test(`resetSearchCutoffMs route`, async () => { const route = `indexes/${index.uid}/settings/search-cutoff-ms`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/searchable_attributes.test.ts b/tests/searchable_attributes.test.ts index 5efec0761..34bf97cbf 100644 --- a/tests/searchable_attributes.test.ts +++ b/tests/searchable_attributes.test.ts @@ -164,7 +164,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getSearchableAttributes route`, async () => { + test(`getSearchableAttributes route`, async () => { const route = `indexes/${index.uid}/settings/searchable-attributes`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -176,7 +176,7 @@ describe.each([ ); }); - test(`Test updateSearchableAttributes route`, async () => { + test(`updateSearchableAttributes route`, async () => { const route = `indexes/${index.uid}/settings/searchable-attributes`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -188,7 +188,7 @@ describe.each([ ); }); - test(`Test resetSearchableAttributes route`, async () => { + test(`resetSearchableAttributes route`, async () => { const route = `indexes/${index.uid}/settings/searchable-attributes`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/separator_tokens.test.ts b/tests/separator_tokens.test.ts index 3588a5dde..bf484f644 100644 --- a/tests/separator_tokens.test.ts +++ b/tests/separator_tokens.test.ts @@ -86,7 +86,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getSeparatorTokens route`, async () => { + test(`getSeparatorTokens route`, async () => { const route = `indexes/${index.uid}/settings/separator-tokens`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -98,7 +98,7 @@ describe.each([ ); }); - test(`Test updateSeparatorTokens route`, async () => { + test(`updateSeparatorTokens route`, async () => { const route = `indexes/${index.uid}/settings/separator-tokens`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -110,7 +110,7 @@ describe.each([ ); }); - test(`Test resetSeparatorTokens route`, async () => { + test(`resetSeparatorTokens route`, async () => { const route = `indexes/${index.uid}/settings/separator-tokens`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/settings.test.ts b/tests/settings.test.ts index 387850d4c..f3a96192c 100644 --- a/tests/settings.test.ts +++ b/tests/settings.test.ts @@ -334,7 +334,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getSettings route`, async () => { + test(`getSettings route`, async () => { const route = `indexes/${index.uid}/settings`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -344,7 +344,7 @@ describe.each([ ); }); - test(`Test updateSettings route`, async () => { + test(`updateSettings route`, async () => { const route = `indexes/${index.uid}/settings`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -356,7 +356,7 @@ describe.each([ ); }); - test(`Test resetSettings route`, async () => { + test(`resetSettings route`, async () => { const route = `indexes/${index.uid}/settings`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/snapshots.test.ts b/tests/snapshots.test.ts index f9029f000..f50e20737 100644 --- a/tests/snapshots.test.ts +++ b/tests/snapshots.test.ts @@ -1,5 +1,5 @@ import { beforeEach, describe, expect, test } from "vitest"; -import { ErrorStatusCode } from "../src/types"; +import { ErrorStatusCode, TaskStatus } from "../src/types"; import { clearAllIndexes, config, @@ -13,13 +13,15 @@ beforeEach(async () => { }); describe.each([{ permission: "Master" }, { permission: "Admin" }])( - "Test on snapshot", + "Test on snapshot should succeed with right permission", ({ permission }) => { test(`${permission} key: create a new snapshot`, async () => { const client = await getClient(permission); const { taskUid } = await client.createSnapshot(); - await client.waitForTask(taskUid); + const taskResult = await client.waitForTask(taskUid); + + expect(taskResult).toHaveProperty("status", TaskStatus.TASK_SUCCEEDED); }); }, ); @@ -55,7 +57,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test createSnapshot route`, async () => { + test(`createSnapshot route`, async () => { const route = `snapshots`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/sortable_attributes.test.ts b/tests/sortable_attributes.test.ts index 29f31aafb..59ba1ae08 100644 --- a/tests/sortable_attributes.test.ts +++ b/tests/sortable_attributes.test.ts @@ -159,7 +159,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getSortableAttributes route`, async () => { + test(`getSortableAttributes route`, async () => { const route = `indexes/${index.uid}/settings/sortable-attributes`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -171,7 +171,7 @@ describe.each([ ); }); - test(`Test updateSortableAttributes route`, async () => { + test(`updateSortableAttributes route`, async () => { const route = `indexes/${index.uid}/settings/sortable-attributes`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -183,7 +183,7 @@ describe.each([ ); }); - test(`Test resetSortableAttributes route`, async () => { + test(`resetSortableAttributes route`, async () => { const route = `indexes/${index.uid}/settings/sortable-attributes`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/stop_words.test.ts b/tests/stop_words.test.ts index 0980a836a..62d53ade5 100644 --- a/tests/stop_words.test.ts +++ b/tests/stop_words.test.ts @@ -146,7 +146,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getStopWords route`, async () => { + test(`getStopWords route`, async () => { const route = `indexes/${index.uid}/settings/stop-words`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -156,7 +156,7 @@ describe.each([ ); }); - test(`Test updateStopWords route`, async () => { + test(`updateStopWords route`, async () => { const route = `indexes/${index.uid}/settings/stop-words`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -168,7 +168,7 @@ describe.each([ ); }); - test(`Test resetStopWords route`, async () => { + test(`resetStopWords route`, async () => { const route = `indexes/${index.uid}/settings/stop-words`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/synonyms.test.ts b/tests/synonyms.test.ts index 110439e67..09fe4e70e 100644 --- a/tests/synonyms.test.ts +++ b/tests/synonyms.test.ts @@ -138,7 +138,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test getSynonyms route`, async () => { + test(`getSynonyms route`, async () => { const route = `indexes/${index.uid}/settings/synonyms`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -148,7 +148,7 @@ describe.each([ ); }); - test(`Test updateSynonyms route`, async () => { + test(`updateSynonyms route`, async () => { const route = `indexes/${index.uid}/settings/synonyms`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -160,7 +160,7 @@ describe.each([ ); }); - test(`Test resetSynonyms route`, async () => { + test(`resetSynonyms route`, async () => { const route = `indexes/${index.uid}/settings/synonyms`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/task.test.ts b/tests/task.test.ts index d36fa677b..18968f5e4 100644 --- a/tests/task.test.ts +++ b/tests/task.test.ts @@ -817,7 +817,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on task url construction", ({ host, trailing }) => { - test(`Test on getTask route`, async () => { + test(`on getTask route`, async () => { const route = `tasks/1`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -828,7 +828,7 @@ describe.each([ ); }); - test(`Test on getTasks route`, async () => { + test(`on getTasks route`, async () => { const route = `tasks?indexUids=movies_test`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/token.test.ts b/tests/token.test.ts index 12f2bef99..3dd10fc44 100644 --- a/tests/token.test.ts +++ b/tests/token.test.ts @@ -125,7 +125,9 @@ describe.each([{ permission: "Admin" }])( const searchClient = new MeiliSearch({ host: HOST, apiKey: token }); // search - expect(searchClient.index(UID).search()).resolves.not.toBeUndefined(); + await expect( + searchClient.index(UID).search(), + ).resolves.not.toBeUndefined(); }); test(`${permission} key: Search in tenant token with custom api key`, async () => { @@ -144,7 +146,7 @@ describe.each([{ permission: "Admin" }])( const searchClient = new MeiliSearch({ host: HOST, apiKey: token }); // search - expect(searchClient.index(UID).search()).resolves.toBeDefined(); + await expect(searchClient.index(UID).search()).resolves.toBeDefined(); }); test(`${permission} key: Search in tenant token with expireAt`, async () => { @@ -162,7 +164,9 @@ describe.each([{ permission: "Admin" }])( expect(JSON.parse(decode64(payload)).exp).toEqual( Math.floor(date.getTime() / 1000), ); - expect(searchClient.index(UID).search()).resolves.not.toBeUndefined(); + await expect( + searchClient.index(UID).search(), + ).resolves.not.toBeUndefined(); }); test(`${permission} key: Search in tenant token with expireAt value set in the past`, async () => { @@ -171,7 +175,7 @@ describe.each([{ permission: "Admin" }])( const { uid } = await client.getKey(apiKey); const date = new Date("December 17, 2000 03:24:00"); - expect( + await expect( client.generateTenantToken(uid, ["*"], { expiresAt: date }), ).rejects.toThrow( `Meilisearch: The expiresAt field must be a date in the future.`, @@ -189,7 +193,9 @@ describe.each([{ permission: "Admin" }])( const searchClient = new MeiliSearch({ host: HOST, apiKey: token }); // search - expect(searchClient.index(UID).search()).resolves.not.toBeUndefined(); + await expect( + searchClient.index(UID).search(), + ).resolves.not.toBeUndefined(); }); test(`${permission} key: Search in tenant token with specific index and specific rules`, async () => { @@ -209,7 +215,9 @@ describe.each([{ permission: "Admin" }])( const searchClient = new MeiliSearch({ host: HOST, apiKey: token }); // search - expect(searchClient.index(UID).search()).resolves.not.toBeUndefined(); + await expect( + searchClient.index(UID).search(), + ).resolves.not.toBeUndefined(); }); test(`${permission} key: Search in tenant token with empty array throws an error`, async () => { @@ -246,7 +254,7 @@ describe.each([{ permission: "Admin" }])( const { uid } = await client.getKey(apiKey); const date = new Date("December 17, 2000 03:24:00"); - expect( + await expect( client.generateTenantToken( uid, {}, @@ -262,15 +270,15 @@ describe.each([{ permission: "Admin" }])( test(`${permission} key: Creates tenant token with wrong uid type throws an error`, async () => { const client = await getClient(permission); - expect(client.generateTenantToken("1234", ["*"])).rejects.toThrow( + await expect(client.generateTenantToken("1234", ["*"])).rejects.toThrow( `Meilisearch: The uid of your key is not a valid uuid4. To find out the uid of your key use getKey().`, ); }); - test(`${permission} key: Creates a tenant token with no api key in client and in parameters throws an error`, () => { + test(`${permission} key: Creates a tenant token with no api key in client and in parameters throws an error`, async () => { const client = new MeiliSearch({ host: HOST }); - expect(client.generateTenantToken("123", [])).rejects.toThrow( + await expect(client.generateTenantToken("123", [])).rejects.toThrow( `Meilisearch: The API key used for the token generation must exist and be of type string.`, ); }); diff --git a/tests/typed_search.test.ts b/tests/typed_search.test.ts index 0036c7413..e7d0dbf8f 100644 --- a/tests/typed_search.test.ts +++ b/tests/typed_search.test.ts @@ -478,7 +478,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test get search route`, async () => { + test(`get search route`, async () => { const route = `indexes/${index.uid}/search`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -490,7 +490,7 @@ describe.each([ ); }); - test(`Test post search route`, async () => { + test(`post search route`, async () => { const route = `indexes/${index.uid}/search`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; diff --git a/tests/typo_tolerance.test.ts b/tests/typo_tolerance.test.ts index f05943033..80ef4ca15 100644 --- a/tests/typo_tolerance.test.ts +++ b/tests/typo_tolerance.test.ts @@ -160,7 +160,7 @@ describe.each([ { host: `${BAD_HOST}/api`, trailing: false }, { host: `${BAD_HOST}/trailing/`, trailing: true }, ])("Tests on url construction", ({ host, trailing }) => { - test(`Test get typo tolerance route`, async () => { + test(`get typo tolerance route`, async () => { const route = `indexes/${index.uid}/settings/typo-tolerance`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -172,7 +172,7 @@ describe.each([ ); }); - test(`Test update typo tolerance route`, async () => { + test(`update typo tolerance route`, async () => { const route = `indexes/${index.uid}/settings/typo-tolerance`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host; @@ -184,7 +184,7 @@ describe.each([ ); }); - test(`Test reset typo tolerance route`, async () => { + test(`reset typo tolerance route`, async () => { const route = `indexes/${index.uid}/settings/typo-tolerance`; const client = new MeiliSearch({ host }); const strippedHost = trailing ? host.slice(0, -1) : host;