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

Submit Check your answers page #811

Conversation

Demwunz
Copy link
Contributor

@Demwunz Demwunz commented Mar 12, 2024

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.

@Demwunz Demwunz force-pushed the WATER-4264-returns-not-required-journey-check-your-answers-page-iteration-2-3-of-3 branch 4 times, most recently from ec5c3ed to e88c992 Compare March 12, 2024 15:36
@Demwunz Demwunz marked this pull request as ready for review March 13, 2024 13:29
Copy link
Member

@Cruikshanks Cruikshanks left a 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,
Copy link
Member

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?

Suggested change
licence_id: session?.data?.licence?.licenceRef,
licenceRef: session?.data?.licence?.licenceRef,

Copy link
Member

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!

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Contributor Author

@Demwunz Demwunz Mar 14, 2024

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.

@Demwunz Demwunz requested a review from Cruikshanks March 19, 2024 10:20
@Demwunz Demwunz added the enhancement New feature or request label Mar 19, 2024
Demwunz and others added 12 commits March 19, 2024 16:05
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 :-) !)
@Demwunz Demwunz force-pushed the WATER-4264-returns-not-required-journey-check-your-answers-page-iteration-2-3-of-3 branch from 4b94b74 to 33ff4c0 Compare March 19, 2024 16:07
Copy link
Member

@Cruikshanks Cruikshanks left a 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.

@Demwunz Demwunz force-pushed the WATER-4264-returns-not-required-journey-check-your-answers-page-iteration-2-3-of-3 branch from 4ecf30b to 26b5c7a Compare March 20, 2024 11:03
@Demwunz Demwunz force-pushed the WATER-4264-returns-not-required-journey-check-your-answers-page-iteration-2-3-of-3 branch from 26b5c7a to 98b6e2a Compare March 20, 2024 11:12
Copy link
Member

@Cruikshanks Cruikshanks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Demwunz Demwunz merged commit 2a70d9e into main Mar 20, 2024
6 checks passed
@Demwunz Demwunz deleted the WATER-4264-returns-not-required-journey-check-your-answers-page-iteration-2-3-of-3 branch March 20, 2024 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants