@@ -258,13 +258,13 @@ FixMyStreet::override_config {
258
258
259
259
FixMyStreet::Script::Reports::send ();
260
260
my @emails = $mech -> get_email;
261
- my $body = $mech -> get_text_body_from_email($emails [1]);
261
+ my $email_body = $mech -> get_text_body_from_email($emails [1]);
262
262
TODO: {
263
263
local $TODO = ' Quantity not yet read in _garden_data.html' ;
264
- like $body , qr / Number of bin subscriptions: 2/ ;
264
+ like $email_body , qr / Number of bin subscriptions: 2/ ;
265
265
}
266
- like $body , qr / Bins to be delivered: 2/ ;
267
- like $body , qr / Total:.*?$test ->{pounds_cost}/ ;
266
+ like $email_body , qr / Bins to be delivered: 2/ ;
267
+ like $email_body , qr / Total:.*?$test ->{pounds_cost}/ ;
268
268
$mech -> clear_emails_ok;
269
269
};
270
270
@@ -296,13 +296,13 @@ FixMyStreet::override_config {
296
296
$mech -> clear_emails_ok;
297
297
FixMyStreet::Script::Reports::send ();
298
298
my @emails = $mech -> get_email;
299
- my $body = $mech -> get_text_body_from_email($emails [1]);
299
+ my $email_body = $mech -> get_text_body_from_email($emails [1]);
300
300
TODO: {
301
301
local $TODO = ' Quantity not yet read in _garden_data.html' ;
302
- like $body , qr / Number of bin subscriptions: 1/ ;
302
+ like $email_body , qr / Number of bin subscriptions: 1/ ;
303
303
}
304
- unlike $body , qr / Bins to be delivered/ ;
305
- like $body , qr / Total:.*?75.00/ ;
304
+ unlike $email_body , qr / Bins to be delivered/ ;
305
+ like $email_body , qr / Total:.*?75.00/ ;
306
306
};
307
307
308
308
subtest ' check new sub credit card payment with one less bin required' => sub {
@@ -331,13 +331,124 @@ FixMyStreet::override_config {
331
331
$mech -> clear_emails_ok;
332
332
FixMyStreet::Script::Reports::send ();
333
333
my @emails = $mech -> get_email;
334
- my $body = $mech -> get_text_body_from_email($emails [1]);
334
+ my $email_body = $mech -> get_text_body_from_email($emails [1]);
335
335
TODO: {
336
336
local $TODO = ' Quantity not yet read in _garden_data.html' ;
337
- like $body , qr / Number of bin subscriptions: 1/ ;
337
+ like $email_body , qr / Number of bin subscriptions: 1/ ;
338
338
}
339
- like $body , qr / Bins to be removed: 1/ ;
340
- like $body , qr / Total:.*?75.00/ ;
339
+ like $email_body , qr / Bins to be removed: 1/ ;
340
+ like $email_body , qr / Total:.*?75.00/ ;
341
+ };
342
+
343
+ subtest ' renew garden subscription' => sub {
344
+ set_fixed_time(' 2024-02-01T00:00:00' );
345
+
346
+ my $uprn = 10001;
347
+ my $contract_id = ' CONTRACT_123' ;
348
+
349
+ # subtest 'with Agile data only' => sub {
350
+ # subtest 'within renewal window' => sub {
351
+ # $agile_mock->mock( 'CustomerSearch', sub { {
352
+ # Customers => [
353
+ # {
354
+ # CustomerExternalReference => 'CUSTOMER_123',
355
+ # ServiceContracts => [
356
+ # {
357
+ # # One month away
358
+ # EndDate => '01/03/2024 12:00',
359
+ # Reference => $contract_id,
360
+ # },
361
+ # ],
362
+ # },
363
+ # ],
364
+ # } } );
365
+
366
+ # $mech->get_ok("/waste/$uprn");
367
+
368
+ # };
369
+
370
+ # # subtest 'too early' => sub {
371
+ # # $agile_mock->mock( 'CustomerSearch', sub { {
372
+ # # Customers => [
373
+ # # {
374
+ # # CustomerExternalReference => 'CUSTOMER_123',
375
+ # # ServiceContracts => [
376
+ # # {
377
+ # # # 2 months away
378
+ # # EndDate => '01/04/2024 12:00',
379
+ # # },
380
+ # # ],
381
+ # # },
382
+ # # ],
383
+ # # } } );
384
+ # # };
385
+
386
+ # # subtest 'subscription expired' => sub {
387
+ # # $agile_mock->mock( 'CustomerSearch', sub { {
388
+ # # Customers => [
389
+ # # {
390
+ # # CustomerExternalReference => 'CUSTOMER_123',
391
+ # # ServiceContracts => [
392
+ # # {
393
+ # # # 1 month ago
394
+ # # EndDate => '01/01/2024 12:00',
395
+ # # },
396
+ # # ],
397
+ # # },
398
+ # # ],
399
+ # # } } );
400
+ # # };
401
+ # };
402
+
403
+ subtest ' with DB data' => sub {
404
+ my ($new_sub_report ) = $mech -> create_problems_for_body(
405
+ 1,
406
+ $body -> id,
407
+ ' Garden Subscription - New' ,
408
+ { category => ' Garden Subscription' ,
409
+ external_id => " Agile-$contract_id " ,
410
+ },
411
+ );
412
+ $new_sub_report -> set_extra_fields(
413
+ { name => ' uprn' , value => $uprn } );
414
+ $new_sub_report -> update;
415
+
416
+ subtest ' within renewal window' => sub {
417
+ $agile_mock -> mock( ' CustomerSearch' , sub { {
418
+ Customers => [
419
+ {
420
+ CustomerExternalReference => ' CUSTOMER_123' ,
421
+ ServiceContracts => [
422
+ {
423
+ # 42 days away
424
+ EndDate => ' 14/03/2024 12:00' ,
425
+ Reference => $contract_id ,
426
+ },
427
+ ],
428
+ },
429
+ ],
430
+ } } );
431
+
432
+ $mech -> get_ok(" /waste/$uprn " );
433
+ # warn "====\n\t" . $mech->text . "\n=÷===";
434
+ # warn "====\n\t" . $mech->content . "\n====";
435
+ like $mech -> content, qr / 14 March 2024, soon due for renewal/ ,
436
+ ' "Due soon" message shown' ;
437
+ like $mech -> content,
438
+ qr / Renew your brown wheelie bin subscription/ ,
439
+ ' Renewal link available' ;
440
+ like $mech -> text, qr / Frequency.*Pending/ , ' Pending details because no Whitespace data' ;
441
+
442
+ };
443
+
444
+ # subtest 'too early' => sub {
445
+
446
+ # };
447
+
448
+ # subtest 'subscription expired' => sub {
449
+
450
+ # };
451
+ };
341
452
};
342
453
343
454
subtest ' cancel garden subscription' => sub {
0 commit comments