Skip to content

Commit 8e6d57d

Browse files
committed
Add tests for templating with params
1 parent a9bdd48 commit 8e6d57d

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

Diff for: handlers/meta/whataspp_test.go

+39
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,45 @@ var whatsappOutgoingTests = []OutgoingTestCase{
421421
}},
422422
ExpectedExtIDs: []string{"157b5e14568e8"},
423423
},
424+
{
425+
Label: "Template Send, buttons params",
426+
MsgText: "templated message",
427+
MsgURN: "whatsapp:250788123123",
428+
MsgLocale: "eng",
429+
MsgMetadata: json.RawMessage(`{ "templating": { "template": { "name": "revive_issue", "uuid": "171f8a4d-f725-46d7-85a6-11aceff0bfe3" }, "params": {
430+
"body": [
431+
{
432+
"type": "text",
433+
"value": "Ryan Lewis"
434+
},
435+
{
436+
"type": "text",
437+
"value": "niño"
438+
}
439+
],
440+
"button.0": [
441+
{
442+
"type": "text",
443+
"value": "Sip"
444+
}
445+
],
446+
"button.1": [
447+
{
448+
"type": "url",
449+
"value": "id00231"
450+
}
451+
]
452+
}, "language": "en_US"}}`),
453+
MockResponses: map[string][]*httpx.MockResponse{
454+
"*/12345_ID/messages": {
455+
httpx.NewMockResponse(201, nil, []byte(`{ "messages": [{"id": "157b5e14568e8"}] }`)),
456+
},
457+
},
458+
ExpectedRequests: []ExpectedRequest{{
459+
Body: `{"messaging_product":"whatsapp","recipient_type":"individual","to":"250788123123","type":"template","template":{"name":"revive_issue","language":{"policy":"deterministic","code":"en_US"},"components":[{"type":"body","sub_type":"","index":"","parameters":[{"type":"text","text":"Ryan Lewis"},{"type":"text","text":"niño"}]},{"type":"button","sub_type":"quick_reply","index":"0","parameters":[{"type":"payload","payload":"Sip"}]},{"type":"button","sub_type":"quick_reply","index":"1","parameters":[{"type":"text","text":"id00231"}]}]}}`,
460+
}},
461+
ExpectedExtIDs: []string{"157b5e14568e8"},
462+
},
424463
{
425464
Label: "Interactive Button Message Send",
426465
MsgText: "Interactive Button Msg",

Diff for: handlers/meta/whatsapp/templates_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ func TestGetTemplating(t *testing.T) {
3333

3434
msg.WithMetadata(json.RawMessage(`{"templating": {"template": {"uuid": "4ed5000f-5c94-4143-9697-b7cbd230a381", "name": "Update"}}}`))
3535

36-
// invalid templating in metadata, error
36+
// valid templating, no error
3737
tpl, err = whatsapp.GetTemplating(msg)
3838
assert.NoError(t, err)
3939
assert.Equal(t, "4ed5000f-5c94-4143-9697-b7cbd230a381", tpl.Template.UUID)

0 commit comments

Comments
 (0)