diff options
| author | Mohamed Bassem <me@mbassem.com> | 2025-11-08 19:40:52 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-08 19:40:52 +0000 |
| commit | c4bee9fe61cc9832eddf0092bc014dff6f4b8cb6 (patch) | |
| tree | ff48f24e4921597fc9130c812575a9691ed600a5 /packages/e2e_tests/tests/api/bookmarks.test.ts | |
| parent | 098e56a8950efbef79e551e12622ae7c8cd90c03 (diff) | |
| download | karakeep-c4bee9fe61cc9832eddf0092bc014dff6f4b8cb6.tar.zst | |
tests: fix crawling and search e2e tests (#2105)
* tests: Attempt to fix flaky tests
* fix internal address
* fix assets tests
Diffstat (limited to 'packages/e2e_tests/tests/api/bookmarks.test.ts')
| -rw-r--r-- | packages/e2e_tests/tests/api/bookmarks.test.ts | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/packages/e2e_tests/tests/api/bookmarks.test.ts b/packages/e2e_tests/tests/api/bookmarks.test.ts index e1cfc8d5..a6bc85e3 100644 --- a/packages/e2e_tests/tests/api/bookmarks.test.ts +++ b/packages/e2e_tests/tests/api/bookmarks.test.ts @@ -3,6 +3,7 @@ import { assert, beforeEach, describe, expect, inject, it } from "vitest"; import { createKarakeepClient } from "@karakeep/sdk"; import { createTestUser } from "../../utils/api"; +import { waitUntil } from "../../utils/general"; describe("Bookmarks API", () => { const port = inject("karakeepPort"); @@ -353,9 +354,22 @@ describe("Bookmarks API", () => { }, }); - // Wait 3 seconds for the search index to be updated - // TODO: Replace with a check that all queues are empty - await new Promise((f) => setTimeout(f, 3000)); + await waitUntil(async () => { + const { data, response, error } = await client.GET("/bookmarks/search", { + params: { + query: { + q: "test bookmark", + }, + }, + }); + if (error) { + throw error; + } + if (response.status !== 200) { + throw new Error(`Search request failed with status ${response.status}`); + } + return (data?.bookmarks.length ?? 0) >= 2; + }, 'Search index contains the new bookmarks for query "test bookmark"'); // Search for bookmarks const { data: searchResults, response: searchResponse } = await client.GET( @@ -387,9 +401,23 @@ describe("Bookmarks API", () => { await Promise.all(bookmarkPromises); - // Wait 3 seconds for the search index to be updated - // TODO: Replace with a check that all queues are empty - await new Promise((f) => setTimeout(f, 3000)); + await waitUntil(async () => { + const { data, response, error } = await client.GET("/bookmarks/search", { + params: { + query: { + q: "pagination", + limit: 5, + }, + }, + }); + if (error) { + throw error; + } + if (response.status !== 200) { + throw new Error(`Search request failed with status ${response.status}`); + } + return (data?.bookmarks.length ?? 0) >= 5; + }, "Search index contains the pagination test bookmarks"); // Get first page const { data: firstPage, response: firstResponse } = await client.GET( |
