diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-12-11 16:26:16 +0000 |
---|---|---|
committer | Matthew Somerville <matthew-github@dracos.co.uk> | 2018-12-19 17:02:04 +0000 |
commit | 584b6297f229f5fa2e1c0b44d9078a7b09e83e63 (patch) | |
tree | 72ec475e98874cabae576cc31ad1aa2887b05364 /t/app | |
parent | cfb0dd09a7be10d6443995930cbb8739f4d1ecc7 (diff) |
[Buckinghamshire] Get topic when reporting abuse.
Diffstat (limited to 't/app')
-rw-r--r-- | t/app/controller/contact.t | 136 |
1 files changed, 62 insertions, 74 deletions
diff --git a/t/app/controller/contact.t b/t/app/controller/contact.t index 3fa83be9b..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,13 +327,7 @@ 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', @@ -350,26 +335,14 @@ for my $test ( ] }, { - 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', @@ -404,33 +377,9 @@ for my $test ( } 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 { @@ -448,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', }, @@ -460,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', }, |