⚡ 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
fix(api): keep parent links on repeating subtasks
olozano-4f3cb9e33ec4
diff --git a/apps/api/src/task/controllers/duplicate-task.ts b/apps/api/src/task/controllers/duplicate-task.tsindex 225946ee4..2b275e564 100644--- a/apps/api/src/task/controllers/duplicate-task.ts+++ b/apps/api/src/task/controllers/duplicate-task.ts@@ -282,7 +282,12 @@ async function duplicateTask({eq(taskRelationTable.targetTaskId, sourceTask.id),eq(projectTable.workspaceId, project.workspaceId),eq(taskRelationTable.relationType, "subtask"),- projectAccessCondition(currentUserId, taskTable.projectId),+ // An occurrence continues its series with the links it already had,+ // whoever completed it; only a manual copy is limited to what the+ // user can see.+ occurrence+ ? undefined+ : projectAccessCondition(currentUserId, taskTable.projectId),),);diff --git a/tests/api-integration/task-recurrence.test.ts b/tests/api-integration/task-recurrence.test.tsindex 57cb2880a..b11dc8dcb 100644--- a/tests/api-integration/task-recurrence.test.ts+++ b/tests/api-integration/task-recurrence.test.ts@@ -10,6 +10,7 @@ import {createProjectFixture,createWorkspaceMember,} from "./helpers/fixtures";+import { createRestrictedWorkspace } from "./helpers/project-access/create-restricted-workspace";const weekly = { frequency: "weekly", interval: 1, timeZone: "UTC" } as const;@@ -541,4 +542,36 @@ describe("API integration: recurring tasks", () => {recurrence: rule,});});++ it("keeps a parent link the completing member cannot see", async () => {+ const { restricted, alpha, alphaTask, betaTask } =+ await createRestrictedWorkspace();+ if (!alphaTask || !betaTask) throw new Error("Failed to seed tasks");+ const done = await db.query.columnTable.findFirst({+ where: and(+ eq(schema.columnTable.projectId, alpha.id),+ eq(schema.columnTable.isFinal, true),+ ),+ });+ if (!done) throw new Error("Missing final column");+ await db.insert(schema.taskRelationTable).values({+ sourceTaskId: betaTask.id,+ targetTaskId: alphaTask.id,+ relationType: "subtask",+ });+ await db+ .update(schema.taskTable)+ .set({ status: done.slug, columnId: done.id, recurrence: weekly })+ .where(eq(schema.taskTable.id, alphaTask.id));++ const next = await createNextOccurrence(alphaTask.id, restricted.id);++ expect(next).not.toBeNull();+ const links = await db.query.taskRelationTable.findMany({+ where: eq(schema.taskRelationTable.targetTaskId, next?.id ?? ""),+ });+ expect(links).toMatchObject([+ { sourceTaskId: betaTask.id, relationType: "subtask" },+ ]);+ });});