Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add temporary write result hardcoding #24

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Save answer for skipped questions
rudigiesler committed Oct 16, 2024

Verified

This commit was signed with the committer’s verified signature.
commit 5d6a1f6943886bb408443dff0a46db488547daaa
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@ jobs:
uses: actions/checkout@v4
with:
repository: praekeltfoundation/flow_tester
ref: v0.3.4
ref: v0.3.5
path: flow_tester
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Check formatting
31 changes: 18 additions & 13 deletions Forms/QA/flows/DMA Form.md
Original file line number Diff line number Diff line change
@@ -342,7 +342,7 @@ card QuestionError when has_all_members(keywords, [@question_response]), then: C
text("@explainer")
end

card QuestionError when @question_response == lower("skip"), then: CheckEnd do
card QuestionError when @question_response == lower("skip"), then: StoreResponse do
# If they skip a question we should
# - record the answer as "skip"
# - increment skip count
@@ -435,7 +435,7 @@ card MultiselectError when has_all_members(keywords, [@question_response]),
text("@explainer")
end

card MultiselectError when lower(@question_response) == "skip", then: GetQuestion do
card MultiselectError when lower(@question_response) == "skip", then: CheckEndMultiselect do
# If they skip a question we should
# - record the answer as "skip"
# - increment skip_count
@@ -540,7 +540,7 @@ card QuestionResponse
question_num = count(questions)
end

card QuestionResponse when lower("@question_response") == "skip", then: CheckEnd do
card QuestionResponse when lower("@question_response") == "skip", then: StoreResponse do
# If they skip a question we should
# - record the answer as "skip"
# - increment skip_count
@@ -578,40 +578,45 @@ These cards are to configure storing the answers of the Form in contact fields.
```stack
card StoreResponse when question_id == "dma-do-things" do
# TODO: remove this hard-coding once we can have dynamic labels for flow results
answer = find(question.answers, &(&1.answer == question_response))
write_result("mnch_onboarding_dma_form_dma-do-things", "@answer.semantic_id")
answer = filter(question.answers, &(&1.answer == question_response))
semantic_id = if(count(answer) == 0, "skip", answer[0].semantic_id)
write_result("mnch_onboarding_dma_form_dma-do-things", semantic_id)
update_contact(dma_01: "@question_response")
then(CheckEnd)
end

card StoreResponse when question_id == "dma-medical-care" do
# TODO: remove this hard-coding once we can have dynamic labels for flow results
answer = find(question.answers, &(&1.answer == question_response))
write_result("mnch_onboarding_dma_form_dma-medical-care", "@answer.semantic_id")
answer = filter(question.answers, &(&1.answer == question_response))
semantic_id = if(count(answer) == 0, "skip", answer[0].semantic_id)
write_result("mnch_onboarding_dma_form_dma-medical-care", semantic_id)
update_contact(dma_02: "@question_response")
then(CheckEnd)
end

card StoreResponse when question_id == "dma-sharing" do
# TODO: remove this hard-coding once we can have dynamic labels for flow results
answer = find(question.answers, &(&1.answer == question_response))
write_result("mnch_onboarding_dma_form_dma-sharing", "@answer.semantic_id")
answer = filter(question.answers, &(&1.answer == question_response))
semantic_id = if(count(answer) == 0, "skip", answer[0].semantic_id)
write_result("mnch_onboarding_dma_form_dma-sharing", semantic_id)
update_contact(dma_03: "@question_response")
then(CheckEnd)
end

card StoreResponse when question_id == "dma-medical-advice" do
# TODO: remove this hard-coding once we can have dynamic labels for flow results
answer = find(question.answers, &(&1.answer == question_response))
write_result("mnch_onboarding_dma_form_dma-medical-advice", "@answer.semantic_id")
answer = filter(question.answers, &(&1.answer == question_response))
semantic_id = if(count(answer) == 0, "skip", answer[0].semantic_id)
write_result("mnch_onboarding_dma_form_dma-medical-advice", semantic_id)
update_contact(dma_04: "@question_response")
then(CheckEnd)
end

card StoreResponse when question_id == "dma-find-solutions" do
# TODO: remove this hard-coding once we can have dynamic labels for flow results
answer = find(question.answers, &(&1.answer == question_response))
write_result("mnch_onboarding_dma_form_dma-find-solutions", "@answer.semantic_id")
answer = filter(question.answers, &(&1.answer == question_response))
semantic_id = if(count(answer) == 0, "skip", answer[0].semantic_id)
write_result("mnch_onboarding_dma_form_dma-find-solutions", semantic_id)
update_contact(dma_05: "@question_response")
then(CheckEnd)
end
2 changes: 1 addition & 1 deletion Forms/QA/flows_json/DMA Form.json

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions Forms/QA/tests/dma_form_test.exs
Original file line number Diff line number Diff line change
@@ -26,6 +26,17 @@ defmodule DMAFormTest do
]
})

FakeCMS.add_page(wh_pid, %ContentPage{
parent: "home",
slug: "skip-result-page",
title: "Skip Result Page",
wa_messages: [
%WAMsg{
message: "You are seeing this message because you skipped an answer."
}
]
})

FakeCMS.add_form(wh_pid, %Form{
id: 1,
title: "DMA_Form_01",
@@ -38,6 +49,7 @@ defmodule DMAFormTest do
high_result_page: "mnch_onboarding_dma_results_high",
medium_inflection: 3.0,
skip_threshold: 1.0,
skip_high_result_page: "skip-result-page",
questions: [
%Forms.CategoricalQuestion{
question:
@@ -126,6 +138,18 @@ defmodule DMAFormTest do
])
end

test "store the results when a question is skipped" do
setup_flow()
|> FlowTester.start()
|> FlowStep.clear_messages()
|> FlowStep.clear_results()
|> FlowTester.send("skip")
|> receive_message(%{text: "You are seeing this message because you skipped an answer."})
|> results_match([
%Result{name: "mnch_onboarding_dma_form_dma-do-things", value: "skip"} | _
])
end

test "store the results when a form is completed" do
setup_flow()
|> FlowTester.start()