Skip to content

Commit

Permalink
WIP renewal costs
Browse files Browse the repository at this point in the history
  • Loading branch information
nephila-nacrea committed Feb 25, 2025
1 parent af28a82 commit 25ecabb
Showing 1 changed file with 110 additions and 50 deletions.
160 changes: 110 additions & 50 deletions t/app/controller/waste_bexley_garden.t
Original file line number Diff line number Diff line change
Expand Up @@ -491,56 +491,116 @@ FixMyStreet::override_config {
like $mech->content, qr/name="bins_wanted.*value="2"/s,
'Wanted bins pre-populated';

$mech->submit_form_ok(
{ with_fields => {
bins_wanted => 3,
payment_method => 'credit_card',
name => 'Trevor Trouble',
email => 'trevor@trouble.com',
phone => '+4407111111111',
},
}
);

like $mech->text,
qr/Please review the information you’ve provided/,
'On review page';
like $mech->text,
qr/Total£185.00/, 'correct cost';
$mech->waste_submit_check(
{ with_fields => { tandc => 1 } } );

my ( $token, $renew_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} );
check_extra_data_pre_confirm(
$renew_report,
type => 'Renew',
current_bins => 2,
new_bins => 1,
bins_wanted => 3,
);
is $renew_report->get_extra_field_value('uprn'), $uprn;
is $renew_report->get_extra_field_value('payment'), 18500;
is $renew_report->get_extra_field_value('type'), 'renew';
is $renew_report->get_extra_field_value(
'customer_external_ref'), 'CUSTOMER_123';

$mech->get_ok("/waste/pay_complete/$report_id/$token?STATUS=9&PAYID=54321");
check_extra_data_post_confirm($renew_report);

$mech->clear_emails_ok;
FixMyStreet::Script::Reports::send();

my @emails = $mech->get_email;
my ($to_user) = grep {
$mech->get_text_body_from_email($_)
=~ /Thank you for renewing your subscription/
} @emails;
ok $to_user, 'Email sent to user';
my $email_body = $mech->get_text_body_from_email($to_user);
like $email_body, qr/Number of bin subscriptions: 3/;
like $email_body, qr/Bins to be delivered: 1/;
unlike $email_body, qr/Bins to be removed/;
like $email_body, qr/Total:.*?185.00/;
subtest 'requesting more bins' => sub {
$mech->submit_form_ok(
{ with_fields => {
bins_wanted => 3,
payment_method => 'credit_card',
name => 'Trevor Trouble',
email => 'trevor@trouble.com',
phone => '+4407111111111',
},
}
);

like $mech->text,
qr/Please review the information you’ve provided/,
'On review page';
like $mech->text,
qr/Total£185.00/, 'correct cost';
$mech->waste_submit_check(
{ with_fields => { tandc => 1 } } );

my ( $token, $renew_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} );
check_extra_data_pre_confirm(
$renew_report,
type => 'Renew',
current_bins => 2,
new_bins => 1,
bins_wanted => 3,
);
is $renew_report->get_extra_field_value('uprn'), $uprn;
is $renew_report->get_extra_field_value('payment'), 18500;
is $renew_report->get_extra_field_value('type'), 'renew';
is $renew_report->get_extra_field_value(
'customer_external_ref'), 'CUSTOMER_123';

$mech->get_ok("/waste/pay_complete/$report_id/$token?STATUS=9&PAYID=54321");
check_extra_data_post_confirm($renew_report);

$mech->clear_emails_ok;
FixMyStreet::Script::Reports::send();

my @emails = $mech->get_email;
my ($to_user) = grep {
$mech->get_text_body_from_email($_)
=~ /Thank you for renewing your subscription/
} @emails;
ok $to_user, 'Email sent to user';
my $email_body = $mech->get_text_body_from_email($to_user);
like $email_body, qr/Number of bin subscriptions: 3/;
like $email_body, qr/Bins to be delivered: 1/;
unlike $email_body, qr/Bins to be removed/;
like $email_body, qr/Total:.*?185.00/;
};

subtest 'requesting fewer bins' => sub {
$mech->get_ok("/waste/$uprn/garden_renew");

like $mech->content, qr/name="current_bins.*value="2"/s,
'Current bins pre-populated';
like $mech->content, qr/name="bins_wanted.*value="2"/s,
'Wanted bins pre-populated';

$mech->submit_form_ok(
{ with_fields => {
bins_wanted => 1,
payment_method => 'credit_card',
name => 'Trevor Trouble',
email => 'trevor@trouble.com',
phone => '+4407111111111',
},
}
);

like $mech->text,
qr/Total£75.00/, 'correct cost';
$mech->waste_submit_check(
{ with_fields => { tandc => 1 } } );

my ( $token, $renew_report, $report_id ) = get_report_from_redirect( $sent_params->{returnUrl} );
check_extra_data_pre_confirm(
$renew_report,
type => 'Renew',
current_bins => 2,
new_bins => -1,
bins_wanted => 1,
);
is $renew_report->get_extra_field_value('uprn'), $uprn;
is $renew_report->get_extra_field_value('payment'), 7500;
is $renew_report->get_extra_field_value('type'), 'renew';
is $renew_report->get_extra_field_value(
'customer_external_ref'), 'CUSTOMER_123';

$mech->get_ok("/waste/pay_complete/$report_id/$token?STATUS=9&PAYID=54321");
check_extra_data_post_confirm($renew_report);

$mech->clear_emails_ok;
FixMyStreet::Script::Reports::send();

my @emails = $mech->get_email;
my ($to_user) = grep {
$mech->get_text_body_from_email($_)
=~ /Thank you for renewing your subscription/
} @emails;
ok $to_user, 'Email sent to user';
my $email_body = $mech->get_text_body_from_email($to_user);
like $email_body, qr/Number of bin subscriptions: 1/;
unlike $email_body, qr/Bins to be delivered/;
like $email_body, qr/Bins to be removed: 1/;
like $email_body, qr/Total:.*?75.00/;
};

};

subtest 'too early' => sub {
Expand Down

0 comments on commit 25ecabb

Please sign in to comment.