Skip to content

Commit 0d70681

Browse files
authored
Merge pull request #80 from praekeltfoundation/update-flowtester
Update flow tester
2 parents 59bd8d1 + 8b9eb1c commit 0d70681

5 files changed

Lines changed: 104 additions & 19 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
uses: actions/checkout@v4
3030
with:
3131
repository: praekeltfoundation/flow_tester
32-
ref: v0.5.1
32+
ref: v0.6.1
3333
path: flow_tester
3434
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
3535

Onboarding/QA/flows_json/profile-pregnancy-health.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

Onboarding/QA/tests/edd-reminders_test.exs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ defmodule EDDRemindersTest do
3737
id: "1",
3838
slug: "mnch_onboarding_edd_reminder",
3939
category: "MARKETING",
40-
image: nil,
40+
image: "https://prk-content-repo-qa-public.s3.af-south-1.amazonaws.com/original_images/EDD_Reminder.png",
4141
message: "This is a test message",
4242
buttons: [],
4343
example_values: [],
@@ -118,6 +118,7 @@ defmodule EDDRemindersTest do
118118
TextTransform.normalise_newlines(trim_trailing_spaces: true)
119119
)
120120
|> FlowTester.set_global_dict("config", %{"contentrepo_token" => auth_token})
121+
#|> FlowTester.set_contact_properties(%{"data_preference" => "text only"})
121122

122123
%{flow: flow}
123124
end
@@ -193,9 +194,10 @@ defmodule EDDRemindersTest do
193194
flow
194195

