@@ -432,6 +432,90 @@ define(function (require, exports, module) {
432432 // Close popup
433433 $profileButton . trigger ( 'click' ) ;
434434 } ) ;
435+
436+ it ( "should show free user popup when entitlements are expired (no trial)" , async function ( ) {
437+ console . log ( "llgT: Starting expired entitlements without trial test" ) ;
438+
439+ // Setup: Expired pro subscription + no trial
440+ setupProUserMock ( true , true ) ;
441+ await cleanupTrialState ( ) ; // Ensure no trial is active
442+
443+ // Verify initial state (no pro branding due to expired entitlements)
444+ await verifyProBranding ( false , "no pro branding initially due to expired entitlements" ) ;
445+
446+ // Perform login
447+ await performFullLoginFlow ( ) ;
448+
449+ // Verify pro branding remains false after login (expired entitlements filtered to free)
450+ await verifyProBranding ( false , "no pro branding after login with expired entitlements" ) ;
451+
452+ // Check profile popup shows free plan status
453+ const $profileButton = testWindow . $ ( "#user-profile-button" ) ;
454+ $profileButton . trigger ( 'click' ) ;
455+ await popupToAppear ( PROFILE_POPUP ) ;
456+ await verifyProfilePopupContent ( VIEW_PHOENIX_FREE ,
457+ "free plan user profile popup for user with expired entitlements" ) ;
458+
459+ // Close popup
460+ $profileButton . trigger ( 'click' ) ;
461+
462+ // Perform logout
463+ await performFullLogoutFlow ( ) ;
464+
465+ // Verify pro branding remains false after logout
466+ await verifyProBranding ( false , "no pro branding after logout with expired entitlements" ) ;
467+
468+ // Check profile popup (signed out state)
469+ $profileButton . trigger ( 'click' ) ;
470+ await popupToAppear ( SIGNIN_POPUP ) ;
471+ // Not logged in user with no trial - no special branding expected
472+ expect ( testWindow . $ ( `.profile-popup .trial-plan-info` ) . length ) . toBe ( 0 ) ;
473+
474+ // Close popup
475+ $profileButton . trigger ( 'click' ) ;
476+ } ) ;
477+
478+ it ( "should show trial user popup when entitlements are expired (active trial)" , async function ( ) {
479+ console . log ( "llgT: Starting expired entitlements with active trial test" ) ;
480+
481+ // Setup: Expired pro subscription + active trial (10 days)
482+ setupProUserMock ( true , true ) ;
483+ await setupTrialState ( 10 ) ;
484+
485+ // Verify initial state shows pro branding due to trial (overrides expired entitlements)
486+ await verifyProBranding ( true , "pro branding initially due to active trial" ) ;
487+
488+ // Perform login
489+ await performFullLoginFlow ( ) ;
490+
491+ // Verify pro branding remains after login (trial overrides expired server entitlements)
492+ await verifyProBranding ( true , "pro branding after login - trial overrides expired entitlements" ) ;
493+
494+ // Check profile popup shows trial status (not expired server entitlements)
495+ const $profileButton = testWindow . $ ( "#user-profile-button" ) ;
496+ $profileButton . trigger ( 'click' ) ;
497+ await popupToAppear ( PROFILE_POPUP ) ;
498+ await verifyProfilePopupContent ( VIEW_TRIAL_DAYS_LEFT ,
499+ "trial user profile popup - trial overrides expired server entitlements" ) ;
500+
501+ // Close popup
502+ $profileButton . trigger ( 'click' ) ;
503+
504+ // Perform logout
505+ await performFullLogoutFlow ( ) ;
506+
507+ // Verify pro branding remains after logout (trial continues)
508+ await verifyProBranding ( true , "pro branding after logout - trial still active" ) ;
509+
510+ // Check profile popup still shows trial status
511+ $profileButton . trigger ( 'click' ) ;
512+ await popupToAppear ( SIGNIN_POPUP ) ;
513+ await verifyProfilePopupContent ( VIEW_TRIAL_DAYS_LEFT ,
514+ "trial user profile popup for logged out user" ) ;
515+
516+ // Close popup
517+ $profileButton . trigger ( 'click' ) ;
518+ } ) ;
435519 }
436520
437521 exports . setup = setup ;
0 commit comments