Skip to content

Commit 66f7923

Browse files
committed
Add mixed types filterable attribute test
1 parent 54b2cc9 commit 66f7923

File tree

3 files changed

+49
-10
lines changed

3 files changed

+49
-10
lines changed

src/types/types.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,7 @@ type GranularFilterableAttribute = {
511511
};
512512

513513
export type FilterableAttributes =
514-
| string[]
515-
| GranularFilterableAttribute[]
514+
| (string | GranularFilterableAttribute)[]
516515
| null;
517516
export type DistinctAttribute = string | null;
518517
export type SearchableAttributes = string[] | null;

tests/filterable_attributes.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ describe.each([{ permission: "Master" }, { permission: "Admin" }])(
5656
test(`${permission} key: Update attributes with granular attribute syntax`, async () => {
5757
const client = await getClient(permission);
5858
const newFilterableAttributes = [
59+
"author",
5960
{
6061
attributePatterns: ["genre"],
6162
features: {

tests/utils/meilisearch-test-utils.ts

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,24 +185,63 @@ const datasetWithNests = [
185185
{ id: 7, title: "The Hitchhiker's Guide to the Galaxy" },
186186
];
187187

188-
const dataset: { id: number; title: string; comment?: string }[] = [
189-
{ id: 123, title: "Pride and Prejudice", comment: "A great book" },
190-
{ id: 456, title: "Le Petit Prince", comment: "A french book" },
191-
{ id: 2, title: "Le Rouge et le Noir", comment: "Another french book" },
192-
{ id: 1, title: "Alice In Wonderland", comment: "A weird book" },
193-
{ id: 1344, title: "The Hobbit", comment: "An awesome book" },
188+
const dataset: Book[] = [
189+
{
190+
id: 123,
191+
title: "Pride and Prejudice",
192+
comment: "A great book",
193+
genre: ["romance", "classic", "literary fiction"],
194+
author: "Jane Austen",
195+
},
196+
{
197+
id: 456,
198+
title: "Le Petit Prince",
199+
comment: "A french book",
200+
genre: ["children", "fantasy", "philosophical"],
201+
author: "Antoine de Saint-Exupéry",
202+
},
203+
{
204+
id: 2,
205+
title: "Le Rouge et le Noir",
206+
comment: "Another french book",
207+
genre: ["classic", "psychological", "historical fiction"],
208+
author: "Stendhal",
209+
},
210+
{
211+
id: 1,
212+
title: "Alice In Wonderland",
213+
comment: "A weird book",
214+
genre: ["fantasy", "children", "classics"],
215+
author: "Lewis Carroll",
216+
},
217+
{
218+
id: 1344,
219+
title: "The Hobbit",
220+
comment: "An awesome book",
221+
genre: ["fantasy", "adventure", "young adult"],
222+
author: "J.R.R. Tolkien",
223+
},
194224
{
195225
id: 4,
196226
title: "Harry Potter and the Half-Blood Prince",
197227
comment: "The best book",
228+
genre: ["fantasy", "young adult", "magic"],
229+
author: "J.K. Rowling",
230+
},
231+
{
232+
id: 42,
233+
title: "The Hitchhiker's Guide to the Galaxy",
234+
genre: ["science fiction", "comedy", "satire"],
235+
author: "Douglas Adams",
198236
},
199-
{ id: 42, title: "The Hitchhiker's Guide to the Galaxy" },
200237
];
201238

202239
export type Book = {
203240
id: number;
204241
title: string;
205-
comment: string;
242+
comment?: string;
243+
genre: string[];
244+
author: string;
206245
};
207246

208247
export {

0 commit comments

Comments
 (0)