diff options
author | Dave Arter <davea@mysociety.org> | 2019-10-14 12:46:26 +0100 |
---|---|---|
committer | Dave Arter <davea@mysociety.org> | 2019-12-09 12:48:12 +0000 |
commit | cbc9a483845567ed0b62709e1ff8b2206acd16ae (patch) | |
tree | d66c9502ec23a3be9043cc7c070f0fab9b4cbb2f /t/cobrand | |
parent | 360791e0f22abd4370e9c0d0c2592643504dafa0 (diff) |
[TfL] Apply pin colours & 6 weeks default age on map
Connects https://github.com/mysociety/fixmystreet-commercial/issues/1628
Diffstat (limited to 't/cobrand')
-rw-r--r-- | t/cobrand/tfl.t | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/t/cobrand/tfl.t b/t/cobrand/tfl.t index 769aeec9b..22727387d 100644 --- a/t/cobrand/tfl.t +++ b/t/cobrand/tfl.t @@ -107,6 +107,51 @@ subtest 'check lookup by reference' => sub { is $mech->uri->path, "/report/$id", "redirected to report page when using non-prefixed ref"; }; +for my $test ( + { + states => [ 'confirmed' ], + colour => 'red' + }, + { + states => ['action scheduled', 'in progress', 'investigating', 'planned'], + colour => 'orange' + }, + { + states => [ FixMyStreet::DB::Result::Problem->fixed_states, FixMyStreet::DB::Result::Problem->closed_states ], + colour => 'green' + }, +) { + subtest 'check ' . $test->{colour} . ' pin states' => sub { + my $report = FixMyStreet::DB->resultset("Problem")->find({ title => 'Test Report 1'}); + my $url = '/around?ajax=1&bbox=' . ($report->longitude - 0.01) . ',' . ($report->latitude - 0.01) + . ',' . ($report->longitude + 0.01) . ',' . ($report->latitude + 0.01); + + for my $state ( @{ $test->{states} } ) { + $report->update({ state => $state }); + my $json = $mech->get_ok_json( $url ); + my $colour = $json->{pins}[0][2]; + is $colour, $test->{colour}, 'correct ' . $test->{colour} . ' pin for state ' . $state; + } + }; +} + +subtest 'check report age on /around' => sub { + my $report = FixMyStreet::DB->resultset("Problem")->find({ title => 'Test Report 1'}); + $report->update({ state => 'confirmed' }); + + $mech->get_ok( '/around?lat=' . $report->latitude . '&lon=' . $report->longitude ); + $mech->content_contains($report->title); + + $report->update({ + confirmed => \"current_timestamp-'7 weeks'::interval", + whensent => \"current_timestamp-'7 weeks'::interval", + lastupdate => \"current_timestamp-'7 weeks'::interval", + }); + + $mech->get_ok( '/around?lat=' . $report->latitude . '&lon=' . $report->longitude ); + $mech->content_lacks($report->title); +}; + }; done_testing(); |