diff options
author | Steven Day <steve@mysociety.org> | 2015-06-29 15:45:08 +0100 |
---|---|---|
committer | Steven Day <steve@mysociety.org> | 2015-06-29 15:45:08 +0100 |
commit | 095b0639feaddfd93f0d371a77cc66a086f096a4 (patch) | |
tree | 41aac598c3d051288228593fddf247562be0d450 /t/app/controller/around.t | |
parent | 01e8f49c0e4caf966e85da05264b7e839fcf0493 (diff) |
Add some tests for the category & status filtering on /ajax
Diffstat (limited to 't/app/controller/around.t')
-rw-r--r-- | t/app/controller/around.t | 39 |
1 files changed, 39 insertions, 0 deletions
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(); |