diff options
| author | Mohamed Bassem <me@mbassem.com> | 2025-05-24 12:59:43 +0000 |
|---|---|---|
| committer | Mohamed Bassem <me@mbassem.com> | 2025-05-24 12:59:43 +0000 |
| commit | 09652176f97f11bc06f4c9b57a448e14744eac12 (patch) | |
| tree | 5205f65bdef233328a7b4af010667c5b8c25f285 /packages/trpc/routers/users.test.ts | |
| parent | 5f3fe5d1a1ad0abd2890283cbff45086cbfa442e (diff) | |
| download | karakeep-09652176f97f11bc06f4c9b57a448e14744eac12.tar.zst | |
feat: Allow defaulting to reader mode when clicking on bookmarks. Fixes #662
Diffstat (limited to 'packages/trpc/routers/users.test.ts')
| -rw-r--r-- | packages/trpc/routers/users.test.ts | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/packages/trpc/routers/users.test.ts b/packages/trpc/routers/users.test.ts index ea342d33..3d2d164d 100644 --- a/packages/trpc/routers/users.test.ts +++ b/packages/trpc/routers/users.test.ts @@ -94,4 +94,39 @@ describe("User Routes", () => { // A normal user can't list all users await expect(() => user2Caller.users.list()).rejects.toThrow(/FORBIDDEN/); }); + + test<CustomTestContext>("get/update user settings", async ({ + db, + unauthedAPICaller, + }) => { + const user = await unauthedAPICaller.users.create({ + name: "Test User", + email: "testupdate@test.com", + password: "pass1234", + confirmPassword: "pass1234", + }); + const caller = getApiCaller(db, user.id); + + const settings = await caller.users.settings(); + // The default settings + expect(settings).toEqual({ + bookmarkClickAction: "open_original_link", + }); + + // Update settings + await caller.users.updateSettings({ + bookmarkClickAction: "expand_bookmark_preview", + }); + + // Verify updated settings + const updatedSettings = await caller.users.settings(); + expect(updatedSettings).toEqual({ + bookmarkClickAction: "expand_bookmark_preview", + }); + + // Test invalid update (e.g., empty input, if schema enforces it) + await expect(() => caller.users.updateSettings({})).rejects.toThrow( + /No settings provided/, + ); + }); }); |
