File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ import { escapeMarkdown } from '@defra/forms-engine-plugin/engine/components/hel
22
33import { format as dateFormat } from '~/src/helpers/date.js'
44
5+ const submisionGuidancePlaceholder =
6+ "Define this text in the 'What happens next' section of the form overview"
7+
58/**
69 * @param {string } formName
710 * @param {Date } submissionDate
@@ -30,7 +33,7 @@ export function getUserConfirmationEmailBody(
3033We received your form submission for ‘${ formName } ’ on ${ formattedSubmissionDate } .
3134
3235## What happens next
33- ${ submissionGuidance }
36+ ${ submissionGuidance ?? submisionGuidancePlaceholder }
3437
3538## Get help
3639${ contactDetails } Do not reply to this emall. We do not monitor reples to this email address.
Original file line number Diff line number Diff line change @@ -22,6 +22,28 @@ Some submission guidance
2222## Get help
2323Do not reply to this emall. We do not monitor reples to this email address.
2424
25+ From Defra
26+ `
27+ )
28+ } )
29+
30+ test ( 'should handle missing submission guidance' , ( ) => {
31+ const formName = 'My Form Name'
32+ const submissionDate = new Date ( '2025-11-04T14:21:35+00:00' )
33+ const metadata = buildMetaData ( )
34+ expect (
35+ getUserConfirmationEmailBody ( formName , submissionDate , metadata )
36+ ) . toBe (
37+ `
38+ # We have your form
39+ We received your form submission for ‘My Form Name’ on 2:21pm on Tuesday 4 November 2025.
40+
41+ ## What happens next
42+ Define this text in the 'What happens next' section of the form overview
43+
44+ ## Get help
45+ Do not reply to this emall. We do not monitor reples to this email address.
46+
2547From Defra
2648`
2749 )
Original file line number Diff line number Diff line change @@ -160,10 +160,6 @@ export async function sendUserConfirmationEmail(formSubmissionMessage) {
160160
161161 logger . info ( logTags , 'Sending user confirmation email' )
162162
163- if ( ! metadata . submissionGuidance ) {
164- throw new Error ( `Missing submission guidance for form id ${ formId } ` )
165- }
166-
167163 try {
168164 // Send confirmation email
169165 await sendNotification ( {
Original file line number Diff line number Diff line change @@ -698,26 +698,6 @@ describe('notify', () => {
698698 } )
699699 } )
700700
701- it ( 'should throw if confirmation email has no submission guidance set' , async ( ) => {
702- jest . mocked ( getFormDefinition ) . mockResolvedValueOnce ( baseDefinition )
703- jest . mocked ( getFormMetadata ) . mockResolvedValueOnce (
704- buildMetaData ( {
705- submissionGuidance : undefined
706- } )
707- )
708- const formAdapterMessageWithUserEmail = structuredClone (
709- formAdapterSubmissionMessage
710- )
711- formAdapterMessageWithUserEmail . meta . custom = {
712- userConfirmationEmail : 'my-email@test.com'
713- }
714- await expect ( ( ) =>
715- sendNotifyEmails ( formAdapterMessageWithUserEmail )
716- ) . rejects . toThrow (
717- 'Missing submission guidance for form id 68a8b0449ab460290c28940a'
718- )
719- } )
720-
721701 it ( 'confirmation email should handle and throw errors' , async ( ) => {
722702 const err = new Error ( 'Upstream failure' )
723703 jest . mocked ( getFormDefinition ) . mockResolvedValueOnce ( baseDefinition )
You can’t perform that action at this time.
0 commit comments