Skip to content

Commit

Permalink
Fix and improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
Robi9 committed Jan 8, 2025
1 parent bb98bd5 commit fffd980
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
3 changes: 3 additions & 0 deletions services/tickets/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ func SendReplyCSAT(ctx context.Context, rt *runtime.Runtime, ticket *models.Tick
}

channel := oa.ChannelByUUID(assets.ChannelUUID(channelUUID))
if channel == nil {
return nil, errors.Errorf("unable to load channel with uuid: %s", channelUUID)
}

msg := models.WppBroadcastMessage{
Text: msgText,
Expand Down
27 changes: 23 additions & 4 deletions services/tickets/zendesk/testdata/csat.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"method": "POST",
"path": "/mr/tickets/types/zendesk/csat",
"body": {},
"status": 400,
"status": 404,
"response": {
"error": "error looking up ticket "
"error": "no such ticketer "
}
},
{
Expand All @@ -15,9 +15,11 @@
"path": "/mr/tickets/types/zendesk/csat",
"body": {
"message": "Satisfaction Survey",
"thread_id": "$cathy_ticket_uuid$",
"ticketer_uuid": "4ee6d4f3-f92b-439b-9718-8da90c05490b",
"ticket_id": "1234",
"channel_uuid": "74729f45-7f29-4868-9dc4-90e491e3c7d8",
"csat_url": "https://csat.zen/e88512d8-acea-46d0-80a0-c7ae19d12cec"
"csat_url": "https://csat.zen/e88512d8-acea-46d0-80a0-c7ae19d12cec",
"button_text": "Survey Link"
},
"status": 200,
"response": {
Expand All @@ -30,5 +32,22 @@
"count": 1
}
]
},
{
"label": "error response if unable to load channel",
"method": "POST",
"path": "/mr/tickets/types/zendesk/csat",
"body": {
"message": "Satisfaction Survey",
"ticketer_uuid": "4ee6d4f3-f92b-439b-9718-8da90c05490b",
"ticket_id": "1234",
"channel_uuid": "1a2b3c",
"csat_url": "https://csat.zen/e88512d8-acea-46d0-80a0-c7ae19d12cec",
"button_text": "Survey Link"
},
"status": 400,
"response": {
"error": "unable to load channel with uuid: 1a2b3c"
}
}
]

0 comments on commit fffd980

Please sign in to comment.