From 85a6b7df9bd0b1711637b39d5a63ed6434686b33 Mon Sep 17 00:00:00 2001 From: M Somerville Date: Mon, 21 Sep 2020 09:10:58 +0100 Subject: If text auth on, ask which method they wish to use --- t/app/controller/report_new_text.t | 49 ++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 13 deletions(-) (limited to 't/app/controller/report_new_text.t') diff --git a/t/app/controller/report_new_text.t b/t/app/controller/report_new_text.t index 852cdac76..9256a00de 100644 --- a/t/app/controller/report_new_text.t +++ b/t/app/controller/report_new_text.t @@ -15,17 +15,43 @@ $mech->create_contact_ok( body_id => $body->id, category => 'Street lighting', e $mech->create_contact_ok( body_id => $body->id, category => 'Trees', email => 'trees@example.com' ); # test that phone number validation works okay +my %defaults = ( + title => 'Title', detail => 'Detail', name => 'Bob Jones', + category => 'Street lighting', may_show_name => 1, + photo1 => '', photo2 => '', photo3 => '', + password_register => '', password_sign_in => '', +); foreach my $test ( + { + msg => 'missing update method', + pc => 'EH1 1BB', + fields => { + update_method => undef, phone => '', email => '', + %defaults, + }, + changes => { + username => '', + }, + errors => [ 'Please enter your email', 'Please pick your update preference' ], + }, + { + msg => 'email method', + pc => 'EH1 1BB', + fields => { + update_method => 'email', phone => '', email => 'bademail', + %defaults, + }, + changes => { + username => 'bademail', + }, + errors => [ 'Please enter a valid email' ], + }, { msg => 'invalid number', pc => 'EH1 1BB', fields => { - username => '0121 4960000000', email => '', phone => '', - title => 'Title', detail => 'Detail', name => 'Bob Jones', - category => 'Street lighting', - may_show_name => '1', - photo1 => '', photo2 => '', photo3 => '', - password_register => '', password_sign_in => '', + update_method => 'phone', phone => '0121 4960000000', email => '', + %defaults, }, changes => { username => '01214960000000', @@ -37,12 +63,8 @@ foreach my $test ( msg => 'landline number', pc => 'EH1 1BB', fields => { - username => '0121 4960000', email => '', phone => '', - title => 'Title', detail => 'Detail', name => 'Bob Jones', - category => 'Street lighting', - may_show_name => '1', - photo1 => '', photo2 => '', photo3 => '', - password_register => '', password_sign_in => '', + update_method => 'phone', phone => '0121 4960000', email => '', + %defaults, }, changes => { username => '0121 496 0000', @@ -142,7 +164,8 @@ foreach my $test ( title => 'Test Report', detail => 'Test report details.', photo1 => '', name => 'Joe Bloggs', may_show_name => '1', - username => $test_phone, + update_method => 'phone', + phone => $test_phone, category => 'Street lighting', password_register => $test->{password} ? 'secret' : '', } -- cgit v1.2.3 From 22cc2b0e1e6bb2dd7bde7231ad7f7190737ce545 Mon Sep 17 00:00:00 2001 From: M Somerville Date: Thu, 24 Sep 2020 14:39:59 +0100 Subject: Split up two username fields. Rename the not-logging-in username field to username_register. Keep the sign-in field as username because that e.g. overlaps with auth code in two-factor authentication. --- t/app/controller/report_new_text.t | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 't/app/controller/report_new_text.t') diff --git a/t/app/controller/report_new_text.t b/t/app/controller/report_new_text.t index 9256a00de..8753e7e20 100644 --- a/t/app/controller/report_new_text.t +++ b/t/app/controller/report_new_text.t @@ -42,7 +42,7 @@ foreach my $test ( %defaults, }, changes => { - username => 'bademail', + username => '', }, errors => [ 'Please enter a valid email' ], }, @@ -54,7 +54,7 @@ foreach my $test ( %defaults, }, changes => { - username => '01214960000000', + username => '', phone => '01214960000000', }, errors => [ 'Please check your phone number is correct' ], @@ -67,7 +67,7 @@ foreach my $test ( %defaults, }, changes => { - username => '0121 496 0000', + username => '', phone => '0121 496 0000', }, errors => [ 'Please enter a mobile number', ], -- cgit v1.2.3 From 2abe443efb8bbbd7cf3048eec271fd28a777932f Mon Sep 17 00:00:00 2001 From: M Somerville Date: Fri, 11 Sep 2020 18:11:03 +0100 Subject: Show error if text confirmation code sending fails --- t/app/controller/report_new_text.t | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 't/app/controller/report_new_text.t') diff --git a/t/app/controller/report_new_text.t b/t/app/controller/report_new_text.t index 8753e7e20..fa012c6ae 100644 --- a/t/app/controller/report_new_text.t +++ b/t/app/controller/report_new_text.t @@ -72,6 +72,19 @@ foreach my $test ( }, errors => [ 'Please enter a mobile number', ], }, + { + msg => 'number that fails', + pc => 'EH1 1BB', + fields => { + update_method => 'phone', phone => '+18165550101', email => '', + %defaults, + }, + changes => { + username => '', + phone => '+1 816-555-0101', + }, + errors => [ 'Sending a confirmation text failed: "Unable to send (21408)"' ], + }, ) { subtest "check form errors where $test->{msg}" => sub { @@ -82,6 +95,7 @@ foreach my $test ( MAPIT_URL => 'http://mapit.uk/', SMS_AUTHENTICATION => 1, PHONE_COUNTRY => 'GB', + TWILIO_ACCOUNT_SID => 'AC123', }, sub { $mech->submit_form_ok( { with_fields => { pc => $test->{pc} } }, "submit location" ); -- cgit v1.2.3