From 4f7e97371309be0e18919302c2da83c82d6b619b Mon Sep 17 00:00:00 2001 From: alvaro Date: Mon, 6 Oct 2025 13:34:22 +0200 Subject: [PATCH 1/2] Support tag filtering in processes endpoint --- src/api/yepcodeApi.ts | 1 + tests/api/yepcodeApi.test.ts | 39 ++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 tests/api/yepcodeApi.test.ts diff --git a/src/api/yepcodeApi.ts b/src/api/yepcodeApi.ts index 8bdf450..10b2064 100644 --- a/src/api/yepcodeApi.ts +++ b/src/api/yepcodeApi.ts @@ -364,6 +364,7 @@ export class YepCodeApi { async getProcesses( params: { keywords?: string; + tags?: string[]; page?: number; limit?: number; } = {} diff --git a/tests/api/yepcodeApi.test.ts b/tests/api/yepcodeApi.test.ts new file mode 100644 index 0000000..5d1fdc3 --- /dev/null +++ b/tests/api/yepcodeApi.test.ts @@ -0,0 +1,39 @@ +import { YepCodeApi } from "../../src/api/yepcodeApi"; +import { ProcessesPaginatedResult } from "../../src/api/types"; + +const apiHost = process.env.YEPCODE_API_HOST; +const apiToken = process.env.YEPCODE_API_TOKEN; + +let api: YepCodeApi; + +describe("YepCodeApi", () => { + beforeAll(async () => { + api = new YepCodeApi({ apiHost, apiToken }); + }); + + describe("processes", () => { + it("should return a paginated list of processes", async () => { + const result: ProcessesPaginatedResult = await api.getProcesses(); + + expect(result).toHaveProperty("hasNextPage"); + expect(result).toHaveProperty("page"); + expect(result).toHaveProperty("limit"); + expect(result).toHaveProperty("total"); + expect(result).toHaveProperty("data"); + expect(Array.isArray(result.data)).toBe(true); + }); + + it("should return a paginated list of processes with a tag", async () => { + const result: ProcessesPaginatedResult = await api.getProcesses({ + tags: ["yc-run"], + }); + + expect(result).toHaveProperty("hasNextPage"); + expect(result).toHaveProperty("page"); + expect(result).toHaveProperty("limit"); + expect(result).toHaveProperty("total"); + expect(result).toHaveProperty("data"); + expect(Array.isArray(result.data)).toBe(true); + }); + }); +}); From 84bc9d974d5e2c15fff4ed2085461b4a2c72bbb2 Mon Sep 17 00:00:00 2001 From: alvaro Date: Mon, 6 Oct 2025 13:56:49 +0200 Subject: [PATCH 2/2] Simplify yepcodeApi initialization in tests --- tests/api/yepcodeApi.test.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tests/api/yepcodeApi.test.ts b/tests/api/yepcodeApi.test.ts index 5d1fdc3..1a6f3da 100644 --- a/tests/api/yepcodeApi.test.ts +++ b/tests/api/yepcodeApi.test.ts @@ -1,16 +1,9 @@ import { YepCodeApi } from "../../src/api/yepcodeApi"; import { ProcessesPaginatedResult } from "../../src/api/types"; -const apiHost = process.env.YEPCODE_API_HOST; -const apiToken = process.env.YEPCODE_API_TOKEN; - -let api: YepCodeApi; +const api = new YepCodeApi(); describe("YepCodeApi", () => { - beforeAll(async () => { - api = new YepCodeApi({ apiHost, apiToken }); - }); - describe("processes", () => { it("should return a paginated list of processes", async () => { const result: ProcessesPaginatedResult = await api.getProcesses(); @@ -25,7 +18,7 @@ describe("YepCodeApi", () => { it("should return a paginated list of processes with a tag", async () => { const result: ProcessesPaginatedResult = await api.getProcesses({ - tags: ["yc-run"], + tags: ["yc-run", "dummy"], }); expect(result).toHaveProperty("hasNextPage");