@@ -31,6 +31,36 @@ is ($agent->status, 200, "Attempting to create new incident and investigation li
3131$agent -> text_like(qr { You must enter a correspondent for the investigation} ,
3232" RT did not allow an empty correspondent field" );
3333
34+ # Same scenario, but submitted as an htmx-boosted request (matching what
35+ # the browser sends when the body's hx-boost intercepts the form).
36+ $agent -> display_ticket($ir );
37+ $agent -> follow_link_ok({id => " create-incident" }, " Followed 'New (Incident)' link (htmx-boosted scenario)" );
38+ $agent -> form_number(3);
39+ $agent -> field(' Subject' , ' Incident for htmx-boosted validation test' );
40+ $agent -> field(' InvestigationSubject' , ' Investigation for htmx-boosted validation test' );
41+ $agent -> field(' InvestigationRequestors' , ' ' );
42+
43+ $agent -> add_header( ' HX-Request' => ' true' );
44+ $agent -> add_header( ' HX-Boosted' => ' true' );
45+
46+ # autocheck would fail the test on a non-2xx response; 422 is what we want here.
47+ my $orig_autocheck = $agent -> autocheck;
48+ $agent -> autocheck(0);
49+
50+ $agent -> click(" InvestigationSubmitTicket" );
51+
52+ is( $agent -> status, 422, ' htmx-boosted InvestigationSubmitTicket validation failure returns 422' );
53+
54+ $agent -> next_warning_like( qr / Validation error/ , ' htmx-boosted validation failure logs expected "Validation error"' );
55+
56+ my $hx_trigger = $agent -> response-> header(' HX-Trigger' );
57+ ok( $hx_trigger , ' HX-Trigger header is set on htmx-boosted validation failure' );
58+ like( $hx_trigger // ' ' , qr / actionsChanged/ , ' HX-Trigger contains actionsChanged event' );
59+ like( $hx_trigger // ' ' , qr / correspondent for the investigation/ , ' HX-Trigger payload mentions the validation error' );
60+
61+ $agent -> autocheck($orig_autocheck );
62+ $agent -> delete_header(' HX-Request' );
63+ $agent -> delete_header(' HX-Boosted' );
3464
3565my ( $inc_id , $inv_id ) = $agent -> create_incident_and_investigation(
3666 ' ' ,
0 commit comments