diff options
author | Matthew Somerville <matthew@mysociety.org> | 2013-01-23 16:56:01 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2013-01-23 18:21:45 +0000 |
commit | 7ce147693430872b3dee29654bafefdf3c18c96c (patch) | |
tree | 3502332c10ef0931482cdf1ba30b779073f2e234 /t/app/controller/report_display.t | |
parent | ca0804fa217d93c0cc10821d283710ad43db55c2 (diff) |
Add some Zurich banner tests.
Diffstat (limited to 't/app/controller/report_display.t')
-rw-r--r-- | t/app/controller/report_display.t | 76 |
1 files changed, 73 insertions, 3 deletions
diff --git a/t/app/controller/report_display.t b/t/app/controller/report_display.t index 9847e3e51..10ef3dfd9 100644 --- a/t/app/controller/report_display.t +++ b/t/app/controller/report_display.t @@ -5,6 +5,7 @@ use Test::More; use FixMyStreet::TestMech; use Web::Scraper; use Path::Class; +use Test::LongString; use DateTime; my $mech = FixMyStreet::TestMech->new; @@ -95,14 +96,14 @@ subtest "change report to unconfirmed and check for 404 status" => sub { }; -subtest "change report to unconfirmed and check for 404 status" => sub { +subtest "Zurich unconfirmeds are 200" => sub { if ( !FixMyStreet::Cobrand->exists('zurich') ) { plan skip_all => 'Skipping Zurich test without Zurich cobrand'; } $mech->host( 'zurich.fixmystreet.com' ); ok $report->update( { state => 'unconfirmed' } ), 'unconfirm report'; - ok $mech->get("/report/$report_id"), "get '/report/$report_id'"; - is $mech->res->code, 200, "page found"; + $mech->get_ok("/report/$report_id"); + $mech->content_contains( 'This report is awaiting moderation' ); ok $report->update( { state => 'confirmed' } ), 'confirm report again'; $mech->host( 'www.fixmystreet.com' ); }; @@ -358,6 +359,75 @@ for my $test ( }; } +subtest "Zurich banners are displayed correctly" => sub { + if ( !FixMyStreet::Cobrand->exists('zurich') ) { + plan skip_all => 'Skipping Zurich test without Zurich cobrand'; + } + $mech->host( 'zurich.fixmystreet.com' ); + + for my $test ( + { + description => 'new report', + state => 'unconfirmed', + banner_id => 'closed', + banner_text => 'Erfasst' + }, + { + description => 'confirmed report', + state => 'confirmed', + banner_id => 'closed', + banner_text => 'Aufgenommen', + }, + { + description => 'fixed report', + state => 'fixed - council', + banner_id => 'fixed', + banner_text => 'Erledigt', + }, + { + description => 'closed report', + state => 'closed', + banner_id => 'fixed', + banner_text => 'Erledigt', + }, + { + description => 'in progress report', + state => 'in progress', + banner_id => 'progress', + banner_text => 'In Bearbeitung', + }, + { + description => 'planned report', + state => 'planned', + banner_id => 'progress', + banner_text => 'In Bearbeitung', + }, + ) { + subtest "banner for $test->{description}" => sub { + $report->state( $test->{state} ); + $report->update; + + $mech->get_ok("/report/$report_id"); + is $mech->uri->path, "/report/$report_id", "at /report/$report_id"; + my $banner = $mech->extract_problem_banner; + if ( $banner->{text} ) { + $banner->{text} =~ s/^ //g; + $banner->{text} =~ s/ $//g; + } + + is $banner->{id}, $test->{banner_id}, 'banner id'; + if ($test->{banner_text}) { + like_string( $banner->{text}, qr/$test->{banner_text}/i, 'banner text is ' . $test->{banner_text} ); + } else { + is $banner->{text}, $test->{banner_text}, 'banner text'; + } + + }; + } + + $mech->host( 'www.fixmystreet.com' ); +}; + $mech->create_body_ok(2504, 'Westminster City Council'); $mech->create_body_ok(2505, 'Camden Borough Council'); |