Skip to content

Commit acc3e47

Browse files
author
Fritz Brand
authored
Merge pull request #75 from praekeltfoundation/fixes-to-v3-tests
Fixes to v3 tests
2 parents 7750a46 + bc62128 commit acc3e47

16 files changed

Lines changed: 257 additions & 170 deletions

.github/workflows/ci.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ jobs:
2929
uses: actions/checkout@v4
3030
with:
3131
repository: praekeltfoundation/flow_tester
32-
#ref: v0.5.0
33-
ref: add-standalone-template-support
32+
ref: v0.5.1
3433
path: flow_tester
3534
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
3635

Onboarding/QA/tests/basic-questions_test.exs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ defmodule BasicQuestionsTest do
3030
end
3131
]
3232

33+
# The onboarding.csv content file contains a page that references a Whatsapp Template.
34+
# We don't support importing of templates yet, so for now we add it manually
35+
FakeCMS.add_template(wh_pid, %WATemplate{
36+
id: "1",
37+
slug: "mnch_onboarding_edd_reminder",
38+
category: "MARKETING",
39+
image: nil,
40+
message: "This is a test message",
41+
buttons: [],
42+
example_values: [],
43+
submission_status: "",
44+
submission_name: "",
45+
submission_result: ""
46+
})
47+
3348
# The content for these tests.
3449
assert :ok =
3550
Helpers.import_content_csv(

Onboarding/QA/tests/dma-form_test.exs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,21 @@ defmodule DMAFormTest do
3232
end
3333
]
3434

35+
# The onboarding.csv content file contains a page that references a Whatsapp Template.
36+
# We don't support importing of templates yet, so for now we add it manually
37+
FakeCMS.add_template(wh_pid, %WATemplate{
38+
id: "1",
39+
slug: "mnch_onboarding_edd_reminder",
40+
category: "MARKETING",
41+
image: nil,
42+
message: "This is a test message",
43+
buttons: [],
44+
example_values: [],
45+
submission_status: "",
46+
submission_name: "",
47+
submission_result: ""
48+
})
49+
3550
# The content for these tests.
3651
assert :ok = Helpers.import_content_csv(wh_pid, "onboarding", import_opts)
3752

Onboarding/QA/tests/edd-reminders_test.exs

Lines changed: 59 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ defmodule EDDRemindersTest do
3131
# These transforms are specific to these tests
3232
end
3333
]
34+
# The onboarding.csv content file contains a page that references a Whatsapp Template.
35+
# We don't support importing of templates yet, so for now we add it manually
36+
FakeCMS.add_template(wh_pid, %WATemplate{
37+
id: "1",
38+
slug: "mnch_onboarding_edd_reminder",
39+
category: "MARKETING",
40+
image: nil,
41+
message: "This is a test message",
42+
buttons: [],
43+
example_values: [],
44+
submission_status: "",
45+
submission_name: "",
46+
submission_result: ""
47+
})
48+
3449

3550
# The content for these tests.
3651
assert :ok = Helpers.import_content_csv(wh_pid, "onboarding", import_opts)
@@ -164,20 +179,20 @@ defmodule EDDRemindersTest do
164179
end
165180

