diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a705c01b7..b0c642a8a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,7 +20,7 @@ jobs: steps: - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - run: yarn diff --git a/controllers/progresses.js b/controllers/progresses.js index 7dd658d45..41b51a9fb 100644 --- a/controllers/progresses.js +++ b/controllers/progresses.js @@ -46,11 +46,11 @@ const { PROGRESS_DOCUMENT_RETRIEVAL_SUCCEEDED, PROGRESS_DOCUMENT_CREATED_SUCCEED const createProgress = async (req, res) => { const { - body: { type, completed, planned, blockers }, + body: { type, completed, planned, blockers, taskId }, } = req; try { const data = await createProgressDocument({ ...req.body, userId: req.userData.id }); - await sendTaskUpdate(completed, blockers, planned); + await sendTaskUpdate(completed, blockers, planned, req.userData.username, taskId); return res.status(201).json({ data, message: `${type.charAt(0).toUpperCase() + type.slice(1)} ${PROGRESS_DOCUMENT_CREATED_SUCCEEDED}`, diff --git a/test/unit/utils/sendTaskUpdate.test.js b/test/unit/utils/sendTaskUpdate.test.js index 5302fa86c..a44f06ac0 100644 --- a/test/unit/utils/sendTaskUpdate.test.js +++ b/test/unit/utils/sendTaskUpdate.test.js @@ -17,7 +17,13 @@ describe("sendTaskUpdate function", function () { it("should send task update successfully", async function () { fetchMock.resolves({ ok: true }); - const result = await sendTaskUpdate("Task completed", "No blockers", "Plan for the next phase"); + const result = await sendTaskUpdate( + "Task completed", + "No blockers", + "Plan for the next phase", + "userName", + "taskId" + ); expect(result).to.equal(undefined); }); @@ -25,7 +31,7 @@ describe("sendTaskUpdate function", function () { const error = new Error("Error"); fetchMock.rejects(error); try { - await sendTaskUpdate("Task completed", "No blockers", "Plan for the next phase"); + await sendTaskUpdate("Task completed", "No blockers", "Plan for the next phase", "userName", "taskId"); } catch (err) { expect(err).to.be.equal(error); } diff --git a/utils/sendTaskUpdate.js b/utils/sendTaskUpdate.js index d990725c3..933df8ca4 100644 --- a/utils/sendTaskUpdate.js +++ b/utils/sendTaskUpdate.js @@ -1,7 +1,7 @@ import { generateCloudFlareHeaders } from "../utils/discord-actions.js"; const DISCORD_BASE_URL = config.get("services.discordBot.baseUrl"); -export const sendTaskUpdate = async (completed, blockers, planned) => { +export const sendTaskUpdate = async (completed, blockers, planned, userName, taskId) => { try { const headers = generateCloudFlareHeaders(); const body = { @@ -9,6 +9,8 @@ export const sendTaskUpdate = async (completed, blockers, planned) => { completed, blockers, planned, + userName, + taskId, }, }; await fetch(`${DISCORD_BASE_URL}/task/update`, {