@@ -7,7 +7,9 @@ describe("sendTaskUpdate function", () => {
7
7
const completed = "Task completed successfully" ;
8
8
const planned = "Plan for the next phase" ;
9
9
const blockers = "No blockers" ;
10
-
10
+ const userName = "Tejas" ;
11
+ const taskId = "69nduIn210" ;
12
+ const taskUrl = config ( mockEnv ) . RDS_STATUS_SITE_URL + `/tasks/${ taskId } ` ;
11
13
const assertFetchCall = ( url : string , bodyObj : any , mockEnv : any ) => {
12
14
expect ( global . fetch ) . toHaveBeenCalledWith ( url , {
13
15
method : "POST" ,
@@ -25,7 +27,11 @@ describe("sendTaskUpdate function", () => {
25
27
26
28
test ( "should send the task update to discord tracking channel when all fields are present" , async ( ) => {
27
29
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 } ` ;
29
35
const bodyObj = {
30
36
content : formattedString ,
31
37
} ;
@@ -34,14 +40,25 @@ describe("sendTaskUpdate function", () => {
34
40
. spyOn ( global , "fetch" )
35
41
. mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
36
42
37
- await sendTaskUpdate ( completed , planned , blockers , mockEnv ) ;
43
+ await sendTaskUpdate (
44
+ completed ,
45
+ planned ,
46
+ blockers ,
47
+ userName ,
48
+ taskId ,
49
+ mockEnv
50
+ ) ;
38
51
39
52
assertFetchCall ( url , bodyObj , mockEnv ) ;
40
53
} ) ;
41
54
42
55
test ( "should send the task update to discord tracking channel when only completed is present" , async ( ) => {
43
56
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` ;
45
62
const bodyObj = {
46
63
content : formattedString ,
47
64
} ;
@@ -50,14 +67,18 @@ describe("sendTaskUpdate function", () => {
50
67
. spyOn ( global , "fetch" )
51
68
. mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
52
69
53
- await sendTaskUpdate ( completed , "" , "" , mockEnv ) ;
70
+ await sendTaskUpdate ( completed , "" , "" , userName , taskId , mockEnv ) ;
54
71
55
72
assertFetchCall ( url , bodyObj , mockEnv ) ;
56
73
} ) ;
57
74
58
75
test ( "should send the task update to discord tracking channel when only planned is present" , async ( ) => {
59
76
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` ;
61
82
const bodyObj = {
62
83
content : formattedString ,
63
84
} ;
@@ -66,14 +87,18 @@ describe("sendTaskUpdate function", () => {
66
87
. spyOn ( global , "fetch" )
67
88
. mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
68
89
69
- await sendTaskUpdate ( "" , planned , "" , mockEnv ) ;
90
+ await sendTaskUpdate ( "" , planned , "" , userName , taskId , mockEnv ) ;
70
91
71
92
assertFetchCall ( url , bodyObj , mockEnv ) ;
72
93
} ) ;
73
94
74
95
test ( "should send the task update to discord tracking channel when only blockers is present" , async ( ) => {
75
96
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 } ` ;
77
102
const bodyObj = {
78
103
content : formattedString ,
79
104
} ;
@@ -82,14 +107,18 @@ describe("sendTaskUpdate function", () => {
82
107
. spyOn ( global , "fetch" )
83
108
. mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
84
109
85
- await sendTaskUpdate ( "" , "" , blockers , mockEnv ) ;
110
+ await sendTaskUpdate ( "" , "" , blockers , userName , taskId , mockEnv ) ;
86
111
87
112
assertFetchCall ( url , bodyObj , mockEnv ) ;
88
113
} ) ;
89
114
90
115
test ( "should send the task update to discord tracking channel when only completed and planned are present" , async ( ) => {
91
116
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` ;
93
122
const bodyObj = {
94
123
content : formattedString ,
95
124
} ;
@@ -98,14 +127,18 @@ describe("sendTaskUpdate function", () => {
98
127
. spyOn ( global , "fetch" )
99
128
. mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
100
129
101
- await sendTaskUpdate ( completed , planned , "" , mockEnv ) ;
130
+ await sendTaskUpdate ( completed , planned , "" , userName , taskId , mockEnv ) ;
102
131
103
132
assertFetchCall ( url , bodyObj , mockEnv ) ;
104
133
} ) ;
105
134
106
135
test ( "should send the task update to discord tracking channel when only completed and blockers are present" , async ( ) => {
107
136
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 } ` ;
109
142
const bodyObj = {
110
143
content : formattedString ,
111
144
} ;
@@ -114,14 +147,18 @@ describe("sendTaskUpdate function", () => {
114
147
. spyOn ( global , "fetch" )
115
148
. mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
116
149
117
- await sendTaskUpdate ( completed , "" , blockers , mockEnv ) ;
150
+ await sendTaskUpdate ( completed , "" , blockers , userName , taskId , mockEnv ) ;
118
151
119
152
assertFetchCall ( url , bodyObj , mockEnv ) ;
120
153
} ) ;
121
154
122
155
test ( "should send the task update to discord tracking channel when only planned and blockers are present" , async ( ) => {
123
156
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 } ` ;
125
162
const bodyObj = {
126
163
content : formattedString ,
127
164
} ;
@@ -130,7 +167,7 @@ describe("sendTaskUpdate function", () => {
130
167
. spyOn ( global , "fetch" )
131
168
. mockImplementation ( ( ) => Promise . resolve ( new JSONResponse ( "" ) ) ) ;
132
169
133
- await sendTaskUpdate ( "" , planned , blockers , mockEnv ) ;
170
+ await sendTaskUpdate ( "" , planned , blockers , userName , taskId , mockEnv ) ;
134
171
135
172
assertFetchCall ( url , bodyObj , mockEnv ) ;
136
173
} ) ;
0 commit comments