166181
describe "EDD Reminder" do
167-
@describetag skip: "TODO: Implement support for Template CSV import etc"
168182
test "Got it", %{flow: flow} do
169183
flow
184+
170185
|> FlowTester.start()
171186
|> receive_message(%{
172-
# text: "[DEBUG]\r\nTemplate edd_reminder_2041 sent with language en_US.\r\nBody parameters: [@name]\r\nMedia link: @image_data.body.meta.download_url" <> _,
173187
text:
174-
"[DEBUG]\r\nTemplate @body.whatsapp_template_name sent with language en_US.\r\nBody parameters: [@name]\r\nMedia link: @image_data.body.meta.download_url\r\n\r\nThe buttons represented here are not necessarily the same as the ones in the real template. Please double check the template buttons when running the flow in a real-world scenario." <>
188+
"[DEBUG]\r\nTemplate @submission_name sent with language en_US.\r\nBody parameters: [@name]\r\nMedia link: @image_data.body.meta.download_url\r\n\r\nThe buttons represented here are not necessarily the same as the ones in the real template. Please double check the template buttons when running the flow in a real-world scenario." <>
175189
_,
176-
buttons: [
177-
{"edd_got_it", "edd_got_it"},
178-
{"edd_month", "edd_month"},
179-
{"eddr_unknown", "eddr_unknown"}
180-
]
190+
# buttons: [
191+
# {"edd_got_it", "edd_got_it"},
192+
# {"edd_month", "edd_month"},
193+
# {"eddr_unknown", "eddr_unknown"}
194+
# ]
195+
# buttons: button_labels(["Got it!", "Update due date", "How to calculate it"]),
181196
})
182197
|> FlowTester.send("edd_got_it")
183198
|> receive_message(%{
@@ -191,15 +206,15 @@ defmodule EDDRemindersTest do
191206
|> FlowTester.set_contact_properties(%{"language" => "por"})
192207
|> FlowTester.start()
193208
|> receive_message(%{
194-
# text: "[DEBUG]\r\nTemplate edd_reminder_2041_pt sent with language pt_PT.\r\nBody parameters: [@name]\r\nMedia link: @image_data.body.meta.download_url" <> _,
195209
text:
196-
"[DEBUG]\r\nTemplate @body.whatsapp_template_name sent with language pt_PT.\r\nBody parameters: [@name]\r\nMedia link: @image_data.body.meta.download_url" <>
210+
"[DEBUG]\r\nTemplate @submission_name sent with language pt_PT.\r\nBody parameters: [@name]\r\nMedia link: @image_data.body.meta.download_url" <>
197211
_,
198-
buttons: [
199-
{"edd_got_it", "edd_got_it"},
200-
{"edd_month", "edd_month"},
201-
{"eddr_unknown", "eddr_unknown"}
202-
]
212+
# buttons: button_labels(["Got it!", "Update due date", "How to calculate it"])
213+
# buttons: [
214+
# {"edd_got_it", "edd_got_it"},
215+
# {"edd_month", "edd_month"},
216+
# {"eddr_unknown", "eddr_unknown"}
217+
# ]
203218
})
204219
|> FlowTester.send("edd_got_it")
205220
|> receive_message(%{
@@ -213,15 +228,16 @@ defmodule EDDRemindersTest do
213228
|> FlowTester.set_contact_properties(%{"data_preference" => "text only"})
214229
|> FlowTester.start()
215230
|> receive_message(%{
216-
# text: "[DEBUG]\r\nTemplate edd_reminder_2041 sent with language en_US.\r\nBody parameters: [@name]\r\n\r\nThe buttons represented" <> _,
217231
text:
218-
"[DEBUG]\r\nTemplate @body.whatsapp_template_name sent with language en_US.\r\nBody parameters: [@name]\r\n\r\nThe buttons represented here are not necessarily the same as the ones in the real template. Please double check the template buttons when running the flow in a real-world scenario." <>
232+
"[DEBUG]\r\nTemplate @submission_name sent with language en_US.\r\nBody parameters: [@name]\r\n\r\nThe buttons represented here are not necessarily the same as the ones in the real template. Please double check the template buttons when running the flow in a real-world scenario." <>
219233
_,
220-
buttons: [
221-
{"edd_got_it", "edd_got_it"},
222-
{"edd_month", "edd_month"},
223-
{"eddr_unknown", "eddr_unknown"}
224-
]
234+
# buttons: button_labels(["Got it!", "Month", "Unknown"]),
235+
# buttons: button_labels(["Got it!", "Update due date", "How to calculate it"])
236+
# buttons: [
237+
# {"edd_got_it", "edd_got_it"},
238+
# {"edd_month", "edd_month"},
239+
# {"eddr_unknown", "eddr_unknown"}
240+
# ]
225241
})
226242
|> FlowTester.send("edd_got_it")
227243
|> receive_message(%{
@@ -231,33 +247,34 @@ defmodule EDDRemindersTest do
231247
end
232248

233249
# TODO: Figure out why this doesn't work - it probably has something to do with the fact that we're sending a template
234-
# test "Got it error", %{flow: flow} do
235-
# flow
236-
# |> FlowTester.start()
237-
# |> receive_message(%{
238-
# text: "[DEBUG]\r\nTemplate edd_reminder_2041 sent with language en_US.\r\nBody parameters: [@name]\r\nMedia link: @image_data.body.meta.download_url" <> _,
239-
# buttons: [{"edd_got_it", "edd_got_it"}, {"edd_month", "edd_month"}, {"eddr_unknown", "eddr_unknown"}],
240-
# })
241-
# |> FlowTester.send(button_label: "nope")
242-
# |> receive_message(%{
243-
# text: "I don't understand your reply.\r\n\r\n👇🏽 Please try that again and respond by tapping a button.",
244-
# buttons: [{"edd_got_it", "edd_got_it"}, {"edd_month", "edd_month"}, {"eddr_unknown", "eddr_unknown"}],
245-
# })
246-
# end
250+
test "Got it error", %{flow: flow} do
251+
flow
252+
|> FlowTester.start()
253+
|> receive_message(%{
254+
text: "[DEBUG]\r\nTemplate @submission_name sent with language en_US.\r\nBody parameters: [@name]\r\nMedia link: @image_data.body.meta.download_url" <> _,
255+
# buttons: button_labels(["Got it!", "Update due date", "How to calculate it"]),
256+
# buttons: [{"edd_got_it", "edd_got_it"}, {"edd_month", "edd_month"}, {"eddr_unknown", "eddr_unknown"}],
257+
})
258+
|> FlowTester.send("nope")
259+
|> receive_message(%{
260+
text: "I don't understand your reply.\r\n\r\n👇🏽 Please try that again and respond by tapping a button.",
261+
# buttons: button_labels(["Got it!", "Month", "Unknown"]),
262+
})
263+
end
247264

248265
test "Got it -> Main menu", %{flow: flow} do
249266
flow
250267
|> FlowTester.start()
251268
|> receive_message(%{
252-
# text: "[DEBUG]\r\nTemplate edd_reminder_2041 sent with language en_US.\r\nBody parameters: [@name]\r\nMedia link: @image_data.body.meta.download_url" <> _,
253269
text:
254-
"[DEBUG]\r\nTemplate @body.whatsapp_template_name sent with language en_US.\r\nBody parameters: [@name]\r\nMedia link: @image_data.body.meta.download_url\r\n\r\nThe buttons represented here are not necessarily the same as the ones in the real template. Please double check the template buttons when running the flow in a real-world scenario." <>
270+
"[DEBUG]\r\nTemplate @submission_name sent with language en_US.\r\nBody parameters: [@name]\r\nMedia link: @image_data.body.meta.download_url\r\n\r\nThe buttons represented here are not necessarily the same as the ones in the real template. Please double check the template buttons when running the flow in a real-world scenario." <>
255271
_,
256-
buttons: [
257-
{"edd_got_it", "edd_got_it"},
258-
{"edd_month", "edd_month"},
259-
{"eddr_unknown", "eddr_unknown"}
260-
]
272+
# buttons: button_labels(["Got it!", "Update due date", "How to calculate it"])
273+
# buttons: [
274+
# {"edd_got_it", "edd_got_it"},
275+
# {"edd_month", "edd_month"},
276+
# {"eddr_unknown", "eddr_unknown"}
277+
# ]
261278
})
262279
|> FlowTester.send("edd_got_it")
263280
|> receive_message(%{

Onboarding/QA/tests/exploring-tour_test.exs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ defmodule ExploringTourTest do
3131
end
3232
]
3333

34+
# The onboarding.csv content file contains a page that references a Whatsapp Template.
35+
# We don't support importing of templates yet, so for now we add it manually
36+
FakeCMS.add_template(wh_pid, %WATemplate{
37+
id: "1",
38+
slug: "mnch_onboarding_edd_reminder",
39+
category: "MARKETING",
40+
image: nil,
41+
message: "This is a test message",
42+
buttons: [],
43+
example_values: [],
44+
submission_status: "",
45+
submission_name: "",
46+
submission_result: ""
47+
})
48+
3449
# The content for these tests.
3550
assert :ok = Helpers.import_content_csv(wh_pid, "onboarding", import_opts)
3651

Onboarding/QA/tests/forms_test.exs

Lines changed: 0 additions & 126 deletions
This file was deleted.

Onboarding/QA/tests/intro-and-welcome_test.exs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,21 @@ defmodule IntroAndWelcomeTest do
4545
end
4646
]
4747

48+
# The onboarding.csv content file contains a page that references a Whatsapp Template.
49+
# We don't support importing of templates yet, so for now we add it manually
50+
FakeCMS.add_template(wh_pid, %WATemplate{
51+
id: "1",
52+
slug: "mnch_onboarding_edd_reminder",
53+
category: "MARKETING",
54+
image: nil,
55+
message: "This is a test message",
56+
buttons: [],
57+
example_values: [],
58+
submission_status: "",
59+
submission_name: "",
60+
submission_result: ""
61+
})
62+
4863
# The content for these tests.
4964
assert :ok = Helpers.import_content_csv(wh_pid, "onboarding", import_opts)
5065

Onboarding/QA/tests/menu-non-personalised_test.exs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,21 @@ defmodule MenuNonPersonalisedTest do
3030
end
3131
]
3232

33+
# The onboarding.csv content file contains a page that references a Whatsapp Template.
34+
# We don't support importing of templates yet, so for now we add it manually
35+
FakeCMS.add_template(wh_pid, %WATemplate{
36+
id: "1",
37+
slug: "mnch_onboarding_edd_reminder",
38+
category: "MARKETING",
39+
image: nil,
40+
message: "This is a test message",
41+
buttons: [],
42+
example_values: [],
43+
submission_status: "",
44+
submission_name: "",
45+
submission_result: ""
46+
})
47+
3348
# The content for these tests.
3449
assert :ok = Helpers.import_content_csv(wh_pid, "onboarding", import_opts)
3550

0 commit comments

Comments
 (0)