⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
test: add integration coverage for labels, tasks, and openapi
Tine2d7da3695a1
diff --git a/tests/api-integration/label.test.ts b/tests/api-integration/label.test.tsindex 1d94f916d..657af90fa 100644--- a/tests/api-integration/label.test.ts+++ b/tests/api-integration/label.test.ts@@ -69,4 +69,45 @@ describe("API integration: labels", () => {color: "#ef4444",});});++ it("rejects label creation for users outside the workspace", async () => {+ const member = await createWorkspaceMember();+ const outsiderId = "user-label-outsider";++ const [outsider] = await db+ .insert(schema.userTable)+ .values({+ id: outsiderId,+ email: `${outsiderId}@example.com`,+ emailVerified: true,+ name: "Label Outsider",+ })+ .returning();++ mockAuthenticatedSession(outsider);+ const { app } = createApp();++ const response = await app.request("/api/label", {+ method: "POST",+ headers: {+ "content-type": "application/json",+ },+ body: JSON.stringify({+ name: "Blocked",+ color: "#6b7280",+ workspaceId: member.workspace.id,+ }),+ });++ expect(response.status).toBe(403);+ await expect(response.text()).resolves.toBe(+ "You don't have access to this workspace",+ );++ const persisted = await db.query.labelTable.findFirst({+ where: eq(schema.labelTable.name, "Blocked"),+ });++ expect(persisted).toBeUndefined();+ });});diff --git a/tests/api-integration/openapi.test.ts b/tests/api-integration/openapi.test.tsnew file mode 100644index 000000000..479c5560e--- /dev/null+++ b/tests/api-integration/openapi.test.ts@@ -0,0 +1,30 @@+import { describe, expect, it } from "vitest";+import { createApp } from "../../apps/api/src/index";++describe("API integration: openapi", () => {+ it("serves a merged OpenAPI document", async () => {+ const { app } = createApp();++ const response = await app.request("/api/openapi");++ expect(response.status).toBe(200);+ const payload = (await response.json()) as {+ openapi: string;+ info?: { title?: string };+ paths?: Record<string, unknown>;+ components?: {+ securitySchemes?: Record<string, unknown>;+ };+ };++ expect(payload.openapi).toBe("3.0.3");+ expect(payload.info?.title).toBe("Kaneo API");+ expect(payload.paths?.["/config"]).toBeTruthy();+ expect(+ Object.keys(payload.paths || {}).some((path) => path.startsWith("/auth/")),+ ).toBe(true);+ expect(payload.components?.securitySchemes).toMatchObject({+ bearerAuth: expect.any(Object),+ });+ });+});diff --git a/tests/api-integration/task.test.ts b/tests/api-integration/task.test.tsindex d7534285f..8e7367669 100644--- a/tests/api-integration/task.test.ts+++ b/tests/api-integration/task.test.ts@@ -168,4 +168,112 @@ describe("API integration: task creation", () => {expect(persistedTask).toBeUndefined();});++ it("creates an unassigned task with parsed dates when optional fields are provided", async () => {+ const member = await createWorkspaceMember();+ const { project, columns } = await createProjectFixture({+ workspaceId: member.workspace.id,+ });++ mockAuthenticatedSession(member.user);+ const { app } = createApp();++ const response = await app.request(`/api/task/${project.id}`, {+ method: "POST",+ headers: {+ "content-type": "application/json",+ },+ body: JSON.stringify({+ title: "Plan release cut",+ description: "Track optional fields too",+ priority: "medium",+ status: "in-progress",+ startDate: "2026-04-01T09:00:00.000Z",+ dueDate: "2026-04-05T17:00:00.000Z",+ }),+ });++ expect(response.status).toBe(200);+ const payload = (await response.json()) as {+ id: string;+ userId: string | null;+ columnId: string | null;+ startDate: string | null;+ dueDate: string | null;+ assigneeName?: string;+ };++ expect(payload).toMatchObject({+ userId: null,+ columnId: columns.inProgress.id,+ startDate: "2026-04-01T09:00:00.000Z",+ dueDate: "2026-04-05T17:00:00.000Z",+ });+ expect(payload.assigneeName).toBeUndefined();++ const persistedTask = await db.query.taskTable.findFirst({+ where: eq(schema.taskTable.id, payload.id),+ });++ expect(persistedTask).toMatchObject({+ id: payload.id,+ userId: null,+ columnId: columns.inProgress.id,+ status: "in-progress",+ });+ expect(persistedTask?.startDate?.toISOString()).toBe(+ "2026-04-01T09:00:00.000Z",+ );+ expect(persistedTask?.dueDate?.toISOString()).toBe(+ "2026-04-05T17:00:00.000Z",+ );+ });++ it("creates tasks without a column when the status has no matching project column", async () => {+ const member = await createWorkspaceMember();+ const { project } = await createProjectFixture({+ workspaceId: member.workspace.id,+ });++ mockAuthenticatedSession(member.user);+ const { app } = createApp();++ const response = await app.request(`/api/task/${project.id}`, {+ method: "POST",+ headers: {+ "content-type": "application/json",+ },+ body: JSON.stringify({+ title: "Future status task",+ description: "Status does not map to a seeded column",+ priority: "low",+ status: "planned",+ }),+ });++ expect(response.status).toBe(200);+ const payload = (await response.json()) as {+ id: string;+ status: string;+ columnId: string | null;+ position: number | null;+ };++ expect(payload).toMatchObject({+ status: "planned",+ columnId: null,+ position: 1,+ });++ const persistedTask = await db.query.taskTable.findFirst({+ where: eq(schema.taskTable.id, payload.id),+ });++ expect(persistedTask).toMatchObject({+ id: payload.id,+ status: "planned",+ columnId: null,+ position: 1,+ });+ });});