-
Notifications
You must be signed in to change notification settings - Fork 42
feature: custom ConfirmationSessionTimeout per form setup #1359
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
base: main
Are you sure you want to change the base?
feature: custom ConfirmationSessionTimeout per form setup #1359
Conversation
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.
Hey, thanks for your PR.
I've tested this by setting confirmationTimeout to something very short - e.g. 10
, but I've found a fault. Could you fix this as part of your PR please?
await cacheService.clearState(request);
needs to be added to applicationStatus/index.ts
, before return h.view("confirmation", viewModel);
- Submit a short form
- see the confirmation page
- refresh the page after 10s
- I still see the confirmation page
I would expect
- Submit a short form
- see the confirmation page
- refresh the page after 10s
- Taken to /{form}/summary page (i.e. confirmation page is not accessible)
const formTimeout = request.server?.app?.forms?.[request.params?.id]?.def?.confirmationTimeout | ||
?? config.confirmationSessionTimeout; |
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 can be shortened since const form
is already available further up.
const formTimeout = request.server?.app?.forms?.[request.params?.id]?.def?.confirmationTimeout | |
?? config.confirmationSessionTimeout; | |
const confirmationTimeout = form.def.confirmationTimeout ?? config.confirmationSessionTimeout; |
model/src/schema/schema.ts
Outdated
feeOptions: feeOptionSchema, | ||
exitOptions: exitSchema.optional(), | ||
showFilenamesOnSummaryPage: joi.boolean().optional(), | ||
confirmationTimeout: joi.number().optional() |
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.
could we match the name confirmationSessionTimeout
please? it makes it clearer this is related to the global config
…ype and service/fixed functionality
Updated PR XGovFormBuilder#1359 with recommended changes to schema, type and service…
bddee48
to
a6ba33d
Compare
This change allows a form-maker to create a custom form which allows users to submit one form after another. It also fixes some minor bugs to do with header tokens not being removed from the front-end upon succesful form submission. The current setup enforces a 20 minute wait time or a cookie refresh via a browser's console to submit a new form. This change enables individual forms to have a custom time limit which can be very low to allow users forms one after another - please note this change does not enable parallel form submissions, it is consecutive. This change only affects forms who OPT-IN. The default time limit is kept if this feature is not used. - Feat: optional form variable confirmationTimeout can now be set (note: 0 is not allowed) in a form's config. - Fix: magiclinkRetry and auth_token not correctly being cleared after a complete submission. What is the type of change you are making? - [X] New feature (non-breaking change which adds functionality) PR titles should be prefixed with the type of change you are making, based on the [README.md#versioning](https://github.com/XGovFormBuilder/digital-form-builder?tab=readme-ov-file#versioning). This is so that when performing a squash merge, the PR title is automatically used as the commit message. Have you updated the PR title to match the type of change you are making? - [X] Yes <!-- Several departments use XGovFormBuilder in production. Automated tests help ensure that changes do not break existing functionality for another department. Maintainers are sympathetic to the time constraints of government departments, but please try to be good citizens and add tests when possible. --> Have you added automated tests? - [X] No (explain why tests are not required or can't be added at this time) - This feature is opt-in and will be tested via End-to-End tests which will be updated when deployed. If we wish to test it in another way, feel free to suggest it and help if capable. Have you manually tested your changes? - [X] Yes Have you attached an example form JSON or snippet for the reviewer in this PR? - [X] No, any existing form can be used Just add this: "confirmationTimeout": 10, for example to the top of the config - see image: <img width="737" height="211" alt="image" src="https://github.com/user-attachments/assets/d6838459-ff94-45f5-8443-9254fb13e7f1" /> <!-- Only fill out this section if you answered "Yes" to manually testing your changes. In this section - describe the tests that you ran to verify your changes - provide instructions and a form JSON or snippet so we can reproduce the test if necessary If uploading a form JSON, use the "attach files" feature in GitHub PR. --> Using the new feature: 1. Insert the "confirmationTimeout": 10 2. Submit a form 3. go back to the form's start page 4. Submit another form 5. Check backend - to see if two submissions submitted. no "confirmationTimeout": 2. Submit a form 3. go back to the form's start page 4. Submit another form 5. There should be no two submissions going in. Have you updated the documentation? - [X] No, I am not sure if documentation is required > [!WARNING] > > Large or complex changes may require discussion with the maintainers before they can be merged. If it has not yet been discussed, it may delay the review process Have you discussed this change with the maintainers? I have discussed this interally within UKHSA - KLS and L2/L3 teams. - [X] No, this change is small and does not require discussion Updated PR XGovFormBuilder#1359 with recommended changes to schema, type and service/fixed functionality
This change allows a form-maker to create a custom form which allows users to submit one form after another. It also fixes some minor bugs to do with header tokens not being removed from the front-end upon succesful form submission. The current setup enforces a 20 minute wait time or a cookie refresh via a browser's console to submit a new form. This change enables individual forms to have a custom time limit which can be very low to allow users forms one after another - please note this change does not enable parallel form submissions, it is consecutive. This change only affects forms who OPT-IN. The default time limit is kept if this feature is not used. - Feat: optional form variable confirmationTimeout can now be set (note: 0 is not allowed) in a form's config. - Fix: magiclinkRetry and auth_token not correctly being cleared after a complete submission. What is the type of change you are making? - [X] New feature (non-breaking change which adds functionality) PR titles should be prefixed with the type of change you are making, based on the [README.md#versioning](https://github.com/XGovFormBuilder/digital-form-builder?tab=readme-ov-file#versioning). This is so that when performing a squash merge, the PR title is automatically used as the commit message. Have you updated the PR title to match the type of change you are making? - [X] Yes <!-- Several departments use XGovFormBuilder in production. Automated tests help ensure that changes do not break existing functionality for another department. Maintainers are sympathetic to the time constraints of government departments, but please try to be good citizens and add tests when possible. --> Have you added automated tests? - [X] No (explain why tests are not required or can't be added at this time) - This feature is opt-in and will be tested via End-to-End tests which will be updated when deployed. If we wish to test it in another way, feel free to suggest it and help if capable. Have you manually tested your changes? - [X] Yes Have you attached an example form JSON or snippet for the reviewer in this PR? - [X] No, any existing form can be used Just add this: "confirmationTimeout": 10, for example to the top of the config - see image: <img width="737" height="211" alt="image" src="https://github.com/user-attachments/assets/d6838459-ff94-45f5-8443-9254fb13e7f1" /> <!-- Only fill out this section if you answered "Yes" to manually testing your changes. In this section - describe the tests that you ran to verify your changes - provide instructions and a form JSON or snippet so we can reproduce the test if necessary If uploading a form JSON, use the "attach files" feature in GitHub PR. --> Using the new feature: 1. Insert the "confirmationTimeout": 10 2. Submit a form 3. go back to the form's start page 4. Submit another form 5. Check backend - to see if two submissions submitted. no "confirmationTimeout": 2. Submit a form 3. go back to the form's start page 4. Submit another form 5. There should be no two submissions going in. Have you updated the documentation? - [X] No, I am not sure if documentation is required > [!WARNING] > > Large or complex changes may require discussion with the maintainers before they can be merged. If it has not yet been discussed, it may delay the review process Have you discussed this change with the maintainers? I have discussed this interally within UKHSA - KLS and L2/L3 teams. - [X] No, this change is small and does not require discussion Updated PR XGovFormBuilder#1359 with recommended changes to schema, type and service/fixed functionality
a6ba33d
to
9a5eb6b
Compare
This change allows a form-maker to create a custom form which allows users to submit one form after another. It also fixes some minor bugs to do with header tokens not being removed from the front-end upon succesful form submission. The current setup enforces a 20 minute wait time or a cookie refresh via a browser's console to submit a new form. This change enables individual forms to have a custom time limit which can be very low to allow users forms one after another - please note this change does not enable parallel form submissions, it is consecutive. This change only affects forms who OPT-IN. The default time limit is kept if this feature is not used. - Feat: optional form variable confirmationTimeout can now be set (note: 0 is not allowed) in a form's config. - Fix: magiclinkRetry and auth_token not correctly being cleared after a complete submission. What is the type of change you are making? - [X] New feature (non-breaking change which adds functionality) PR titles should be prefixed with the type of change you are making, based on the [README.md#versioning](https://github.com/XGovFormBuilder/digital-form-builder?tab=readme-ov-file#versioning). This is so that when performing a squash merge, the PR title is automatically used as the commit message. Have you updated the PR title to match the type of change you are making? - [X] Yes <!-- Several departments use XGovFormBuilder in production. Automated tests help ensure that changes do not break existing functionality for another department. Maintainers are sympathetic to the time constraints of government departments, but please try to be good citizens and add tests when possible. --> Have you added automated tests? - [X] No (explain why tests are not required or can't be added at this time) - This feature is opt-in and will be tested via End-to-End tests which will be updated when deployed. If we wish to test it in another way, feel free to suggest it and help if capable. Have you manually tested your changes? - [X] Yes Have you attached an example form JSON or snippet for the reviewer in this PR? - [X] No, any existing form can be used Just add this: "confirmationTimeout": 10, for example to the top of the config - see image: <img width="737" height="211" alt="image" src="https://github.com/user-attachments/assets/d6838459-ff94-45f5-8443-9254fb13e7f1" /> <!-- Only fill out this section if you answered "Yes" to manually testing your changes. In this section - describe the tests that you ran to verify your changes - provide instructions and a form JSON or snippet so we can reproduce the test if necessary If uploading a form JSON, use the "attach files" feature in GitHub PR. --> Using the new feature: 1. Insert the "confirmationTimeout": 10 2. Submit a form 3. go back to the form's start page 4. Submit another form 5. Check backend - to see if two submissions submitted. no "confirmationTimeout": 2. Submit a form 3. go back to the form's start page 4. Submit another form 5. There should be no two submissions going in. Have you updated the documentation? - [X] No, I am not sure if documentation is required > [!WARNING] > > Large or complex changes may require discussion with the maintainers before they can be merged. If it has not yet been discussed, it may delay the review process Have you discussed this change with the maintainers? I have discussed this interally within UKHSA - KLS and L2/L3 teams. - [X] No, this change is small and does not require discussion Updated PR XGovFormBuilder#1359 with recommended changes to schema, type and service/fixed functionality
9a5eb6b
to
4dfd73a
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.
Thanks @SullyK. Would it be possible to add a cypress test for this too please?
Add a form with 1 question, summary page and a short confirmation session timeout to e2e/cypress/fixtures
, e.g. confirmation-timeout.json
then add a test to e2e/cypress/e2e/runner
.
your test should look something like
Feature: Confirmation timeout
Background: Given the form "confirmation-timeout" exists
Scenario:
//.. steps to finish the form
And I wait "10" seconds
And I navigate to "confirmation-timeout/status"
Then I don't see "Application complete"
feeOptions: feeOptionSchema, | ||
exitOptions: exitSchema.optional(), | ||
showFilenamesOnSummaryPage: joi.boolean().optional(), | ||
confirmationSessionTimeout: joi.number().optional() |
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 seems to be a linting error here. add ,
to the end of the line
Sure thing, will get to it ASAP. I also apologise for not updating you yesterday or today, I was testing the change locally and haven't quite completed that, otherwise I would have replied to your review. |
This change allows a form-maker to create a custom form which allows users to submit one form after another. It also fixes some minor bugs to do with header tokens not being removed from the front-end upon succesful form submission. The current setup enforces a 20 minute wait time or a cookie refresh via a browser's console to submit a new form. This change enables individual forms to have a custom time limit which can be very low to allow users forms one after another - please note this change does not enable parallel form submissions, it is consecutive. This change only affects forms who OPT-IN. The default time limit is kept if this feature is not used. - Feat: optional form variable confirmationTimeout can now be set (note: 0 is not allowed) in a form's config. - Fix: magiclinkRetry and auth_token not correctly being cleared after a complete submission. What is the type of change you are making? - [X] New feature (non-breaking change which adds functionality) PR titles should be prefixed with the type of change you are making, based on the [README.md#versioning](https://github.com/XGovFormBuilder/digital-form-builder?tab=readme-ov-file#versioning). This is so that when performing a squash merge, the PR title is automatically used as the commit message. Have you updated the PR title to match the type of change you are making? - [X] Yes <!-- Several departments use XGovFormBuilder in production. Automated tests help ensure that changes do not break existing functionality for another department. Maintainers are sympathetic to the time constraints of government departments, but please try to be good citizens and add tests when possible. --> Have you added automated tests? - [X] No (explain why tests are not required or can't be added at this time) - This feature is opt-in and will be tested via End-to-End tests which will be updated when deployed. If we wish to test it in another way, feel free to suggest it and help if capable. Have you manually tested your changes? - [X] Yes Have you attached an example form JSON or snippet for the reviewer in this PR? - [X] No, any existing form can be used Just add this: "confirmationTimeout": 10, for example to the top of the config - see image: <img width="737" height="211" alt="image" src="https://github.com/user-attachments/assets/d6838459-ff94-45f5-8443-9254fb13e7f1" /> <!-- Only fill out this section if you answered "Yes" to manually testing your changes. In this section - describe the tests that you ran to verify your changes - provide instructions and a form JSON or snippet so we can reproduce the test if necessary If uploading a form JSON, use the "attach files" feature in GitHub PR. --> Using the new feature: 1. Insert the "confirmationTimeout": 10 2. Submit a form 3. go back to the form's start page 4. Submit another form 5. Check backend - to see if two submissions submitted. no "confirmationTimeout": 2. Submit a form 3. go back to the form's start page 4. Submit another form 5. There should be no two submissions going in. Have you updated the documentation? - [X] No, I am not sure if documentation is required > [!WARNING] > > Large or complex changes may require discussion with the maintainers before they can be merged. If it has not yet been discussed, it may delay the review process Have you discussed this change with the maintainers? I have discussed this interally within UKHSA - KLS and L2/L3 teams. - [X] No, this change is small and does not require discussion Updated PR XGovFormBuilder#1359 with recommended changes to schema, type and service/fixed functionality
4dfd73a
to
2f8e373
Compare
Description
This change allows a form-maker to create a custom form which allows users to submit one form after another with their own defined time-limit.
Context
The current setup enforces a 20 minute wait time or a cookie refresh via a browser's console to submit a new form. This change enables individual forms to have a custom time limit which can be very low to allow users forms one after another - please note this change does not enable parallel form submissions, it is consecutive.
This change only affects forms who OPT-IN. The default time limit is kept if this feature is not used.
Changes
Type of change
What is the type of change you are making?
PR title
PR titles should be prefixed with the type of change you are making, based on the README.md#versioning. This is so that when performing a squash merge, the PR title is automatically used as the commit message.
Have you updated the PR title to match the type of change you are making?
Testing
Automated tests
Have you added automated tests?
This feature is opt-in and will be tested via End-to-End tests which will be updated when deployed. If we wish to test it in another way, feel free to suggest it and help if capable.
Manual tests
Have you manually tested your changes?
Have you attached an example form JSON or snippet for the reviewer in this PR?
Just add this: "confirmationTimeout": 10,
for example to the top of the config - see image:
Steps to test
Using the new feature:
no "confirmationTimeout":
2. Submit a form
3. go back to the form's start page
4. Submit another form
5. There should be no two submissions going in.
Documentation
Have you updated the documentation?
Discussion
Warning
Large or complex changes may require discussion with the maintainers before they can be merged. If it has not yet been discussed, it may delay the review process
Have you discussed this change with the maintainers?
I have discussed this interally within UKHSA - KLS and L2/L3 teams.