195196
|> FlowTester.start()
197+
|> FlowTester.set_contact_properties(%{"data_preference" => "text only"})
196198
|> receive_message(%{
197199
text:
198-
"[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." <>
200+
"[DEBUG]\r\nTemplate @submission_name sent with language en_US.\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." <>
199201
_,
200202
# buttons: [
201203
# {"edd_got_it", "edd_got_it"},
@@ -213,11 +215,11 @@ defmodule EDDRemindersTest do
213215

214216
test "Got it (pt)", %{flow: flow} do
215217
flow
216-
|> FlowTester.set_contact_properties(%{"language" => "por"})
218+
|> FlowTester.set_contact_properties(%{"language" => "por", "data_preference" => "text only"})
217219
|> FlowTester.start()
218220
|> receive_message(%{
219221
text:
220-
"[DEBUG]\r\nTemplate @submission_name sent with language pt_PT.\r\nBody parameters: [@name]\r\nMedia link: @image_data.body.meta.download_url" <>
222+
"[DEBUG]\r\nTemplate @submission_name sent with language pt_PT.\r\n" <>
221223
_,
222224
# buttons: button_labels(["Got it!", "Update due date", "How to calculate it"])
223225
# buttons: [
@@ -239,7 +241,7 @@ defmodule EDDRemindersTest do
239241
|> FlowTester.start()
240242
|> receive_message(%{
241243
text:
242-
"[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." <>
244+
"[DEBUG]\r\nTemplate @submission_name sent with language en_US.\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." <>
243245
_,
244246
# buttons: button_labels(["Got it!", "Month", "Unknown"]),
245247
# buttons: button_labels(["Got it!", "Update due date", "How to calculate it"])
@@ -256,12 +258,12 @@ defmodule EDDRemindersTest do
256258
})
257259
end
258260

259-
# TODO: Figure out why this doesn't work - it probably has something to do with the fact that we're sending a template
260261
test "Got it error", %{flow: flow} do
261262
flow
263+
|> FlowTester.set_contact_properties(%{"data_preference" => "text only"})
262264
|> FlowTester.start()
263265
|> receive_message(%{
264-
text: "[DEBUG]\r\nTemplate @submission_name sent with language en_US.\r\nBody parameters: [@name]\r\nMedia link: @image_data.body.meta.download_url" <> _,
266+
text: "[DEBUG]\r\nTemplate @submission_name sent with language en_US.\r\n" <> _,
265267
# buttons: button_labels(["Got it!", "Update due date", "How to calculate it"]),
266268
# buttons: [{"edd_got_it", "edd_got_it"}, {"edd_month", "edd_month"}, {"eddr_unknown", "eddr_unknown"}],
267269
})
@@ -274,10 +276,11 @@ defmodule EDDRemindersTest do
274276

275277
test "Got it -> Main menu", %{flow: flow} do
276278
flow
279+
|> FlowTester.set_contact_properties(%{"data_preference" => "text only"})
277280
|> FlowTester.start()
278281
|> receive_message(%{
279282
text:
280-
"[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." <>
283+
"[DEBUG]\r\nTemplate @submission_name sent with language en_US.\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." <>
281284
_,
282285
# buttons: button_labels(["Got it!", "Update due date", "How to calculate it"])
283286
# buttons: [
@@ -298,6 +301,7 @@ defmodule EDDRemindersTest do
298301

299302
test "EDD Unknown", %{flow: flow} do
300303
flow
304+
|> FlowTester.set_contact_properties(%{"data_preference" => "text only"})
301305
|> FlowTester.start()
302306
|> receive_message(%{})
303307
|> FlowTester.send("eddr_unknown")
@@ -310,6 +314,7 @@ defmodule EDDRemindersTest do
310314

311315
test "EDD Unknown error", %{flow: flow} do
312316
flow
317+
|> FlowTester.set_contact_properties(%{"data_preference" => "text only"})
313318
|> FlowTester.start()
314319
|> receive_message(%{})
315320
|> FlowTester.send("eddr_unknown")
@@ -328,6 +333,7 @@ defmodule EDDRemindersTest do
328333

329334
test "EDD Unknown -> I'll do this later", %{flow: flow} do
330335
flow
336+
|> FlowTester.set_contact_properties(%{"data_preference" => "text only"})
331337
|> FlowTester.start()
332338
|> receive_message(%{})
333339
|> FlowTester.send("eddr_unknown")
@@ -345,6 +351,7 @@ defmodule EDDRemindersTest do
345351
{list_of_months, _edd_confirmation_text, _full_edd} = get_edd(months, month_words)
346352

347353
flow
354+
|> FlowTester.set_contact_properties(%{"data_preference" => "text only"})
348355
|> FlowTester.start()
349356
|> receive_message(%{})
350357
|> FlowTester.send("eddr_unknown")
@@ -358,6 +365,7 @@ defmodule EDDRemindersTest do
358365

359366
test "I'll do this later error", %{flow: flow} do
360367
flow
368+
|> FlowTester.set_contact_properties(%{"data_preference" => "text only"})
361369
|> FlowTester.start()
362370
|> receive_message(%{})
363371
|> FlowTester.send("eddr_unknown")
@@ -374,6 +382,7 @@ defmodule EDDRemindersTest do
374382

375383
test "I'll do this later -> main menu", %{flow: flow} do
376384
flow
385+
|> FlowTester.set_contact_properties(%{"data_preference" => "text only"})
377386
|> FlowTester.start()
378387
|> receive_message(%{})
379388
|> FlowTester.send("eddr_unknown")
@@ -391,6 +400,7 @@ defmodule EDDRemindersTest do
391400
@tag :temptest
392401
test "I'll do this later -> go to health guide", %{flow: flow} do
393402
flow
403+
|> FlowTester.set_contact_properties(%{"data_preference" => "text only"})
394404
|> FlowTester.start()
395405
|> receive_message(%{})
396406
|> FlowTester.send("eddr_unknown")
@@ -599,7 +609,7 @@ defmodule EDDRemindersTest do
599609
end
600610

601611
test "edd day then feb 29 is valid", %{flow: flow} do
602-
fake_time = ~U[2023-02-28 00:00:00Z]
612+
fake_time = ~U[2024-02-28 00:00:00Z]
603613
months = get_months(fake_time)
604614
month_words = get_month_words(months)
605615
{list_of_months, edd_confirmation_text, _full_edd} = get_edd(months, month_words, 29, 0)
@@ -617,7 +627,7 @@ defmodule EDDRemindersTest do
617627
|> FlowTester.send("29")
618628
|> receive_message(%{
619629
text:
620-
"I’ve updated your baby’s estimated due date to: 2023-02-29\r\n\r\nWell done on taking care of yours and baby’s health 🫶🏽",
630+
"I’ve updated your baby’s estimated due date to: 2024-02-29\r\n\r\nWell done on taking care of yours and baby’s health 🫶🏽",
621631
# text: ^edd_confirmation_text,
622632
buttons: button_labels(["See main menu"])
623633
})

Onboarding/QA/tests/profile-hcw_test.exs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ defmodule ProfileHCWTest do
3131
]
3232

3333
# 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
34+
# We don't support importing of templates yet, so for now we add it manually
3535
FakeCMS.add_template(wh_pid, %WATemplate{
3636
id: "1",
3737
slug: "mnch_onboarding_edd_reminder",
@@ -82,6 +82,7 @@ defmodule ProfileHCWTest do
8282
test "100% complete", %{flow: flow} do
8383
flow
8484
|> Helpers.init_contact_fields()
85+
|> FlowTester.set_contact_properties(%{"data_preference" => "text only"})
8586
|> FlowTester.start()
8687
|> contact_matches(%{"profile_completion" => "0%", "checkpoint" => "hcw_profile_0"})
8788
|> receive_message(%{

Onboarding/QA/tests/profile-pregnancy-health_test.exs

Lines changed: 80 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,27 @@ defmodule ProfilePregnancyHealthTest do
102102
"https://prk-content-repo-qa-public.s3.af-south-1.amazonaws.com/original_images/Baby_birth-amico_2.png"
103103
}
104104

105+
image_mood_swings = %Image{
106+
id: 14,
107+
title: "Mood swings",
108+
download_url:
109+
"https://prk-content-repo-qa-public.s3.af-south-1.amazonaws.com/original_images/Mood_swings.png"
110+
}
111+
112+
image_profile_progess_100 = %Image{
113+
id: 15,
114+
title: "Profile progress 100",
115+
download_url:
116+
"https://prk-content-repo-qa-public.s3.af-south-1.amazonaws.com/original_images/Profile_progress_100.png"
117+
}
118+
119+
image_edd_unknown = %Image{
120+
id: 16,
121+
title: "EDD unknown",
122+
download_url:
123+
"https://prk-content-repo-qa-public.s3.af-south-1.amazonaws.com/original_images/EDD_Unknown.png"
124+
}
125+
105126
assert :ok =
106127
FakeCMS.add_images(wh_pid, [
107128
image,
@@ -112,11 +133,14 @@ defmodule ProfilePregnancyHealthTest do
112133
image_pregnancy_stages_rafiki,
113134
image_pregnancy_stages_rafiki_1,
114135
image_profile_progress_50,
136+
image_profile_progess_100,
115137
image_pregnancy_stages_pana_1,
116138
image_pregnancy_stages_cute,
117139
image_pregnancy_stages_cute_1,
118140
image_baby_birth_amico_1,
119-
image_baby_birth_amico_2
141+
image_baby_birth_amico_2,
142+
image_mood_swings,
143+
image_edd_unknown
120144
])
121145

122146
# The various index pages aren't in the content sheet, so we need to add them manually.
@@ -141,7 +165,7 @@ defmodule ProfilePregnancyHealthTest do
141165
]
142166

143167
# The onboarding.csv content file contains a page that references a Whatsapp Template.
144-
# We don't support importing of templates yet, so for now we add it manually
168+
# We don't support importing of templates yet, so for now we add it manually
145169
FakeCMS.add_template(wh_pid, %WATemplate{
146170
id: "1",
147171
slug: "mnch_onboarding_edd_reminder",
@@ -158,8 +182,6 @@ defmodule ProfilePregnancyHealthTest do
158182
# The content for these tests.
159183
assert :ok = Helpers.import_content_csv(wh_pid, "onboarding", import_opts)
160184

161-
162-
163185
# Variations
164186
var_facts = Helpers.pages_from_content_csv("variations-facts", import_opts)
165187
assert :ok = FakeCMS.add_pages(wh_pid, var_facts)
@@ -170,8 +192,11 @@ defmodule ProfilePregnancyHealthTest do
170192
# Add images to pages
171193
FakeCMS.add_img_to_page(wh_pid, "mnch_onboarding_content_intro", 0, image_topics_for_you.id)
172194
FakeCMS.add_img_to_page(wh_pid, "mnch_onboarding_topics_01", 0, image_topics_for_you.id)
195+
FakeCMS.add_img_to_page(wh_pid, "mnch_onboarding_article_topic_01", 0, image_mood_swings.id)
173196
FakeCMS.add_img_to_page(wh_pid, "mnch_onboarding_content_intro", 0, image_topics_for_you.id)
174197

198+
FakeCMS.add_img_to_page(wh_pid, "mnch_onboarding_article_topic_01_secondary", 0, image_loading_1.id)
199+
175200
FakeCMS.add_img_to_page(
176201
wh_pid,
177202
"mnch_onboarding_curious_content_intro",
@@ -252,6 +277,13 @@ defmodule ProfilePregnancyHealthTest do
252277
image_baby_birth_amico_2.id
253278
)
254279

280+
FakeCMS.add_img_to_page(
281+
wh_pid,
282+
"mnch_onboarding_profile_progress_25",
283+
0,
284+
image_profile_progress_50.id
285+
)
286+
255287
FakeCMS.add_img_to_page(
256288
wh_pid,
257289
"mnch_onboarding_profile_progress_25_secondary_",
@@ -280,6 +312,48 @@ defmodule ProfilePregnancyHealthTest do
280312
image_profile_progress_50.id
281313
)
282314

315+
FakeCMS.add_img_to_page(
316+
wh_pid,
317+
"mnch_onboarding_profile_progress_100",
318+
0,
319+
image_profile_progess_100.id
320+
)
321+
322+
FakeCMS.add_img_to_page(
323+
wh_pid,
324+
"mnch_onboarding_profile_progress_100_generic",
325+
0,
326+
image_profile_progess_100.id
327+
)
328+
329+
FakeCMS.add_img_to_page(
330+
wh_pid,
331+
"mnch_onboarding_profile_progress_100_hcw",
332+
0,
333+
image_profile_progess_100.id
334+
)
335+
336+
FakeCMS.add_img_to_page(
337+
wh_pid,
338+
"mnch_onboarding_edd_unknown",
339+
0,
340+
image_edd_unknown.id
341+
)
342+
343+
FakeCMS.add_img_to_page(
344+
wh_pid,
345+
"mnch_onboarding_edd_unknown_1",
346+
0,
347+
image_edd_unknown.id
348+
)
349+
350+
FakeCMS.add_img_to_page(
351+
wh_pid,
352+
"mnch_onboarding_edd_unknown_secondary",
353+
0,
354+
image_edd_unknown.id
355+
)
356+
283357
# Return the adapter.
284358
FakeCMS.wh_adapter(wh_pid)
285359
end
@@ -1172,7 +1246,7 @@ defmodule ProfilePregnancyHealthTest do
11721246
end
11731247

11741248
test "edd day then feb 29 is valid", %{flow: flow} do
1175-
fake_time = ~U[2023-02-28 00:00:00Z]
1249+
fake_time = ~U[2024-02-28 00:00:00Z]
11761250
months = get_months(fake_time)
11771251
month_words = get_month_words(months)
11781252
{list_of_months, edd_confirmation_text, _full_edd} = get_edd(months, month_words, 29, 0)
@@ -3289,7 +3363,7 @@ defmodule ProfilePregnancyHealthTest do
32893363
end
32903364

32913365
test "edd day then feb 29 is valid", %{flow: flow} do
3292-
fake_time = ~U[2023-02-28 00:00:00Z]
3366+
fake_time = ~U[2024-02-28 00:00:00Z]
32933367
months = get_months(fake_time)
32943368
month_words = get_month_words(months)
32953369
{list_of_months, edd_confirmation_text, _full_edd} = get_edd(months, month_words, 29, 0)

0 commit comments

Comments
 (0)