diff --git a/src/constants.js b/src/constants.js index 5774fa1..e2ff631 100644 --- a/src/constants.js +++ b/src/constants.js @@ -6,5 +6,4 @@ "use strict"; module.exports = { - NEEDS_TRIAGE_COLUMN_ID: 11153344 }; diff --git a/src/plugins/add-to-triage-project/index.js b/src/plugins/add-to-triage-project/index.js deleted file mode 100644 index 2d0f0c5..0000000 --- a/src/plugins/add-to-triage-project/index.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * @fileoverview Adds a newly opened issue to the Triage project - * @author Nicholas C. Zakas - */ - -"use strict"; - -const { NEEDS_TRIAGE_COLUMN_ID } = require("../../constants"); - -/** - * Adds the issue to the triage project. - * @param {Context} context Probot webhook event context - * @returns {Promise} A Promise that fulfills when the action is complete - * @private - */ -async function triage(context) { - - const issue = context.payload.issue; - - // issues with "triage:no" label are exempt - if (issue.labels.some(label => label.name === "triage:no")) { - return; - } - - await context.github.projects.createCard({ - column_id: NEEDS_TRIAGE_COLUMN_ID, - content_id: issue.id, - content_type: "Issue" - }); -} - -module.exports = robot => { - robot.on("issues.opened", triage); -}; diff --git a/src/plugins/index.js b/src/plugins/index.js index 010388a..6a1a97e 100644 --- a/src/plugins/index.js +++ b/src/plugins/index.js @@ -13,7 +13,6 @@ */ module.exports = { - addToTriageProject: require("./add-to-triage-project"), autoCloser: require("./auto-closer"), checkUnitTest: require("./check-unit-test"), commitMessage: require("./commit-message"), diff --git a/tests/plugins/add-to-triage-project/index.js b/tests/plugins/add-to-triage-project/index.js deleted file mode 100644 index 823ae44..0000000 --- a/tests/plugins/add-to-triage-project/index.js +++ /dev/null @@ -1,105 +0,0 @@ -"use strict"; - -const { addToTriageProject } = require("../../../src/plugins/index"); -const nock = require("nock"); -const { Application } = require("probot"); -const { NEEDS_TRIAGE_COLUMN_ID } = require("../../../src/constants"); -const GitHubApi = require("@octokit/rest"); - -describe("add-to-triage-project", () => { - let bot = null; - - beforeAll(() => { - bot = new Application({ - id: "test", - cert: "test", - cache: { - wrap: () => Promise.resolve({ data: { token: "test" } }) - } - }); - bot.auth = () => new GitHubApi(); - addToTriageProject(bot); - }); - - afterEach(() => { - nock.cleanAll(); - }); - - describe("issue opened", () => { - test("Adds the issue to the project", async () => { - const addIssueToTriageProject = nock("https://api.github.com") - .post(`/projects/columns/${NEEDS_TRIAGE_COLUMN_ID}/cards`, body => { - expect(body).toEqual({ - content_id: 1234, - content_type: "Issue" - }); - return true; - }) - .reply(200); - - await bot.receive({ - name: "issues", - payload: { - action: "opened", - installation: { - id: 1 - }, - issue: { - labels: [], - number: 1, - id: 1234 - }, - repository: { - name: "repo-test", - owner: { - login: "test" - } - } - } - }); - - expect(addIssueToTriageProject.isDone()).toBeTruthy(); - }); - - test("doesn't add the issue to the project when 'triage:no' label is present", async () => { - - const addIssueToTriageProject = nock("https://api.github.com") - .post(`/projects/columns/${NEEDS_TRIAGE_COLUMN_ID}/cards`, body => { - expect(body).toEqual({ - content_id: 1234, - content_type: "Issue" - }); - return true; - }) - .reply(200); - - await bot.receive({ - name: "issues", - payload: { - action: "opened", - installation: { - id: 1 - }, - issue: { - labels: [ - { - name: "triage:no" - } - ], - number: 1, - id: 1234 - }, - repository: { - name: "repo-test", - owner: { - login: "test" - } - } - } - }); - - expect(addIssueToTriageProject.isDone()).toBeFalsy(); - - }); - }); -});