diff --git a/help_to_heat/frontdoor/schemas.py b/help_to_heat/frontdoor/schemas.py index 664b122a..06aee38d 100644 --- a/help_to_heat/frontdoor/schemas.py +++ b/help_to_heat/frontdoor/schemas.py @@ -598,30 +598,76 @@ "value": "No loft", }, ) -multichoice_options = ( +agreement_multichoice_options = ( { - "value": "Completely disagree", - "label": _("Completely disagree"), + "value": "Completely agree", + "label": _("Completely agree"), }, { - "value": "Disagree", - "label": _("Disagree"), + "value": "Agree", + "label": _("Agree"), }, { "value": "Neutral", "label": _("Neutral"), }, { - "value": "Agree", - "label": _("Agree"), + "value": "Disagree", + "label": _("Disagree"), }, { - "value": "Completely agree", - "label": _("Completely agree"), + "value": "Completely disagree", + "label": _("Completely disagree"), + }, +) + +satisfaction_multichoice_options = ( + { + "value": "Very satisfied", + "label": _("Very satisfied"), + }, + { + "value": "Somewhat satisfied", + "label": _("Somewhat satisfied"), + }, + { + "value": "Neither satisfied nor dissatisfied", + "label": _("Neither satisfied nor dissatisfied"), + }, + { + "value": "Somewhat dissatisfied", + "label": _("Somewhat dissatisfied"), + }, + { + "value": "Very dissatisfied", + "label": _("Very dissatisfied"), + }, +) + +service_usage_multichoice_options = ( + { + "value": "To find ways to reduce my energy bills", + "label": _("To find ways to reduce my energy bills"), + }, + { + "value": "To find ways to reduce my carbon emissions", + "label": _("To find ways to reduce my carbon emissions"), + }, + { + "value": "To find ways to install a specific measure in my home", + "label": _("To find ways to install a specific measure in my home"), + }, + { + "value": "To find ways to improve my EPC rating", + "label": _("To find ways to improve my EPC rating"), + }, + { + "value": "To find ways to make my home more comfortable", + "label": _("To find ways to make my home more comfortable"), }, { - "value": "Not sure / not applicable", - "label": _("Not sure / not applicable"), + "value": "Other", + "label": _("Other"), }, ) diff --git a/help_to_heat/frontdoor/views.py b/help_to_heat/frontdoor/views.py index 36349094..52575c4c 100644 --- a/help_to_heat/frontdoor/views.py +++ b/help_to_heat/frontdoor/views.py @@ -725,24 +725,46 @@ def get_context(self, session_id, *args, **kwargs): class FeedbackView(utils.MethodDispatcher): - def get(self, request, session_id=None, page_name=None): + def get(self, request, session_id=None, page_name=None, errors=None): template_name = "frontdoor/feedback.html" prev_page_url = page_name and reverse("frontdoor:page", kwargs=dict(session_id=session_id, page_name=page_name)) context = { "session_id": session_id, "page_name": page_name, "prev_url": prev_page_url, - "multichoice_options": schemas.multichoice_options, + "multichoice_options_agreement": schemas.agreement_multichoice_options, + "multichoice_options_satisfaction": schemas.satisfaction_multichoice_options, + "multichoice_options_service_usage": schemas.service_usage_multichoice_options, + "errors": errors, } return render(request, template_name=template_name, context=context) def post(self, request, session_id=None, page_name=None): data = request.POST.dict() - interface.api.feedback.save_feedback(session_id, page_name, data) - if session_id and page_name: - return redirect("frontdoor:feedback-thanks", session_id=session_id, page_name=page_name) + errors = self.validate(data) + if errors: + return self.get(request, session_id, page_name, errors=errors) + else: + interface.api.feedback.save_feedback(session_id, page_name, data) + if session_id and page_name: + return redirect("frontdoor:feedback-thanks", session_id=session_id, page_name=page_name) + + else: + return redirect("frontdoor:feedback-thanks") + + def validate(self, data): + if ( + (not data.get("satisfaction")) + and (not data.get("usage-reason")) + and (not data.get("guidance")) + and (not data.get("accuracy")) + and (not data.get("advice")) + and (data.get("more-detail") == "") + ): + errors = True + return errors else: - return redirect("frontdoor:feedback-thanks") + return None def feedback_thanks_view(request, session_id=None, page_name=None): diff --git a/help_to_heat/locale/cy/LC_MESSAGES/django.mo b/help_to_heat/locale/cy/LC_MESSAGES/django.mo index f658a049..0bbdce3f 100644 Binary files a/help_to_heat/locale/cy/LC_MESSAGES/django.mo and b/help_to_heat/locale/cy/LC_MESSAGES/django.mo differ diff --git a/help_to_heat/locale/cy/LC_MESSAGES/django.po b/help_to_heat/locale/cy/LC_MESSAGES/django.po index 3f1d036b..229ed8ce 100644 --- a/help_to_heat/locale/cy/LC_MESSAGES/django.po +++ b/help_to_heat/locale/cy/LC_MESSAGES/django.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-10-19 09:28+0000\n" +"POT-Creation-Date: 2023-10-25 12:01+0000\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -382,46 +382,86 @@ msgid "Bulb, now part of Octopus Energy" msgstr "Bulb, sydd bellach yn rhan o Octopus" #: help_to_heat/frontdoor/schemas.py:604 -msgid "Completely disagree" -msgstr "Anghytuno'n llwyr" +msgid "Completely agree" +msgstr "Cytuno'n llwyr" #: help_to_heat/frontdoor/schemas.py:608 -msgid "Disagree" -msgstr "Anghytuno" +msgid "Agree" +msgstr "Cytuno" #: help_to_heat/frontdoor/schemas.py:612 msgid "Neutral" msgstr "Niwtral" #: help_to_heat/frontdoor/schemas.py:616 -msgid "Agree" -msgstr "Cytuno" +msgid "Disagree" +msgstr "Anghytuno" #: help_to_heat/frontdoor/schemas.py:620 -msgid "Completely agree" -msgstr "Cytuno'n llwyr" +msgid "Completely disagree" +msgstr "Anghytuno'n llwyr" + +#: help_to_heat/frontdoor/schemas.py:627 +msgid "Very satisfied" +msgstr "Bodlon iawn" + +#: help_to_heat/frontdoor/schemas.py:631 +msgid "Somewhat satisfied" +msgstr "Eithaf bodlon" + +#: help_to_heat/frontdoor/schemas.py:635 +msgid "Neither satisfied nor dissatisfied" +msgstr "Ddim yn fodlon nac yn anfodlon" + +#: help_to_heat/frontdoor/schemas.py:639 +msgid "Somewhat dissatisfied" +msgstr "Eithaf anfodlon" + +#: help_to_heat/frontdoor/schemas.py:643 +msgid "Very dissatisfied" +msgstr "Anfodlon iawn" + +#: help_to_heat/frontdoor/schemas.py:650 +msgid "To find ways to reduce my energy bills" +msgstr "Dod o hyd i ffyrdd i leihau fy miliau ynni" + +#: help_to_heat/frontdoor/schemas.py:654 +msgid "To find ways to reduce my carbon emissions" +msgstr "Dod o hyd i ffyrdd i leihau fy allyriadau carbon" + +#: help_to_heat/frontdoor/schemas.py:658 +msgid "To find ways to install a specific measure in my home" +msgstr "Dod o hyd i ffyrdd o osod mesur penodol yn fy nghartref" + +#: help_to_heat/frontdoor/schemas.py:662 +msgid "To find ways to improve my EPC rating" +msgstr "Dod o hyd i ffyrdd i wella fy sgôr EPC" + +#: help_to_heat/frontdoor/schemas.py:666 +msgid "To find ways to make my home more comfortable" +msgstr "Dod o hyd i ffyrdd i wneud fy nghartref yn fwy cyffyrddus" -#: help_to_heat/frontdoor/schemas.py:624 -msgid "Not sure / not applicable" -msgstr "Ansicr / Amherthnasol" +#: help_to_heat/frontdoor/schemas.py:670 +msgid "Other" +msgstr "Arall" -#: help_to_heat/frontdoor/schemas.py:657 +#: help_to_heat/frontdoor/schemas.py:703 msgid "Please enter a valid UK postcode" msgstr "Rhowch god post dilys yn y Deyrnas Unedig" -#: help_to_heat/frontdoor/schemas.py:693 +#: help_to_heat/frontdoor/schemas.py:739 msgid "Invalid contact number" msgstr "Rhif ffôn annilys" -#: help_to_heat/frontdoor/schemas.py:701 +#: help_to_heat/frontdoor/schemas.py:747 msgid "Invalid email format" msgstr "Fformat ebost annilys" -#: help_to_heat/frontdoor/schemas.py:712 +#: help_to_heat/frontdoor/schemas.py:758 msgid "Energy Company Obligation 4" msgstr "Rhwymedigaeth Cwmni Ynni 4" -#: help_to_heat/frontdoor/schemas.py:713 +#: help_to_heat/frontdoor/schemas.py:759 msgid "Great British Insulation Scheme" msgstr "Cynllun Inswleiddio Mawr Prydain" @@ -545,7 +585,7 @@ msgstr "" "roi tic yn y blwch hwn" #: help_to_heat/templates/allauth/account/base.html:103 -#: help_to_heat/templates/frontdoor/base.html:183 +#: help_to_heat/templates/frontdoor/base.html:182 #: help_to_heat/templates/portal/base_generic_gov.html:164 msgid "©Crown copyright" msgstr "©Hawlfraint y Goron" @@ -587,7 +627,7 @@ msgstr "" "Inswleiddio Mawr Prydain - GOV.UK" #: help_to_heat/templates/frontdoor/accessibility-statement.html:11 -#: help_to_heat/templates/frontdoor/base.html:164 +#: help_to_heat/templates/frontdoor/base.html:163 msgid "Accessibility Statement" msgstr "Datganiad Hygyrchedd" @@ -908,11 +948,11 @@ msgstr "" msgid "Great British Insulation Scheme - GOV.UK" msgstr "Cynllun Inswleiddio Mawr Prydain - GOV.UK" -#: help_to_heat/templates/frontdoor/base.html:38 +#: help_to_heat/templates/frontdoor/base.html:37 msgid "Cookies we are using on our service" msgstr "Cwcis rydyn ni'n eu defnyddio ar ein gwasanaeth" -#: help_to_heat/templates/frontdoor/base.html:41 +#: help_to_heat/templates/frontdoor/base.html:40 msgid "" "We will use necessary cookies when you use this service to help you move " "around the site." @@ -920,7 +960,7 @@ msgstr "" "Byddwn yn defnyddio cwcis angenrheidiol wrth ichi ddefnyddio'r gwasanaeth " "yma, a hynny i'ch helpu i symud o amgylch y wefan." -#: help_to_heat/templates/frontdoor/base.html:44 +#: help_to_heat/templates/frontdoor/base.html:43 msgid "" "We will also use analytic cookies using Google Analytics to tell us how you " "got to our service, the pages you visit, and how long you spent on them. " @@ -935,55 +975,55 @@ msgstr "" "caniatáu i Google ddefnyddio na rhannu'r data am sut rydych chi'n " "defnyddio'r wefan yma ac mae'r data'n cael ei storio'n ddienw." -#: help_to_heat/templates/frontdoor/base.html:53 +#: help_to_heat/templates/frontdoor/base.html:52 msgid "Accept cookies" msgstr "Derbyn cwcis" -#: help_to_heat/templates/frontdoor/base.html:54 +#: help_to_heat/templates/frontdoor/base.html:53 msgid "Reject cookies" msgstr "Gwrthod cwcis" -#: help_to_heat/templates/frontdoor/base.html:55 +#: help_to_heat/templates/frontdoor/base.html:54 msgid "View cookies we use on this service" msgstr "Gweld y cwcis rydyn ni'n eu defnyddio ar y gwasanaeth yma" -#: help_to_heat/templates/frontdoor/base.html:62 +#: help_to_heat/templates/frontdoor/base.html:61 msgid "Skip to main content" msgstr "Neidio i'r prif gynnwys" -#: help_to_heat/templates/frontdoor/base.html:89 +#: help_to_heat/templates/frontdoor/base.html:88 msgid "Check eligibility for Great British Insulation Scheme" msgstr "Gwirio'ch Cymhwystra ar gyfer Cynllun Inswleiddio Mawr Prydain" -#: help_to_heat/templates/frontdoor/base.html:102 +#: help_to_heat/templates/frontdoor/base.html:101 msgid "This is a new service – your " msgstr "Gwasanaeth newydd yw hwn – bydd eich " -#: help_to_heat/templates/frontdoor/base.html:104 +#: help_to_heat/templates/frontdoor/base.html:103 msgid "feedback" msgstr "adborth" -#: help_to_heat/templates/frontdoor/base.html:104 +#: help_to_heat/templates/frontdoor/base.html:103 msgid " will help us to improve it." msgstr " yn ein helpu i'w wella." -#: help_to_heat/templates/frontdoor/base.html:154 +#: help_to_heat/templates/frontdoor/base.html:153 msgid "Support links" msgstr "Dolenni cymorth" -#: help_to_heat/templates/frontdoor/base.html:159 +#: help_to_heat/templates/frontdoor/base.html:158 msgid "Privacy Policy" msgstr "Polisi Preifatrwydd" -#: help_to_heat/templates/frontdoor/base.html:174 +#: help_to_heat/templates/frontdoor/base.html:173 msgid "All content is available under the " msgstr "Mae'r cynnwys i gyd ar gael o dan " -#: help_to_heat/templates/frontdoor/base.html:176 +#: help_to_heat/templates/frontdoor/base.html:175 msgid "Open Government Licence v3.0" msgstr "Drwydded Llywodraeth Agored v3.0" -#: help_to_heat/templates/frontdoor/base.html:177 +#: help_to_heat/templates/frontdoor/base.html:176 msgid ", except where otherwise stated" msgstr ", ac eithrio lle nodir fel arall" @@ -1477,49 +1517,60 @@ msgstr "" msgid "Help us improve the service" msgstr "Helpwch ni i wella'r gwasanaeth" -#: help_to_heat/templates/frontdoor/feedback.html:23 -msgid "" -"I found this service useful for learning about government energy efficiency " -"support." -msgstr "" -"Roedd y gwasanaeth yma’n fuddiol imi ddysgu am gymorth effeithlonrwydd " -"ynni'r llywodraeth." +#: help_to_heat/templates/frontdoor/feedback.html:22 +#: help_to_heat/templates/macros.html:77 +msgid "There is a problem" +msgstr "Mae yna broblem" #: help_to_heat/templates/frontdoor/feedback.html:27 -#: help_to_heat/templates/frontdoor/feedback.html:45 -#: help_to_heat/templates/frontdoor/feedback.html:64 -msgid "How much do you agree with the statement above?" -msgstr "I ba raddau rydych chi'n cytuno â'r gosodiad uchod?" +msgid "Please answer at least one question before submitting feedback" +msgstr "Atebwch o leiaf un cwestiwn cyn cyflwyno adborth" + +#: help_to_heat/templates/frontdoor/feedback.html:40 +msgid "Overall, how satisfied are you with this online service?" +msgstr "Yn gyffredinol, pa mor fodlon rydych chi â'r gwasanaeth ar-lein yma?" -#: help_to_heat/templates/frontdoor/feedback.html:41 +#: help_to_heat/templates/frontdoor/feedback.html:53 +msgid "Why did you use this service today?" +msgstr "Pam defnyddioch chi'r gwasanaeth yma heddiw?" + +#: help_to_heat/templates/frontdoor/feedback.html:66 msgid "" "I had sufficient detail or guidance on every page to proceed to the next " "step." msgstr "" -"Roedd digon o fanylion neu ganllawiau imi ar bob tudalen i symud ymlaen i'r " +"Fe ges i ddigon o fanylion neu arweiniad ar bob tudalen i symud ymlaen i'r " "cam nesaf." -#: help_to_heat/templates/frontdoor/feedback.html:60 +#: help_to_heat/templates/frontdoor/feedback.html:70 +#: help_to_heat/templates/frontdoor/feedback.html:86 +#: help_to_heat/templates/frontdoor/feedback.html:102 +msgid "To what extent do you agree with the above statement?" +msgstr "I ba raddau rydych chi'n cytuno â'r gosodiad uchod?" + +#: help_to_heat/templates/frontdoor/feedback.html:82 msgid "" "I was able to answer all questions accurately, to the best of my knowledge." msgstr "" "Roeddwn i'n gallu ateb pob cwestiwn yn gywir, hyd eithaf fy ngwybodaeth." -#: help_to_heat/templates/frontdoor/feedback.html:76 -msgid "" -"While using our service, was there any specific aspect of this service that " -"you believe can be improved?" -msgstr "" -"Wrth ddefnyddio’n gwasanaeth ni, oedd unrhyw agwedd benodol ar y gwasanaeth " -"rydych chi’n credu bod modd ei gwella?" +#: help_to_heat/templates/frontdoor/feedback.html:98 +msgid "I received the advice I was looking for." +msgstr "Fe ges i’r cyngor roeddwn i’n chwilio amdano." -#: help_to_heat/templates/frontdoor/feedback.html:80 +#: help_to_heat/templates/frontdoor/feedback.html:114 +msgid "How could we improve the service?" +msgstr "Sut gallen ni wella'r gwasanaeth?" + +#: help_to_heat/templates/frontdoor/feedback.html:118 msgid "" -"Please do not include any personal or financial information in your response." +"Do not include any personal or financial information, for example your " +"National Insurance or credit card numbers." msgstr "" -"Peidiwch â chynnwys unrhyw wybodaeth bersonol neu ariannol yn eich ymateb." +"Peidiwch â chynnwys unrhyw faterion personol na gwybodaeth ariannol, er " +"enghraifft eich rhif Yswiriant Gwladol neu rifau cardiau credyd." -#: help_to_heat/templates/frontdoor/feedback.html:86 +#: help_to_heat/templates/frontdoor/feedback.html:124 msgid "Send feedback" msgstr "Anfon adborth" @@ -2965,10 +3016,6 @@ msgstr "" msgid "Continue" msgstr "Parhau" -#: help_to_heat/templates/macros.html:77 -msgid "There is a problem" -msgstr "Mae yna broblem" - #: help_to_heat/templates/macros.html:104 msgid "Change" msgstr "Newid" diff --git a/help_to_heat/portal/download_views.py b/help_to_heat/portal/download_views.py index ea1955ab..34a0c5ef 100644 --- a/help_to_heat/portal/download_views.py +++ b/help_to_heat/portal/download_views.py @@ -77,9 +77,11 @@ feedback_column_headings = ( "page_name", - "useful_for_learning", - "sufficient_guidance", - "able_to_answer", + "satisfaction_level", + "service_usage_reason", + "sufficient_detail_or_guidance", + "able_to_answer_accurately", + "received_desired_advice", "improvement_comment", "submission_date", "submission_time", @@ -160,7 +162,7 @@ def handle_create_spreadsheet_request(request, creator): @require_http_methods(["GET"]) @decorators.requires_service_manager def download_feedback_view(request): - feedbacks = frontdoor_models.Feedback.objects.all() + feedbacks = frontdoor_models.Feedback.objects.all().order_by("created_at") downloaded_at = timezone.now() file_name = downloaded_at.strftime("%d-%m-%Y %H_%M") new_feedback_download = frontdoor_models.FeedbackDownload.objects.create( @@ -276,9 +278,11 @@ def match_rows_for_feedback(feedback): row = dict(feedback.data) row = { **row, - "useful_for_learning": row.get("how-much", "Unanswered"), - "sufficient_guidance": row.get("guidance-detail", "Unanswered"), - "able_to_answer": row.get("accuracy-detail", "Unanswered"), + "satisfaction_level": row.get("satisfaction", "Unanswered"), + "service_usage_reason": row.get("usage-reason", "Unanswered"), + "sufficient_detail_or_guidance": row.get("guidance", "Unanswered"), + "able_to_answer_accurately": row.get("accuracy", "Unanswered"), + "received_desired_advice": row.get("advice", "Unanswered"), "improvement_comment": row["more-detail"], "page_name": page_name, "submission_date": created_at.date(), diff --git a/help_to_heat/templates/frontdoor/base.html b/help_to_heat/templates/frontdoor/base.html index 48ed2328..f76d056e 100644 --- a/help_to_heat/templates/frontdoor/base.html +++ b/help_to_heat/templates/frontdoor/base.html @@ -22,7 +22,6 @@ - diff --git a/help_to_heat/templates/frontdoor/feedback.html b/help_to_heat/templates/frontdoor/feedback.html index 3ff3d3b2..012b1d7c 100644 --- a/help_to_heat/templates/frontdoor/feedback.html +++ b/help_to_heat/templates/frontdoor/feedback.html @@ -12,72 +12,110 @@ {% endif %}

{{_("Help us improve the service")}}

-
+ {{csrf_input}} + {% if errors %} +
+
+

+ {{_("There is a problem")}} +

+ +
+
+ {% endif %} + +
+
+ +

+ +

+
+ {{macros.radios('satisfaction', multichoice_options_satisfaction, data={}, errors={})}} +
+
+ +
+
+ +

+ +

+
+ {{macros.radios('usage-reason', multichoice_options_service_usage, data={}, errors={})}} +
+
+
-

-

+
+ {{_("To what extent do you agree with the above statement?")}}
- - {{macros.radios('how-much', multichoice_options, data={}, errors={})}} - + {{macros.radios('guidance', multichoice_options_agreement, data={}, errors={})}}
-

-

+
+ {{_("To what extent do you agree with the above statement?")}}
-
- - {{macros.radios('guidance-detail', multichoice_options, data={}, errors={})}} - + {{macros.radios('accuracy', multichoice_options_agreement, data={}, errors={})}}
-

-

+
+ {{_("To what extent do you agree with the above statement?")}}
- {{macros.radios('accuracy-detail', multichoice_options, data={}, errors={})}} + {{macros.radios('advice', multichoice_options_agreement, data={}, errors={})}}
-

+

-

+
- {{_("Please do not include any personal or financial information in your response.")}} + {{_("Do not include any personal or financial information, for example your National Insurance or credit card numbers.")}}
diff --git a/static/feedback.css b/static/feedback.css deleted file mode 100644 index 85bdbb57..00000000 --- a/static/feedback.css +++ /dev/null @@ -1,44 +0,0 @@ -@media (min-width: 40.0625em) { - form#feedback .govuk-radios { - display: flex; - } - form#feedback .govuk-radios .govuk-radios__item { - display: flex; - flex: 1; - flex-direction: column; - padding-left: 0; - } - - form#feedback .govuk-radios__label:before { - top: auto; - bottom: 0; - left: 35%; - } - - form#feedback .govuk-radios__input:checked + .govuk-radios__label:after { - opacity: 1; - } - - form#feedback .govuk-radios__label:after { - content: ""; - position: absolute; - top: auto; - bottom: 10px; - left: calc(35% + 10px); - width: 0; - height: 0; - border: 10px solid; - border-radius: 50%; - opacity: 0; - background: currentcolor; - } - - form#feedback .govuk-radios__label { - margin-bottom: 40px; - flex: 1; - align-items: center; - text-align: center; - justify-content: center; - display: flex; - } -} diff --git a/tests/test_frontdoor.py b/tests/test_frontdoor.py index 2acca35e..47ec094c 100644 --- a/tests/test_frontdoor.py +++ b/tests/test_frontdoor.py @@ -667,20 +667,24 @@ def test_feedback_no_session(): page = page.follow() page = page.click(contains="feedback") form = page.get_form() - form["how-much"] = "Agree" - form["guidance-detail"] = "Completely disagree" - form["accuracy-detail"] = "Disagree" - form["more-detail"] = "Blah, blah, blah" + form["satisfaction"] = "Somewhat satisfied" + form["usage-reason"] = "To find ways to reduce my energy bills" + form["guidance"] = "Agree" + form["accuracy"] = "Neutral" + form["advice"] = "Agree" + form["more-detail"] = "Improvement comment" page = form.submit().follow() assert page.has_one("h1:contains('Thank you for your feedback')") assert not page.all("a:contains('Back')") feedback = frontdoor_models.Feedback.objects.latest("created_at") - assert feedback.data["how-much"] == "Agree" - assert feedback.data["guidance-detail"] == "Completely disagree" - assert feedback.data["accuracy-detail"] == "Disagree" - assert feedback.data["more-detail"] == "Blah, blah, blah" + assert feedback.data["satisfaction"] == "Somewhat satisfied" + assert feedback.data["usage-reason"] == "To find ways to reduce my energy bills" + assert feedback.data["guidance"] == "Agree" + assert feedback.data["accuracy"] == "Neutral" + assert feedback.data["advice"] == "Agree" + assert feedback.data["more-detail"] == "Improvement comment" def test_feedback_with_session(): @@ -703,19 +707,90 @@ def test_feedback_with_session(): page = page.click(contains="feedback") form = page.get_form() - form["how-much"] = "Agree" - form["guidance-detail"] = "Completely disagree" - form["accuracy-detail"] = "Disagree" - form["more-detail"] = "Blah, blah, blah" + form["satisfaction"] = "Somewhat satisfied" + form["usage-reason"] = "To find ways to reduce my energy bills" + form["guidance"] = "Agree" + form["accuracy"] = "Neutral" + form["advice"] = "Agree" + form["more-detail"] = "Improvement comment" + + page = form.submit().follow() + + assert page.has_one("h1:contains('Thank you for your feedback')") + + feedback = frontdoor_models.Feedback.objects.latest("created_at") + assert feedback.data["satisfaction"] == "Somewhat satisfied" + assert feedback.data["usage-reason"] == "To find ways to reduce my energy bills" + assert feedback.data["guidance"] == "Agree" + assert feedback.data["accuracy"] == "Neutral" + assert feedback.data["advice"] == "Agree" + assert feedback.data["more-detail"] == "Improvement comment" + + feedback_session_id = page.path.split("/")[3] + assert uuid.UUID(feedback_session_id) + + page = page.click(contains="Return to your application") + assert page.has_one("h1:contains('Do you own the property?')") + + +def test_feedback_validation_with_session_no_answers(): + client = utils.get_client() + page = client.get("/start") + page = page.follow() + + session_id = page.path.split("/")[1] + assert uuid.UUID(session_id) + + form = page.get_form() + form["country"] = "Scotland" + page = form.submit().follow() + + form = page.get_form() + form["supplier"] = "Utilita" + page = form.submit().follow() + + assert page.has_one("h1:contains('Do you own the property?')") + + page = page.click(contains="feedback") + form = page.get_form() + + page = form.submit() + + assert page.has_one("h1:contains('Help us improve the service')") + assert page.has_one("h2:contains('There is a problem')") + assert page.has_one("a:contains('Please answer at least one question before submitting feedback')") + + +def test_feedback_validation_with_session_two_answers(): + client = utils.get_client() + page = client.get("/start") + page = page.follow() + + session_id = page.path.split("/")[1] + assert uuid.UUID(session_id) + + form = page.get_form() + form["country"] = "Scotland" + page = form.submit().follow() + + form = page.get_form() + form["supplier"] = "Utilita" + page = form.submit().follow() + + assert page.has_one("h1:contains('Do you own the property?')") + + page = page.click(contains="feedback") + form = page.get_form() + form["satisfaction"] = "Somewhat satisfied" + form["more-detail"] = "Improvement comment" + page = form.submit().follow() assert page.has_one("h1:contains('Thank you for your feedback')") feedback = frontdoor_models.Feedback.objects.latest("created_at") - assert feedback.data["how-much"] == "Agree" - assert feedback.data["guidance-detail"] == "Completely disagree" - assert feedback.data["accuracy-detail"] == "Disagree" - assert feedback.data["more-detail"] == "Blah, blah, blah" + assert feedback.data["satisfaction"] == "Somewhat satisfied" + assert feedback.data["more-detail"] == "Improvement comment" feedback_session_id = page.path.split("/")[3] assert uuid.UUID(feedback_session_id)