Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

chore: merge main to resolve comment markdown conflicts

Tina5ffdd7e9344
diff --cc tests/api-integration/comment.test.ts
index 928f51fa0,60f1926c5..46a9b3e6c
--- a/tests/api-integration/comment.test.ts
+++ b/tests/api-integration/comment.test.ts
@@@ -97,129 -95,8 +97,129 @@@ describe("API integration: task comment
expect(legacyComments).toHaveLength(0);
});
+ it.each([
+ { length: 10_000, status: 200 },
+ { length: 10_001, status: 400 },
+ ])(
+ "returns $status when creating a $length-character comment",
+ async ({ length, status }) => {
+ const member = await createWorkspaceMember();
+ const { project, columns } = await createProjectFixture({
+ workspaceId: member.workspace.id,
+ });
+ const [task] = await db
+ .insert(schema.taskTable)
+ .values({
+ projectId: project.id,
+ title: "Comment length limit",
+ status: "to-do",
+ columnId: columns.todo.id,
+ priority: "medium",
+ number: 1,
+ position: 1,
+ })
+ .returning();
+
+ mockAuthenticatedSession(member.user);
+ const { app } = createApp();
+
+ const comment = "x".repeat(length);
+ const response = await app.request("/api/activity/comment", {
+ method: "POST",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify({ taskId: task.id, comment }),
+ });
+
+ expect(response.status).toBe(status);
+ },
+ );
+
+ it.each([
+ { length: 10_000, status: 200 },
+ { length: 10_001, status: 400 },
+ ])(
+ "returns $status when updating a $length-character comment",
+ async ({ length, status }) => {
+ const member = await createWorkspaceMember();
+ const { project, columns } = await createProjectFixture({
+ workspaceId: member.workspace.id,
+ });
+ const [task] = await db
+ .insert(schema.taskTable)
+ .values({
+ projectId: project.id,
+ title: "Comment length limit",
+ status: "to-do",
+ columnId: columns.todo.id,
+ priority: "medium",
+ number: 1,
+ position: 1,
+ })
+ .returning();
+ mockAuthenticatedSession(member.user);
+ const { app } = createApp();
+ const createResponse = await app.request("/api/activity/comment", {
+ method: "POST",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify({ taskId: task.id, comment: "Short comment" }),
+ });
+ expect(createResponse.status).toBe(200);
+ const createdComment = (await createResponse.json()) as { id: string };
+ const comment = "x".repeat(length);
+
+ const response = await app.request("/api/activity/comment", {
+ method: "PUT",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify({
+ activityId: createdComment.id,
+ comment,
+ }),
+ });
+
+ expect(response.status).toBe(status);
+ },
+ );
+
+ it("rejects comments through the generic activity endpoint", async () => {
+ const member = await createWorkspaceMember();
+ const { project, columns } = await createProjectFixture({
+ workspaceId: member.workspace.id,
+ });
+ const [task] = await db
+ .insert(schema.taskTable)
+ .values({
+ projectId: project.id,
+ title: "Generic comment activity",
+ status: "to-do",
+ columnId: columns.todo.id,
+ priority: "medium",
+ number: 1,
+ position: 1,
+ })
+ .returning();
+ mockAuthenticatedSession(member.user);
+ const { app } = createApp();
+
+ const response = await app.request("/api/activity/create", {
+ method: "POST",
+ headers: { "content-type": "application/json" },
+ body: JSON.stringify({
+ taskId: task.id,
+ userId: member.user.id,
+ message: "Comment through generic endpoint",
+ type: "comment",
+ }),
+ });
+
+ expect(response.status).toBe(400);
+ expect(response.headers.get("content-type")).toContain("application/json");
+ expect(await response.json()).toEqual({
+ message: "Use the comment endpoint to create comments",
+ });
+ });
+
- it("records an external author when both name and source are given", async () => {
- const member = await createWorkspaceMember();
+ it("records an external author for an authorized workspace administrator", async () => {
+ const member = await createWorkspaceMember({ role: "admin" });
const { project, columns } = await createProjectFixture({
workspaceId: member.workspace.id,
});