Skip to content

Commit 12f7d78

Browse files
committed
test: integ tests for KernalModeTrust.Entitlements APIs
1 parent f97f27f commit 12f7d78

File tree

1 file changed

+62
-1
lines changed

1 file changed

+62
-1
lines changed

test/spec/login-shared.js

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,19 +484,32 @@ define(function (require, exports, module) {
484484
it("should show free branding for user without pro subscription (expired trial)", async function () {
485485
console.log("llgT: Starting desktop trial user test");
486486

487-
// Setup: No pro subscription + active trial (15 days)
487+
// Setup: No pro subscription + expired trial
488488
setupProUserMock(false);
489489
await setupExpiredTrial();
490490

491491
// Verify initial state (no pro branding)
492492
await verifyProBranding(false, "no pro branding to start with");
493493

494+
// Verify entitlements API consistency for logged out user with expired trial
495+
await verifyPlanEntitlements({ paidSubscriber: false, name: testWindow.Strings.USER_FREE_PLAN_NAME },
496+
"free plan for logged out user with expired trial");
497+
await verifyIsInProTrialEntitlement(false, "no trial for user with expired trial");
498+
await verifyTrialRemainingDaysEntitlement(0, "no trial days remaining for expired trial");
499+
await verifyLiveEditEntitlement({ activated: false }, "live edit deactivated for expired trial");
500+
494501
// Perform login
495502
await performFullLoginFlow();
496503

497504
// Verify pro branding remains after login
498505
await verifyProBranding(false, "after trial free user login");
499506

507+
// Verify entitlements API consistency for logged in free user
508+
await verifyPlanEntitlements({ paidSubscriber: false, name: testWindow.Strings.USER_FREE_PLAN_NAME },
509+
"free plan for logged in user with expired trial");
510+
await verifyIsInProTrialEntitlement(false, "still no trial after login");
511+
await verifyLiveEditEntitlement({ activated: false }, "live edit still deactivated after login");
512+
500513
// Check profile popup shows free plan status
501514
const $profileButton = testWindow.$("#user-profile-button");
502515
$profileButton.trigger('click');
@@ -513,6 +526,10 @@ define(function (require, exports, module) {
513526
// Verify pro branding remains after logout (trial continues)
514527
await verifyProBranding(false, "Trial branding to remain after logout");
515528

529+
// Verify entitlements API consistency after logout
530+
await verifyRawEntitlements(null, "no raw entitlements when logged out");
531+
await verifyIsInProTrialEntitlement(false, "no trial after logout");
532+
516533
// Check profile popup still shows free plan status as trial expired
517534
$profileButton.trigger('click');
518535
await popupToAppear(SIGNIN_POPUP);
@@ -533,12 +550,31 @@ define(function (require, exports, module) {
533550
// Verify initial state (no pro branding due to expired entitlements)
534551
await verifyProBranding(false, "no pro branding initially due to expired entitlements");
535552

553+
// Verify entitlements API consistency for logged out user with no trial
554+
await verifyPlanEntitlements({ paidSubscriber: false, name: testWindow.Strings.USER_FREE_PLAN_NAME },
555+
"free plan for logged out user with no trial");
556+
await verifyIsInProTrialEntitlement(false, "no trial for logged out user");
557+
await verifyTrialRemainingDaysEntitlement(0, "no trial days remaining");
558+
await verifyRawEntitlements(null, "no raw entitlements when logged out");
559+
await verifyLiveEditEntitlement({ activated: false }, "live edit deactivated with no trial");
560+
536561
// Perform login
537562
await performFullLoginFlow();
538563

539564
// Verify pro branding remains false after login (expired entitlements filtered to free)
540565
await verifyProBranding(false, "no pro branding after login with expired entitlements");
541566

567+
// Verify entitlements API consistency for logged in user with expired entitlements
568+
await verifyPlanEntitlements({ paidSubscriber: false },
569+
"expired entitlements filtered to free plan after login");
570+
await verifyIsInProTrialEntitlement(false, "no trial for user with expired entitlements");
571+
await verifyTrialRemainingDaysEntitlement(0, "no trial days for expired entitlements user");
572+
await verifyLiveEditEntitlement({
573+
activated: false,
574+
subscribeURL: testWindow.brackets.config.purchase_url,
575+
upgradeToPlan: testWindow.brackets.config.main_pro_plan
576+
}, "live edit deactivated with fallback URLs for expired entitlements");
577+
542578
// Check profile popup shows free plan status
543579
const $profileButton = testWindow.$("#user-profile-button");
544580
$profileButton.trigger('click');
@@ -555,6 +591,10 @@ define(function (require, exports, module) {
555591
// Verify pro branding remains false after logout
556592
await verifyProBranding(false, "no pro branding after logout with expired entitlements");
557593

594+
// Verify entitlements API consistency after logout
595+
await verifyRawEntitlements(null, "no raw entitlements when logged out");
596+
await verifyIsInProTrialEntitlement(false, "no trial after logout");
597+
558598
// Check profile popup (signed out state)
559599
$profileButton.trigger('click');
560600
await popupToAppear(SIGNIN_POPUP);
@@ -575,12 +615,27 @@ define(function (require, exports, module) {
575615
// Verify initial state shows pro branding due to trial (overrides expired entitlements)
576616
await verifyProBranding(true, "pro branding initially due to active trial");
577617

618+
// Verify entitlements API consistency for logged out user with active trial
619+
await verifyPlanEntitlements({ paidSubscriber: true, name: testWindow.brackets.config.main_pro_plan },
620+
"trial plan for logged out user overrides expired entitlements");
621+
await verifyIsInProTrialEntitlement(true, "user should be in trial initially");
622+
await verifyTrialRemainingDaysEntitlement(10, "should have 10 trial days remaining");
623+
await verifyRawEntitlements(null, "no raw entitlements when logged out");
624+
await verifyLiveEditEntitlement({ activated: true }, "live edit activated via trial");
625+
578626
// Perform login
579627
await performFullLoginFlow();
580628

581629
// Verify pro branding remains after login (trial overrides expired server entitlements)
582630
await verifyProBranding(true, "pro branding after login - trial overrides expired entitlements");
583631

632+
// Verify entitlements API consistency for logged in user (trial overrides expired server entitlements)
633+
await verifyPlanEntitlements({ paidSubscriber: true },
634+
"trial overrides expired server entitlements to show paid subscriber");
635+
await verifyIsInProTrialEntitlement(true, "user should still be in trial after login");
636+
await verifyTrialRemainingDaysEntitlement(10, "trial days should remain 10 after login");
637+
await verifyLiveEditEntitlement({ activated: true }, "live edit should be activated via trial override");
638+
584639
// Check profile popup shows trial status (not expired server entitlements)
585640
const $profileButton = testWindow.$("#user-profile-button");
586641
$profileButton.trigger('click');
@@ -597,6 +652,12 @@ define(function (require, exports, module) {
597652
// Verify pro branding remains after logout (trial continues)
598653
await verifyProBranding(true, "pro branding after logout - trial still active");
599654

655+
// Verify entitlements API consistency after logout (trial persists)
656+
await verifyIsInProTrialEntitlement(true, "trial should persist after logout");
657+
await verifyTrialRemainingDaysEntitlement(10, "trial days should persist after logout");
658+
await verifyRawEntitlements(null, "no raw entitlements when logged out");
659+
await verifyLiveEditEntitlement({ activated: true }, "live edit still activated via trial after logout");
660+
600661
// Check profile popup still shows trial status
601662
$profileButton.trigger('click');
602663
await popupToAppear(SIGNIN_POPUP);

0 commit comments

Comments
 (0)