diff options
Diffstat (limited to 't')
-rw-r--r-- | t/app/controller/auth.t | 12 | ||||
-rw-r--r-- | t/app/controller/report_new.t | 50 |
2 files changed, 56 insertions, 6 deletions
diff --git a/t/app/controller/auth.t b/t/app/controller/auth.t index fef45ac90..efc5e60e6 100644 --- a/t/app/controller/auth.t +++ b/t/app/controller/auth.t @@ -24,16 +24,16 @@ $mech->not_logged_in_ok; $mech->get_ok('/auth'); for my $test ( - [ '' => 'enter your email' ], - [ 'not an email' => 'check your email address is correct' ], - [ 'bob@foo' => 'check your email address is correct' ], - [ 'bob@foonaoedudnueu.co.uk' => 'check your email address is correct' ], + [ '' => 'Please enter your email' ], + [ 'not an email' => 'Please check your email address is correct' ], + [ 'bob@foo' => 'Please check your email address is correct' ], + [ 'bob@foonaoedudnueu.co.uk' => 'Please check your email address is correct' ], ) { my ( $email, $error_message ) = @$test; pass "--- testing bad email '$email' gives error '$error_message'"; $mech->get_ok('/auth'); - $mech->content_lacks($error_message); + is_deeply $mech->form_errors, [], 'no errors initially'; $mech->submit_form_ok( { form_name => 'general_auth', @@ -43,7 +43,7 @@ for my $test ( "try to create an account with email '$email'" ); is $mech->uri->path, '/auth', "still on auth page"; - $mech->content_contains($error_message); + is_deeply $mech->form_errors, [ $error_message ], 'no errors initially'; } # create a new account diff --git a/t/app/controller/report_new.t b/t/app/controller/report_new.t index 9ec8fa4a8..15237e041 100644 --- a/t/app/controller/report_new.t +++ b/t/app/controller/report_new.t @@ -1,4 +1,5 @@ use strict; +use utf8; # sign in error message has – in it use warnings; use Test::More; use utf8; @@ -428,6 +429,55 @@ foreach my $test ( }; } +# this test to make sure that we don't see spurious error messages about +# the name being blank when there is a sign in error +subtest "test password errors for a user who is signing in as they report" => sub { + $mech->log_out_ok; + $mech->clear_emails_ok; + + # check that the user does not exist + my $test_email = 'test-2@example.com'; + + my $user = FixMyStreet::App->model('DB::User')->find_or_create( { email => $test_email } ); + ok $user, "test user does exist"; + + # setup the user. + ok $user->update( { + name => 'Joe Bloggs', + phone => '01234 567 890', + password => 'secret2', + } ), "set user details"; + + # submit initial pc form + $mech->get_ok('/around'); + $mech->submit_form_ok( { with_fields => { pc => 'EH1 1BB', } }, + "submit location" ); + + # click through to the report page + $mech->follow_link_ok( { text => 'skip this step', }, + "follow 'skip this step' link" ); + + $mech->submit_form_ok( + { + button => 'submit_sign_in', + with_fields => { + title => 'Test Report', + detail => 'Test report details.', + photo => '', + email => 'test-2@example.com', + password_sign_in => 'secret1', + category => 'Street lighting', + } + }, + "submit with wrong password" + ); + + # check that we got the errors expected + is_deeply $mech->form_errors, [ + 'There was a problem with your email/password combination. Passwords and user accounts are a brand new service, so you probably do not have one yet – please fill in the right hand side of this form to get one.' + ], "check there were errors"; +}; + subtest "test report creation for a user who is signing in as they report" => sub { $mech->log_out_ok; $mech->clear_emails_ok; |