diff options
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/admin/bodies.t | 18 | ||||
-rw-r--r-- | t/app/controller/report_new_open311.t | 47 | ||||
-rw-r--r-- | t/app/model/problem.t | 9 |
3 files changed, 65 insertions, 9 deletions
diff --git a/t/app/controller/admin/bodies.t b/t/app/controller/admin/bodies.t index db53b7cda..6fb13f0ff 100644 --- a/t/app/controller/admin/bodies.t +++ b/t/app/controller/admin/bodies.t @@ -182,6 +182,7 @@ subtest 'check open311 configuring' => sub { send_comments => 0, send_method => 'Open311', fetch_all_problems => 0, + can_be_devolved => 1, # for next test } } ); @@ -192,6 +193,23 @@ subtest 'check open311 configuring' => sub { ok !$conf->get_extra_metadata('fetch_all_problems'), 'fetch all problems unset'; }; +subtest 'check open311 devolved editing' => sub { + $mech->get_ok('/admin/body/' . $body->id . '/test%20category'); + $mech->submit_form_ok( { with_fields => { + send_method => 'Email', + email => 'testing@example.org', + note => 'Updating contact to email', + } } ); + $mech->content_contains('Values updated'); + $mech->get_ok('/admin/body/' . $body->id . '/test%20category'); + $mech->submit_form_ok( { with_fields => { + send_method => '', + email => 'open311-code', + note => 'Removing email send method', + } } ); + $mech->content_contains('Values updated'); +}; + subtest 'check text output' => sub { $mech->get_ok('/admin/body/' . $body->id . '?text=1'); is $mech->content_type, 'text/plain'; diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t index b52e0af18..52f1ddc6e 100644 --- a/t/app/controller/report_new_open311.t +++ b/t/app/controller/report_new_open311.t @@ -62,6 +62,12 @@ my $contact4 = $mech->create_contact_ok( { description => 'Asset ID', code => 'central_asset_id', required => 'true', automated => 'hidden_field', variable => 'true', order => '2' }, ] }, ); +# Another one to switch to in disable form test +$mech->create_contact_ok( + body_id => $body2->id, # Edinburgh + category => 'Something Other', + email => '104', +); # test that the various bit of form get filled in and errors correctly # generated. @@ -310,6 +316,47 @@ subtest "Category extras includes form disabling string" => sub { answers => [ 'yes' ], }; } + + # Test new non-JS form disabling flow + $mech->get_ok('/report/new?latitude=55.952055&longitude=-3.189579'); + $mech->content_contains('name="submit_category_part_only"'); + $mech->submit_form_ok({ with_fields => { category => 'Pothole' } }); + $mech->content_contains('<div id="js-category-stopper" class="box-warning" role="alert" aria-live="assertive">'); + $mech->content_contains('Please ring us!'); + # Switch to another, okay, category + $mech->submit_form_ok({ with_fields => { category => 'Something Other' } }); + $mech->content_lacks('<div id="js-category-stopper" class="box-warning" role="alert" aria-live="assertive">'); + $mech->content_lacks('Please ring us!'); + + # Remove the required extra field so its error checking doesn't get in the way + my $extra = $contact4->get_extra_fields; + @$extra = grep { $_->{code} ne 'size' } @$extra; + $contact4->set_extra_fields(@$extra); + $contact4->update; + + # Test submission of whole form, switching back to a blocked category at the same time + $mech->submit_form_ok({ with_fields => { + category => 'Pothole', title => 'Title', detail => 'Detail', + username => 'testing@example.org', name => 'Testing Example', + } }); + $mech->content_contains('<div id="js-category-stopper" class="box-warning" role="alert" aria-live="assertive">'); + $mech->content_contains('Please ring us!'); + + # Test special answer disabling of form + $extra = $contact4->get_extra_fields; + @$extra = grep { $_->{code} ne 'ring' } @$extra; # Remove that all-category one + $contact4->set_extra_fields(@$extra); + $contact4->update; + $mech->get_ok('/report/new?latitude=55.952055&longitude=-3.189579'); + $mech->content_contains('name="submit_category_part_only"'); + $mech->submit_form_ok({ with_fields => { category => 'Pothole' } }); + $mech->content_contains('name="submit_category_part_only"'); + $mech->submit_form_ok({ with_fields => { dangerous => 'no' } }); + $mech->content_lacks('<div id="js-category-stopper" class="box-warning" role="alert" aria-live="assertive">'); + $mech->content_lacks('Please please ring'); + $mech->submit_form_ok({ with_fields => { dangerous => 'yes' } }); + $mech->content_contains('<div id="js-category-stopper" class="box-warning" role="alert" aria-live="assertive">'); + $mech->content_contains('Please please ring'); }; }; diff --git a/t/app/model/problem.t b/t/app/model/problem.t index 503fa9276..e973febc1 100644 --- a/t/app/model/problem.t +++ b/t/app/model/problem.t @@ -106,15 +106,6 @@ for my $test ( } }, { - desc => 'bad category', - changed => { - category => '-- Pick a category --', - }, - errors => { - category => 'Please choose a category', - } - }, - { desc => 'correct category', changed => { category => 'Horse!', |