@@ -7,7 +7,9 @@ describe("sendTaskUpdate function", () => {
77 const completed = "Task completed successfully" ;
88 const planned = "Plan for the next phase" ;
99 const blockers = "No blockers" ;
10-
10+ const userName = "Tejas" ;
11+ const taskId = "69nduIn210" ;
12+ const taskUrl = config ( mockEnv ) . RDS_STATUS_SITE_URL + `/tasks/${ taskId } ` ;
1113 const assertFetchCall = ( url : string , bodyObj : any , mockEnv : any ) => {
1214 expect ( global . fetch ) . toHaveBeenCalledWith ( url , {
1315 method : "POST" ,
@@ -25,7 +27,11 @@ describe("sendTaskUpdate function", () => {
2527
2628 test ( "should send the task update to discord tracking channel when all fields are present" , async ( ) => {
2729 const url = config ( mockEnv ) . TRACKING_CHANNEL_URL ;
28- const formattedString = `**Completed**: ${ completed } \n\n**Planned**: ${ planned } \n\n**Blockers**: ${ blockers } ` ;
30+ const formattedString =
31+ `${ userName } added an update to their task: <${ taskUrl } >\n` +
32+ `\n**Completed**\n${ completed } \n\n` +
33+ `**Planned**\n${ planned } \n\n` +
34+ `**Blockers**\n${ blockers } ` ;
2935 const bodyObj = {
3036 content : formattedString ,
3137 } ;
@@ -34,14 +40,25 @@ describe("sendTaskUpdate function", () => {
3440 . spyOn ( global , "fetch" )
3541 . mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
3642
37- await sendTaskUpdate ( completed , planned , blockers , mockEnv ) ;
43+ await sendTaskUpdate (
44+ completed ,
45+ planned ,
46+ blockers ,
47+ userName ,
48+ taskId ,
49+ mockEnv
50+ ) ;
3851
3952 assertFetchCall ( url , bodyObj , mockEnv ) ;
4053 } ) ;
4154
4255 test ( "should send the task update to discord tracking channel when only completed is present" , async ( ) => {
4356 const url = config ( mockEnv ) . TRACKING_CHANNEL_URL ;
44- const formattedString = `**Completed**: ${ completed } \n\n**Planned**: \n\n**Blockers**: ` ;
57+ const formattedString =
58+ `${ userName } added an update to their task: <${ taskUrl } >\n` +
59+ `\n**Completed**\n${ completed } \n\n` +
60+ `**Planned**\n\n\n` +
61+ `**Blockers**\n` ;
4562 const bodyObj = {
4663 content : formattedString ,
4764 } ;
@@ -50,14 +67,18 @@ describe("sendTaskUpdate function", () => {
5067 . spyOn ( global , "fetch" )
5168 . mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
5269
53- await sendTaskUpdate ( completed , "" , "" , mockEnv ) ;
70+ await sendTaskUpdate ( completed , "" , "" , userName , taskId , mockEnv ) ;
5471
5572 assertFetchCall ( url , bodyObj , mockEnv ) ;
5673 } ) ;
5774
5875 test ( "should send the task update to discord tracking channel when only planned is present" , async ( ) => {
5976 const url = config ( mockEnv ) . TRACKING_CHANNEL_URL ;
60- const formattedString = `**Completed**: \n\n**Planned**: ${ planned } \n\n**Blockers**: ` ;
77+ const formattedString =
78+ `${ userName } added an update to their task: <${ taskUrl } >\n` +
79+ `\n**Completed**\n\n\n` +
80+ `**Planned**\n${ planned } \n\n` +
81+ `**Blockers**\n` ;
6182 const bodyObj = {
6283 content : formattedString ,
6384 } ;
@@ -66,14 +87,18 @@ describe("sendTaskUpdate function", () => {
6687 . spyOn ( global , "fetch" )
6788 . mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
6889
69- await sendTaskUpdate ( "" , planned , "" , mockEnv ) ;
90+ await sendTaskUpdate ( "" , planned , "" , userName , taskId , mockEnv ) ;
7091
7192 assertFetchCall ( url , bodyObj , mockEnv ) ;
7293 } ) ;
7394
7495 test ( "should send the task update to discord tracking channel when only blockers is present" , async ( ) => {
7596 const url = config ( mockEnv ) . TRACKING_CHANNEL_URL ;
76- const formattedString = `**Completed**: \n\n**Planned**: \n\n**Blockers**: ${ blockers } ` ;
97+ const formattedString =
98+ `${ userName } added an update to their task: <${ taskUrl } >\n` +
99+ `\n**Completed**\n\n\n` +
100+ `**Planned**\n\n\n` +
101+ `**Blockers**\n${ blockers } ` ;
77102 const bodyObj = {
78103 content : formattedString ,
79104 } ;
@@ -82,14 +107,18 @@ describe("sendTaskUpdate function", () => {
82107 . spyOn ( global , "fetch" )
83108 . mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
84109
85- await sendTaskUpdate ( "" , "" , blockers , mockEnv ) ;
110+ await sendTaskUpdate ( "" , "" , blockers , userName , taskId , mockEnv ) ;
86111
87112 assertFetchCall ( url , bodyObj , mockEnv ) ;
88113 } ) ;
89114
90115 test ( "should send the task update to discord tracking channel when only completed and planned are present" , async ( ) => {
91116 const url = config ( mockEnv ) . TRACKING_CHANNEL_URL ;
92- const formattedString = `**Completed**: ${ completed } \n\n**Planned**: ${ planned } \n\n**Blockers**: ` ;
117+ const formattedString =
118+ `${ userName } added an update to their task: <${ taskUrl } >\n` +
119+ `\n**Completed**\n${ completed } \n\n` +
120+ `**Planned**\n${ planned } \n\n` +
121+ `**Blockers**\n` ;
93122 const bodyObj = {
94123 content : formattedString ,
95124 } ;
@@ -98,14 +127,18 @@ describe("sendTaskUpdate function", () => {
98127 . spyOn ( global , "fetch" )
99128 . mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
100129
101- await sendTaskUpdate ( completed , planned , "" , mockEnv ) ;
130+ await sendTaskUpdate ( completed , planned , "" , userName , taskId , mockEnv ) ;
102131
103132 assertFetchCall ( url , bodyObj , mockEnv ) ;
104133 } ) ;
105134
106135 test ( "should send the task update to discord tracking channel when only completed and blockers are present" , async ( ) => {
107136 const url = config ( mockEnv ) . TRACKING_CHANNEL_URL ;
108- const formattedString = `**Completed**: ${ completed } \n\n**Planned**: \n\n**Blockers**: ${ blockers } ` ;
137+ const formattedString =
138+ `${ userName } added an update to their task: <${ taskUrl } >\n` +
139+ `\n**Completed**\n${ completed } \n\n` +
140+ `**Planned**\n\n\n` +
141+ `**Blockers**\n${ blockers } ` ;
109142 const bodyObj = {
110143 content : formattedString ,
111144 } ;
@@ -114,14 +147,18 @@ describe("sendTaskUpdate function", () => {
114147 . spyOn ( global , "fetch" )
115148 . mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
116149
117- await sendTaskUpdate ( completed , "" , blockers , mockEnv ) ;
150+ await sendTaskUpdate ( completed , "" , blockers , userName , taskId , mockEnv ) ;
118151
119152 assertFetchCall ( url , bodyObj , mockEnv ) ;
120153 } ) ;
121154
122155 test ( "should send the task update to discord tracking channel when only planned and blockers are present" , async ( ) => {
123156 const url = config ( mockEnv ) . TRACKING_CHANNEL_URL ;
124- const formattedString = `**Completed**: \n\n**Planned**: ${ planned } \n\n**Blockers**: ${ blockers } ` ;
157+ const formattedString =
158+ `${ userName } added an update to their task: <${ taskUrl } >\n` +
159+ `\n**Completed**\n\n\n` +
160+ `**Planned**\n${ planned } \n\n` +
161+ `**Blockers**\n${ blockers } ` ;
125162 const bodyObj = {
126163 content : formattedString ,
127164 } ;
@@ -130,7 +167,7 @@ describe("sendTaskUpdate function", () => {
130167 . spyOn ( global , "fetch" )
131168 . mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
132169
133- await sendTaskUpdate ( "" , planned , blockers , mockEnv ) ;
170+ await sendTaskUpdate ( "" , planned , blockers , userName , taskId , mockEnv ) ;
134171
135172 assertFetchCall ( url , bodyObj , mockEnv ) ;
136173 } ) ;
0 commit comments