Skip to content

Commit

Permalink
Merge pull request #22 from praekeltfoundation/bugfix/DELTA-1316/fix-…
Browse files Browse the repository at this point in the history
…next-message-button-state

Fix state for go_to_page and use whatsapp titles
  • Loading branch information
rudigiesler authored Oct 1, 2024
2 parents fcdf359 + 530117b commit e52f95f
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 10 deletions.
13 changes: 8 additions & 5 deletions Browsable FAQs/QA/flows/Browsable FAQs.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ card IndexMenu, then: FetchContent do
headers: [
["Authorization", "Token @global.config.contentrepo_token"]
],
query: [["child_of", "@selected_index_id"]]
query: [["child_of", "@selected_index_id"], ["whatsapp", "true"]]
)
index_menu_items = map(page_list_data.body.results, &[&1.title, &1.title])
Expand Down Expand Up @@ -202,7 +202,8 @@ card DisplayContent when content_data.body.has_children do
["Authorization", "Token @global.config.contentrepo_token"]
],
query: [
["child_of", "@selected_content_id"]
["child_of", "@selected_content_id"],
["whatsapp", "true"]
]
)
Expand Down Expand Up @@ -297,7 +298,7 @@ card DisplayContent when isnumber(content_data.body.body.text.value.image), then
get(
"https://content-repo-api-qa.prk-k8s.prd-p6t.org/api/v2/images/@image_id/",
headers: [
["Authorization", "Token @globals.config.contentrepo_token"]
["Authorization", "Token @global.config.contentrepo_token"]
]
)
Expand Down Expand Up @@ -335,7 +336,7 @@ card SelectRelatedPage, then: GetVariation do
headers: [
["Authorization", "Token @global.config.contentrepo_token"]
],
query: [["child_of", "@content_data.body.meta.parent.id"]]
query: [["child_of", "@content_data.body.meta.parent.id"], ["whatsapp", "true"]]
)
end
Expand Down Expand Up @@ -410,13 +411,15 @@ card ActionButton when selected_button.type == "go_to_page" do
query: [["whatsapp", "true"], ["message", "@message"]]
)
selected_content_name = content_data.body.title
page_list_data =
get(
"https://content-repo-api-qa.prk-k8s.prd-p6t.org/api/v2/pages/",
headers: [
["Authorization", "Token @global.config.contentrepo_token"]
],
query: [["child_of", "@content_data.body.meta.parent.id"]]
query: [["child_of", "@content_data.body.meta.parent.id"], ["whatsapp", "true"]]
)
then(GetVariation)
Expand Down
2 changes: 1 addition & 1 deletion Browsable FAQs/QA/flows_json/Browsable FAQs.json

Large diffs are not rendered by default.

32 changes: 28 additions & 4 deletions Browsable FAQs/QA/tests/browsable_faqs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,20 @@ defmodule BrowsableFAQsTest do
title: "Leaf Page 1",
wa_messages: [
%WAMsg{
message: "Test leaf content page"
message: "Test leaf content page",
buttons: [%Btn.Next{title: "Next"}]
},
%WAMsg{
message: "Last message"
}
]
}

parent_page = %ContentPage{
parent: "topic-1",
slug: "parent-page-1",
title: "Parent Page 1"
title: "Parent Page 1",
wa_messages: [%WAMsg{message: "Show this in whatsapp menus"}]
}

nested_leaf_page = %ContentPage{
Expand Down Expand Up @@ -213,7 +218,7 @@ defmodule BrowsableFAQsTest do
|> FlowTester.send("Leaf Page 1")
|> receive_message(%{
text: "Leaf Page 1\nTest leaf content page\n",
buttons: [{"Main Menu", "Main Menu"}]
buttons: [{"Next", "Next"}]
})
end

Expand All @@ -225,6 +230,8 @@ defmodule BrowsableFAQsTest do
|> receive_message(%{})
|> FlowTester.send("Leaf Page 1")
|> receive_message(%{})
|> FlowTester.send("Next")
|> receive_message(%{})
|> FlowTester.send("Main Menu")
|> receive_message(%{text: "TODO: Exit"})
end
Expand Down Expand Up @@ -283,10 +290,27 @@ defmodule BrowsableFAQsTest do
|> FlowTester.send("Another page")
|> receive_message(%{
text: "Leaf Page 1\nTest leaf content page\n",
buttons: [{"Main Menu", "Main Menu"}]
buttons: [{"Next", "Next"}]
})
end

test "next_message buttons should work after go_to_page button" do
# Picked up by QA, DELTA-1316
setup_flow()
|> FlowTester.start()
|> receive_message(%{})
|> FlowTester.send("Topic 1")
|> receive_message(%{})
|> FlowTester.send("Multiple Messages Leaf")
|> receive_message(%{})
|> FlowTester.send("Next")
|> receive_message(%{})
|> FlowTester.send("Another page")
|> receive_message(%{})
|> FlowTester.send("Next")
|> receive_message(%{text: "Leaf Page 1\nLast message\n"})
end

# TODO: Add media support to FakeCMS
# test "give the user a choice when both image and document is present" do
# setup_flow()
Expand Down

0 comments on commit e52f95f

Please sign in to comment.