From 095b0639feaddfd93f0d371a77cc66a086f096a4 Mon Sep 17 00:00:00 2001 From: Steven Day Date: Mon, 29 Jun 2015 15:45:08 +0100 Subject: Add some tests for the category & status filtering on /ajax --- t/app/controller/around.t | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 't/app/controller') diff --git a/t/app/controller/around.t b/t/app/controller/around.t index df4f18660..4040d1024 100644 --- a/t/app/controller/around.t +++ b/t/app/controller/around.t @@ -127,4 +127,43 @@ subtest 'check non public reports are not displayed on around page' => sub { }; +subtest 'check category and status filtering works on /ajax' => sub { + my $categories = [ 'Pothole', 'Vegetation', 'Flytipping' ]; + my $params = { + postcode => 'OX1 1ND', + latitude => 51.7435918829363, + longitude => -1.23201966270446, + }; + my $bbox = ($params->{longitude} - 0.01) . ',' . ($params->{latitude} - 0.01) + . ',' . ($params->{longitude} + 0.01) . ',' . ($params->{latitude} + 0.01); + + # Create one open and one fixed report in each category + foreach my $category ( @$categories ) { + foreach my $state ( 'confirmed', 'fixed' ) { + my %report_params = ( + %$params, + category => $category, + state => $state, + ); + $mech->create_problems_for_body( 1, 2237, 'Around page', \%report_params ); + } + } + + my $json = $mech->get_ok_json( '/ajax?bbox=' . $bbox ); + my $pins = $json->{pins}; + is scalar @$pins, 6, 'correct number of reports when no filters'; + + $json = $mech->get_ok_json( '/ajax?category=Pothole&bbox=' . $bbox ); + $pins = $json->{pins}; + is scalar @$pins, 2, 'correct number of Pothole reports'; + + $json = $mech->get_ok_json( '/ajax?status=open&bbox=' . $bbox ); + $pins = $json->{pins}; + is scalar @$pins, 3, 'correct number of open reports'; + + $json = $mech->get_ok_json( '/ajax?status=fixed&category=Vegetation&bbox=' . $bbox ); + $pins = $json->{pins}; + is scalar @$pins, 1, 'correct number of fixed Vegetation reports'; +}; + done_testing(); -- cgit v1.2.3 From 69ed1cda6a315a46e3309dcf3035ad7229931829 Mon Sep 17 00:00:00 2001 From: Steven Day Date: Mon, 29 Jun 2015 12:03:17 +0100 Subject: Rename map filtering GET param, remove unnecessary query --- t/app/controller/around.t | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 't/app/controller') diff --git a/t/app/controller/around.t b/t/app/controller/around.t index 4040d1024..03bcebf96 100644 --- a/t/app/controller/around.t +++ b/t/app/controller/around.t @@ -153,7 +153,7 @@ subtest 'check category and status filtering works on /ajax' => sub { my $pins = $json->{pins}; is scalar @$pins, 6, 'correct number of reports when no filters'; - $json = $mech->get_ok_json( '/ajax?category=Pothole&bbox=' . $bbox ); + $json = $mech->get_ok_json( '/ajax?filter_category=Pothole&bbox=' . $bbox ); $pins = $json->{pins}; is scalar @$pins, 2, 'correct number of Pothole reports'; @@ -161,7 +161,7 @@ subtest 'check category and status filtering works on /ajax' => sub { $pins = $json->{pins}; is scalar @$pins, 3, 'correct number of open reports'; - $json = $mech->get_ok_json( '/ajax?status=fixed&category=Vegetation&bbox=' . $bbox ); + $json = $mech->get_ok_json( '/ajax?status=fixed&filter_category=Vegetation&bbox=' . $bbox ); $pins = $json->{pins}; is scalar @$pins, 1, 'correct number of fixed Vegetation reports'; }; -- cgit v1.2.3