aboutsummaryrefslogtreecommitdiffstats
path: root/t/map/tilma/original.t
blob: f16f5b2448013c67b116d92db52542b30771f502 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
use strict;
use warnings;
use Test::More;
use FixMyStreet::DB;
use FixMyStreet::Map;
use FixMyStreet::TestMech;
use DateTime;
use mySociety::Locale;

use Catalyst::Test 'FixMyStreet::App';

my $mech = FixMyStreet::TestMech->new;

mySociety::Locale::gettext_domain('FixMyStreet');

FixMyStreet::Map::set_map_class();
my $c = ctx_request('http://fixmystreet.com/test?bbox=-7.6,49.7,-7.5,49.8');

$mech->delete_user('test@example.com');
my $user =
  FixMyStreet::DB->resultset('User')
  ->find_or_create( { email => 'test@example.com', name => 'Test User' } );
ok $user, "created test user";

my $dt = DateTime->now();


my $report = FixMyStreet::DB->resultset('Problem')->find_or_create(
    {
        postcode           => 'SW1A 1AA',
        bodies_str         => '2504',
        areas              => ',105255,11806,11828,2247,2504,',
        category           => 'Other',
        title              => 'Test 2',
        detail             => 'Test 2 Detail',
        used_map           => 't',
        name               => 'Test User',
        anonymous          => 'f',
        state              => 'fixed',
        confirmed          => $dt->ymd . ' ' . $dt->hms,
        lang               => 'en-gb',
        service            => '',
        cobrand            => 'default',
        cobrand_data       => '',
        send_questionnaire => 't',
        latitude           => '49.7668057243776',
        longitude          => '-7.55715980363992',
        user_id            => $user->id,
    }
);

for my $test ( 
    {
        state => 'fixed', 
        colour => 'yellow',
    },
    {
        state => 'fixed - user', 
        colour => 'yellow',
    },
    {
        state => 'fixed - council', 
        colour => 'yellow',
    },
    {
        state => 'confirmed', 
        colour => 'yellow',
    },
    {
        state => 'duplicate', 
        colour => 'yellow',
    },
    {
        state => 'unable to fix', 
        colour => 'yellow',
    },
    {
        state => 'not responsible', 
        colour => 'yellow',
    },
    {
        state => 'investigating', 
        colour => 'yellow',
    },
    {
        state => 'action scheduled', 
        colour => 'yellow',
    },
    {
        state => 'planned', 
        colour => 'yellow',
    },
    {
        state => 'in progress', 
        colour => 'yellow',
    },
) {
    subtest "pin colour for state $test->{state}" => sub {
        $report->state($test->{state});
        $report->update;

        my ( $on_map_all, $on_map_list, $nearby, $dist ) =
            FixMyStreet::Map::map_features($c, bbox => "0,0,0,0");

        ok $on_map_list;
        ok $nearby;
        ok $dist;

        my $id = $report->id;
        my $colour = $test->{colour};

        my $pin_colour = $c->cobrand->pin_colour($on_map_all->[0], 'around');
        is $pin_colour, $colour, 'pin colour';
    };
}

$mech->delete_user( $user );


done_testing();