@@ -613,6 +613,7 @@ describe('NewPlanSelection component', () => {
613613 planType : PLAN_TYPE . byContact ,
614614 isFreeAccount : false ,
615615 planSubscription : 12 ,
616+ subscribersCount : 900 ,
616617 promotion : {
617618 idUserTypePlan : 10222 ,
618619 code : 'PROMOCODE_ANNUAL' ,
@@ -625,7 +626,9 @@ describe('NewPlanSelection component', () => {
625626
626627 const promocodeInput = within ( getContactsPlanSection ( ) ) . getByRole ( 'textbox' ) ;
627628 expect ( promocodeInput ) . toHaveValue ( '' ) ;
628- expect ( screen . queryByRole ( 'link' , { name : / E l e g i r P l a n / i } ) ) . not . toBeInTheDocument ( ) ;
629+ const choosePlanHref = screen . getByRole ( 'link' , { name : / E l e g i r P l a n / i } ) . getAttribute ( 'href' ) ;
630+ expect ( choosePlanHref ) . not . toContain ( 'PromoCode=' ) ;
631+ expect ( choosePlanHref ) . not . toContain ( 'promo-code=' ) ;
629632 } ) ;
630633
631634 it ( 'should update selected contacts plan in checkout URL when contacts dropdown changes' , async ( ) => {
@@ -693,6 +696,30 @@ describe('NewPlanSelection component', () => {
693696 ) . toHaveAttribute ( 'href' , '/checkout/premium/monthly-deliveries?selected-plan=30223&buyType=1' ) ;
694697 } ) ;
695698
699+ it ( 'should show current plan warning and hide promocode when selected byEmail plan equals current one' , async ( ) => {
700+ await renderNewPlanSelection (
701+ [ '/new-plan-selection' ] ,
702+ {
703+ appSessionUser : {
704+ plan : {
705+ idPlan : 30223 ,
706+ planType : PLAN_TYPE . byEmail ,
707+ isFreeAccount : false ,
708+ planSubscription : 1 ,
709+ } ,
710+ } ,
711+ } ,
712+ { useI18nKeysAsValues : true } ,
713+ ) ;
714+
715+ expect ( getEmailsSelect ( ) ) . toHaveValue ( '1' ) ;
716+ expect ( screen . getByTestId ( 'dp-emails-current-plan-message' ) ) . toBeInTheDocument ( ) ;
717+ expect (
718+ screen . getByText ( 'buy_process.new_plan_selection.contacts_current_plan_warning_message' ) ,
719+ ) . toBeInTheDocument ( ) ;
720+ expect ( within ( getEmailsPlanSection ( ) ) . queryByRole ( 'textbox' ) ) . not . toBeInTheDocument ( ) ;
721+ } ) ;
722+
696723 it ( 'should preselect the next contact plan when subscribers count is lower than current plan capacity and a higher plan exists' , async ( ) => {
697724 const contactPlansWithExtraLevel = [
698725 {
@@ -792,6 +819,34 @@ describe('NewPlanSelection component', () => {
792819 ) . toBeDisabled ( ) ;
793820 } ) ;
794821
822+ it ( 'should show current plan warning and hide subscription and promocode when selected plan equals current one' , async ( ) => {
823+ await renderNewPlanSelection (
824+ [ '/new-plan-selection' ] ,
825+ {
826+ appSessionUser : {
827+ plan : {
828+ idPlan : 10223 ,
829+ planType : PLAN_TYPE . byContact ,
830+ isFreeAccount : false ,
831+ planSubscription : 1 ,
832+ subscribersCount : 1300 ,
833+ } ,
834+ } ,
835+ } ,
836+ { useI18nKeysAsValues : true } ,
837+ ) ;
838+
839+ expect ( getContactsSelect ( ) ) . toHaveValue ( '1' ) ;
840+ expect ( screen . getByTestId ( 'dp-contacts-current-plan-message' ) ) . toBeInTheDocument ( ) ;
841+ expect (
842+ screen . getByText ( 'buy_process.new_plan_selection.contacts_current_plan_warning_message' ) ,
843+ ) . toBeInTheDocument ( ) ;
844+ expect (
845+ within ( getContactsPlanSection ( ) ) . queryByRole ( 'button' , { name : / M e n s u a l / i } ) ,
846+ ) . not . toBeInTheDocument ( ) ;
847+ expect ( within ( getContactsPlanSection ( ) ) . queryByRole ( 'textbox' ) ) . not . toBeInTheDocument ( ) ;
848+ } ) ;
849+
795850 it ( 'should preselect a higher contact plan when subscribers count is greater than current plan capacity' , async ( ) => {
796851 await renderNewPlanSelection ( [ '/new-plan-selection' ] , {
797852 appSessionUser : {
@@ -967,6 +1022,10 @@ describe('NewPlanSelection component', () => {
9671022 await waitFor ( ( ) =>
9681023 expect ( screen . getByTestId ( 'dp-contacts-downgrade-message' ) ) . toBeInTheDocument ( ) ,
9691024 ) ;
1025+ expect (
1026+ within ( getContactsPlanSection ( ) ) . queryByRole ( 'button' , { name : / M e n s u a l / i } ) ,
1027+ ) . not . toBeInTheDocument ( ) ;
1028+ expect ( within ( getContactsPlanSection ( ) ) . queryByRole ( 'textbox' ) ) . not . toBeInTheDocument ( ) ;
9701029 expect (
9711030 screen . getByText ( 'buy_process.new_plan_selection.contacts_downgrade_warning_message' ) ,
9721031 ) . toBeInTheDocument ( ) ;
@@ -1135,10 +1194,11 @@ describe('NewPlanSelection component', () => {
11351194 } ,
11361195 } ) ;
11371196
1138- const annualFrequencyButton = within ( getContactsPlanSection ( ) ) . getByRole ( 'button' , {
1139- name : / A n u a l / i,
1140- } ) ;
1141- expect ( annualFrequencyButton ) . toBeDisabled ( ) ;
1197+ expect ( screen . getByTestId ( 'dp-contacts-current-plan-message' ) ) . toBeInTheDocument ( ) ;
1198+ expect (
1199+ within ( getContactsPlanSection ( ) ) . queryByRole ( 'button' , { name : / A n u a l / i } ) ,
1200+ ) . not . toBeInTheDocument ( ) ;
1201+ expect ( within ( getContactsPlanSection ( ) ) . queryByRole ( 'textbox' ) ) . not . toBeInTheDocument ( ) ;
11421202 } ) ;
11431203
11441204 it ( 'should render credits plan before contacts plan for users with current credit plan' , async ( ) => {
@@ -1195,6 +1255,10 @@ describe('NewPlanSelection component', () => {
11951255
11961256 const infoBanner = screen . getByTestId ( 'dp-more-than-100k-message' ) ;
11971257 expect ( infoBanner ) . toBeInTheDocument ( ) ;
1258+ expect (
1259+ within ( getContactsPlanSection ( ) ) . queryByRole ( 'button' , { name : / M e n s u a l / i } ) ,
1260+ ) . not . toBeInTheDocument ( ) ;
1261+ expect ( within ( getContactsPlanSection ( ) ) . queryByRole ( 'textbox' ) ) . not . toBeInTheDocument ( ) ;
11981262 expect ( within ( infoBanner ) . getByText ( / b a s e s u p e r a l o s 1 0 0 k d e C o n t a c t o s / i) ) . toBeInTheDocument ( ) ;
11991263 expect (
12001264 within ( infoBanner ) . getByRole ( 'link' , { name : / c o n t [ a á ] c t a n o s | c o n t a c t u s / i } ) ,
@@ -1431,4 +1495,29 @@ describe('NewPlanSelection component', () => {
14311495 within ( getCreditsPlanSection ( ) ) . getByText ( / I n c l u y e 5 .0 0 0 C r e d i t o s e x t r a / i) ,
14321496 ) . toBeInTheDocument ( ) ;
14331497 } ) ;
1498+
1499+ it ( 'should keep prepayment breakdown in a new line for quarterly, semiannual and annual frequencies' , async ( ) => {
1500+ await renderNewPlanSelection ( ) ;
1501+
1502+ const contactsSection = getContactsPlanSection ( ) ;
1503+ const scenarios = [
1504+ { buttonName : / T r i m e s t r a l / i, expectedText : '1 pago trimestral de' } ,
1505+ { buttonName : / S e m e s t r a l / i, expectedText : '1 pago semestral de' } ,
1506+ { buttonName : / A n u a l / i, expectedText : '1 pago anual de' } ,
1507+ ] ;
1508+
1509+ for ( const scenario of scenarios ) {
1510+ fireEvent . click ( within ( contactsSection ) . getByRole ( 'button' , { name : scenario . buttonName } ) ) ;
1511+ await settleAsyncState ( ) ;
1512+
1513+ await waitFor ( ( ) => {
1514+ const savingsElement = contactsSection . querySelector (
1515+ '.dp-new-plan-selection-price-detail .dp-new-plan-selection-savings' ,
1516+ ) ;
1517+ expect ( savingsElement ) . toBeInTheDocument ( ) ;
1518+ expect ( savingsElement . textContent . toLowerCase ( ) ) . toContain ( scenario . expectedText ) ;
1519+ expect ( savingsElement . querySelector ( 'br' ) ) . toBeInTheDocument ( ) ;
1520+ } ) ;
1521+ }
1522+ } ) ;
14341523} ) ;
0 commit comments