@@ -1581,17 +1581,18 @@ describe('Signin component', () => {
15811581 hasPassword : false ,
15821582 } ) ;
15831583
1584- // the specific case here is the falsy condition of the above ternary
1585- // so, we make sure our mock headline is NOT in the document as a guard against
1586- // snapshotting the wrong render.
1587- expect (
1588- screen . queryByText ( cmsProps . cmsInfo . SigninPage . headline )
1589- ) . not . toBeInTheDocument ( ) ;
1590-
15911584 const cmsLogo = screen . getByRole ( 'img' , {
15921585 name : cmsProps . cmsInfo . shared . logoAltText ,
15931586 } ) ;
15941587 expect ( cmsLogo ) . toMatchSnapshot ( ) ;
1588+
1589+ // When no SigninCachedPage is set, the non-password path falls back
1590+ // to SigninPage headline and description
1591+ expect (
1592+ screen . getByRole ( 'heading' , {
1593+ name : cmsProps . cmsInfo . SigninPage . headline ,
1594+ } )
1595+ ) . toBeInTheDocument ( ) ;
15951596 } ) ;
15961597
15971598 it ( 'renders the CMS-styled submit button' , ( ) => {
@@ -1621,5 +1622,77 @@ describe('Signin component', () => {
16211622
16221623 expect ( additionalInfo ) . toBeInTheDocument ( ) ;
16231624 } ) ;
1625+
1626+ describe ( 'SigninCachedPage CMS config' , ( ) => {
1627+ const cachedCmsProps = {
1628+ cmsInfo : {
1629+ ...MOCK_CMS_INFO ,
1630+ SigninCachedPage : {
1631+ headline : 'Welcome back' ,
1632+ description : 'Continue to your Mozilla account' ,
1633+ primaryButtonText : 'Continue' ,
1634+ pageTitle : 'Welcome back' ,
1635+ } ,
1636+ } ,
1637+ } ;
1638+
1639+ it ( 'renders cached CMS headline and description for cached user' , ( ) => {
1640+ render ( {
1641+ integration : createMockSigninWebIntegration ( cachedCmsProps ) ,
1642+ sessionToken : MOCK_SESSION_TOKEN ,
1643+ hasPassword : true ,
1644+ } ) ;
1645+
1646+ expect (
1647+ screen . getByRole ( 'heading' , { name : 'Welcome back' } )
1648+ ) . toBeInTheDocument ( ) ;
1649+ expect (
1650+ screen . getByText ( 'Continue to your Mozilla account' )
1651+ ) . toBeInTheDocument ( ) ;
1652+ } ) ;
1653+
1654+ it ( 'renders cached CMS button text for cached user' , ( ) => {
1655+ render ( {
1656+ integration : createMockSigninWebIntegration ( cachedCmsProps ) ,
1657+ sessionToken : MOCK_SESSION_TOKEN ,
1658+ hasPassword : true ,
1659+ } ) ;
1660+
1661+ expect (
1662+ screen . getByRole ( 'button' , { name : 'Continue' } )
1663+ ) . toBeInTheDocument ( ) ;
1664+ } ) ;
1665+
1666+ it ( 'falls back to SigninPage CMS config when SigninCachedPage is not set' , ( ) => {
1667+ render ( {
1668+ integration : createMockSigninWebIntegration ( cmsProps ) ,
1669+ sessionToken : MOCK_SESSION_TOKEN ,
1670+ hasPassword : true ,
1671+ } ) ;
1672+
1673+ expect (
1674+ screen . getByRole ( 'heading' , {
1675+ name : cmsProps . cmsInfo . SigninPage . headline ,
1676+ } )
1677+ ) . toBeInTheDocument ( ) ;
1678+ } ) ;
1679+
1680+ it ( 'uses SigninPage CMS config for non-cached user even when SigninCachedPage is set' , ( ) => {
1681+ render ( {
1682+ integration : createMockSigninWebIntegration ( cachedCmsProps ) ,
1683+ hasPassword : true ,
1684+ sessionToken : undefined ,
1685+ } ) ;
1686+
1687+ expect (
1688+ screen . getByRole ( 'heading' , {
1689+ name : cachedCmsProps . cmsInfo . SigninPage . headline ,
1690+ } )
1691+ ) . toBeInTheDocument ( ) ;
1692+ expect (
1693+ screen . queryByRole ( 'heading' , { name : 'Welcome back' } )
1694+ ) . not . toBeInTheDocument ( ) ;
1695+ } ) ;
1696+ } ) ;
16241697 } ) ;
16251698} ) ;
0 commit comments