aboutsummaryrefslogtreecommitdiffstats
path: root/t/cobrand
diff options
context:
space:
mode:
Diffstat (limited to 't/cobrand')
-rw-r--r--t/cobrand/rutland.t60
-rw-r--r--t/cobrand/zurich.t147
2 files changed, 180 insertions, 27 deletions
diff --git a/t/cobrand/rutland.t b/t/cobrand/rutland.t
new file mode 100644
index 000000000..8943e64fc
--- /dev/null
+++ b/t/cobrand/rutland.t
@@ -0,0 +1,60 @@
+use CGI::Simple;
+use FixMyStreet::TestMech;
+use FixMyStreet::Script::Reports;
+my $mech = FixMyStreet::TestMech->new;
+
+# Create test data
+my $user = $mech->create_user_ok( 'rutland@example.com' );
+my $body = $mech->create_body_ok( 2482, 'Rutland County Council');
+my $contact = $mech->create_contact_ok(
+ body_id => $body->id,
+ category => 'Other',
+ email => 'LIGHT',
+);
+$contact->update;
+
+my @reports = $mech->create_problems_for_body( 1, $body->id, 'Test', {
+ cobrand => 'rutland',
+ user => $user,
+});
+my $report = $reports[0];
+
+for my $update ('in progress', 'unable to fix') {
+ FixMyStreet::DB->resultset('Comment')->find_or_create( {
+ problem_state => $update,
+ problem_id => $report->id,
+ user_id => $user->id,
+ name => 'User',
+ mark_fixed => 'f',
+ text => "This update marks it as $update",
+ state => 'confirmed',
+ confirmed => 'now()',
+ anonymous => 'f',
+ } );
+}
+
+subtest 'testing special Open311 behaviour', sub {
+ $report->set_extra_fields();
+ $report->update;
+ $body->update( { send_method => 'Open311', endpoint => 'http://rutland.endpoint.example.com', jurisdiction => 'FMS', api_key => 'test', send_comments => 1 } );
+ my $test_data;
+ FixMyStreet::override_config {
+ STAGING_FLAGS => { send_reports => 1 },
+ ALLOWED_COBRANDS => [ 'fixmystreet', 'rutland' ],
+ }, sub {
+ $test_data = FixMyStreet::Script::Reports::send();
+ };
+ $report->discard_changes;
+ ok $report->whensent, 'Report marked as sent';
+ is $report->send_method_used, 'Open311', 'Report sent via Open311';
+ is $report->external_id, 248, 'Report has right external ID';
+
+ my $req = $test_data->{test_req_used};
+ my $c = CGI::Simple->new($req->content);
+ is $c->param('attribute[title]'), $report->title, 'Request had title';
+ is $c->param('attribute[description]'), $report->detail, 'Request had description';
+ is $c->param('attribute[external_id]'), $report->id, 'Request had correct ID';
+ is $c->param('jurisdiction_id'), 'FMS', 'Request had correct jurisdiction';
+};
+
+done_testing();
diff --git a/t/cobrand/zurich.t b/t/cobrand/zurich.t
index 4ae9a0cde..eccb0c8eb 100644
--- a/t/cobrand/zurich.t
+++ b/t/cobrand/zurich.t
@@ -23,6 +23,7 @@ my $mech = FixMyStreet::TestMech->new;
use FixMyStreet;
my $cobrand = FixMyStreet::Cobrand::Zurich->new();
+$cobrand->db_state_migration;
my $sample_file = path(__FILE__)->parent->parent->child("app/controller/sample.jpg");
ok $sample_file->exists, "sample file $sample_file exists";
@@ -48,7 +49,7 @@ sub reset_report_state {
$report->unset_extra_metadata('closed_overdue');
$report->unset_extra_metadata('closure_status');
$report->whensent(undef);
- $report->state('unconfirmed');
+ $report->state('submitted');
$report->created($created) if $created;
$report->update;
}
@@ -109,7 +110,7 @@ subtest "set up superuser" => sub {
};
my @reports = $mech->create_problems_for_body( 1, $division->id, 'Test', {
- state => 'unconfirmed',
+ state => 'submitted',
confirmed => undef,
cobrand => 'zurich',
areas => ',423017,',
@@ -125,6 +126,89 @@ FixMyStreet::override_config {
$mech->content_contains('Überprüfung ausstehend')
or die $mech->content;
+FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+ MAP_TYPE => 'Zurich,OSM',
+}, sub {
+ my $json = $mech->get_ok_json( '/report/ajax/' . $report->id );
+ is $json->{report}->{title}, "Überprüfung ausstehend", "correct title";
+ is $json->{report}->{state}, "submitted", "correct state";
+};
+
+subtest "Banners are displayed correctly" => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'zurich' ],
+ MAP_TYPE => 'Zurich,OSM',
+ }, sub {
+ for my $test (
+ {
+ description => 'new report',
+ state => 'submitted',
+ 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 => 'Beantwortet',
+ },
+ {
+ description => 'closed report',
+ state => 'external',
+ banner_id => 'closed',
+ banner_text => 'Extern',
+ },
+ {
+ description => 'in progress report',
+ state => 'in progress',
+ banner_id => 'progress',
+ banner_text => 'In Bearbeitung',
+ },
+ {
+ description => 'planned report',
+ state => 'feedback pending',
+ banner_id => 'progress',
+ banner_text => 'In Bearbeitung',
+ },
+ {
+ description => 'jurisdiction unknown',
+ state => 'jurisdiction unknown',
+ banner_id => 'fixed',
+ banner_text => 'Zust\x{e4}ndigkeit unbekannt',
+ },
+ ) {
+ 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';
+ }
+
+ };
+ }
+ $report->update({ state => 'submitted' });
+ };
+};
+
# Check logging in to deal with this report
FixMyStreet::override_config {
ALLOWED_COBRANDS => [ 'zurich' ],
@@ -158,7 +242,7 @@ subtest "changing of categories" => sub {
);
}
- # full Categories dropdown is hidden for unconfirmed reports
+ # full Categories dropdown is hidden for submitted reports
$report->update({ state => 'confirmed' });
# put report into known category
@@ -274,7 +358,7 @@ subtest "report_edit" => sub {
$report->discard_changes;
is ( $report->get_extra_metadata('moderated_overdue'), 0, 'Still marked moderated_overdue' );
is ( $report->get_extra_metadata('closed_overdue'), undef, "Marking hidden doesn't set closed_overdue..." );
- is ( $report->state, 'planned', 'Marking hidden actually sets state to planned');
+ is ( $report->state, 'feedback pending', 'Marking hidden actually sets state to feedback pending');
is ( $report->get_extra_metadata('closure_status'), 'hidden', 'Marking hidden sets closure_status to hidden');
is get_moderated_count(), 1, 'Check still counted moderated'
or diag $report->get_column('extra');
@@ -411,6 +495,12 @@ subtest 'SDM' => sub {
$mech->submit_form_ok( { button => 'no_more_updates' } );
is $mech->uri->path, '/admin/summary', "redirected now finished with report.";
+ # Can still view the edit page but can't change anything
+ $mech->get_ok( '/admin/report_edit/' . $report->id );
+ $mech->content_contains('<input disabled');
+ $mech->submit_form_ok( { with_fields => { status_update => 'This is a disallowed update.' } } );
+ $mech->content_lacks('This is a disallowed update');
+
$mech->get_ok( '/report/' . $report->id );
$mech->content_contains('In Bearbeitung');
$mech->content_contains('Test Test');
@@ -423,7 +513,7 @@ subtest 'SDM' => sub {
$mech->clear_emails_ok;
$report->discard_changes;
- is $report->state, 'planned', 'Report now in planned state';
+ is $report->state, 'feedback pending', 'Report now in feedback pending state';
subtest 'send_back' => sub {
FixMyStreet::override_config {
@@ -448,8 +538,8 @@ subtest 'SDM' => sub {
$mech->get_ok( '/admin/report_edit/' . $report->id );
$mech->submit_form_ok( { button => 'not_contactable', form_number => 2 } );
$report->discard_changes;
- is $report->state, 'planned', 'Report sent back to Rueckmeldung ausstehend state';
- is $report->get_extra_metadata('closure_status'), 'partial', 'Report sent back to partial (not_contactable) state';
+ is $report->state, 'feedback pending', 'Report sent back to Rueckmeldung ausstehend state';
+ is $report->get_extra_metadata('closure_status'), 'not contactable', 'Report sent back to not_contactable state';
is $report->bodies_str, $division->id, 'Report sent back to division';
};
};
@@ -465,7 +555,7 @@ FixMyStreet::override_config {
};
reset_report_state($report);
-$report->update({ state => 'planned' });
+$report->update({ state => 'feedback pending' });
$mech->content_contains( 'report_edit/' . $report->id );
$mech->content_contains( DateTime->now->strftime("%d.%m.%Y") );
@@ -500,9 +590,9 @@ like $email->header('From'), qr/do-not-reply\@example.org/, 'from line looks cor
like $email->body, qr/FINAL UPDATE/, 'body looks correct';
$mech->clear_emails_ok;
-# Assign planned (via confirmed), don't confirm email
+# Assign feedback pending (via confirmed), don't confirm email
@reports = $mech->create_problems_for_body( 1, $division->id, 'Second', {
- state => 'unconfirmed',
+ state => 'submitted',
confirmed => undef,
cobrand => 'zurich',
areas => ',423017,',
@@ -516,7 +606,7 @@ FixMyStreet::override_config {
$mech->get_ok( '/admin/report_edit/' . $report->id );
$mech->submit_form_ok( { with_fields => { state => 'confirmed' } } );
$mech->get_ok( '/admin/report_edit/' . $report->id );
- $mech->submit_form_ok( { with_fields => { state => 'planned' } } );
+ $mech->submit_form_ok( { with_fields => { state => 'feedback pending' } } );
$mech->get_ok( '/report/' . $report->id );
};
$mech->content_contains('In Bearbeitung');
@@ -543,7 +633,7 @@ $mech->email_count_is(0);
# Report assigned to third party
@reports = $mech->create_problems_for_body( 1, $division->id, 'Third', {
- state => 'unconfirmed',
+ state => 'submitted',
confirmed => undef,
cobrand => 'zurich',
areas => ',423017,',
@@ -558,8 +648,8 @@ subtest "external report triggers email" => sub {
}, sub {
# required to see body_external field
- $report->state('planned');
- $report->set_extra_metadata('closure_status' => 'closed');
+ $report->state('feedback pending');
+ $report->set_extra_metadata('closure_status' => 'external');
# Set the public_response manually here because the default one will have line breaks that get escaped as HTML, causing the comparison to fail.
$report->set_extra_metadata('public_response' => 'Freundliche Gruesse Ihre Stadt Zuerich');
$report->update;
@@ -575,7 +665,7 @@ subtest "external report triggers email" => sub {
$report->discard_changes;
$mech->get_ok( '/report/' . $report->id );
};
- is ($report->state, 'closed', 'Report was closed correctly');
+ is ($report->state, 'external', 'Report was closed correctly');
$mech->content_contains('Extern')
or die $mech->content;
$mech->content_contains('Third Test');
@@ -596,8 +686,8 @@ subtest "external report triggers email" => sub {
}, sub {
$mech->get_ok( '/admin' );
# required to see body_external field
- $report->state('planned');
- $report->set_extra_metadata('closure_status' => 'closed');
+ $report->state('feedback pending');
+ $report->set_extra_metadata('closure_status' => 'external');
$report->set_extra_metadata('public_response' => 'Freundliche Gruesse Ihre Stadt Zuerich');
$report->update;
@@ -632,10 +722,10 @@ subtest "external report triggers email" => sub {
}, sub {
# set as wish
$report->discard_changes;
- $report->state('planned');
- $report->set_extra_metadata('closure_status' => 'investigating');
+ $report->state('feedback pending');
+ $report->set_extra_metadata('closure_status' => 'wish');
$report->update;
- is ($report->state, 'planned', 'Sanity check') or die;
+ is ($report->state, 'feedback pending', 'Sanity check') or die;
$mech->get_ok( '/admin/report_edit/' . $report->id );
@@ -646,6 +736,9 @@ subtest "external report triggers email" => sub {
body_external => $external_body->id,
external_message => $EXTERNAL_MESSAGE,
} });
+ # Wishes publicly viewable
+ $mech->get_ok( '/report/' . $report->id );
+ $mech->content_contains('Freundliche Gruesse Ihre Stadt Zuerich');
};
send_reports_for_zurich();
$email = $mech->get_email;
@@ -665,12 +758,12 @@ subtest "external report triggers email" => sub {
}, sub {
# set as extern
reset_report_state($report);
- $report->state('planned');
- $report->set_extra_metadata('closure_status' => 'closed');
+ $report->state('feedback pending');
+ $report->set_extra_metadata('closure_status' => 'external');
$report->set_extra_metadata('email_confirmed' => 1);
$report->unset_extra_metadata('public_response');
$report->update;
- is ($report->state, 'planned', 'Sanity check') or die;
+ is ($report->state, 'feedback pending', 'Sanity check') or die;
$mech->get_ok( '/admin/report_edit/' . $report->id );
@@ -872,7 +965,7 @@ subtest "test admin_log" => sub {
# XXX: following is dependent on all of test up till now, rewrite to explicitly
# test which things need to be logged!
is scalar @entries, 4, 'State changes logged';
- is $entries[-1]->action, 'state change to closed', 'State change logged as expected';
+ is $entries[-1]->action, 'state change to external', 'State change logged as expected';
};
subtest 'email images to external partners' => sub {
@@ -892,7 +985,7 @@ subtest 'email images to external partners' => sub {
# The below email comparison must not have an external message.
$report->unset_extra_metadata('external_message');
$report->update({
- state => 'closed',
+ state => 'external',
photo => $fileid,
external_body => $external_body->id,
});
@@ -944,9 +1037,9 @@ subtest 'Status update shown as appropriate' => sub {
}, sub {
# ALL closed states must hide the public_response edit, and public ones
# must show the answer in blue.
- for (['planned', 1, 0, 0],
+ for (['feedback pending', 1, 0, 0],
['fixed - council', 0, 1, 0],
- ['closed', 0, 1, 0],
+ ['external', 0, 1, 0],
['hidden', 0, 0, 1])
{
my ($state, $update, $public, $user_response) = @$_;