-
Notifications
You must be signed in to change notification settings - Fork 0
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
Submit Check your answers page #811
Submit Check your answers page #811
Conversation
ec5c3ed
to
e88c992
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.
I've suggested merging FetchLicenceService
and part of SubmitCheckYourAnswers
into a new CheckLicenceEnded
service that is also going to affect tests.
Happy to pair on this or jump on to get this over the line or if it's not clear what I'm suggesting 😜
|
||
return { | ||
activeNavBar: 'search', | ||
licence_id: session?.data?.licence?.licenceRef, |
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.
There might be a valid reason. But could this not also just be licenceRef
?
licence_id: session?.data?.licence?.licenceRef, | |
licenceRef: session?.data?.licence?.licenceRef, |
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'd avoid using the Optional Chaining (sometimes known as the safe navigation operator) unless we have a situation where we know a property may not be populated.
In the case of this service, the session should be correctly populated. If it isn't it's because someone has purposely tried to access the page with a valid session ID but an invalid session. So, it's own them!
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.
@Cruikshanks ok, that makes sense. I'll remove it and replace with a direct reference.
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.
Looking at SubmitCheckYourAnswers
the only thing we need from this service is $ends
. In fact, we know SubmitCheckYourAnswers
is going to get busier in the near future as it will be doing the work of persisting the return requirements.
So, it might be prudent to combine this service and _checkLicenceEnded()
from SubmitCheckYourAnswers
into a CheckLicenceEndedService
that just returns a true/false
. SubmitCheckYourAnswers
can then use this result to decide whether to throw the error.
What do you think?
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.
@Cruikshanks It does make sense to use the $ends
property. I didn't want to jump the gun given the previous structure of JIRA tickets. I can make the above change you've suggested to save time later.
https://eaflood.atlassian.net/browse/WATER-4264 This page allows the user to submit their answers. Ther page will run submit the data to the check your answers service which in turn will check the licence. If the licence is valid, the user will be directed to the approved page. If the licence is invalid, the service will throw an error.
The fetch-licence.service.test.js was failing because it was getting a stubbed result back when what we wanted was the actual service to be called. The reason it was still stubbed out was because submit-check-your-answers.test.js was stubbing the service outside of a `beforeEach()`. This is the equivalent of stubbing the service as soon as the test suite is loaded (which it always is even if you then just run one test). It's outside the scope of the tests and therefore a `Sinon.restore()` in an `afterEach()` is not going to apply. Putting it inside of a `beforeEach()` means the stubbing now only happens in the scope of the `submit-check-your-answers.service.test.js`.
When dealing with async code unless we need to await the result (as we do in `go()` in order to be able to pass the licence to `_data()`) we should be returning immediately so the calling code then has the option to await or not. The other cleanup is that `_data()` was not doing anything blocking so didn't need to be `async`.
For the existing test that was there we can just let `LicenceHelper.add()` do its thing and don't need to provide any other details. With the other changes in place the test should now pass (works on my machine :-) !)
4b94b74
to
33ff4c0
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.
I've not gone through the tests or view yet because I think some things need tidying up in the services first.
Let's deal with those as they'll impact the tests then ping me and I'll check the rest.
app/services/return-requirements/check-licence-ended.service.js
Outdated
Show resolved
Hide resolved
app/services/return-requirements/check-licence-ended.service.js
Outdated
Show resolved
Hide resolved
app/services/return-requirements/check-licence-ended.service.js
Outdated
Show resolved
Hide resolved
app/services/return-requirements/check-licence-ended.service.js
Outdated
Show resolved
Hide resolved
app/services/return-requirements/check-licence-ended.service.js
Outdated
Show resolved
Hide resolved
app/services/return-requirements/check-licence-ended.service.js
Outdated
Show resolved
Hide resolved
app/services/return-requirements/submit-check-your-answers.service.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Alan Cruikshanks <[email protected]>
Co-authored-by: Alan Cruikshanks <[email protected]>
Co-authored-by: Alan Cruikshanks <[email protected]>
Co-authored-by: Alan Cruikshanks <[email protected]>
Co-authored-by: Alan Cruikshanks <[email protected]>
Co-authored-by: Alan Cruikshanks <[email protected]>
…vice.js Co-authored-by: Alan Cruikshanks <[email protected]>
Co-authored-by: Alan Cruikshanks <[email protected]>
…k-your-answers-page-iteration-2-3-of-3
…k-your-answers-page-iteration-2-3-of-3
4ecf30b
to
26b5c7a
Compare
26b5c7a
to
98b6e2a
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.
https://eaflood.atlassian.net/browse/WATER-4264
This page allows the user to submit their answers.
The "check your answers" page will submit the data to the check your answers service which in turn will check the licence.
If the licence is valid, the user will be directed to the approved page.
If the licence is invalid (expired, lapsed or revoked), the service will throw an error.