Skip to content

Commit

Permalink
Add unit test for received from NFM Reply
Browse files Browse the repository at this point in the history
  • Loading branch information
Robi9 committed Feb 1, 2024
1 parent bb961ac commit ff76f58
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
9 changes: 8 additions & 1 deletion handlers/facebookapp/facebookapp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,14 @@ var testCasesWAC = []ChannelHandleTestCase{
},
}),
PrepRequest: addValidSignatureWAC},

{Label: "Receive NFM Reply WAC", URL: wacReceiveURL, Data: string(courier.ReadFile("./testdata/wac/flowWAC.json")), Status: 200, Response: "Handled", NoQueueErrorCheck: true, NoInvalidChannelCheck: true,
URN: Sp("whatsapp:5678"), ExternalID: Sp("external_id"), Date: Tp(time.Date(2016, 1, 30, 1, 57, 9, 0, time.UTC)), Metadata: Jp(map[string]interface{}{
"nfm_reply": map[string]interface{}{
"name": "Flow Wpp",
"response_json": "{\"flow_token\": \"<FLOW_TOKEN>\", \"optional_param1\": \"<value1>\", \"optional_param2\": \"<value2>\"}",
},
}),
PrepRequest: addValidSignatureWAC},
{Label: "Receive Valid Document Message", URL: wacReceiveURL, Data: string(courier.ReadFile("./testdata/wac/documentWAC.json")), Status: 200, Response: "Handled", NoQueueErrorCheck: true, NoInvalidChannelCheck: true,
Text: Sp("80skaraokesonglistartist"), URN: Sp("whatsapp:5678"), ExternalID: Sp("external_id"), Attachment: Sp("https://foo.bar/attachmentURL_Document"), Date: Tp(time.Date(2016, 1, 30, 1, 57, 9, 0, time.UTC)),
PrepRequest: addValidSignatureWAC},
Expand Down
43 changes: 43 additions & 0 deletions handlers/facebookapp/testdata/wac/flowWAC.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"object": "whatsapp_business_account",
"entry": [
{
"id": "8856996819413533",
"changes": [
{
"value": {
"messaging_product": "whatsapp",
"metadata": {
"display_phone_number": "+250 788 123 200",
"phone_number_id": "12345"
},
"contacts": [
{
"profile": {
"name": "Kerry Fisher"
},
"wa_id": "5678"
}
],
"messages": [
{
"from": "5678",
"id": "external_id",
"timestamp": "1454119029",
"type": "interactive",
"interactive": {
"type": "nfm_reply",
"nfm_reply": {
"name": "Flow Wpp",
"response_json": "{\"flow_token\": \"<FLOW_TOKEN>\", \"optional_param1\": \"<value1>\", \"optional_param2\": \"<value2>\"}"
}
}
}
]
},
"field": "messages"
}
]
}
]
}

0 comments on commit ff76f58

Please sign in to comment.