⚡ 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 task in place when a draft gitlab mr is opened
zaralX485a4d423a42
diff --git a/apps/api/src/plugins/gitlab/webhook-handler.ts b/apps/api/src/plugins/gitlab/webhook-handler.tsindex 0a3dce771..60eab52be 100644--- a/apps/api/src/plugins/gitlab/webhook-handler.ts+++ b/apps/api/src/plugins/gitlab/webhook-handler.ts@@ -192,7 +192,9 @@ async function dispatchGitlabEvent(}const action = objectAction(payload);if (action === "open" || action === "reopen") {- await handleGitlabMergeRequestOpened(payload, integrationId);+ await handleGitlabMergeRequestOpened(payload, integrationId, {+ moveTask: payload.object_attributes.draft !== true,+ });return;}if (action === "update") {diff --git a/tests/api/plugins/gitlab/webhook-handler.test.ts b/tests/api/plugins/gitlab/webhook-handler.test.tsindex bd154dd6c..f2e9868b5 100644--- a/tests/api/plugins/gitlab/webhook-handler.test.ts+++ b/tests/api/plugins/gitlab/webhook-handler.test.ts@@ -74,6 +74,27 @@ function mergeRequestUpdate(changes: Record<string, unknown>) {});}+function mergeRequestOpen(draft: boolean) {+ return JSON.stringify({+ object_kind: "merge_request",+ object_attributes: {+ iid: 2,+ title: "Draft: Rework the checkout form",+ description: null,+ url: "https://gitlab.com/acme/web/-/merge_requests/2",+ state: "opened",+ action: "open",+ draft,+ source_branch: "kan-2",+ },+ project: {+ name: "web",+ web_url: "https://gitlab.com/acme/web",+ path_with_namespace: "acme/web",+ },+ });+}+function issueEvent({action,eventType = "issue",@@ -112,6 +133,36 @@ beforeEach(() => {});});+describe("handleGitlabWebhookRequest merge request opened", () => {+ it("links a draft merge request without moving the task", async () => {+ await handleGitlabWebhookRequest(+ "integration-1",+ mergeRequestOpen(true),+ secret,+ );++ expect(mocks.handleGitlabMergeRequestOpened).toHaveBeenCalledWith(+ expect.anything(),+ "integration-1",+ { moveTask: false },+ );+ });++ it("moves the task when a merge request is opened ready for review", async () => {+ await handleGitlabWebhookRequest(+ "integration-1",+ mergeRequestOpen(false),+ secret,+ );++ expect(mocks.handleGitlabMergeRequestOpened).toHaveBeenCalledWith(+ expect.anything(),+ "integration-1",+ { moveTask: true },+ );+ });+});+describe("handleGitlabWebhookRequest merge request updates", () => {it("refreshes the link without moving the task when a merge request becomes a draft", async () => {const result = await handleGitlabWebhookRequest(