diff options
author | Matthew Somerville <matthew@mysociety.org> | 2020-06-29 16:07:52 +0100 |
---|---|---|
committer | M Somerville <matthew-github@dracos.co.uk> | 2020-11-11 10:29:05 +0000 |
commit | dbde76a5090e772c806bd189426ee078b9b7e4ba (patch) | |
tree | f15015485554b852865e2388063a6942940f8340 /t | |
parent | ce1b3ec61fdaa954c26e55b8ce8cd1ad619b3538 (diff) |
[Bromley] Add waste reporting service.
This creates a non-map property-based reporting flow for reporting
missed collections and requesting new containers. Such reports are
always private, in categories that are hidden from the map filters
and never shown on .com.
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/waste.t | 85 | ||||
-rw-r--r-- | t/cobrand/bromley.t | 7 |
2 files changed, 91 insertions, 1 deletions
diff --git a/t/app/controller/waste.t b/t/app/controller/waste.t index 77b1ef5bc..454a593a6 100644 --- a/t/app/controller/waste.t +++ b/t/app/controller/waste.t @@ -1,8 +1,35 @@ use Test::MockModule; use FixMyStreet::TestMech; +FixMyStreet::App->log->disable('info'); +END { FixMyStreet::App->log->enable('info'); } + my $mech = FixMyStreet::TestMech->new; +my $body = $mech->create_body_ok(2482, 'Bromley Council'); +my $user = $mech->create_user_ok('test@example.net', name => 'Normal User'); +my $staff_user = $mech->create_user_ok('staff@example.org', from_body => $body, name => 'Staff User'); +$staff_user->user_body_permissions->create({ body => $body, permission_type => 'contribute_as_another_user' }); +$staff_user->user_body_permissions->create({ body => $body, permission_type => 'report_mark_private' }); + +sub create_contact { + my ($params, @extra) = @_; + my $contact = $mech->create_contact_ok(body => $body, %$params); + $contact->set_extra_metadata(group => ['Waste']); + $contact->set_extra_fields( + { code => 'uprn', required => 1, automated => 'hidden_field' }, + { code => 'service_id', required => 0, automated => 'hidden_field' }, + @extra, + ); + $contact->update; +} + +create_contact({ category => 'Report missed collection', email => 'missed' }); +create_contact({ category => 'Request new container', email => 'request' }, + { code => 'Quantity', required => 1, automated => 'hidden_field' }, + { code => 'Container_Type', required => 1, automated => 'hidden_field' }, +); + FixMyStreet::override_config { ALLOWED_COBRANDS => ['bromley', 'fixmystreet'], COBRAND_FEATURES => { echo => { bromley => { sample_data => 1 } }, waste => { bromley => 1 } }, @@ -21,6 +48,64 @@ FixMyStreet::override_config { $mech->content_contains('2 Example Street'); $mech->content_contains('Food Waste'); }; + subtest 'Report a missed bin' => sub { + $mech->follow_link_ok({ text => 'Report a missed collection' }); + $mech->submit_form_ok({ form_number => 2 }); + $mech->content_contains('Please specify what was missed'); + $mech->submit_form_ok({ with_fields => { 'service-101' => 1 } }); + $mech->submit_form_ok({ with_fields => { name => "Test" } }); + $mech->content_contains('Please enter your full name'); + $mech->content_contains('Please specify at least one of phone or email'); + $mech->submit_form_ok({ with_fields => { name => "Test McTest", email => 'test@example.org' } }); + $mech->content_contains('Refuse collection'); + $mech->content_contains('Test McTest'); + $mech->content_contains('test@example.org'); + $mech->submit_form_ok({ form_number => 3 }); + $mech->submit_form_ok({ with_fields => { name => "Test McTest", email => $user->email } }); + $mech->content_contains($user->email); + $mech->submit_form_ok({ with_fields => { process => 'summary' } }); + $mech->content_contains('Your report has been sent'); + + is $user->alerts->count, 1; + }; + subtest 'Check report visibility' => sub { + my $report = FixMyStreet::DB->resultset("Problem")->first; + my $res = $mech->get('/report/' . $report->id); + is $res->code, 403; + $mech->log_in_ok($user->email); + $mech->get_ok('/report/' . $report->id); + $mech->log_in_ok($staff_user->email); + $mech->get_ok('/report/' . $report->id); + + $mech->host('www.fixmystreet.com'); + $res = $mech->get('/report/' . $report->id); + is $res->code, 404; + $mech->log_in_ok($user->email); + $res = $mech->get('/report/' . $report->id); + is $res->code, 404; + $mech->log_in_ok($staff_user->email); + $res = $mech->get('/report/' . $report->id); + is $res->code, 404; + $mech->host('bromley.fixmystreet.com'); + }; + subtest 'Request a new container' => sub { + $mech->get_ok('/waste/uprn/1000000002/request'); + $mech->submit_form_ok({ form_number => 2 }); + $mech->content_contains('Please specify what you need'); + $mech->submit_form_ok({ with_fields => { 'container-1' => 1 } }); + $mech->content_contains('Quantity field is required'); + $mech->submit_form_ok({ with_fields => { 'container-1' => 1, 'quantity-1' => 2 } }); + $mech->submit_form_ok({ with_fields => { name => "Test McTest", email => $user->email } }); + $mech->content_contains('Green Box'); + $mech->content_contains('Test McTest'); + $mech->content_contains($user->email); + $mech->submit_form_ok({ with_fields => { process => 'summary' } }); + $mech->content_contains('Your request has been sent'); + my $report = FixMyStreet::DB->resultset("Problem")->search(undef, { order_by => { -desc => 'id' } })->first; + is $report->get_extra_field_value('uprn'), 1000000002; + is $report->get_extra_field_value('Quantity'), 2; + is $report->get_extra_field_value('Container_Type'), 1; + }; }; package SOAP::Result; diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t index d26b10709..f2b1c7a39 100644 --- a/t/cobrand/bromley.t +++ b/t/cobrand/bromley.t @@ -26,6 +26,10 @@ $mech->create_contact_ok( email => 'tfl@example.org', ); +my $waste = $mech->create_contact_ok(body => $body, category => 'Report missed collection', email => 'missed'); +$waste->set_extra_metadata(group => ['Waste']); +$waste->update; + my @reports = $mech->create_problems_for_body( 1, $body->id, 'Test', { latitude => 51.402096, longitude => 0.015784, @@ -177,7 +181,7 @@ for my $test ( }; } -subtest 'check display of TfL reports' => sub { +subtest 'check display of TfL and waste reports' => sub { $mech->create_problems_for_body( 1, $tfl->id, 'TfL Test', { latitude => 51.402096, longitude => 0.015784, @@ -193,6 +197,7 @@ subtest 'check display of TfL reports' => sub { }; $mech->content_like(qr{<a title="TfL Test[^>]*www.example.org[^>]*><img[^>]*grey}); $mech->content_like(qr{<a title="Test Test[^>]*href="/[^>]*><img[^>]*yellow}); + $mech->content_lacks('Report missed collection'); }; subtest 'check geolocation overrides' => sub { |