Skip to content

Commit 2952574

Browse files
authored
feat: add fields to the util (#2026)
1 parent 4800b0c commit 2952574

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

controllers/progresses.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ const { PROGRESS_DOCUMENT_RETRIEVAL_SUCCEEDED, PROGRESS_DOCUMENT_CREATED_SUCCEED
4646

4747
const createProgress = async (req, res) => {
4848
const {
49-
body: { type, completed, planned, blockers },
49+
body: { type, completed, planned, blockers, taskId },
5050
} = req;
5151
try {
5252
const data = await createProgressDocument({ ...req.body, userId: req.userData.id });
53-
await sendTaskUpdate(completed, blockers, planned);
53+
await sendTaskUpdate(completed, blockers, planned, req.userData.username, taskId);
5454
return res.status(201).json({
5555
data,
5656
message: `${type.charAt(0).toUpperCase() + type.slice(1)} ${PROGRESS_DOCUMENT_CREATED_SUCCEEDED}`,

test/unit/utils/sendTaskUpdate.test.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@ describe("sendTaskUpdate function", function () {
1717
it("should send task update successfully", async function () {
1818
fetchMock.resolves({ ok: true });
1919

20-
const result = await sendTaskUpdate("Task completed", "No blockers", "Plan for the next phase");
20+
const result = await sendTaskUpdate(
21+
"Task completed",
22+
"No blockers",
23+
"Plan for the next phase",
24+
"userName",
25+
"taskId"
26+
);
2127
expect(result).to.equal(undefined);
2228
});
2329

2430
it("should throw an error if fails", async function () {
2531
const error = new Error("Error");
2632
fetchMock.rejects(error);
2733
try {
28-
await sendTaskUpdate("Task completed", "No blockers", "Plan for the next phase");
34+
await sendTaskUpdate("Task completed", "No blockers", "Plan for the next phase", "userName", "taskId");
2935
} catch (err) {
3036
expect(err).to.be.equal(error);
3137
}

utils/sendTaskUpdate.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
import { generateCloudFlareHeaders } from "../utils/discord-actions.js";
22
const DISCORD_BASE_URL = config.get("services.discordBot.baseUrl");
33

4-
export const sendTaskUpdate = async (completed, blockers, planned) => {
4+
export const sendTaskUpdate = async (completed, blockers, planned, userName, taskId) => {
55
try {
66
const headers = generateCloudFlareHeaders();
77
const body = {
88
content: {
99
completed,
1010
blockers,
1111
planned,
12+
userName,
13+
taskId,
1214
},
1315
};
1416
await fetch(`${DISCORD_BASE_URL}/task/update`, {

0 commit comments

Comments
 (0)