@@ -248,9 +248,6 @@ describe('TermsOfService', () => {
248248 / 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
249249 )
250250
251- const customerIntent = screen . getByRole ( 'radio' , { name : / P e r s o n a l u s e / } )
252- await user . click ( customerIntent )
253-
254251 await user . click ( selectedTos )
255252
256253 const submit = await screen . findByRole ( 'button' , { name : / C o n t i n u e / } )
@@ -263,7 +260,7 @@ describe('TermsOfService', () => {
263260 businessEmail :
'[email protected] ' , 264261 termsAgreement : true ,
265262 marketingConsent : false ,
266- customerIntent : 'PERSONAL ' ,
263+ name : 'Chetney ' ,
267264 } ,
268265 } )
269266 )
@@ -298,7 +295,7 @@ describe('TermsOfService', () => {
298295 'case #1' ,
299296 {
300297 validationDescription :
301- 'user has email, signs TOS, submit is now enabled' ,
298+ 'user has email and name , signs TOS, submit is now enabled' ,
302299 internalUserData : {
303300304301 termsAgreement : false ,
@@ -309,15 +306,15 @@ describe('TermsOfService', () => {
309306 } ,
310307 [ expectPageIsReady ] ,
311308 [ expectSubmitIsDisabled ] ,
309+ [ expectPrepopulatedFields , { email :
'[email protected] ' , name :
'Chetney' } ] , 312310 [ expectUserSignsTOS ] ,
313- [ expectUserToChooseCustomerIntent ] ,
314311 [ expectSubmitIsEnabled ] ,
315312 ] ,
316313 [
317314 'case #2' ,
318315 {
319316 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' ,
321318 internalUserData : {
322319323320 termsAgreement : false ,
@@ -327,38 +324,18 @@ describe('TermsOfService', () => {
327324 } ,
328325 } ,
329326 [ expectPageIsReady ] ,
330- [ expectUserSelectsMarketingWithFoundEmail , { email :
'[email protected] ' } ] , 327+ [ expectPrepopulatedFields , { email :
'[email protected] ' , name : 'Chetney ' } ] , 331328 [ 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 ] ,
352330 [ expectSubmitIsDisabled ] ,
353331 [ expectUserSignsTOS ] ,
354- [ expectUserToChooseCustomerIntent ] ,
355332 [ expectSubmitIsEnabled ] ,
356333 ] ,
357334 [
358- 'case #4 ' ,
335+ 'case #3 ' ,
359336 {
360337 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' ,
362339 internalUserData : {
363340364341 termsAgreement : false ,
@@ -369,18 +346,18 @@ describe('TermsOfService', () => {
369346 } ,
370347 [ expectPageIsReady ] ,
371348 [ expectSubmitIsDisabled ] ,
372- [ expectUserToChooseCustomerIntent ] ,
349+ [ expectPrepopulatedFields , { email : '[email protected] ' , name : 'Chetney' } ] , 373350 [ expectUserSignsTOS ] ,
374351 [ expectSubmitIsEnabled ] ,
375352 [ expectUserSignsTOS ] ,
376353 [ expectSubmitIsDisabled ] ,
377354 [ expectUserIsWarnedTOS ] ,
378355 ] ,
379356 [
380- 'case #5 ' ,
357+ 'case #4 ' ,
381358 {
382359 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)' ,
384361 internalUserData : {
385362 termsAgreement : false ,
386363 name : 'Chetney' ,
@@ -391,21 +368,20 @@ describe('TermsOfService', () => {
391368 } ,
392369 [ expectPageIsReady ] ,
393370 [ expectSubmitIsDisabled ] ,
394- [ expectEmailRequired ] ,
395371 [ expectUserTextEntryEmailField , { email : 'chetney' } ] ,
396372 [ expectUserIsWarnedForValidEmail ] ,
397373 [ expectSubmitIsDisabled ] ,
398- [ expectUserTextEntryEmailField , { email : '@cr .com' } ] ,
374+ [ expectUserTextEntryEmailField , { email : '@hello .com' } ] ,
399375 [ expectUserIsNotWarnedForValidEmail ] ,
400376 [ expectSubmitIsDisabled ] ,
377+ [ expectUserTextEntryNameField ] ,
401378 [ expectUserSelectsMarketing ] ,
402379 [ expectSubmitIsDisabled ] ,
403- [ expectUserToChooseCustomerIntent ] ,
404380 [ expectUserSignsTOS ] ,
405381 [ expectSubmitIsEnabled ] ,
406382 ] ,
407383 [
408- 'case #6 ' ,
384+ 'case #5 ' ,
409385 {
410386 validationDescription :
411387 'user checks marketing consent and does not provide an email, sign TOS (check email validation messages)' ,
@@ -418,29 +394,28 @@ describe('TermsOfService', () => {
418394 } ,
419395 } ,
420396 [ expectPageIsReady ] ,
421- [ expectEmailRequired ] ,
422397 [ expectSubmitIsDisabled ] ,
423398 [ expectUserSignsTOS ] ,
424399 [ expectSubmitIsDisabled ] ,
425- [ expectUserToChooseCustomerIntent ] ,
426400 ] ,
427401 [
428- 'case #7 ' ,
402+ 'case #6 ' ,
429403 {
430404 validationDescription : 'server unknown error notification' ,
431405 isUnknownError : true ,
432406 internalUserData : {
433407 termsAgreement : false ,
434- 435- name : 'Chetney ' ,
408+ email : '' ,
409+ name : '' ,
436410 externalId : '1234' ,
437411 owners : null ,
438412 } ,
439413 } ,
440414 [ expectPageIsReady ] ,
415+ [ expectUserTextEntryEmailField , { email :
'[email protected] ' } ] , 416+ [ expectUserTextEntryNameField ] ,
441417 [ expectUserSignsTOS ] ,
442418 [ expectClickSubmit ] ,
443- [ expectUserToChooseCustomerIntent ] ,
444419 [
445420 expectRendersServerFailureResult ,
446421 {
@@ -456,22 +431,23 @@ describe('TermsOfService', () => {
456431 ] ,
457432 ] ,
458433 [
459- 'case #8 ' ,
434+ 'case #7 ' ,
460435 {
461436 validationDescription : 'server failure error notification' ,
462437 isUnAuthError : true ,
463438 internalUserData : {
464439 termsAgreement : false ,
465- 466- name : 'Chetney ' ,
440+ email : '' ,
441+ name : '' ,
467442 externalId : '1234' ,
468443 owners : null ,
469444 } ,
470445 } ,
471446 [ expectPageIsReady ] ,
447+ [ expectUserTextEntryEmailField , { email :
'[email protected] ' } ] , 448+ [ expectUserTextEntryNameField ] ,
472449 [ expectUserSignsTOS ] ,
473450 [ expectClickSubmit ] ,
474- [ expectUserToChooseCustomerIntent ] ,
475451 [
476452 expectRendersServerFailureResult ,
477453 {
@@ -481,27 +457,28 @@ describe('TermsOfService', () => {
481457 ] ,
482458 ] ,
483459 [
484- 'case #9 ' ,
460+ 'case #8 ' ,
485461 {
486462 validationDescription :
487463 'server validation error notification (saveTerms)' ,
488464 isValidationError : true ,
489465 internalUserData : {
490466 termsAgreement : false ,
491- 492- name : 'Chetney ' ,
467+ email : '' ,
468+ name : '' ,
493469 externalId : '1234' ,
494470 owners : null ,
495471 } ,
496472 } ,
497473 [ expectPageIsReady ] ,
474+ [ expectUserTextEntryEmailField , { email :
'[email protected] ' } ] , 475+ [ expectUserTextEntryNameField ] ,
498476 [ expectUserSignsTOS ] ,
499477 [ expectClickSubmit ] ,
500- [ expectUserToChooseCustomerIntent ] ,
501478 [ expectRendersServerFailureResult , 'validation error' ] ,
502479 ] ,
503480 [
504- 'case #10 ' ,
481+ 'case #9 ' ,
505482 {
506483 validationDescription :
507484 'redirects to main root if user has already synced a provider' ,
@@ -526,33 +503,6 @@ describe('TermsOfService', () => {
526503 } ,
527504 [ expectRedirectTo , '/gh/codecov/cool-repo' ] ,
528505 ] ,
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- ] ,
556506 ] ) (
557507 'form validation, %s' ,
558508 (
@@ -693,33 +643,43 @@ async function expectPageIsReady() {
693643 expect ( welcome ) . toBeInTheDocument ( )
694644}
695645
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+ } )
700662}
701663
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' )
708667}
709668
710- async function expectUserSelectsMarketingWithFoundEmail (
669+ async function expectUserTextEntryEmailField (
711670 user : UserEvent ,
712671 args : { email : string }
713672) {
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
719680 )
720- expect ( emailIsInTheLabelOfSelectedMarketing ) . toBeInTheDocument ( )
721681
722- await user . click ( selectedMarketing )
682+ await user . click ( selectedTos )
723683}
724684
725685async function expectUserSelectsMarketing ( user : UserEvent ) {
@@ -730,15 +690,6 @@ async function expectUserSelectsMarketing(user: UserEvent) {
730690 await user . click ( selectedMarketing )
731691}
732692
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-
742693async function expectSubmitIsDisabled ( ) {
743694 const submit = screen . getByRole ( 'button' , { name : / C o n t i n u e / } )
744695 expect ( submit ) . toBeDisabled ( )
@@ -770,17 +721,6 @@ async function expectClickSubmit(user: UserEvent) {
770721 await user . click ( submit )
771722}
772723
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-
784724async function expectRendersServerFailureResult (
785725 user : UserEvent ,
786726 expectedError = { }
0 commit comments