diff --git a/t/cobrand/isleofwight.t b/t/cobrand/isleofwight.t index 04054663c8..3c5591d966 100644 --- a/t/cobrand/isleofwight.t +++ b/t/cobrand/isleofwight.t @@ -45,6 +45,7 @@ $contact->set_extra_fields( ( { order => 1, datatype_description => 'datatype', } ) ); +$contact->set_extra_metadata( group => ['Roads'] ); $contact->update; my $user = $mech->create_user_ok('user@example.org', name => 'Test User'); @@ -67,6 +68,10 @@ $admin_user->user_body_permissions->create({ body => $isleofwight, permission_type => 'triage' }); +$admin_user->user_body_permissions->create({ + body => $isleofwight, + permission_type => 'report_inspect', +}); my @reports = $mech->create_problems_for_body(1, $isleofwight->id, 'An Isle of wight report', { confirmed => '2019-10-25 09:00', @@ -590,6 +595,37 @@ subtest "reports are marked for triage upon submission" => sub { my $email = $mech->get_email; like $mech->get_text_body_from_email($email), qr/submitted to Island Roads for review/, 'correct text for email sent for Triage'; + + $mech->log_in_ok( $admin_user->email ); + $mech->get_ok( '/report/' . $report->id ); + $mech->content_contains( + '', + 'there is a "Roads" optgroup', + ); + $mech->content_contains( + '', + 'there is an empty-valued option selected by default', + ); + + $mech->submit_form( form_id => 'report_inspect_form' ); + $mech->text_contains( 'Please choose a category', + 'Form requires a category be chosen' ); + + $mech->submit_form( + form_id => 'report_inspect_form', + fields => { category => $contact->id }, # Pothole + ); + $mech->get_ok( '/report/' . $report->id ); + $mech->text_contains( + 'Report triaged from Roads to Potholes', + 'Update message describes triage', + ); + $mech->content_contains( + '[% END %] [% group_select = 0 %] [% selected = 0 %] - [%~ FOREACH cat_op IN group.categories ~%] + + [% SET categories = group.categories %] + [% IF c.cobrand.moniker == 'isleofwight' %] + [% + # Isle of Wight selects a blank option by default, + # to force admin user to select a triage category + %] + [% categories.unshift( + { id => '', category_display => loc('-- Please select --') } + ) + %] + [% END %] + + [%~ FOREACH cat_op IN categories ~%] [% IF group_select == 0 AND problem.category == group.name %] [% selected = 1; group_select = 1 %] [% END %] - + [% selected = 0 %] [%~ END ~%] [% IF group.name %][% END %]