aboutsummaryrefslogtreecommitdiffstats
path: root/t/cobrand
diff options
context:
space:
mode:
Diffstat (limited to 't/cobrand')
-rw-r--r--t/cobrand/bromley.t4
-rw-r--r--t/cobrand/councils.t36
-rw-r--r--t/cobrand/fixamingata.t10
-rw-r--r--t/cobrand/fixmystreet.t114
-rw-r--r--t/cobrand/form_extras.t2
-rw-r--r--t/cobrand/oxfordshire.t17
-rw-r--r--t/cobrand/zurich.t2
7 files changed, 168 insertions, 17 deletions
diff --git a/t/cobrand/bromley.t b/t/cobrand/bromley.t
index f3053c29a..a64337085 100644
--- a/t/cobrand/bromley.t
+++ b/t/cobrand/bromley.t
@@ -74,7 +74,7 @@ for my $test (
cobrand => 'bromley',
fields => {
submit_update => 1,
- rznvy => 'unregistered@example.com',
+ username => 'unregistered@example.com',
update => 'Update from an unregistered user',
add_alert => undef,
first_name => 'Unreg',
@@ -87,7 +87,7 @@ for my $test (
cobrand => 'fixmystreet',
fields => {
submit_update => 1,
- rznvy => 'unregistered@example.com',
+ username => 'unregistered@example.com',
update => 'Update from an unregistered user',
add_alert => undef,
name => 'Unreg User',
diff --git a/t/cobrand/councils.t b/t/cobrand/councils.t
index 4de8bbf2e..c44605bd9 100644
--- a/t/cobrand/councils.t
+++ b/t/cobrand/councils.t
@@ -1,6 +1,15 @@
use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
+my $oxon = $mech->create_body_ok(2237, 'Oxfordshire County Council' );
+my $contact = $mech->create_contact_ok( body_id => $oxon->id, category => 'Cows', email => 'cows@example.net' );
+
+my ($report) = $mech->create_problems_for_body(1, $oxon->id, 'Test', {
+ category => 'Cows', cobrand => 'fixmystreet',
+});
+my $report_id = $report->id;
+
+
foreach my $council (qw/oxfordshire bromley/) {
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ $council ],
@@ -11,4 +20,31 @@ foreach my $council (qw/oxfordshire bromley/) {
};
}
+
+foreach my $test (
+ { cobrand => 'fixmystreet', social => 1 },
+ { cobrand => 'bromley', social => 0 },
+) {
+
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ $test->{cobrand} ],
+ FACEBOOK_APP_ID => 'facebook-app-id',
+ TWITTER_KEY => 'twitter-key',
+ MAPIT_URL => 'http://mapit.uk/',
+ }, sub {
+ $mech->get_ok('/auth');
+ $mech->contains_or_lacks($test->{social}, "Log in with Facebook");
+ $mech->contains_or_lacks($test->{social}, "Log in with Twitter");
+
+ $mech->get_ok("/report/new?lat=51.754926&lon=-1.256179");
+ $mech->contains_or_lacks($test->{social}, "Log in with Facebook");
+ $mech->contains_or_lacks($test->{social}, "Log in with Twitter");
+
+ $mech->get_ok("/report/$report_id");
+ $mech->contains_or_lacks($test->{social}, "Log in with Facebook");
+ $mech->contains_or_lacks($test->{social}, "Log in with Twitter");
+ };
+};
+
+
done_testing();
diff --git a/t/cobrand/fixamingata.t b/t/cobrand/fixamingata.t
index 1e6bd7e65..133a8c950 100644
--- a/t/cobrand/fixamingata.t
+++ b/t/cobrand/fixamingata.t
@@ -1,13 +1,10 @@
-use Test::MockModule;
-
use mySociety::Locale;
use FixMyStreet::TestMech;
my $mech = FixMyStreet::TestMech->new;
-# Closest road reverse geocode mock
-my $resolver = Test::MockModule->new('LWP::Simple');
-$resolver->mock('get', sub($) { "<result></result>" });
+use t::Mock::Nominatim;
+LWP::Protocol::PSGI->register(t::Mock::Nominatim->to_psgi_app, host => 'nominatim.openstreetmap.org');
# Front page test
@@ -103,6 +100,9 @@ subtest "Test ajax decimal points" => sub {
$mech->get_ok('/ajax/lookup_location?term=12345');
# We want an actual decimal point in a JSON response...
$mech->content_contains('51.5');
+
+ $mech->get_ok('/ajax/lookup_location?term=high+street');
+ $mech->content_contains("Ed\xc3\xadnburgh");
};
};
diff --git a/t/cobrand/fixmystreet.t b/t/cobrand/fixmystreet.t
new file mode 100644
index 000000000..30d5765a2
--- /dev/null
+++ b/t/cobrand/fixmystreet.t
@@ -0,0 +1,114 @@
+use FixMyStreet::Script::UpdateAllReports;
+
+use FixMyStreet::TestMech;
+my $mech = FixMyStreet::TestMech->new;
+
+my $body = $mech->create_body_ok( 2514, 'Birmingham' );
+
+my $contact = $mech->create_contact_ok(
+ body_id => $body->id,
+ category => 'Traffic lights',
+ email => 'lights@example.com'
+);
+
+my $data;
+FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.uk/',
+}, sub {
+ $data = FixMyStreet::Script::UpdateAllReports::generate_dashboard($body);
+};
+
+FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.uk/',
+ TEST_DASHBOARD_DATA => $data,
+ ALLOWED_COBRANDS => 'fixmystreet',
+}, sub {
+ subtest 'check marketing dashboard access' => sub {
+ # Not logged in, redirected
+ $mech->get_ok('/reports/Birmingham/summary');
+ is $mech->uri->path, '/about/council-dashboard';
+
+ $mech->submit_form_ok({ with_fields => { username => 'someone@somewhere.example.org' }});
+ $mech->content_contains('We will be in touch');
+ # XXX Check email arrives
+
+ $mech->log_in_ok('someone@somewhere.example.org');
+ $mech->get_ok('/reports/Birmingham/summary');
+ is $mech->uri->path, '/about/council-dashboard';
+ $mech->content_contains('Ending in .gov.uk');
+
+ $mech->submit_form_ok({ with_fields => { name => 'Someone', username => 'someone@birmingham.gov.uk' }});
+ $mech->content_contains('Now check your email');
+ # XXX Check email arrives, click link
+
+ $mech->log_in_ok('someone@birmingham.gov.uk');
+ # Logged in, redirects
+ $mech->get_ok('/about/council-dashboard');
+ is $mech->uri->path, '/reports/Birmingham/summary';
+ $mech->content_contains('Where we send Birmingham');
+ $mech->content_contains('lights@example.com');
+ };
+
+ subtest 'check marketing dashboard csv' => sub {
+ $mech->log_in_ok('someone@birmingham.gov.uk');
+ $mech->create_problems_for_body(105, $body->id, 'Title', {
+ detail => "this report\nis split across\nseveral lines",
+ areas => ",2514,",
+ });
+
+ $mech->get_ok('/reports/Birmingham/summary?csv=1');
+ open my $data_handle, '<', \$mech->content;
+ my $csv = Text::CSV->new( { binary => 1 } );
+ my @rows;
+ while ( my $row = $csv->getline( $data_handle ) ) {
+ push @rows, $row;
+ }
+ is scalar @rows, 101, '1 (header) + 100 (reports) = 101 lines';
+
+ is scalar @{$rows[0]}, 10, '10 columns present';
+
+ is_deeply $rows[0],
+ [
+ 'Report ID',
+ 'Title',
+ 'Category',
+ 'Created',
+ 'Confirmed',
+ 'Status',
+ 'Latitude',
+ 'Longitude',
+ 'Query',
+ 'Report URL',
+ ],
+ 'Column headers look correct';
+
+ my $body_id = $body->id;
+ like $rows[1]->[1], qr/Title Test \d+ for $body_id/, 'problem title correct';
+ };
+
+ subtest 'check marketing dashboard contact listings' => sub {
+ $mech->log_in_ok('someone@birmingham.gov.uk');
+ $body->send_method('Open311');
+ $body->update();
+ $mech->get_ok('/about/council-dashboard');
+ $mech->content_contains('Reports to Birmingham are currently sent directly');
+
+ $body->send_method('Refused');
+ $body->update();
+ $mech->get_ok('/about/council-dashboard');
+ $mech->content_contains('Birmingham currently does not accept');
+
+ $body->send_method('Noop');
+ $body->update();
+ $mech->get_ok('/about/council-dashboard');
+ $mech->content_contains('Reports are currently not being sent');
+
+ $mech->log_out_ok();
+ $mech->get_ok('/reports');
+ $mech->content_lacks('Where we send Birmingham');
+ };
+};
+
+END {
+ done_testing();
+}
diff --git a/t/cobrand/form_extras.t b/t/cobrand/form_extras.t
index f450d908e..84ded5bc1 100644
--- a/t/cobrand/form_extras.t
+++ b/t/cobrand/form_extras.t
@@ -37,7 +37,7 @@ FixMyStreet::override_config {
detail => 'Test report details.',
name => 'Joe Bloggs',
may_show_name => '1',
- email => 'test-1@example.com',
+ username => 'test-1@example.com',
passport => '123456',
password_register => '',
}
diff --git a/t/cobrand/oxfordshire.t b/t/cobrand/oxfordshire.t
index a79a8f2a4..ee30e7e0b 100644
--- a/t/cobrand/oxfordshire.t
+++ b/t/cobrand/oxfordshire.t
@@ -7,7 +7,7 @@ my $mech = FixMyStreet::TestMech->new;
my $oxon = $mech->create_body_ok(2237, 'Oxfordshire County Council');
-subtest 'check /ajax defaults to open reports only' => sub {
+subtest 'check /around?ajax defaults to open reports only' => sub {
my $categories = [ 'Bridges', 'Fences', 'Manhole' ];
my $params = {
postcode => 'OX28 4DS',
@@ -33,15 +33,15 @@ subtest 'check /ajax defaults to open reports only' => sub {
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ { 'oxfordshire' => '.' } ],
}, sub {
- my $json = $mech->get_ok_json( '/ajax?status=all&bbox=' . $bbox );
+ my $json = $mech->get_ok_json( '/around?ajax=1&status=all&bbox=' . $bbox );
my $pins = $json->{pins};
is scalar @$pins, 6, 'correct number of reports created';
- $json = $mech->get_ok_json( '/ajax?bbox=' . $bbox );
+ $json = $mech->get_ok_json( '/around?ajax=1&bbox=' . $bbox );
$pins = $json->{pins};
is scalar @$pins, 3, 'correct number of reports returned with no filters';
- $json = $mech->get_ok_json( '/ajax?filter_category=Fences&bbox=' . $bbox );
+ $json = $mech->get_ok_json( '/around?ajax=1&filter_category=Fences&bbox=' . $bbox );
$pins = $json->{pins};
is scalar @$pins, 1, 'only one Fences report by default';
}
@@ -107,6 +107,7 @@ subtest 'Exor file looks okay' => sub {
foreach my $problem (@problems) {
$problem->update({ state => 'action scheduled', external_id => $i });
$problem->update({ defect_type => $dt }) if $i == 123;
+ $problem->set_extra_metadata(traffic_information => 'Signs and Cones') if $i == 124;
$problem->update({ defect_type => $dt2 }) if $i == 124;
FixMyStreet::DB->resultset('AdminLog')->create({
admin_user => $inspector->name,
@@ -129,19 +130,19 @@ subtest 'Exor file looks okay' => sub {
"1,1.8,1.0.0.0,ENHN,"
"G,1989169,,,XX,170505,1600,D,INS,N,,,,"
"H,FC"
-"I,FC,,XXX,"434970E 209683N Nearest postcode: OX28 4DS.",1200,,,,,,,,"TM none","123 ""
+"I,FC,,XXX,"434970E 209683N Nearest postcode: OX28 4DS.",1200,,,,,,,,"TM none","123 XX TM0 ""
"J,SFP1,2,,,434970,209683,,,,,"
"M,resolve,,,/CFC,,"
"P,0,999999"
"G,1989169,,,XX,170505,1600,D,INS,N,,,,"
"H,MC"
-"I,MC,,XXX,"434970E 209683N Nearest postcode: OX28 4DS.",1200,,,,,,,,"TM none","125 ""
+"I,MC,,XXX,"434970E 209683N Nearest postcode: OX28 4DS.",1200,,,,,,,,"TM none","125 XX TM0 ""
"J,SFP2,2,,,434970,209683,,,,,"
"M,resolve,,,/CMC,,"
"P,0,999999"
"G,1989169,,,XX,170505,1600,D,INS,N,,,,"
"H,S"
-"I,S,,XXX,"434970E 209683N Nearest postcode: OX28 4DS.",1200,,,,,,,,"TM none","124 ""
+"I,S,,XXX,"434970E 209683N Nearest postcode: OX28 4DS.",1200,,,,,,,,"TM Signs and Cones","124 XX TM1 ""
"J,ACC2,2,,,434970,209683,,,,,"
"M,resolve,,,/CSI,,"
"P,0,999999"
@@ -217,7 +218,7 @@ subtest 'response times messages displayed' => sub {
title => 'Test Report',
detail => 'Test report details.',
photo1 => '',
- email => 'test-2@example.com',
+ username => 'test-2@example.com',
name => 'Test User',
category => 'Pothole',
}
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index 03b20b087..e0671db2a 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -808,7 +808,7 @@ subtest "photo must be supplied for categories that require it" => sub {
$mech->get_ok('/report/new?lat=47.381817&lon=8.529156');
$mech->submit_form_ok({ with_fields => {
detail => 'Problem-Bericht',
- email => 'user@example.org',
+ username => 'user@example.org',
category => 'Graffiti - photo required',
}});
is $mech->res->code, 200, "missing photo shouldn't return anything but 200";