aboutsummaryrefslogtreecommitdiffstats
path: root/packages/e2e_tests
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2026-01-18 21:38:21 +0000
committerGitHub <noreply@github.com>2026-01-18 21:38:21 +0000
commite09061bd37c6496685ea0fdabe1d4d01f1b659ad (patch)
tree2896ccceb54e7af8dc006d4bdc89b18af42ca078 /packages/e2e_tests
parentedf3f681a77ce6739ca0773af6e5a645e2c91ee9 (diff)
downloadkarakeep-e09061bd37c6496685ea0fdabe1d4d01f1b659ad.tar.zst
feat: Add attachedBy field to update tags endpoint (#2281)
* feat: Add attachedBy field to updateTags endpoint This change allows callers to specify the attachedBy field when updating tags on a bookmark. The field defaults to "human" if not provided, maintaining backward compatibility with existing code. Changes: - Added attachedBy field to zManipulatedTagSchema with default "human" - Updated updateTags endpoint to use the specified attachedBy value - Created mapping logic to correctly assign attachedBy to each tag * fix(cli): migrate bookmark source in migration command * fix * reduce queries --------- Co-authored-by: Claude <noreply@anthropic.com>
Diffstat (limited to 'packages/e2e_tests')
-rw-r--r--packages/e2e_tests/tests/api/bookmarks.test.ts70
1 files changed, 70 insertions, 0 deletions
diff --git a/packages/e2e_tests/tests/api/bookmarks.test.ts b/packages/e2e_tests/tests/api/bookmarks.test.ts
index a6bc85e3..7c14ee61 100644
--- a/packages/e2e_tests/tests/api/bookmarks.test.ts
+++ b/packages/e2e_tests/tests/api/bookmarks.test.ts
@@ -289,6 +289,76 @@ describe("Bookmarks API", () => {
expect(removeTagsRes.status).toBe(200);
});
+ it("should manage tags with attachedBy field", async () => {
+ // Create a new bookmark
+ const { data: createdBookmark, error: createError } = await client.POST(
+ "/bookmarks",
+ {
+ body: {
+ type: "text",
+ title: "Test Bookmark for attachedBy",
+ text: "Testing attachedBy field",
+ },
+ },
+ );
+
+ if (createError) {
+ console.error("Error creating bookmark:", createError);
+ throw createError;
+ }
+ if (!createdBookmark) {
+ throw new Error("Bookmark creation failed");
+ }
+
+ // Add tags with different attachedBy values
+ const { data: addTagsResponse, response: addTagsRes } = await client.POST(
+ "/bookmarks/{bookmarkId}/tags",
+ {
+ params: {
+ path: {
+ bookmarkId: createdBookmark.id,
+ },
+ },
+ body: {
+ tags: [
+ { tagName: "ai-tag", attachedBy: "ai" },
+ { tagName: "human-tag", attachedBy: "human" },
+ { tagName: "default-tag" }, // Should default to "human"
+ ],
+ },
+ },
+ );
+
+ expect(addTagsRes.status).toBe(200);
+ expect(addTagsResponse!.attached.length).toBe(3);
+
+ // Get the bookmark and verify the attachedBy values
+ const { data: retrievedBookmark } = await client.GET(
+ "/bookmarks/{bookmarkId}",
+ {
+ params: {
+ path: {
+ bookmarkId: createdBookmark.id,
+ },
+ },
+ },
+ );
+
+ expect(retrievedBookmark!.tags.length).toBe(3);
+
+ const aiTag = retrievedBookmark!.tags.find((t) => t.name === "ai-tag");
+ const humanTag = retrievedBookmark!.tags.find(
+ (t) => t.name === "human-tag",
+ );
+ const defaultTag = retrievedBookmark!.tags.find(
+ (t) => t.name === "default-tag",
+ );
+
+ expect(aiTag?.attachedBy).toBe("ai");
+ expect(humanTag?.attachedBy).toBe("human");
+ expect(defaultTag?.attachedBy).toBe("human");
+ });
+
it("should get lists for a bookmark", async () => {
const { data: createdBookmark } = await client.POST("/bookmarks", {
body: {