diff options
author | Struan Donald <struan@exo.org.uk> | 2017-11-30 15:23:22 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2017-12-15 17:35:53 +0000 |
commit | 9931b8aac55df6baef69cee76f34d76bc08d293c (patch) | |
tree | 9b2ced85970854030f8ab34b8eef52535baf4fcc /t | |
parent | af7a457bfaed2ba143aaeccfc7ccf2b8d443e22d (diff) |
[fixmystreet.com] CSV download from marketing page
Limited to most recent 100 rows and not full data.
Factor the two CSV generations together.
Diffstat (limited to 't')
-rw-r--r-- | t/cobrand/fixmystreet.t | 126 |
1 files changed, 84 insertions, 42 deletions
diff --git a/t/cobrand/fixmystreet.t b/t/cobrand/fixmystreet.t index b48593593..30d5765a2 100644 --- a/t/cobrand/fixmystreet.t +++ b/t/cobrand/fixmystreet.t @@ -23,48 +23,90 @@ FixMyStreet::override_config { TEST_DASHBOARD_DATA => $data, ALLOWED_COBRANDS => 'fixmystreet', }, sub { - # Not logged in, redirected - $mech->get_ok('/reports/Birmingham/summary'); - is $mech->uri->path, '/about/council-dashboard'; - - $mech->submit_form_ok({ with_fields => { username => 'someone@somewhere.example.org' }}); - $mech->content_contains('We will be in touch'); - # XXX Check email arrives - - $mech->log_in_ok('someone@somewhere.example.org'); - $mech->get_ok('/reports/Birmingham/summary'); - is $mech->uri->path, '/about/council-dashboard'; - $mech->content_contains('Ending in .gov.uk'); - - $mech->submit_form_ok({ with_fields => { name => 'Someone', username => 'someone@birmingham.gov.uk' }}); - $mech->content_contains('Now check your email'); - # XXX Check email arrives, click link - - $mech->log_in_ok('someone@birmingham.gov.uk'); - # Logged in, redirects - $mech->get_ok('/about/council-dashboard'); - is $mech->uri->path, '/reports/Birmingham/summary'; - $mech->content_contains('Where we send Birmingham'); - $mech->content_contains('lights@example.com'); - - $body->send_method('Open311'); - $body->update(); - $mech->get_ok('/about/council-dashboard'); - $mech->content_contains('Reports to Birmingham are currently sent directly'); - - $body->send_method('Refused'); - $body->update(); - $mech->get_ok('/about/council-dashboard'); - $mech->content_contains('Birmingham currently does not accept'); - - $body->send_method('Noop'); - $body->update(); - $mech->get_ok('/about/council-dashboard'); - $mech->content_contains('Reports are currently not being sent'); - - $mech->log_out_ok(); - $mech->get_ok('/reports'); - $mech->content_lacks('Where we send Birmingham'); + subtest 'check marketing dashboard access' => sub { + # Not logged in, redirected + $mech->get_ok('/reports/Birmingham/summary'); + is $mech->uri->path, '/about/council-dashboard'; + + $mech->submit_form_ok({ with_fields => { username => 'someone@somewhere.example.org' }}); + $mech->content_contains('We will be in touch'); + # XXX Check email arrives + + $mech->log_in_ok('someone@somewhere.example.org'); + $mech->get_ok('/reports/Birmingham/summary'); + is $mech->uri->path, '/about/council-dashboard'; + $mech->content_contains('Ending in .gov.uk'); + + $mech->submit_form_ok({ with_fields => { name => 'Someone', username => 'someone@birmingham.gov.uk' }}); + $mech->content_contains('Now check your email'); + # XXX Check email arrives, click link + + $mech->log_in_ok('someone@birmingham.gov.uk'); + # Logged in, redirects + $mech->get_ok('/about/council-dashboard'); + is $mech->uri->path, '/reports/Birmingham/summary'; + $mech->content_contains('Where we send Birmingham'); + $mech->content_contains('lights@example.com'); + }; + + subtest 'check marketing dashboard csv' => sub { + $mech->log_in_ok('someone@birmingham.gov.uk'); + $mech->create_problems_for_body(105, $body->id, 'Title', { + detail => "this report\nis split across\nseveral lines", + areas => ",2514,", + }); + + $mech->get_ok('/reports/Birmingham/summary?csv=1'); + open my $data_handle, '<', \$mech->content; + my $csv = Text::CSV->new( { binary => 1 } ); + my @rows; + while ( my $row = $csv->getline( $data_handle ) ) { + push @rows, $row; + } + is scalar @rows, 101, '1 (header) + 100 (reports) = 101 lines'; + + is scalar @{$rows[0]}, 10, '10 columns present'; + + is_deeply $rows[0], + [ + 'Report ID', + 'Title', + 'Category', + 'Created', + 'Confirmed', + 'Status', + 'Latitude', + 'Longitude', + 'Query', + 'Report URL', + ], + 'Column headers look correct'; + + my $body_id = $body->id; + like $rows[1]->[1], qr/Title Test \d+ for $body_id/, 'problem title correct'; + }; + + subtest 'check marketing dashboard contact listings' => sub { + $mech->log_in_ok('someone@birmingham.gov.uk'); + $body->send_method('Open311'); + $body->update(); + $mech->get_ok('/about/council-dashboard'); + $mech->content_contains('Reports to Birmingham are currently sent directly'); + + $body->send_method('Refused'); + $body->update(); + $mech->get_ok('/about/council-dashboard'); + $mech->content_contains('Birmingham currently does not accept'); + + $body->send_method('Noop'); + $body->update(); + $mech->get_ok('/about/council-dashboard'); + $mech->content_contains('Reports are currently not being sent'); + + $mech->log_out_ok(); + $mech->get_ok('/reports'); + $mech->content_lacks('Where we send Birmingham'); + }; }; END { |