aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/app/controller/report_new_open311.t53
-rw-r--r--t/cobrand/bexley.t25
-rw-r--r--t/cobrand/staging.t18
-rw-r--r--t/map/cheshireeast.t18
-rw-r--r--t/map/tests.t1
5 files changed, 112 insertions, 3 deletions
diff --git a/t/app/controller/report_new_open311.t b/t/app/controller/report_new_open311.t
index 264198052..3488b96ce 100644
--- a/t/app/controller/report_new_open311.t
+++ b/t/app/controller/report_new_open311.t
@@ -67,6 +67,23 @@ $mech->create_contact_ok(
category => 'Something Other',
email => '104',
);
+$mech->create_contact_ok(
+ body_id => $body2->id, # Edinburgh
+ category => 'Abandoned vehicle',
+ email => '105',
+ extra => { _fields => [
+ { description => 'This is a warning message.', code => 'notice', required => 'false', variable => 'false', order => '0' },
+ { description => 'USRN', code => 'usrn', required => 'false', automated => 'hidden_field' },
+ ] },
+);
+$mech->create_contact_ok(
+ body_id => $body2->id, # Edinburgh
+ category => 'Traffic signals',
+ email => '106',
+ extra => { _fields => [
+ { description => 'This is a warning message for traffic signals.', code => 'notice', required => 'false', variable => 'false', order => '0' },
+ ] },
+);
my $staff_user = $mech->create_user_ok('staff@example.org', name => 'staff', from_body => $body->id);
@@ -283,6 +300,42 @@ subtest "Category extras omits description label when all fields are hidden" =>
};
};
+subtest "Category extras omits preamble when all fields are notices" => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
+ MAPIT_URL => 'http://mapit.uk/',
+ }, sub {
+ for (
+ { url => '/report/new/ajax?' },
+ { url => '/report/new/category_extras?category=Traffic+signals' },
+ ) {
+ my $json = $mech->get_ok_json($_->{url} . '&latitude=55.952055&longitude=-3.189579');
+ my $category_extra = $json->{by_category} ? $json->{by_category}{'Traffic signals'}{category_extra} : $json->{category_extra};
+ contains_string($category_extra, "This is a warning message for traffic signals.");
+ lacks_string($category_extra, "resolve your problem quicker, by providing some extra detail", "Lacks description text");
+ }
+ };
+};
+
+subtest "Category extras omits preamble when fields are only notices and hidden" => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
+ MAPIT_URL => 'http://mapit.uk/',
+ }, sub {
+ for (
+ { url => '/report/new/ajax?' },
+ { url => '/report/new/category_extras?category=Abandoned+vehicle' },
+ ) {
+ my $json = $mech->get_ok_json($_->{url} . '&latitude=55.952055&longitude=-3.189579');
+ my $category_extra = $json->{by_category} ? $json->{by_category}{'Abandoned vehicle'}{category_extra} : $json->{category_extra};
+ contains_string($category_extra, "This is a warning message.");
+ contains_string($category_extra, "usrn");
+ lacks_string($category_extra, "USRN", "Lacks 'USRN' label");
+ lacks_string($category_extra, "resolve your problem quicker, by providing some extra detail", "Lacks description text");
+ }
+ };
+};
+
subtest "Category extras includes description label for user" => sub {
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ { fixmystreet => '.' } ],
diff --git a/t/cobrand/bexley.t b/t/cobrand/bexley.t
index 511c0770e..d7e996e0d 100644
--- a/t/cobrand/bexley.t
+++ b/t/cobrand/bexley.t
@@ -35,7 +35,7 @@ my $mech = FixMyStreet::TestMech->new;
my $body = $mech->create_body_ok(2494, 'London Borough of Bexley', {
send_method => 'Open311', api_key => 'key', 'endpoint' => 'e', 'jurisdiction' => 'j' });
$mech->create_contact_ok(body_id => $body->id, category => 'Abandoned and untaxed vehicles', email => "ABAN");
-$mech->create_contact_ok(body_id => $body->id, category => 'Lamp post', email => "LAMP");
+$mech->create_contact_ok(body_id => $body->id, category => 'Lamp post', email => "StreetLightingLAMP");
$mech->create_contact_ok(body_id => $body->id, category => 'Gulley covers', email => "GULL");
$mech->create_contact_ok(body_id => $body->id, category => 'Damaged road', email => "ROAD");
$mech->create_contact_ok(body_id => $body->id, category => 'Flooding in the road', email => "ConfirmFLOD");
@@ -90,9 +90,9 @@ FixMyStreet::override_config {
extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'No' } },
{ category => 'Damaged road', code => 'ROAD', email => ['p1'],
extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'Yes' } },
- { category => 'Lamp post', code => 'LAMP', email => ['thirdparty', 'another'],
+ { category => 'Lamp post', code => 'StreetLightingLAMP', email => ['thirdparty', 'another'],
extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'No' } },
- { category => 'Lamp post', code => 'LAMP', email => ['thirdparty', 'another'],
+ { category => 'Lamp post', code => 'StreetLightingLAMP', email => ['thirdparty', 'another'],
extra => { 'name' => 'dangerous', description => 'Was it dangerous?', 'value' => 'Yes' } },
{ category => 'Flytipping', code => 'UniformFLY', email => ['eh'] },
{ category => 'Flooding in the road', code => 'ConfirmFLOD', email => ['flooding'] },
@@ -146,6 +146,25 @@ FixMyStreet::override_config {
$mech->content_lacks('Resend report');
};
+ subtest "resending of reports by changing category" => sub {
+ $mech->get_ok('/admin/report_edit/' . $report->id);
+ $mech->submit_form_ok({ with_fields => { category => 'Damaged road' } });
+ my $test_data = FixMyStreet::Script::Reports::send();
+ my $req = $test_data->{test_req_used};
+ my $c = CGI::Simple->new($req->content);
+ is $c->param('service_code'), 'ROAD', 'Report resent in new category';
+
+ $mech->submit_form_ok({ with_fields => { category => 'Gulley covers' } });
+ $test_data = FixMyStreet::Script::Reports::send();
+ is $test_data, undef, 'Report not resent';
+
+ $mech->submit_form_ok({ with_fields => { category => 'Lamp post' } });
+ $test_data = FixMyStreet::Script::Reports::send();
+ $req = $test_data->{test_req_used};
+ $c = CGI::Simple->new($req->content);
+ is $c->param('service_code'), 'StreetLightingLAMP', 'Report resent';
+ };
+
subtest 'extra CSV column present' => sub {
$mech->get_ok('/dashboard?export=1');
$mech->content_contains(',Category,Subcategory,');
diff --git a/t/cobrand/staging.t b/t/cobrand/staging.t
new file mode 100644
index 000000000..5d79daa4b
--- /dev/null
+++ b/t/cobrand/staging.t
@@ -0,0 +1,18 @@
+use FixMyStreet::TestMech;
+my $mech = FixMyStreet::TestMech->new;
+
+subtest 'staging banner is visible by default on staging sites' => sub {
+ $mech->get_ok('/');
+ $mech->content_contains('<div class="dev-site-notice">');
+};
+
+FixMyStreet::override_config {
+ STAGING_FLAGS => { hide_staging_banner => 1 },
+}, sub {
+ subtest 'staging banner can be hidden through STAGING_FLAGS config' => sub {
+ $mech->get_ok('/');
+ $mech->content_lacks('<div class="dev-site-notice">');
+ };
+};
+
+done_testing();
diff --git a/t/map/cheshireeast.t b/t/map/cheshireeast.t
new file mode 100644
index 000000000..a90a1606e
--- /dev/null
+++ b/t/map/cheshireeast.t
@@ -0,0 +1,18 @@
+use Test::More;
+use FixMyStreet::Map::CheshireEast;
+
+# https://maps-cache.cheshiresharedservices.gov.uk/maps/?wmts/CE_OS_AllBasemaps_COLOUR/oscce_grid/10/10187/8134.jpeg&KEY=3a3f5c60eca1404ea114e6941c9d3895
+my $tiles = FixMyStreet::Map::CheshireEast->map_tiles(x_tile => 10187, y_tile => 8134, zoom_act => 10);
+$tiles = [ map { m{(\d+/\d+/\d+)}; $1; } @$tiles ];
+is_deeply $tiles, [ '10/10186/8133', '10/10187/8133', '10/10186/8134', '10/10187/8134' ];
+
+use Data::Dumper;
+my ($x, $y) = FixMyStreet::Map::CheshireEast->latlon_to_tile_with_adjust(53.150624, -2.386809, 10);
+is $x, 10187;
+is $y, 8134;
+
+my ($lat, $lon) = FixMyStreet::Map::CheshireEast->tile_to_latlon(10187, 8134, 10);
+is sprintf("%.6f", $lat), 53.150624;
+is sprintf("%.6f", $lon), -2.386809;
+
+done_testing();
diff --git a/t/map/tests.t b/t/map/tests.t
index 499447ad5..02ec4e69d 100644
--- a/t/map/tests.t
+++ b/t/map/tests.t
@@ -7,6 +7,7 @@ my $requires = {
'Bromley' => 'map-fms.js',
'Buckinghamshire' => 'map-wmts-buckinghamshire.js',
'Lincolnshire' => 'lincolnshire/assets.js',
+ 'CheshireEast' => 'map-cheshireeast.js',
'FMS' => 'map-fms.js',
'Google' => 'map-google.js',
'GoogleOL' => 'map-google-ol.js',