aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorStruan Donald <struan@exo.org.uk>2014-04-09 17:09:14 +0100
committerStruan Donald <struan@exo.org.uk>2014-04-15 15:53:18 +0100
commit565c6498aefea0fd39ec7453019bbf86b52672dd (patch)
treefa11d5c90de95202da33086a56285b6a348aee88 /t
parentb82228ce014cc87866d976eeb3ce6e454e87c336 (diff)
Add a who are you trying to contact option to contact form
In order to try and cut down on people mistakingly using this form to try and contact their council all some 'who are you trying to contact' options to the form that display appropriate messaged unless the 'FMS team option is selected. Add the validation code for this in the cobrand module. Fixes #41
Diffstat (limited to 't')
-rw-r--r--t/app/controller/contact.t111
1 files changed, 110 insertions, 1 deletions
diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t
index 11e0d30cf..89a1db5b2 100644
--- a/t/app/controller/contact.t
+++ b/t/app/controller/contact.t
@@ -8,7 +8,7 @@ my $mech = FixMyStreet::TestMech->new;
$mech->get_ok('/contact');
$mech->title_like(qr/Contact Us/);
-$mech->content_contains("We'd love to hear what you think about this site");
+$mech->content_contains("It's often quickest to ");
my $problem_main;
@@ -282,6 +282,115 @@ for my $test (
};
}
+for my $test (
+ {
+ fields => {
+ em => 'test@example.com',
+ name => 'A name',
+ subject => 'A subject',
+ message => 'A message',
+ dest => undef,
+ },
+ page_errors =>
+ [ 'There were problems with your report. Please see below.',
+ 'Please enter who your message is for',
+ ]
+ },
+ {
+ fields => {
+ em => 'test@example.com',
+ name => 'A name',
+ subject => 'A subject',
+ message => 'A message',
+ dest => 'council',
+ },
+ page_errors =>
+ [ 'There were problems with your report. Please see below.',
+ 'You can only contact the team behind FixMyStreet using our contact form',
+ ]
+ },
+ {
+ fields => {
+ em => 'test@example.com',
+ name => 'A name',
+ subject => 'A subject',
+ message => 'A message',
+ dest => 'update',
+ },
+ page_errors =>
+ [ 'There were problems with your report. Please see below.',
+ 'You can only contact the team behind FixMyStreet using our contact form',
+ ]
+ },
+ )
+{
+ subtest 'check submit page incorrect destination handling' => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'fixmystreet' ],
+ }, sub {
+ $mech->host('www.fixmystreet.com');
+ $mech->get_ok( $test->{url} ? $test->{url} : '/contact' );
+ $mech->submit_form_ok( { with_fields => $test->{fields} } );
+ is_deeply $mech->page_errors, $test->{page_errors}, 'page errors';
+
+ # we santise this when we submit so need to remove it
+ delete $test->{fields}->{id}
+ if $test->{fields}->{id} and $test->{fields}->{id} eq 'invalid';
+ is_deeply $mech->visible_form_values, $test->{fields}, 'form values';
+
+ if ( $test->{fields}->{dest} and $test->{fields}->{dest} eq 'update' ) {
+ $mech->content_contains( 'www.writetothem.com', 'includes link to WTT if trying to update report' );
+ } elsif ( $test->{fields}->{dest} and $test->{fields}->{dest} eq 'council' ) {
+ $mech->content_lacks( 'www.writetothem.com', 'does not include link to WTT if trying to contact council' );
+ $mech->content_contains( 'should find contact details', 'mentions checking council website for contact details' );
+ }
+ }
+ };
+}
+
+for my $test (
+ {
+ fields => {
+ em => 'test@example.com',
+ name => 'A name',
+ subject => 'A subject',
+ message => 'A message',
+ dest => 'help',
+ },
+ },
+ {
+ fields => {
+ em => 'test@example.com',
+ name => 'A name',
+ subject => 'A subject',
+ message => 'A message',
+ dest => 'feedback',
+ },
+ },
+ {
+ fields => {
+ em => 'test@example.com',
+ name => 'A name',
+ subject => 'A subject',
+ message => 'A message',
+ dest => 'from_council',
+ },
+ },
+ )
+{
+ subtest 'check email sent correctly with dest field set to us' => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'fixmystreet' ],
+ }, sub {
+ $mech->clear_emails_ok;
+ $mech->get_ok('/contact');
+ $mech->submit_form_ok( { with_fields => $test->{fields} } );
+ $mech->content_contains('Thanks for your feedback');
+ $mech->email_count_is(1);
+ }
+ };
+}
+
$problem_main->delete;
done_testing();