diff options
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/report_new_update.t | 71 | ||||
-rw-r--r-- | t/cobrand/oxfordshire.t | 37 | ||||
-rw-r--r-- | t/open311/getservicerequestupdates.t | 2 |
3 files changed, 85 insertions, 25 deletions
diff --git a/t/app/controller/report_new_update.t b/t/app/controller/report_new_update.t new file mode 100644 index 000000000..cbb31cea4 --- /dev/null +++ b/t/app/controller/report_new_update.t @@ -0,0 +1,71 @@ +use FixMyStreet::TestMech; + +# disable info logs for this test run +FixMyStreet::App->log->disable('info'); +END { FixMyStreet::App->log->enable('info'); } + +my $mech = FixMyStreet::TestMech->new; + +my $comment_user = $mech->create_user_ok('systemuser@example.org', name => 'Glos Council'); +my $body = $mech->create_body_ok(2226, 'Gloucestershire County Council', { + comment_user => $comment_user, +}); + +$mech->create_contact_ok( + body_id => $body->id, + category => 'Potholes', + email => 'potholes@example.com', +); + +my $user = $mech->log_in_ok('test-2@example.com'); + +subtest "test report creation with no initial auto-update" => sub { + my $report = make_report(); + my $comment = FixMyStreet::DB->resultset('Comment')->count; + is $comment, 0, 'No comments left'; + $report->delete; +}; + +my $template = FixMyStreet::DB->resultset("ResponseTemplate")->create({ + body => $body, + state => 'confirmed', + title => 'Initial email response', + text => 'Thanks for your report. We will investigate within 5 working days.', + auto_response => 1, +}); +ok $template, 'Template created'; + +subtest "test report creation with initial auto-update" => sub { + my $report = make_report(); + my $comment = FixMyStreet::DB->resultset('Comment')->single; + is $comment->text, 'Thanks for your report. We will investigate within 5 working days.'; + is $comment->problem->id, $report->id; + is $comment->user->id, $comment_user->id; + is $comment->external_id, 'auto-internal'; + is $comment->name, 'Glos Council'; +}; + +done_testing; + +sub make_report { + FixMyStreet::override_config { + ALLOWED_COBRANDS => 'fixmystreet', + MAPIT_URL => 'http://mapit.uk/', + }, sub { + $mech->get_ok('/around?pc=GL50+2PR'); + $mech->follow_link_ok({ text_regex => qr/skip this step/i, }, "follow 'skip this step' link" ); + $mech->submit_form_ok({ + with_fields => { + title => "Test Report", + detail => 'Test report details.', + name => 'Joe Bloggs', + category => 'Potholes', + } + }, "submit good details"); + }; + + my $report = $user->problems->first; + ok $report, "Found the report"; + + return $report; +} diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t index 1d59909b9..65c6a3864 100644 --- a/t/cobrand/oxfordshire.t +++ b/t/cobrand/oxfordshire.t @@ -31,7 +31,7 @@ subtest 'check /around?ajax defaults to open reports only' => sub { } FixMyStreet::override_config { - ALLOWED_COBRANDS => [ { 'oxfordshire' => '.' } ], + ALLOWED_COBRANDS => 'oxfordshire', }, sub { my $json = $mech->get_ok_json( '/around?ajax=1&status=all&bbox=' . $bbox ); my $pins = $json->{pins}; @@ -47,13 +47,14 @@ subtest 'check /around?ajax defaults to open reports only' => sub { } }; -my @problems = FixMyStreet::DB->resultset('Problem')->search({}, { rows => 3 })->all; +my @problems = FixMyStreet::DB->resultset('Problem')->search({}, { rows => 3, order_by => 'id' })->all; -subtest 'can use customer reference to search for reports' => sub { - FixMyStreet::override_config { - ALLOWED_COBRANDS => [ 'oxfordshire' ], - MAPIT_URL => 'http://mapit.uk/', - }, sub { +FixMyStreet::override_config { + ALLOWED_COBRANDS => 'oxfordshire', + MAPIT_URL => 'http://mapit.uk/', +}, sub { + + subtest 'can use customer reference to search for reports' => sub { my $problem = $problems[0]; $problem->set_extra_metadata( customer_reference => 'ENQ12456' ); $problem->update; @@ -61,16 +62,11 @@ subtest 'can use customer reference to search for reports' => sub { $mech->get_ok('/around?pc=ENQ12456'); is $mech->uri->path, '/report/' . $problem->id, 'redirects to report'; }; -}; -my $user = $mech->create_user_ok( 'user@example.com', name => 'Test User' ); -my $user2 = $mech->create_user_ok( 'user2@example.com', name => 'Test User2' ); + subtest 'check unable to fix label' => sub { + my $user = $mech->create_user_ok( 'user@example.com', name => 'Test User' ); + my $user2 = $mech->create_user_ok( 'user2@example.com', name => 'Test User2' ); -subtest 'check unable to fix label' => sub { - FixMyStreet::override_config { - ALLOWED_COBRANDS => [ 'oxfordshire' ], - MAPIT_URL => 'http://mapit.uk/', - }, sub { my $problem = $problems[0]; $problem->state( 'unable to fix' ); $problem->update; @@ -104,13 +100,8 @@ subtest 'check unable to fix label' => sub { my $body = $mech->get_text_body_from_email($email); like $body, qr/Investigation complete/, 'state correct in email'; }; -}; -subtest 'extra CSV columns are present' => sub { - FixMyStreet::override_config { - ALLOWED_COBRANDS => [ 'oxfordshire' ], - MAPIT_URL => 'http://mapit.uk/', - }, sub { + subtest 'extra CSV columns are present' => sub { $problems[1]->update({ external_id => $problems[1]->id }); $problems[2]->update({ external_id => "123098123" }); @@ -139,6 +130,4 @@ subtest 'extra CSV columns are present' => sub { }; }; -END { - done_testing(); -} +done_testing(); diff --git a/t/open311/getservicerequestupdates.t b/t/open311/getservicerequestupdates.t index 35be0f7b5..4651c38b2 100644 --- a/t/open311/getservicerequestupdates.t +++ b/t/open311/getservicerequestupdates.t @@ -1057,7 +1057,7 @@ for my $test ( $problem->discard_changes; is $problem->comments->count, 2, 'two comment after fetching updates'; - my @comments = $problem->comments; + my @comments = $problem->comments->search(undef, { order_by => 'confirmed' }); is $comments[0]->text, "Thank you for your report. We will provide an update within 48 hours.", "correct external status code on first comment"; is $comments[1]->text, "Thank you for your report. We will provide an update within 24 hours.", "correct external status code on second comment"; |