aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller/dashboard.t
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2012-05-14 19:15:49 +0100
committerStruan Donald <struan@exo.org.uk>2012-05-14 19:15:49 +0100
commitc12c7836af432302fe3805e6081df3182f0bc2b6 (patch)
treec161fa56bf8e667fc287842f0f884790c4f273c8 /t/app/controller/dashboard.t
parent4268024f74085b25a985fdfde431cd9b17e4cffb (diff)
add in some basic tests of data
Diffstat (limited to 't/app/controller/dashboard.t')
-rw-r--r--t/app/controller/dashboard.t45
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;