@@ -248,9 +248,6 @@ describe('TermsOfService', () => {
248
248
/ I a g r e e t o t h e T O S a n d p r i v a c y p o l i c y / i
249
249
)
250
250
251
- const customerIntent = screen . getByRole ( 'radio' , { name : / P e r s o n a l u s e / } )
252
- await user . click ( customerIntent )
253
-
254
251
await user . click ( selectedTos )
255
252
256
253
const submit = await screen . findByRole ( 'button' , { name : / C o n t i n u e / } )
@@ -263,7 +260,7 @@ describe('TermsOfService', () => {
263
260
businessEmail :
'[email protected] ' ,
264
261
termsAgreement : true ,
265
262
marketingConsent : false ,
266
- customerIntent : 'PERSONAL ' ,
263
+ name : 'Chetney ' ,
267
264
} ,
268
265
} )
269
266
)
@@ -298,7 +295,7 @@ describe('TermsOfService', () => {
298
295
'case #1' ,
299
296
{
300
297
validationDescription :
301
- 'user has email, signs TOS, submit is now enabled' ,
298
+ 'user has email and name , signs TOS, submit is now enabled' ,
302
299
internalUserData : {
303
300
304
301
termsAgreement : false ,
@@ -309,15 +306,15 @@ describe('TermsOfService', () => {
309
306
} ,
310
307
[ expectPageIsReady ] ,
311
308
[ expectSubmitIsDisabled ] ,
309
+ [ expectPrepopulatedFields , { email :
'[email protected] ' , name :
'Chetney' } ] ,
312
310
[ expectUserSignsTOS ] ,
313
- [ expectUserToChooseCustomerIntent ] ,
314
311
[ expectSubmitIsEnabled ] ,
315
312
] ,
316
313
[
317
314
'case #2' ,
318
315
{
319
316
validationDescription :
320
- 'user wants to receive emails, signs TOS, submit is now enabled' ,
317
+ 'user has email and name, user wants to receive emails, signs TOS, submit is now enabled' ,
321
318
internalUserData : {
322
319
323
320
termsAgreement : false ,
@@ -327,38 +324,18 @@ describe('TermsOfService', () => {
327
324
} ,
328
325
} ,
329
326
[ expectPageIsReady ] ,
330
- [ expectUserSelectsMarketingWithFoundEmail , { email :
'[email protected] ' } ] ,
327
+ [ expectPrepopulatedFields , { email :
'[email protected] ' , name : 'Chetney ' } ] ,
331
328
[ expectSubmitIsDisabled ] ,
332
- [ expectUserToChooseCustomerIntent ] ,
333
- [ expectUserSignsTOS ] ,
334
- [ expectSubmitIsEnabled ] ,
335
- ] ,
336
- [
337
- 'case #3' ,
338
- {
339
- validationDescription :
340
- 'user has email, user wants to receive emails, signs TOS, submit is now enabled' ,
341
- internalUserData : {
342
-
343
- termsAgreement : false ,
344
- name : 'Chetney' ,
345
- externalId : '1234' ,
346
- owners : null ,
347
- } ,
348
- } ,
349
- [ expectPageIsReady ] ,
350
- [ expectSubmitIsDisabled ] ,
351
- [ expectUserSelectsMarketingWithFoundEmail , { email :
'[email protected] ' } ] ,
329
+ [ expectUserSelectsMarketing ] ,
352
330
[ expectSubmitIsDisabled ] ,
353
331
[ expectUserSignsTOS ] ,
354
- [ expectUserToChooseCustomerIntent ] ,
355
332
[ expectSubmitIsEnabled ] ,
356
333
] ,
357
334
[
358
- 'case #4 ' ,
335
+ 'case #3 ' ,
359
336
{
360
337
validationDescription :
361
- 'signs TOS, decides not to, is warned they must sign and cannot submit' ,
338
+ 'has prefilled email and name, signs TOS, decides not to, is warned they must sign and cannot submit' ,
362
339
internalUserData : {
363
340
364
341
termsAgreement : false ,
@@ -369,18 +346,18 @@ describe('TermsOfService', () => {
369
346
} ,
370
347
[ expectPageIsReady ] ,
371
348
[ expectSubmitIsDisabled ] ,
372
- [ expectUserToChooseCustomerIntent ] ,
349
+ [ expectPrepopulatedFields , { email : '[email protected] ' , name : 'Chetney' } ] ,
373
350
[ expectUserSignsTOS ] ,
374
351
[ expectSubmitIsEnabled ] ,
375
352
[ expectUserSignsTOS ] ,
376
353
[ expectSubmitIsDisabled ] ,
377
354
[ expectUserIsWarnedTOS ] ,
378
355
] ,
379
356
[
380
- 'case #5 ' ,
357
+ 'case #4 ' ,
381
358
{
382
359
validationDescription :
383
- 'user checks marketing consent and is required to provide an email, sign TOS (check email validation messages)' ,
360
+ 'user checks marketing consent and is required to provide an email, provide a name, sign TOS (check email validation messages)' ,
384
361
internalUserData : {
385
362
termsAgreement : false ,
386
363
name : 'Chetney' ,
@@ -391,21 +368,20 @@ describe('TermsOfService', () => {
391
368
} ,
392
369
[ expectPageIsReady ] ,
393
370
[ expectSubmitIsDisabled ] ,
394
- [ expectEmailRequired ] ,
395
371
[ expectUserTextEntryEmailField , { email : 'chetney' } ] ,
396
372
[ expectUserIsWarnedForValidEmail ] ,
397
373
[ expectSubmitIsDisabled ] ,
398
- [ expectUserTextEntryEmailField , { email : '@cr .com' } ] ,
374
+ [ expectUserTextEntryEmailField , { email : '@hello .com' } ] ,
399
375
[ expectUserIsNotWarnedForValidEmail ] ,
400
376
[ expectSubmitIsDisabled ] ,
377
+ [ expectUserTextEntryNameField ] ,
401
378
[ expectUserSelectsMarketing ] ,
402
379
[ expectSubmitIsDisabled ] ,
403
- [ expectUserToChooseCustomerIntent ] ,
404
380
[ expectUserSignsTOS ] ,
405
381
[ expectSubmitIsEnabled ] ,
406
382
] ,
407
383
[
408
- 'case #6 ' ,
384
+ 'case #5 ' ,
409
385
{
410
386
validationDescription :
411
387
'user checks marketing consent and does not provide an email, sign TOS (check email validation messages)' ,
@@ -418,29 +394,28 @@ describe('TermsOfService', () => {
418
394
} ,
419
395
} ,
420
396
[ expectPageIsReady ] ,
421
- [ expectEmailRequired ] ,
422
397
[ expectSubmitIsDisabled ] ,
423
398
[ expectUserSignsTOS ] ,
424
399
[ expectSubmitIsDisabled ] ,
425
- [ expectUserToChooseCustomerIntent ] ,
426
400
] ,
427
401
[
428
- 'case #7 ' ,
402
+ 'case #6 ' ,
429
403
{
430
404
validationDescription : 'server unknown error notification' ,
431
405
isUnknownError : true ,
432
406
internalUserData : {
433
407
termsAgreement : false ,
434
-
435
- name : 'Chetney ' ,
408
+ email : '' ,
409
+ name : '' ,
436
410
externalId : '1234' ,
437
411
owners : null ,
438
412
} ,
439
413
} ,
440
414
[ expectPageIsReady ] ,
415
+ [ expectUserTextEntryEmailField , { email :
'[email protected] ' } ] ,
416
+ [ expectUserTextEntryNameField ] ,
441
417
[ expectUserSignsTOS ] ,
442
418
[ expectClickSubmit ] ,
443
- [ expectUserToChooseCustomerIntent ] ,
444
419
[
445
420
expectRendersServerFailureResult ,
446
421
{
@@ -456,22 +431,23 @@ describe('TermsOfService', () => {
456
431
] ,
457
432
] ,
458
433
[
459
- 'case #8 ' ,
434
+ 'case #7 ' ,
460
435
{
461
436
validationDescription : 'server failure error notification' ,
462
437
isUnAuthError : true ,
463
438
internalUserData : {
464
439
termsAgreement : false ,
465
-
466
- name : 'Chetney ' ,
440
+ email : '' ,
441
+ name : '' ,
467
442
externalId : '1234' ,
468
443
owners : null ,
469
444
} ,
470
445
} ,
471
446
[ expectPageIsReady ] ,
447
+ [ expectUserTextEntryEmailField , { email :
'[email protected] ' } ] ,
448
+ [ expectUserTextEntryNameField ] ,
472
449
[ expectUserSignsTOS ] ,
473
450
[ expectClickSubmit ] ,
474
- [ expectUserToChooseCustomerIntent ] ,
475
451
[
476
452
expectRendersServerFailureResult ,
477
453
{
@@ -481,27 +457,28 @@ describe('TermsOfService', () => {
481
457
] ,
482
458
] ,
483
459
[
484
- 'case #9 ' ,
460
+ 'case #8 ' ,
485
461
{
486
462
validationDescription :
487
463
'server validation error notification (saveTerms)' ,
488
464
isValidationError : true ,
489
465
internalUserData : {
490
466
termsAgreement : false ,
491
-
492
- name : 'Chetney ' ,
467
+ email : '' ,
468
+ name : '' ,
493
469
externalId : '1234' ,
494
470
owners : null ,
495
471
} ,
496
472
} ,
497
473
[ expectPageIsReady ] ,
474
+ [ expectUserTextEntryEmailField , { email :
'[email protected] ' } ] ,
475
+ [ expectUserTextEntryNameField ] ,
498
476
[ expectUserSignsTOS ] ,
499
477
[ expectClickSubmit ] ,
500
- [ expectUserToChooseCustomerIntent ] ,
501
478
[ expectRendersServerFailureResult , 'validation error' ] ,
502
479
] ,
503
480
[
504
- 'case #10 ' ,
481
+ 'case #9 ' ,
505
482
{
506
483
validationDescription :
507
484
'redirects to main root if user has already synced a provider' ,
@@ -526,33 +503,6 @@ describe('TermsOfService', () => {
526
503
} ,
527
504
[ expectRedirectTo , '/gh/codecov/cool-repo' ] ,
528
505
] ,
529
- [
530
- 'case #11' ,
531
- {
532
- validationDescription : 'provide no customer intent, does not submit' ,
533
- internalUserData : {
534
- termsAgreement : true ,
535
- name : 'Chetney' ,
536
- externalId : '1234' ,
537
- email : '' ,
538
- owners : [
539
- {
540
- avatarUrl : 'http://roland.com/avatar-url' ,
541
- integrationId : null ,
542
- name : null ,
543
- ownerid : 2 ,
544
- stats : null ,
545
- service : 'github' ,
546
- username : 'roland' ,
547
- } ,
548
- ] ,
549
- } ,
550
- } ,
551
- [ expectPageIsReady ] ,
552
- [ expectSubmitIsDisabled ] ,
553
- [ expectUserSignsTOS ] ,
554
- [ expectSubmitIsDisabled ] ,
555
- ] ,
556
506
] ) (
557
507
'form validation, %s' ,
558
508
(
@@ -693,33 +643,43 @@ async function expectPageIsReady() {
693
643
expect ( welcome ) . toBeInTheDocument ( )
694
644
}
695
645
696
- async function expectUserToChooseCustomerIntent ( user : UserEvent ) {
697
- const customerIntent = screen . getByRole ( 'radio' , { name : / P e r s o n a l u s e / } )
698
-
699
- await user . click ( customerIntent )
646
+ async function expectPrepopulatedFields (
647
+ user : UserEvent ,
648
+ args : { email : string ; name : string }
649
+ ) {
650
+ await waitFor ( ( ) => {
651
+ const emailInput = screen . getByLabelText (
652
+ / E n t e r y o u r e m a i l / i
653
+ ) as HTMLInputElement
654
+ expect ( emailInput ) . toHaveValue ( args . email )
655
+ } )
656
+ await waitFor ( ( ) => {
657
+ const nameInput = screen . getByLabelText (
658
+ / E n t e r y o u r n a m e / i
659
+ ) as HTMLInputElement
660
+ expect ( nameInput ) . toHaveValue ( args . name )
661
+ } )
700
662
}
701
663
702
- async function expectUserSignsTOS ( user : UserEvent ) {
703
- const selectedTos = screen . getByLabelText (
704
- / I a g r e e t o t h e T O S a n d p r i v a c y p o l i c y / i
705
- )
706
-
707
- await user . click ( selectedTos )
664
+ async function expectUserTextEntryNameField ( user : UserEvent ) {
665
+ const nameInput = screen . getByLabelText ( / E n t e r y o u r n a m e / i)
666
+ await user . type ( nameInput , 'My name' )
708
667
}
709
668
710
- async function expectUserSelectsMarketingWithFoundEmail (
669
+ async function expectUserTextEntryEmailField (
711
670
user : UserEvent ,
712
671
args : { email : string }
713
672
) {
714
- const selectedMarketing = screen . getByLabelText (
715
- / I w o u l d l i k e t o r e c e i v e u p d a t e s v i a e m a i l / i
716
- )
717
- const emailIsInTheLabelOfSelectedMarketing = screen . getByText (
718
- new RegExp ( args . email , 'i' )
673
+ const emailInput = screen . getByLabelText ( / E n t e r y o u r e m a i l / i)
674
+ await user . type ( emailInput , args . email )
675
+ }
676
+
677
+ async function expectUserSignsTOS ( user : UserEvent ) {
678
+ const selectedTos = screen . getByLabelText (
679
+ / I a g r e e t o t h e T O S a n d p r i v a c y p o l i c y / i
719
680
)
720
- expect ( emailIsInTheLabelOfSelectedMarketing ) . toBeInTheDocument ( )
721
681
722
- await user . click ( selectedMarketing )
682
+ await user . click ( selectedTos )
723
683
}
724
684
725
685
async function expectUserSelectsMarketing ( user : UserEvent ) {
@@ -730,15 +690,6 @@ async function expectUserSelectsMarketing(user: UserEvent) {
730
690
await user . click ( selectedMarketing )
731
691
}
732
692
733
- async function expectUserTextEntryEmailField (
734
- user : UserEvent ,
735
- args : { email : string }
736
- ) {
737
- const emailInput = screen . getByLabelText ( / C o n t a c t e m a i l / i)
738
-
739
- await user . type ( emailInput , args . email )
740
- }
741
-
742
693
async function expectSubmitIsDisabled ( ) {
743
694
const submit = screen . getByRole ( 'button' , { name : / C o n t i n u e / } )
744
695
expect ( submit ) . toBeDisabled ( )
@@ -770,17 +721,6 @@ async function expectClickSubmit(user: UserEvent) {
770
721
await user . click ( submit )
771
722
}
772
723
773
- async function expectEmailRequired ( user : UserEvent ) {
774
- const selectedMarketing = screen . getByLabelText (
775
- / I w o u l d l i k e t o r e c e i v e u p d a t e s v i a e m a i l / i
776
- )
777
-
778
- await user . click ( selectedMarketing )
779
-
780
- const emailRequired = screen . getByText ( / C o n t a c t e m a i l / i)
781
- expect ( emailRequired ) . toBeInTheDocument ( )
782
- }
783
-
784
724
async function expectRendersServerFailureResult (
785
725
user : UserEvent ,
786
726
expectedError = { }
0 commit comments