Skip to content

Commit a9b5f3e

Browse files
authored
Add markdownEnabled in taskRequest models (#1965)
* Add markdownEnabled in taskRequest models Signed-off-by: Tushar Goel <[email protected]> * Fix tests Signed-off-by: Tushar Goel <[email protected]> * Fix tests Signed-off-by: Tushar Goel <[email protected]> * Add markdownEnabled in validators Signed-off-by: Tushar Goel <[email protected]> * Fix validators Signed-off-by: Tushar Goel <[email protected]> --------- Signed-off-by: Tushar Goel <[email protected]>
1 parent de08ced commit a9b5f3e

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

middlewares/validators/task-requests.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const postTaskRequests = async (req, res, next) => {
2020
proposedStartDate: joi.number().required(),
2121
proposedDeadline: joi.number().required(),
2222
description: joi.string().optional(),
23+
markdownEnabled: joi.boolean().optional(),
2324
});
2425

2526
const taskCreationSchema = joi
@@ -33,6 +34,7 @@ const postTaskRequests = async (req, res, next) => {
3334
proposedStartDate: joi.number().required(),
3435
proposedDeadline: joi.number().required(),
3536
description: joi.string().optional(),
37+
markdownEnabled: joi.boolean().optional(),
3638
});
3739
const schema = joi.alternatives().try(taskAssignmentSchema, taskCreationSchema);
3840

models/taskRequests.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ const fetchTaskRequestById = async (taskRequestId) => {
196196
* @param {string} data.proposedDeadline - The proposed deadline for the task.
197197
* @param {string} data.proposedStartDate - The proposed start date for the task.
198198
* @param {string} data.description - The description of the task request.
199+
* @param {string} data.markdownEnabled - If markdown is enabled in task request's description.
199200
* @param {string} data.taskTitle - The title of the task.
200201
* @param {string} data.taskId - The ID of the task (optional).
201202
* @param {string} data.externalIssueUrl - The external issue URL (optional).
@@ -239,6 +240,7 @@ const createRequest = async (data, authorUserId) => {
239240
proposedDeadline: data.proposedDeadline,
240241
proposedStartDate: data.proposedStartDate,
241242
description: data.description,
243+
markdownEnabled: data?.markdownEnabled ?? false,
242244
status: TASK_REQUEST_STATUS.PENDING,
243245
};
244246
if (!userRequest.description) delete userRequest.description;

test/fixtures/task-requests/task-requests.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const taskRequestData = {
3737
requestType: TASK_REQUEST_TYPE.CREATION,
3838
externalIssueUrl: "https://api.github.com/repos/Real-Dev-Squad/website-backend/issues/1599",
3939
externalIssueHtmlUrl: "https://github.com/Real-Dev-Squad/website-backend/issues/1599",
40+
markdownEnabled: false,
4041
};
4142
const existingTaskRequest = {
4243
requestors: ["user123"],
@@ -49,6 +50,7 @@ const existingTaskRequest = {
4950
users: [
5051
{
5152
userId: "user123",
53+
markdownEnabled: false,
5254
proposedDeadline: 1697452226789,
5355
proposedStartDate: 1697452226789,
5456
description: "Task description",

test/unit/models/task-requests.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ describe("Task requests | models", function () {
5656
proposedStartDate: requestData.proposedStartDate,
5757
status: TASK_REQUEST_STATUS.PENDING,
5858
description: requestData.description,
59+
markdownEnabled: requestData.markdownEnabled,
5960
},
6061
]);
6162
expect(addedTaskRequest.createdBy).to.equal(authenticatedUsername);
@@ -89,6 +90,7 @@ describe("Task requests | models", function () {
8990
proposedStartDate: requestData.proposedStartDate,
9091
status: TASK_REQUEST_STATUS.PENDING,
9192
description: requestData.description,
93+
markdownEnabled: requestData.markdownEnabled,
9294
},
9395
]);
9496
expect(addedTaskRequest.createdBy).to.equal(mockData.existingTaskRequest.createdBy);
@@ -124,6 +126,7 @@ describe("Task requests | models", function () {
124126
proposedStartDate: requestData.proposedStartDate,
125127
status: TASK_REQUEST_STATUS.PENDING,
126128
description: requestData.description,
129+
markdownEnabled: requestData.markdownEnabled,
127130
},
128131
]);
129132
expect(addedTaskRequest.createdBy).to.equal(authenticatedUsername);
@@ -163,6 +166,7 @@ describe("Task requests | models", function () {
163166
proposedStartDate: requestData.proposedStartDate,
164167
status: TASK_REQUEST_STATUS.PENDING,
165168
description: requestData.description,
169+
markdownEnabled: requestData.markdownEnabled,
166170
},
167171
]);
168172
expect(addedTaskRequest.createdBy).to.equal(mockData.existingTaskRequest.createdBy);

0 commit comments

Comments
 (0)