aboutsummaryrefslogtreecommitdiffstats
path: root/packages/trpc/lib/__tests__
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2025-04-27 17:40:41 +0000
committerMohamed Bassem <me@mbassem.com>2025-04-27 17:40:41 +0000
commit6178736d64180f9bc8954099c90d54aa2f9f35f5 (patch)
tree02c86e88010d22592258f621f1d2a6b498caeae2 /packages/trpc/lib/__tests__
parent28ca9d5f451b34c6221e9127eaf1d61841fa886c (diff)
downloadkarakeep-6178736d64180f9bc8954099c90d54aa2f9f35f5.tar.zst
fix: Fix smart lists not working in list search qualifiers. Fixes #845
Diffstat (limited to 'packages/trpc/lib/__tests__')
-rw-r--r--packages/trpc/lib/__tests__/search.test.ts69
1 files changed, 69 insertions, 0 deletions
diff --git a/packages/trpc/lib/__tests__/search.test.ts b/packages/trpc/lib/__tests__/search.test.ts
index 9d9b39d7..72b53368 100644
--- a/packages/trpc/lib/__tests__/search.test.ts
+++ b/packages/trpc/lib/__tests__/search.test.ts
@@ -34,6 +34,12 @@ beforeEach(async () => {
email: "test@example.com",
role: "user",
},
+ {
+ id: "another-user",
+ name: "Another User",
+ email: "another@example.com",
+ role: "user",
+ },
]);
// Setup test data
@@ -86,6 +92,14 @@ beforeEach(async () => {
favourited: false,
createdAt: new Date("2024-01-06"),
},
+ {
+ id: "b7",
+ type: BookmarkTypes.ASSET,
+ userId: "another-user",
+ archived: true,
+ favourited: false,
+ createdAt: new Date("2024-01-06"),
+ },
]);
await db.insert(bookmarkLinks).values([
@@ -143,6 +157,21 @@ beforeEach(async () => {
type: "manual",
},
{ id: "l4", userId: testUserId, name: "work", icon: "💼", type: "manual" },
+ {
+ id: "l5",
+ userId: testUserId,
+ name: "smartlist",
+ icon: "🧠",
+ type: "smart",
+ query: "#tag1 or #tag2",
+ },
+ {
+ id: "l6",
+ userId: testUserId,
+ name: "emptylist",
+ icon: "∅",
+ type: "manual",
+ },
]);
await db.insert(bookmarksInLists).values([
@@ -224,6 +253,26 @@ describe("getBookmarkIdsFromMatcher", () => {
expect(result).toEqual(["b1", "b6"]);
});
+ it("should handle listName matcher with smartList", async () => {
+ const matcher: Matcher = {
+ type: "listName",
+ listName: "smartlist",
+ inverse: false,
+ };
+ const result = await getBookmarkIdsFromMatcher(mockCtx, matcher);
+ expect(result).toEqual(["b1", "b2"]);
+ });
+
+ it("should handle listName matcher with empty list", async () => {
+ const matcher: Matcher = {
+ type: "listName",
+ listName: "emptylist",
+ inverse: false,
+ };
+ const result = await getBookmarkIdsFromMatcher(mockCtx, matcher);
+ expect(result).toEqual([]);
+ });
+
it("should handle listName matcher with inverse=true", async () => {
const matcher: Matcher = {
type: "listName",
@@ -234,6 +283,26 @@ describe("getBookmarkIdsFromMatcher", () => {
expect(result.sort()).toEqual(["b2", "b3", "b4", "b5"]);
});
+ it("should handle listName matcher with smartList with inverse=true", async () => {
+ const matcher: Matcher = {
+ type: "listName",
+ listName: "smartlist",
+ inverse: true,
+ };
+ const result = await getBookmarkIdsFromMatcher(mockCtx, matcher);
+ expect(result).toEqual(["b3", "b4", "b5", "b6"]);
+ });
+
+ it("should handle listName matcher with empty list with inverse=true", async () => {
+ const matcher: Matcher = {
+ type: "listName",
+ listName: "emptylist",
+ inverse: true,
+ };
+ const result = await getBookmarkIdsFromMatcher(mockCtx, matcher);
+ expect(result).toEqual(["b1", "b2", "b3", "b4", "b5", "b6"]);
+ });
+
it("should handle archived matcher", async () => {
const matcher: Matcher = { type: "archived", archived: true };
const result = await getBookmarkIdsFromMatcher(mockCtx, matcher);