diff options
Diffstat (limited to 't/app/controller/dashboard.t')
-rw-r--r-- | t/app/controller/dashboard.t | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/t/app/controller/dashboard.t b/t/app/controller/dashboard.t index 788b41dbe..eccbc0cde 100644 --- a/t/app/controller/dashboard.t +++ b/t/app/controller/dashboard.t @@ -3,6 +3,7 @@ use warnings; use Test::More; use FixMyStreet::TestMech; +use Web::Scraper; my $mech = FixMyStreet::TestMech->new; @@ -38,4 +39,48 @@ $mech->submit_form_ok( { $mech->content_contains( 'Summary Statistics for City of Edinburgh' ); +FixMyStreet::App->model('DB::Contact')->search( { area_id => $test_council } ) + ->delete; + +my $eight_weeks_ago = DateTime->now->subtract( weeks => 8 ); + +FixMyStreet::App->model('DB::Problem')->search( { council => $test_council } ) + ->update( { confirmed => $eight_weeks_ago } ); + +my @cats = qw( Grafitti Litter Potholes ); +for my $contact ( @cats ) { + FixMyStreet::App->model('DB::Contact')->create( + { + area_id => $test_council, + category => $contact, + email => "$contact\@example.org", + confirmed => 1, + whenedited => DateTime->now, + deleted => 0, + editor => 'test', + note => 'test', + } + ); +} + +$mech->get_ok('/dashboard'); + +my $categories = scraper { + process "select[name=category] > option", 'cats[]' => 'TEXT', + process "select[name=ward] > option", 'wards[]' => 'TEXT', + process "table[id=overview] > tr", 'rows[]' => scraper { + process 'td', 'cols[]' => 'TEXT' + } +}; + +my $expected_cats = [ 'All', '-- Pick a category --', @cats, 'Other' ]; +my $res = $categories->scrape( $mech->content ); +is_deeply( $res->{cats}, $expected_cats, 'correct list of categories' ); + +foreach my $row ( @{ $res->{rows} }[1 .. 11] ) { + foreach my $col ( @{ $row->{cols} } ) { + is $col, 0; + } +} + done_testing; |