aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rw-r--r--t/app/controller/reports.t19
-rw-r--r--t/cobrand/fixmystreet.t47
2 files changed, 60 insertions, 6 deletions
diff --git a/t/app/controller/reports.t b/t/app/controller/reports.t
index 7773223dd..76c920562 100644
--- a/t/app/controller/reports.t
+++ b/t/app/controller/reports.t
@@ -12,9 +12,6 @@ END {
ok( my $mech = FixMyStreet::TestMech->new, 'Created mech object' );
-# Run the cron script with empty database
-FixMyStreet::Script::UpdateAllReports::generate_dashboard();
-
$mech->create_body_ok(2514, 'Birmingham City Council');
my $body_edin_id = $mech->create_body_ok(2651, 'City of Edinburgh Council')->id;
my $body_west_id = $mech->create_body_ok(2504, 'Westminster City Council')->id;
@@ -99,10 +96,14 @@ $fife_problems[10]->update( {
});
# Run the cron script that makes the data for /reports so we don't get an error.
-FixMyStreet::Script::UpdateAllReports::generate_dashboard();
+my $data = FixMyStreet::Script::UpdateAllReports::generate_dashboard();
# check that we can get the page
-$mech->get_ok('/reports');
+FixMyStreet::override_config {
+ TEST_DASHBOARD_DATA => $data,
+}, sub {
+ $mech->get_ok('/reports');
+};
$mech->title_like(qr{Dashboard});
$mech->content_contains('Birmingham');
@@ -138,6 +139,7 @@ is scalar @$problems, 5, 'correct number of problems displayed';
FixMyStreet::override_config {
MAPIT_URL => 'http://mapit.uk/',
+ TEST_DASHBOARD_DATA => $data,
}, sub {
$mech->get_ok('/reports');
$mech->submit_form_ok({ with_fields => { body => $body_slash_id } }, 'Submitted dropdown okay');
@@ -199,13 +201,18 @@ is scalar @$problems, 4, 'only public problems are displayed';
$mech->content_lacks('All reports Test 3 for ' . $body_west_id, 'non public problem is not visible');
# No change to numbers if report is non-public
-$mech->get_ok('/reports');
+FixMyStreet::override_config {
+ TEST_DASHBOARD_DATA => $data,
+}, sub {
+ $mech->get_ok('/reports');
+};
$mech->content_contains('"Apr","May","Jun","Jul"');
$mech->content_contains('5,9,10,22');
subtest "test fiksgatami all reports page" => sub {
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'fiksgatami' ],
+ TEST_DASHBOARD_DATA => $data, # Not relevant to what we're testing, just so page loads
}, sub {
$mech->create_body_ok(3, 'Oslo');
ok $mech->host("fiksgatami.no"), 'change host to fiksgatami';
diff --git a/t/cobrand/fixmystreet.t b/t/cobrand/fixmystreet.t
new file mode 100644
index 000000000..eda93e187
--- /dev/null
+++ b/t/cobrand/fixmystreet.t
@@ -0,0 +1,47 @@
+use FixMyStreet::Script::UpdateAllReports;
+
+use FixMyStreet::TestMech;
+my $mech = FixMyStreet::TestMech->new;
+
+my $body = $mech->create_body_ok( 2514, 'Birmingham' );
+
+my $data;
+FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.uk/',
+}, sub {
+ $data = FixMyStreet::Script::UpdateAllReports::generate_dashboard($body);
+};
+
+FixMyStreet::override_config {
+ MAPIT_URL => 'http://mapit.uk/',
+ 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('Top 5 wards');
+
+};
+
+END {
+ done_testing();
+}