Skip to content

Commit 84f1aee

Browse files
committed
CCM-11492 Fix unit tests
1 parent d15bfe9 commit 84f1aee

File tree

7 files changed

+439
-238
lines changed

7 files changed

+439
-238
lines changed

frontend/src/__tests__/app/choose-templates/__snapshots__/page.test.tsx.snap

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ exports[`ChooseTemplatesPage renders correctly for a message plan with multiple
124124
</a>
125125
</li>
126126
<li>
127-
<form
128-
action="javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')"
129-
>
127+
<form>
130128
<input
131129
name="channel"
132130
type="hidden"
@@ -140,6 +138,7 @@ exports[`ChooseTemplatesPage renders correctly for a message plan with multiple
140138
<button
141139
class="channel-template-link--remove nhsuk-link"
142140
data-testid="remove-template-link-NHSAPP"
141+
formaction="javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')"
143142
type="submit"
144143
>
145144
Remove
@@ -298,9 +297,7 @@ exports[`ChooseTemplatesPage renders correctly for a message plan with multiple
298297
</a>
299298
</li>
300299
<li>
301-
<form
302-
action="javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')"
303-
>
300+
<form>
304301
<input
305302
name="channel"
306303
type="hidden"
@@ -314,6 +311,7 @@ exports[`ChooseTemplatesPage renders correctly for a message plan with multiple
314311
<button
315312
class="channel-template-link--remove nhsuk-link"
316313
data-testid="remove-template-link-SMS"
314+
formaction="javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')"
317315
type="submit"
318316
>
319317
Remove
@@ -610,9 +608,7 @@ exports[`ChooseTemplatesPage renders correctly for a message plan with multiple
610608
</a>
611609
</li>
612610
<li>
613-
<form
614-
action="javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')"
615-
>
611+
<form>
616612
<input
617613
name="channel"
618614
type="hidden"
@@ -626,6 +622,7 @@ exports[`ChooseTemplatesPage renders correctly for a message plan with multiple
626622
<button
627623
class="channel-template-link--remove nhsuk-link"
628624
data-testid="remove-template-link-LETTER"
625+
formaction="javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')"
629626
type="submit"
630627
>
631628
Remove

frontend/src/__tests__/components/molecules/MessagePlanChannelTemplate.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,14 @@ describe('MessagePlanChannelTemplate', () => {
9696
);
9797
});
9898

99-
it('should display the "Remove template" button inside a form with hidden inputs and remove action', () => {
99+
it('should display the "Remove template" button inside a form with hidden inputs', () => {
100100
const removeButton = screen.getByRole('button', {
101101
name: 'Remove Text message (SMS) template',
102102
});
103103
const form = removeButton.closest('form');
104104

105105
expect(removeButton).toBeInTheDocument();
106106
expect(form).toBeInTheDocument();
107-
expect(form).toHaveAttribute('action');
108107

109108
const channelInput = form?.querySelector('input[name="channel"]');
110109
const routingConfigIdInput = form?.querySelector(

frontend/src/__tests__/components/molecules/__snapshots__/MessagePlanBlock.test.tsx.snap

Lines changed: 100 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -106,19 +106,32 @@ exports[`MessagePlanBlock for channel EMAIL with template should match snapshot
106106
</a>
107107
</li>
108108
<li>
109-
<button
110-
class="channel-template-link--remove nhsuk-link"
111-
data-testid="remove-template-link-EMAIL"
112-
type="button"
113-
>
114-
Remove
115-
<span
116-
class="nhsuk-u-visually-hidden"
109+
<form>
110+
<input
111+
name="channel"
112+
type="hidden"
113+
value="EMAIL"
114+
/>
115+
<input
116+
name="routingConfigId"
117+
type="hidden"
118+
value="test-routing-config-id"
119+
/>
120+
<button
121+
class="channel-template-link--remove nhsuk-link"
122+
data-testid="remove-template-link-EMAIL"
123+
formaction="javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')"
124+
type="submit"
117125
>
118-
Email
119-
</span>
120-
template
121-
</button>
126+
Remove
127+
<span
128+
class="nhsuk-u-visually-hidden"
129+
>
130+
Email
131+
</span>
132+
template
133+
</button>
134+
</form>
122135
</li>
123136
</ul>
124137
</div>
@@ -233,19 +246,32 @@ exports[`MessagePlanBlock for channel LETTER with template should match snapshot
233246
</a>
234247
</li>
235248
<li>
236-
<button
237-
class="channel-template-link--remove nhsuk-link"
238-
data-testid="remove-template-link-LETTER"
239-
type="button"
240-
>
241-
Remove
242-
<span
243-
class="nhsuk-u-visually-hidden"
249+
<form>
250+
<input
251+
name="channel"
252+
type="hidden"
253+
value="LETTER"
254+
/>
255+
<input
256+
name="routingConfigId"
257+
type="hidden"
258+
value="test-routing-config-id"
259+
/>
260+
<button
261+
class="channel-template-link--remove nhsuk-link"
262+
data-testid="remove-template-link-LETTER"
263+
formaction="javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')"
264+
type="submit"
244265
>
245-
Letter
246-
</span>
247-
template
248-
</button>
266+
Remove
267+
<span
268+
class="nhsuk-u-visually-hidden"
269+
>
270+
Letter
271+
</span>
272+
template
273+
</button>
274+
</form>
249275
</li>
250276
</ul>
251277
</div>
@@ -360,19 +386,32 @@ exports[`MessagePlanBlock for channel NHSAPP with template should match snapshot
360386
</a>
361387
</li>
362388
<li>
363-
<button
364-
class="channel-template-link--remove nhsuk-link"
365-
data-testid="remove-template-link-NHSAPP"
366-
type="button"
367-
>
368-
Remove
369-
<span
370-
class="nhsuk-u-visually-hidden"
389+
<form>
390+
<input
391+
name="channel"
392+
type="hidden"
393+
value="NHSAPP"
394+
/>
395+
<input
396+
name="routingConfigId"
397+
type="hidden"
398+
value="test-routing-config-id"
399+
/>
400+
<button
401+
class="channel-template-link--remove nhsuk-link"
402+
data-testid="remove-template-link-NHSAPP"
403+
formaction="javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')"
404+
type="submit"
371405
>
372-
NHS App
373-
</span>
374-
template
375-
</button>
406+
Remove
407+
<span
408+
class="nhsuk-u-visually-hidden"
409+
>
410+
NHS App
411+
</span>
412+
template
413+
</button>
414+
</form>
376415
</li>
377416
</ul>
378417
</div>
@@ -487,19 +526,32 @@ exports[`MessagePlanBlock for channel SMS with template should match snapshot 1`
487526
</a>
488527
</li>
489528
<li>
490-
<button
491-
class="channel-template-link--remove nhsuk-link"
492-
data-testid="remove-template-link-SMS"
493-
type="button"
494-
>
495-
Remove
496-
<span
497-
class="nhsuk-u-visually-hidden"
529+
<form>
530+
<input
531+
name="channel"
532+
type="hidden"
533+
value="SMS"
534+
/>
535+
<input
536+
name="routingConfigId"
537+
type="hidden"
538+
value="test-routing-config-id"
539+
/>
540+
<button
541+
class="channel-template-link--remove nhsuk-link"
542+
data-testid="remove-template-link-SMS"
543+
formaction="javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')"
544+
type="submit"
498545
>
499-
Text message (SMS)
500-
</span>
501-
template
502-
</button>
546+
Remove
547+
<span
548+
class="nhsuk-u-visually-hidden"
549+
>
550+
Text message (SMS)
551+
</span>
552+
template
553+
</button>
554+
</form>
503555
</li>
504556
</ul>
505557
</div>

0 commit comments

Comments
 (0)