@@ -121,163 +121,6 @@ describe('WebhookController', () => {
121121 ) ;
122122 } ) ;
123123
124- it ( 'resolved 액션에 대해 올바른 메시지를 생성해야 한다' , async ( ) => {
125- const resolvedData = {
126- ...mockSentryData ,
127- action : 'resolved' as const ,
128- data : {
129- ...mockSentryData . data ,
130- issue : {
131- ...mockSentryData . data . issue ,
132- status : 'resolved' as const
133- }
134- }
135- } ;
136- mockRequest . body = resolvedData ;
137- mockSendSlackMessage . mockResolvedValue ( ) ;
138-
139- await webhookController . handleSentryWebhook (
140- mockRequest as Request ,
141- mockResponse as Response ,
142- nextFunction
143- ) ;
144-
145- expect ( mockSendSlackMessage ) . toHaveBeenCalledWith (
146- expect . stringContaining ( '🚨 *오류가 해결되었습니다*' )
147- ) ;
148- expect ( mockSendSlackMessage ) . toHaveBeenCalledWith (
149- expect . stringContaining ( '✅ *제목:*' )
150- ) ;
151- } ) ;
152-
153- it ( 'ignored 액션에 대해 올바른 메시지를 생성해야 한다' , async ( ) => {
154- const ignoredData = {
155- ...mockSentryData ,
156- action : 'ignored' as const ,
157- data : {
158- ...mockSentryData . data ,
159- issue : {
160- ...mockSentryData . data . issue ,
161- status : 'ignored' as const
162- }
163- }
164- } ;
165- mockRequest . body = ignoredData ;
166- mockSendSlackMessage . mockResolvedValue ( ) ;
167-
168- await webhookController . handleSentryWebhook (
169- mockRequest as Request ,
170- mockResponse as Response ,
171- nextFunction
172- ) ;
173-
174- expect ( mockSendSlackMessage ) . toHaveBeenCalledWith (
175- expect . stringContaining ( '🚨 *오류가 무시되었습니다*' )
176- ) ;
177- expect ( mockSendSlackMessage ) . toHaveBeenCalledWith (
178- expect . stringContaining ( '🔇 *제목:*' )
179- ) ;
180- } ) ;
181-
182- it ( 'assigned 액션에 대해 올바른 메시지를 생성해야 한다' , async ( ) => {
183- const assignedData = {
184- ...mockSentryData ,
185- action : 'assigned' as const ,
186- data : {
187- ...mockSentryData . data ,
188- issue : {
189- ...mockSentryData . data . issue ,
190- status : 'unresolved' as const
191- }
192- }
193- } ;
194- mockRequest . body = assignedData ;
195- mockSendSlackMessage . mockResolvedValue ( ) ;
196-
197- await webhookController . handleSentryWebhook (
198- mockRequest as Request ,
199- mockResponse as Response ,
200- nextFunction
201- ) ;
202-
203- expect ( mockSendSlackMessage ) . toHaveBeenCalledWith (
204- expect . stringContaining ( '🚨 *오류가 할당되었습니다*' )
205- ) ;
206- } ) ;
207-
208- it ( 'archived 액션에 대해 올바른 메시지를 생성해야 한다' , async ( ) => {
209- const archivedData = {
210- ...mockSentryData ,
211- action : 'archived' as const ,
212- data : {
213- ...mockSentryData . data ,
214- issue : {
215- ...mockSentryData . data . issue ,
216- status : 'archived' as const
217- }
218- }
219- } ;
220- mockRequest . body = archivedData ;
221- mockSendSlackMessage . mockResolvedValue ( ) ;
222-
223- await webhookController . handleSentryWebhook (
224- mockRequest as Request ,
225- mockResponse as Response ,
226- nextFunction
227- ) ;
228-
229- expect ( mockSendSlackMessage ) . toHaveBeenCalledWith (
230- expect . stringContaining ( '🚨 *오류가 아카이브되었습니다*' )
231- ) ;
232- expect ( mockSendSlackMessage ) . toHaveBeenCalledWith (
233- expect . stringContaining ( '📦 *제목:*' )
234- ) ;
235- } ) ;
236-
237- it ( '알 수 없는 액션에 대해 기본 메시지를 생성해야 한다' , async ( ) => {
238- const unknownActionData = {
239- ...mockSentryData ,
240- action : 'unknown_action' as 'created'
241- } ;
242- mockRequest . body = unknownActionData ;
243- mockSendSlackMessage . mockResolvedValue ( ) ;
244-
245- await webhookController . handleSentryWebhook (
246- mockRequest as Request ,
247- mockResponse as Response ,
248- nextFunction
249- ) ;
250-
251- expect ( mockSendSlackMessage ) . toHaveBeenCalledWith (
252- expect . stringContaining ( '오류 이벤트: unknown_action' )
253- ) ;
254- } ) ;
255-
256- it ( '알 수 없는 상태에 대해 기본 이모지를 사용해야 한다' , async ( ) => {
257- const unknownStatusData = {
258- ...mockSentryData ,
259- data : {
260- ...mockSentryData . data ,
261- issue : {
262- ...mockSentryData . data . issue ,
263- status : 'unknown_status' as 'unresolved'
264- }
265- }
266- } ;
267- mockRequest . body = unknownStatusData ;
268- mockSendSlackMessage . mockResolvedValue ( ) ;
269-
270- await webhookController . handleSentryWebhook (
271- mockRequest as Request ,
272- mockResponse as Response ,
273- nextFunction
274- ) ;
275-
276- expect ( mockSendSlackMessage ) . toHaveBeenCalledWith (
277- expect . stringContaining ( '❓ *제목:*' )
278- ) ;
279- } ) ;
280-
281124 it ( 'Slack 메시지 전송 실패 시 에러를 전달해야 한다' , async ( ) => {
282125 mockRequest . body = mockSentryData ;
283126 const slackError = new Error ( 'Slack 전송 실패' ) ;
@@ -292,46 +135,6 @@ describe('WebhookController', () => {
292135 expect ( nextFunction ) . toHaveBeenCalledWith ( slackError ) ;
293136 expect ( mockResponse . json ) . not . toHaveBeenCalled ( ) ;
294137 } ) ;
295-
296- it ( '빈 body로 요청 시에도 처리해야 한다' , async ( ) => {
297- mockRequest . body = { } ;
298- mockSendSlackMessage . mockResolvedValue ( ) ;
299-
300- await webhookController . handleSentryWebhook (
301- mockRequest as Request ,
302- mockResponse as Response ,
303- nextFunction
304- ) ;
305-
306- // undefined 값들에 대해서도 처리되어야 함
307- expect ( mockSendSlackMessage ) . toHaveBeenCalled ( ) ;
308- expect ( mockResponse . status ) . toHaveBeenCalledWith ( 200 ) ;
309- } ) ;
310-
311- it ( '필수 필드가 없는 경우에도 처리해야 한다' , async ( ) => {
312- const incompleteData = {
313- action : 'created' ,
314- data : {
315- issue : {
316- id : 'test-123'
317- // title, culprit 등 누락
318- }
319- }
320- } ;
321- mockRequest . body = incompleteData ;
322- mockSendSlackMessage . mockResolvedValue ( ) ;
323-
324- await webhookController . handleSentryWebhook (
325- mockRequest as Request ,
326- mockResponse as Response ,
327- nextFunction
328- ) ;
329-
330- expect ( mockSendSlackMessage ) . toHaveBeenCalledWith (
331- expect . stringContaining ( '🔗 *상세 보기:* https://velog-dashboardv2.sentry.io/issues/test-123/' )
332- ) ;
333- expect ( mockResponse . status ) . toHaveBeenCalledWith ( 200 ) ;
334- } ) ;
335138 } ) ;
336139
337140 describe ( 'formatSentryMessage (private method integration test)' , ( ) => {
0 commit comments