Skip to content

Commit 3c9c438

Browse files
committed
Merge with main
2 parents 6e4318f + 77505c0 commit 3c9c438

File tree

3 files changed

+55
-44
lines changed

3 files changed

+55
-44
lines changed

tests/documents.test.ts

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -680,17 +680,13 @@ describe("Documents tests", () => {
680680
test(`${permission} key: test updateDocumentsByFunction`, async () => {
681681
const client = await getClient(permission);
682682
const index = client.index<(typeof dataset)[number]>(indexPk.uid);
683-
const adminKey = await getKey("Admin");
684683

685684
await index.updateFilterableAttributes(["id"]).waitTask();
686685

687-
await fetch(`${HOST}/experimental-features`, {
688-
body: JSON.stringify({ editDocumentsByFunction: true }),
689-
headers: {
690-
Authorization: `Bearer ${adminKey}`,
691-
"Content-Type": "application/json",
692-
},
693-
method: "PATCH",
686+
await (
687+
await getClient("Master")
688+
).updateExperimentalFeatures({
689+
editDocumentsByFunction: true,
694690
});
695691

696692
await index.addDocuments(dataset).waitTask();
@@ -761,15 +757,11 @@ describe("Documents tests", () => {
761757

762758
test(`${permission} key: Try updateDocumentsByFunction and be denied`, async () => {
763759
const client = await getClient(permission);
764-
const adminKey = await getKey("Admin");
765760

766-
await fetch(`${HOST}/experimental-features`, {
767-
body: JSON.stringify({ editDocumentsByFunction: true }),
768-
headers: {
769-
Authorization: `Bearer ${adminKey}`,
770-
"Content-Type": "application/json",
771-
},
772-
method: "PATCH",
761+
await (
762+
await getClient("Master")
763+
).updateExperimentalFeatures({
764+
editDocumentsByFunction: true,
773765
});
774766

775767
await expect(
@@ -848,15 +840,11 @@ describe("Documents tests", () => {
848840

849841
test(`${permission} key: Try updateDocumentsByFunction and be denied`, async () => {
850842
const client = await getClient(permission);
851-
const adminKey = await getKey("Admin");
852843

853-
await fetch(`${HOST}/experimental-features`, {
854-
body: JSON.stringify({ editDocumentsByFunction: true }),
855-
headers: {
856-
Authorization: `Bearer ${adminKey}`,
857-
"Content-Type": "application/json",
858-
},
859-
method: "PATCH",
844+
await (
845+
await getClient("Master")
846+
).updateExperimentalFeatures({
847+
editDocumentsByFunction: true,
860848
});
861849

862850
await expect(
@@ -962,15 +950,11 @@ describe("Documents tests", () => {
962950
const route = `indexes/${indexPk.uid}/documents/edit`;
963951
const client = new MeiliSearch({ host });
964952
const strippedHost = trailing ? host.slice(0, -1) : host;
965-
const adminKey = await getKey("Admin");
966-
967-
await fetch(`${HOST}/experimental-features`, {
968-
body: JSON.stringify({ editDocumentsByFunction: true }),
969-
headers: {
970-
Authorization: `Bearer ${adminKey}`,
971-
"Content-Type": "application/json",
972-
},
973-
method: "PATCH",
953+
954+
await (
955+
await getClient("Master")
956+
).updateExperimentalFeatures({
957+
editDocumentsByFunction: true,
974958
});
975959

976960
await expect(

tests/embedders.test.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import {
66
BAD_HOST,
77
MeiliSearch,
88
getClient,
9-
getKey,
10-
HOST,
9+
masterClient,
1110
} from "./utils/meilisearch-test-utils.js";
1211

1312
const index = {
@@ -206,16 +205,9 @@ describe.each([{ permission: "Master" }, { permission: "Admin" }])(
206205
});
207206

208207
test(`${permission} key: Update embedders with composite embedder`, async () => {
209-
const adminKey = await getKey("Admin");
210-
211208
// first enable the network endpoint.
212-
await fetch(`${HOST}/experimental-features`, {
213-
body: JSON.stringify({ compositeEmbedders: true }),
214-
headers: {
215-
Authorization: `Bearer ${adminKey}`,
216-
"Content-Type": "application/json",
217-
},
218-
method: "PATCH",
209+
await masterClient.updateExperimentalFeatures({
210+
compositeEmbedders: true,
219211
});
220212

221213
const client = await getClient(permission);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { afterAll, test } from "vitest";
2+
import { assert, getClient } from "./utils/meilisearch-test-utils.js";
3+
import type { RuntimeTogglableFeatures } from "../src/index.js";
4+
5+
const ms = await getClient("Master");
6+
7+
afterAll(async () => {
8+
await ms.updateExperimentalFeatures({
9+
metrics: false,
10+
logsRoute: false,
11+
editDocumentsByFunction: false,
12+
containsFilter: false,
13+
network: false,
14+
getTaskDocumentsRoute: false,
15+
compositeEmbedders: false,
16+
} satisfies { [TKey in keyof RuntimeTogglableFeatures]-?: false });
17+
});
18+
19+
test(`${ms.updateExperimentalFeatures.name} and ${ms.getExperimentalFeatures.name} methods`, async () => {
20+
const features: { [TKey in keyof RuntimeTogglableFeatures]-?: true } = {
21+
metrics: true,
22+
logsRoute: true,
23+
editDocumentsByFunction: true,
24+
containsFilter: true,
25+
network: true,
26+
getTaskDocumentsRoute: true,
27+
compositeEmbedders: true,
28+
};
29+
30+
const updateFeatures = await ms.updateExperimentalFeatures(features);
31+
assert.deepEqual(updateFeatures, features);
32+
33+
const getFeatures = await ms.getExperimentalFeatures();
34+
assert.deepEqual(getFeatures, features);
35+
});

0 commit comments

Comments
 (0)