From 5348691e1c9931ca328c650ee23135848a1ad58a Mon Sep 17 00:00:00 2001 From: ARREY-ETTA BESSONG EKEP OBASI Date: Wed, 27 Mar 2024 13:03:27 +0100 Subject: [PATCH] fix: close assigned issue logic - updated devpool issue logic - wrote tests to confirm that existing logic works well --- index.ts | 2 +- tests/main.test.ts | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/index.ts b/index.ts index 958805b06..272e9abd3 100644 --- a/index.ts +++ b/index.ts @@ -149,7 +149,7 @@ async function main() { issue_number: devpoolIssue.number, title: projectIssue.title, body, - state: projectIssue.state as "open" | "closed", + state: !isDevpoolUnavailableLabel ? (projectIssue.state as "open" | "closed") : "closed", labels: getDevpoolIssueLabels(projectIssue, projectUrl), }); console.log(`Updated: ${devpoolIssue.html_url} (${projectIssue.html_url})`); diff --git a/tests/main.test.ts b/tests/main.test.ts index 5412798a5..bf9f32031 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -106,4 +106,30 @@ describe("Devpool Updates", () => { }, ]); }); + + test("Close devpool issues when the issue has been assigned in other projects", async () => { + db.issue.create({ + ...issueDevpoolTemplate, + id: 1, + owner: DEVPOOL_OWNER_NAME, + repo: DEVPOOL_REPO_NAME, + }); + db.issue.create({ + ...issueTemplate, + id: 2, + assignee: { ...issueTemplate.assignee, login: "john doe" }, + owner: DEVPOOL_OWNER_NAME, + repo: "test-repo", + }); + await main(); + const devpoolIssue = await getAllIssues(DEVPOOL_OWNER_NAME, DEVPOOL_REPO_NAME); + + expect(devpoolIssue).toMatchObject([ + { + ...issueDevpoolTemplate, + id: 1, + state: "closed", + }, + ]); + }); });