aboutsummaryrefslogtreecommitdiffstats
path: root/t/app/controller
diff options
context:
space:
mode:
Diffstat (limited to 't/app/controller')
-rw-r--r--t/app/controller/contact.t144
1 files changed, 67 insertions, 77 deletions
diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t
index 254522b92..fe67e89ec 100644
--- a/t/app/controller/contact.t
+++ b/t/app/controller/contact.t
@@ -279,25 +279,16 @@ for my $test (
};
}
-for my $test (
- {
- fields => {
- em => 'test@example.com',
- name => 'A name',
- subject => 'A subject',
- message => 'A message',
- },
- },
- {
- fields => {
- em => 'test@example.com',
- name => 'A name',
- subject => 'A subject',
- message => 'A message',
- id => $problem_main->id,
- },
- },
+my %common = (
+ em => 'test@example.com',
+ name => 'A name',
+ subject => 'A subject',
+ message => 'A message',
+);
+for my $test (
+ { fields => \%common },
+ { fields => { %common, id => $problem_main->id } },
)
{
subtest 'check email sent correctly' => sub {
@@ -336,39 +327,22 @@ for my $test (
for my $test (
{
- fields => {
- em => 'test@example.com',
- name => 'A name',
- subject => 'A subject',
- message => 'A message',
- dest => undef,
- },
+ fields => { %common, dest => undef },
page_errors =>
[ 'There were problems with your report. Please see below.',
'Please enter who your message is for',
+ 'You can only contact the team behind FixMyStreet using our contact form', # The JS-hidden one
]
},
{
- fields => {
- em => 'test@example.com',
- name => 'A name',
- subject => 'A subject',
- message => 'A message',
- dest => 'council',
- },
+ fields => { %common, 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',
- },
+ fields => { %common, 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',
@@ -391,44 +365,21 @@ for my $test (
$test->{fields}->{'extra.phone'} = '';
is_deeply $mech->visible_form_values, $test->{fields}, 'form values';
+ # Ugh, but checking div not hidden; text always shown and hidden with CSS
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' );
+ $mech->content_contains('<div class="form-error__box form-error--update">');
} 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' );
+ # Ugh, but checking div not hidden
+ $mech->content_contains('<div class="form-error__box form-error--council">');
}
}
};
}
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',
- },
- },
+ { fields => { %common, dest => 'help' } },
+ { fields => { %common, dest => 'feedback' } },
+ { fields => { %common, dest => 'from_council' } },
)
{
subtest 'check email sent correctly with dest field set to us' => sub {
@@ -446,11 +397,53 @@ for my $test (
for my $test (
{
+ fields => { %common, dest => undef },
+ page_errors =>
+ [ 'There were problems with your report. Please see below.',
+ 'Please enter a topic of your message',
+ 'You can only use this form to report inappropriate content', # The JS-hidden one
+ ]
+ },
+ {
+ fields => { %common, dest => 'council' },
+ page_errors =>
+ [ 'There were problems with your report. Please see below.',
+ 'You can only use this form to report inappropriate content',
+ ]
+ },
+ {
+ fields => { %common, dest => 'update' },
+ page_errors =>
+ [ 'There were problems with your report. Please see below.',
+ 'You can only use this form to report inappropriate content',
+ ]
+ },
+ )
+{
+ subtest 'check Bucks submit page incorrect destination handling' => sub {
+ FixMyStreet::override_config {
+ ALLOWED_COBRANDS => [ 'buckinghamshire' ],
+ }, sub {
+ $mech->get_ok( '/contact?id=' . $problem_main->id, 'can visit for abuse report' );
+ $mech->submit_form_ok( { with_fields => $test->{fields} } );
+ is_deeply $mech->page_errors, $test->{page_errors}, 'page errors';
+
+ $test->{fields}->{'extra.phone'} = '';
+ is_deeply $mech->visible_form_values, $test->{fields}, 'form values';
+
+ if ( $test->{fields}->{dest} and $test->{fields}->{dest} eq 'update' ) {
+ $mech->content_contains('please leave an update');
+ } elsif ( $test->{fields}->{dest} and $test->{fields}->{dest} eq 'council' ) {
+ $mech->content_contains('should find other contact details');
+ }
+ }
+ };
+}
+
+for my $test (
+ {
fields => {
- em => 'test@example.com',
- name => 'A name',
- subject => 'A subject',
- message => 'A message',
+ %common,
dest => 'from_council',
success_url => '/faq',
},
@@ -458,10 +451,7 @@ for my $test (
},
{
fields => {
- em => 'test@example.com',
- name => 'A name',
- subject => 'A subject',
- message => 'A message',
+ %common,
dest => 'from_council',
success_url => 'http://www.example.com',
},