Skip to content

Conversation

SullyK
Copy link

@SullyK SullyK commented Sep 15, 2025

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

  • Feat: optional form variable confirmationTimeout can now be set (note: 0 is not allowed) in a form's config.

Type of change

What is the type of change you are making?

  • New feature (non-breaking change which adds functionality)

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?

  • Yes

Testing

Automated tests

Have you added automated tests?

  • 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.

Manual tests

Have you manually tested your changes?

  • Yes

Have you attached an example form JSON or snippet for the reviewer in this PR?

  • No, any existing form can be used

Just add this: "confirmationTimeout": 10,
for example to the top of the config - see image:

image

Steps to test

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.

Documentation

Have you updated the documentation?

  • No, I am not sure if documentation is required

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.

  • No, this change is small and does not require discussion

Copy link
Contributor

@jenbutongit jenbutongit left a 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);

  1. Submit a short form
  2. see the confirmation page
  3. refresh the page after 10s
  4. I still see the confirmation page

I would expect

  1. Submit a short form
  2. see the confirmation page
  3. refresh the page after 10s
  4. Taken to /{form}/summary page (i.e. confirmation page is not accessible)

Comment on lines 75 to 76
const formTimeout = request.server?.app?.forms?.[request.params?.id]?.def?.confirmationTimeout
?? config.confirmationSessionTimeout;
Copy link
Contributor

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.

Suggested change
const formTimeout = request.server?.app?.forms?.[request.params?.id]?.def?.confirmationTimeout
?? config.confirmationSessionTimeout;
const confirmationTimeout = form.def.confirmationTimeout ?? config.confirmationSessionTimeout;

feeOptions: feeOptionSchema,
exitOptions: exitSchema.optional(),
showFilenamesOnSummaryPage: joi.boolean().optional(),
confirmationTimeout: joi.number().optional()
Copy link
Contributor

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

@SullyK SullyK marked this pull request as draft September 28, 2025 22:50
SullyK added a commit to ukhsa-collaboration/digital-form-builder that referenced this pull request Sep 28, 2025
SullyK added a commit to ukhsa-collaboration/digital-form-builder that referenced this pull request Sep 28, 2025
Updated PR XGovFormBuilder#1359 with recommended changes to schema, type and service…
@SullyK SullyK force-pushed the custom-submit-timeout branch from bddee48 to a6ba33d Compare September 28, 2025 23:13
SullyK added a commit to ukhsa-collaboration/digital-form-builder that referenced this pull request Sep 28, 2025
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
SullyK added a commit to ukhsa-collaboration/digital-form-builder that referenced this pull request Sep 28, 2025
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
@SullyK SullyK force-pushed the custom-submit-timeout branch from a6ba33d to 9a5eb6b Compare September 28, 2025 23:15
SullyK added a commit to ukhsa-collaboration/digital-form-builder that referenced this pull request Sep 28, 2025
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
@SullyK SullyK force-pushed the custom-submit-timeout branch from 9a5eb6b to 4dfd73a Compare September 28, 2025 23:18
Copy link
Contributor

@jenbutongit jenbutongit left a 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()
Copy link
Contributor

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

@SullyK
Copy link
Author

SullyK commented Sep 30, 2025

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"

   



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.

@jenbutongit
Copy link
Contributor

Hi @SullyK, please rebase your branch. I recently merged in #1363 which resolves smoke tests from failing

@SullyK
Copy link
Author

SullyK commented Oct 7, 2025

Hi @SullyK, please rebase your branch. I recently merged in #1363 which resolves smoke tests from failing

No problem. Sorry for delays have other priorities but this will be done this week.

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
@kitttang kitttang force-pushed the custom-submit-timeout branch from 4dfd73a to 2f8e373 Compare October 7, 2025 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants