-
Notifications
You must be signed in to change notification settings - Fork 1
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
PC-1463: Improve UX for when no address found #410
PC-1463: Improve UX for when no address found #410
Conversation
55d1d46
to
57f2031
Compare
@@ -13,6 +13,22 @@ <h1 class="govuk-heading-l"> | |||
{{_("What is the property's address?")}} | |||
</h1> | |||
</legend> | |||
|
|||
{% if show_address_manually_error %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this isn't an error in the normal sense in GBIS (it has no linked field, is not a validation error) so decided to add a specific case here rather than trying to extend the error showing logic
eb6db71
to
cf829d9
Compare
@@ -2032,41 +2031,6 @@ def test_on_epc_select_page_enter_manually_can_be_selected(): | |||
assert page.has_one('h1:contains("What is the property\'s address?")') | |||
|
|||
|
|||
@unittest.mock.patch("help_to_heat.frontdoor.interface.EPCApi", MockNotFoundEPCApi) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test is no longer meaningful; the user no longer needs to click the select manual link
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm puzzled by the whole approach: we call the API to check the number of results, then set a flag in the session, then immediately read from that flag again to determine the next page - have I got that right? Why do we need that extra machinery? Can we not pass values through to navigation without saving them to the session?
help_to_heat/frontdoor/views.py
Outdated
check_address_has_results_in_address_api() | ||
else: | ||
data[address_choice_field] = address_choice_field_write_address | ||
check_address_has_results_in_address_api() | ||
except Exception as e: # noqa: B902 | ||
logger.exception(f"An error occurred: {e}") | ||
data[address_choice_field] = address_choice_field_epc_api_fail | ||
check_address_has_results_in_address_api() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doing this feels brittle. I think I'd rather have one call after the try-catch. I don't follow why we don't call it in the one branch - why's that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in some cases we don't care for what the OS API response is, the only case being if the epc api returns results. could rewrite the logic to include just one call by checking afterwards
cf829d9
to
ab1f9bd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another general approach point: are we now making an API call to check how many results, then throwing it away and making the exact same API call on the next page? That feels silly - it's worth interrogating why we can't just fetch the list once.
help_to_heat/frontdoor/views.py
Outdated
will_use_os_api = ( | ||
data[address_choice_field] == address_choice_field_epc_api_fail | ||
or country == country_field_scotland | ||
and data[address_choice_field] == address_choice_field_write_address | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we now re-implementing logic from above (which could be equally brittle)? This is why I'd consider returning early in the case(s) where we don't want to do it.
this is something that I think is possible and there is time to do; can look into tweaking this to request the os api just the one time |
ab1f9bd
to
08deb05
Compare
as well as respective tests, including this new route into flow generators
08deb05
to
041dce9
Compare
@jdgage this should be ready for re-review now, code now only makes one api call, & the logic should be less brittle (no more re-expression) |
041dce9
to
f585966
Compare
This looks better: still refer back to the first comment: why do we need this intermediate field that we write to and then immediately read from? |
in general this is our mechanism for sending information to navigation, saving to session makes the routing reproducible. it's not too different from saving the answer to session and immediately querying that |
Sure. I think the reason it feels weird is that we've got these 'navigation-only' fields all together with actual user input fields? Can we make the distinction clearer? |
f585966
to
a15074b
Compare
have renamed these as 'journey fields' to make the distinction clearer |
help_to_heat/frontdoor/consts.py
Outdated
@@ -149,7 +149,9 @@ | |||
address_choice_field_enter_manually = "enter manually" | |||
address_building_name_or_number_field = "building_name_or_number" | |||
address_postcode_field = "postcode" | |||
address_all_address_and_lmk_details_field = "address_and_lmk_details" | |||
# PC-1463: removed lmk from field name as it stores info from both flows (lmk & uprn) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit message should have the ticket number, so don't need that here. Otherwise I think it's missing half of the why: why does the value still refer to 'LMK'?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing the value would mean the key used in the users' session would change and we'd need to consider not breaking existing sessions. the constant name can change for free. I think it's fine for a small semantic change here, though if we'd rather change the value too can look into that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's fine, but the comment should say this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have updated this
help_to_heat/frontdoor/consts.py
Outdated
address_all_address_and_lmk_details_field = "address_and_lmk_details" | ||
# PC-1463: removed lmk from field name as it stores info from both flows (lmk & uprn) | ||
address_all_address_and_details_field = "address_and_lmk_details" | ||
address_no_results_field = "no_results" # yes/no options |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these comments adding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#yes/no options just to mark that that field takes a yes or a no. can go and update the rest of such fields to the same effect
Some comments about comments, otherwise all fine |
to make their use distinct from user input fields
a15074b
to
3898568
Compare
3898568
to
4ddd68b
Compare
4ddd68b
to
0c27ae9
Compare
This is good to go |
Link to Jira ticket
Description
adds routing logic to send directly to address manual if no addresses are found
also adds extra logic on the address page to check whether it will find any addresses. this does mean that each flow that uses OS API will send twice the number of requests. if this is too undesirable then can look into caching the result here
Checklist
make extract-translations
Screenshots