-
-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Sutton] Bin not being returned and waste spillage
- Loading branch information
Showing
6 changed files
with
110 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ FixMyStreet::App->log->disable('info'); | |
END { FixMyStreet::App->log->enable('info'); } | ||
|
||
my $mech = FixMyStreet::TestMech->new; | ||
my $sample_file = path(__FILE__)->parent->child("sample.jpg"); | ||
|
||
my $bin_data = decode_json(path(__FILE__)->sibling('waste_sutton_4443082.json')->slurp_utf8); | ||
my $bin_140_data = decode_json(path(__FILE__)->sibling('waste_sutton_4443082_140.json')->slurp_utf8); | ||
|
@@ -59,6 +60,15 @@ create_contact({ category => 'Request new container', email => '1635' }, 'Waste' | |
{ code => 'payment_method', required => 0, automated => 'hidden_field' }, | ||
{ code => 'payment', required => 0, automated => 'hidden_field' }, | ||
); | ||
create_contact({ category => 'Bin not returned', email => '3135' }, 'Waste', | ||
{ code => 'Image', description => 'Image', required => 0, datatype => 'image' }, | ||
{ code => 'Exact_Location', description => 'Exact location', required => 0, datatype => 'text' }, | ||
{ code => 'Notes', required => 0, automated => 'hidden_field' }, | ||
); | ||
create_contact({ category => 'Waste spillage', email => '3227' }, 'Waste', | ||
{ code => 'Image', description => 'Image', required => 0, datatype => 'image' }, | ||
{ code => 'Notes', description => 'Details of the spillage', required => 0, datatype => 'text' }, | ||
); | ||
|
||
my $sent_params; | ||
|
||
|
@@ -425,6 +435,67 @@ FixMyStreet::override_config { | |
$mech->content_contains('Put your bags out between 6pm and 8pm'); | ||
$e->mock('GetServiceUnitsForObject', sub { $bin_data }); | ||
}; | ||
|
||
subtest 'test report a problem' => sub { | ||
FixMyStreet::Script::Reports::send(); | ||
$mech->clear_emails_ok; | ||
$mech->get_ok('/waste/12345'); | ||
$mech->content_contains('Report a problem with a non-recyclable refuse collection', 'Can report a problem with non-recyclable waste'); | ||
$mech->content_contains('Report a problem with a food waste collection', 'Can report a problem with food waste'); | ||
my $root = HTML::TreeBuilder->new_from_content($mech->content()); | ||
my $panel = $root->look_down(id => 'panel-948'); | ||
is $panel->as_text =~ /.*Please note that missed collections can only be reported.*/, 1, "Paper and card past reporting deadline"; | ||
$mech->content_lacks('Report a problem with a paper and card collection', 'Can not report a problem with paper and card as past reporting deadline'); | ||
$mech->follow_link_ok({ text => 'Report a problem with a non-recyclable refuse collection' }); | ||
$mech->submit_form_ok( { with_fields => { category => 'Bin not returned' } }); | ||
$mech->submit_form_ok( { with_fields => { extra_Exact_Location => 'hello' } } ); | ||
$mech->submit_form_ok( { with_fields => { name => 'Joe Schmoe', email => '[email protected]' } }); | ||
$mech->submit_form_ok( { with_fields => { submit => '1' } }); | ||
$mech->content_contains('Your enquiry has been submitted'); | ||
$mech->content_contains('Return to property details'); | ||
$mech->content_contains('/waste/12345"'); | ||
my $report = FixMyStreet::DB->resultset("Problem")->search(undef, { order_by => { -desc => 'id' } })->first; | ||
is $report->get_extra_field_value('Notes'), '', "Blank notes field is empty string"; | ||
is $report->detail, "2 Example Street, Sutton, SM1 1AA", "Details of report contain information about problem"; | ||
is $report->user->email, '[email protected]', 'User details added to report'; | ||
is $report->name, 'Joe Schmoe', 'User details added to report'; | ||
is $report->category, 'Bin not returned', "Correct category"; | ||
FixMyStreet::Script::Reports::send(); | ||
my $email = $mech->get_email; | ||
is $mech->get_text_body_from_email($email) =~ /Your report over the problem with your bin collection has been made to the council/, 1, 'Other problem text included in email'; | ||
my $req = Open311->test_req_used; | ||
my $cgi = CGI::Simple->new($req->content); | ||
is $cgi->param('api_key'), 'KEY'; | ||
is $cgi->param('attribute[Exact_Location]'), 'hello'; | ||
is $cgi->param('attribute[Notes]'), ''; | ||
$mech->get_ok('/waste/12345'); | ||
$mech->follow_link_ok({ text => 'Report a problem with a non-recyclable refuse collection' }); | ||
$mech->submit_form_ok( { with_fields => { category => 'Waste spillage' } }); | ||
$mech->submit_form_ok( { with_fields => { | ||
extra_Notes => 'Rubbish left on driveway', | ||
extra_Image => [ $sample_file, undef, Content_Type => 'image/jpeg' ], | ||
} }); | ||
$mech->submit_form_ok( { with_fields => { name => 'Joe Schmoe', email => '[email protected]' } }); | ||
$mech->submit_form_ok( { with_fields => { submit => '1' } }); | ||
$mech->content_contains('Your enquiry has been submitted'); | ||
$mech->content_contains('Return to property details'); | ||
$mech->content_contains('/waste/12345"'); | ||
$report = FixMyStreet::DB->resultset("Problem")->search(undef, { order_by => { -desc => 'id' } })->first; | ||
is $report->category, 'Waste spillage', "Correct category"; | ||
is $report->get_extra_field_value('Notes'), 'Rubbish left on driveway', "Notes filled in"; | ||
is $report->detail, "Rubbish left on driveway\n\n2 Example Street, Sutton, SM1 1AA", "Details of report contain information about problem"; | ||
is $report->user->email, '[email protected]', 'User details added to report'; | ||
is $report->name, 'Joe Schmoe', 'User details added to report'; | ||
$mech->clear_emails_ok; | ||
FixMyStreet::Script::Reports::send(); | ||
$email = $mech->get_email; | ||
is $mech->get_text_body_from_email($email) =~ /Your report over the problem with your bin collection has been made to the council/, 1, 'Other problem text included in email'; | ||
$req = Open311->test_req_used; | ||
$cgi = CGI::Simple->new($req->content); | ||
is $cgi->param('api_key'), 'KEY'; | ||
is $cgi->param('attribute[Notes]'), 'Rubbish left on driveway', "Notes added to open311 data for Echo"; | ||
}; | ||
|
||
}; | ||
|
||
sub get_report_from_redirect { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[% PROCESS waste/enquiry.html | ||
title = 'Report a problem' | ||
field_options = [ | ||
{ value = 'Bin not returned', label = 'Bin not returned correctly' }, | ||
{ value = 'Waste spillage', label = 'Waste spillage' }, | ||
] | ||
%] |