Skip to content

Commit c74ac2c

Browse files
committed
refactor: login desktop and browser tests common code
1 parent f246133 commit c74ac2c

File tree

3 files changed

+158
-315
lines changed

3 files changed

+158
-315
lines changed

test/spec/login-browser-integ-test.js

Lines changed: 0 additions & 157 deletions
Original file line numberDiff line numberDiff line change
@@ -291,163 +291,6 @@ define(function (require, exports, module) {
291291
});
292292

293293
LoginShared.setupSharedTests();
294-
295-
it("should show pro branding for user with pro subscription (expired trial)", async function () {
296-
console.log("llgT: Starting browser pro user with expired trial test");
297-
298-
// Setup: Pro subscription + expired trial
299-
setupProUserMock(true);
300-
await setupExpiredTrial();
301-
302-
// Verify initial state (no pro branding)
303-
await verifyProBranding(false, "no pro branding to start with");
304-
305-
// Perform login
306-
await performFullLoginFlow();
307-
await verifyProBranding(true, "pro branding to appear after pro user login");
308-
309-
// Check profile popup shows pro status (not trial)
310-
const $profileButton = testWindow.$("#user-profile-button");
311-
$profileButton.trigger('click');
312-
313-
// Wait for profile popup to show "phoenix pro <leaf>"
314-
await verifyProfilePopupContent(VIEW_PHOENIX_PRO, "pro user profile popup");
315-
316-
// Close popup
317-
$profileButton.trigger('click');
318-
319-
// Perform logout
320-
await performFullLogoutFlow();
321-
322-
// For user with pro subscription + expired trial:
323-
// After logout, pro branding should disappear because:
324-
// 1. No server entitlements (logged out)
325-
// 2. Trial is expired (0 days remaining)
326-
await verifyProBranding(false, "Pro branding to disappear after logout");
327-
});
328-
329-
it("should show trial branding for user without pro subscription (active trial)", async function () {
330-
console.log("llgT: Starting browser trial user test");
331-
332-
// Setup: No pro subscription + active trial (15 days)
333-
setupProUserMock(false);
334-
await setupTrialState(15);
335-
336-
// Verify initial state shows pro branding due to trial
337-
await verifyProBranding(true, "Trial branding to appear initially");
338-
339-
// Perform login
340-
await performFullLoginFlow();
341-
342-
// Verify pro branding remains after login
343-
await verifyProBranding(true, "after trial user login");
344-
345-
// Check profile popup shows trial status
346-
const $profileButton = testWindow.$("#user-profile-button");
347-
$profileButton.trigger('click');
348-
await popupToAppear(PROFILE_POPUP);
349-
await verifyProfilePopupContent(VIEW_TRIAL_DAYS_LEFT,
350-
"trial user profile popup for logged in user");
351-
352-
// Close popup
353-
$profileButton.trigger('click');
354-
355-
// Perform logout
356-
await performFullLogoutFlow();
357-
358-
// Verify pro branding remains after logout (trial continues)
359-
await verifyProBranding(true, "Trial branding to remain after logout");
360-
361-
// Check profile popup still shows trial status
362-
$profileButton.trigger('click');
363-
await popupToAppear(SIGNIN_POPUP);
364-
await verifyProfilePopupContent(VIEW_TRIAL_DAYS_LEFT,
365-
"trial user profile popup for logged out user");
366-
367-
// Close popup
368-
$profileButton.trigger('click');
369-
});
370-
371-
it("should prioritize pro subscription over trial in profile popup", async function () {
372-
console.log("llgT: Starting browser trial user with pro subscription test");
373-
374-
// Setup: Pro subscription + active trial
375-
setupProUserMock(true);
376-
await setupTrialState(10);
377-
378-
// Perform login
379-
await performFullLoginFlow();
380-
381-
// Verify pro branding appears
382-
await verifyProBranding(true, "Pro branding to appear for pro user");
383-
384-
// Check profile popup shows pro status (not trial text)
385-
const $profileButton = testWindow.$("#user-profile-button");
386-
$profileButton.trigger('click');
387-
await popupToAppear(PROFILE_POPUP);
388-
389-
// Should show pro, not trial, since user has paid subscription
390-
await verifyProfilePopupContent(VIEW_PHOENIX_PRO,
391-
"pro+trial user profile should not show trial branding");
392-
393-
// Close popup
394-
$profileButton.trigger('click');
395-
396-
// Perform logout
397-
await performFullLogoutFlow();
398-
399-
// Verify pro branding remains due to trial (even though subscription is gone)
400-
await verifyProBranding(true, "Pro branding should remain after logout as trial user");
401-
$profileButton.trigger('click');
402-
await popupToAppear(SIGNIN_POPUP);
403-
await verifyProfilePopupContent(VIEW_TRIAL_DAYS_LEFT,
404-
"trial user profile popup for logged out user");
405-
406-
// Close popup
407-
$profileButton.trigger('click');
408-
});
409-
410-
it("should show free branding for user without pro subscription (expired trial)", async function () {
411-
console.log("llgT: Starting desktop trial user test");
412-
413-
// Setup: No pro subscription + active trial (15 days)
414-
setupProUserMock(false);
415-
await setupExpiredTrial();
416-
417-
// Verify initial state (no pro branding)
418-
await verifyProBranding(false, "no pro branding to start with");
419-
420-
// Perform login
421-
await performFullLoginFlow();
422-
423-
// Verify pro branding remains after login
424-
await verifyProBranding(false, "after trial free user login");
425-
426-
// Check profile popup shows free plan status
427-
const $profileButton = testWindow.$("#user-profile-button");
428-
$profileButton.trigger('click');
429-
await popupToAppear(PROFILE_POPUP);
430-
await verifyProfilePopupContent(VIEW_PHOENIX_FREE,
431-
"free plan user profile popup for logged in user");
432-
433-
// Close popup
434-
$profileButton.trigger('click');
435-
436-
// Perform logout
437-
await performFullLogoutFlow();
438-
439-
// Verify pro branding remains after logout (trial continues)
440-
await verifyProBranding(false, "Trial branding to remain after logout");
441-
442-
// Check profile popup still shows free plan status as trial expired
443-
$profileButton.trigger('click');
444-
await popupToAppear(SIGNIN_POPUP);
445-
// not logged in user, we wont show free plan tag as base editor is always free.
446-
expect(testWindow.$(`.profile-popup .trial-plan-info`).length).toBe(0);
447-
448-
// Close popup
449-
$profileButton.trigger('click');
450-
});
451294
});
452295
});
453296
});

test/spec/login-desktop-integ-test.js

Lines changed: 1 addition & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,6 @@ define(function (require, exports, module) {
306306
await cleanupTrialState();
307307
});
308308

309-
LoginShared.setupSharedTests();
310-
311309
it("should open browser and copy validation code", async function () {
312310
// Setup basic user mock
313311
setupProUserMock(false);
@@ -352,162 +350,7 @@ define(function (require, exports, module) {
352350
expect(capturedBrowserURL).toContain('test-session-123');
353351
});
354352

355-
it("should show pro branding for user with pro subscription (expired trial)", async function () {
356-
console.log("llgT: Starting desktop pro user with expired trial test");
357-
358-
// Setup: Pro subscription + expired trial
359-
setupProUserMock(true);
360-
await setupExpiredTrial();
361-
362-
// Verify initial state (no pro branding)
363-
await verifyProBranding(false, "no pro branding to start with");
364-
365-
// Perform login
366-
await performFullLoginFlow();
367-
await verifyProBranding(true, "pro branding to appear after pro user login");
368-
369-
// Check profile popup shows pro status (not trial)
370-
const $profileButton = testWindow.$("#user-profile-button");
371-
$profileButton.trigger('click');
372-
373-
// Wait for profile popup to show "phoenix pro <leaf>"
374-
await verifyProfilePopupContent(VIEW_PHOENIX_PRO, "pro user profile popup");
375-
376-
// Close popup
377-
$profileButton.trigger('click');
378-
379-
// Perform logout
380-
await performFullLogoutFlow();
381-
382-
// For user with pro subscription + expired trial:
383-
// After logout, pro branding should disappear because:
384-
// 1. No server entitlements (logged out)
385-
// 2. Trial is expired (0 days remaining)
386-
await verifyProBranding(false, "Pro branding to disappear after logout");
387-
});
388-
389-
it("should show trial branding for user without pro subscription (active trial)", async function () {
390-
console.log("llgT: Starting desktop trial user test");
391-
392-
// Setup: No pro subscription + active trial (15 days)
393-
setupProUserMock(false);
394-
await setupTrialState(15);
395-
396-
// Verify initial state shows pro branding due to trial
397-
await verifyProBranding(true, "Trial branding to appear initially");
398-
399-
// Perform login
400-
await performFullLoginFlow();
401-
402-
// Verify pro branding remains after login
403-
await verifyProBranding(true, "after trial user login");
404-
405-
// Check profile popup shows trial status
406-
const $profileButton = testWindow.$("#user-profile-button");
407-
$profileButton.trigger('click');
408-
await popupToAppear(PROFILE_POPUP);
409-
await verifyProfilePopupContent(VIEW_TRIAL_DAYS_LEFT,
410-
"trial user profile popup for logged in user");
411-
412-
// Close popup
413-
$profileButton.trigger('click');
414-
415-
// Perform logout
416-
await performFullLogoutFlow();
417-
418-
// Verify pro branding remains after logout (trial continues)
419-
await verifyProBranding(true, "Trial branding to remain after logout");
420-
421-
// Check profile popup still shows trial status
422-
$profileButton.trigger('click');
423-
await popupToAppear(SIGNIN_POPUP);
424-
await verifyProfilePopupContent(VIEW_TRIAL_DAYS_LEFT,
425-
"trial user profile popup for logged out user");
426-
427-
// Close popup
428-
$profileButton.trigger('click');
429-
});
430-
431-
it("should prioritize pro subscription over trial in profile popup", async function () {
432-
console.log("llgT: Starting desktop trial user with pro subscription test");
433-
434-
// Setup: Pro subscription + active trial
435-
setupProUserMock(true);
436-
await setupTrialState(10);
437-
438-
// Perform login
439-
await performFullLoginFlow();
440-
441-
// Verify pro branding appears
442-
await verifyProBranding(true, "Pro branding to appear for pro user");
443-
444-
// Check profile popup shows pro status (not trial text)
445-
const $profileButton = testWindow.$("#user-profile-button");
446-
$profileButton.trigger('click');
447-
await popupToAppear(PROFILE_POPUP);
448-
449-
// Should show pro, not trial, since user has paid subscription
450-
await verifyProfilePopupContent(VIEW_PHOENIX_PRO,
451-
"pro+trial user profile should not show trial branding");
452-
453-
// Close popup
454-
$profileButton.trigger('click');
455-
456-
// Perform logout
457-
await performFullLogoutFlow();
458-
459-
// Verify pro branding remains due to trial (even though subscription is gone)
460-
await verifyProBranding(true, "Pro branding should remain after logout as trial user");
461-
$profileButton.trigger('click');
462-
await popupToAppear(SIGNIN_POPUP);
463-
await verifyProfilePopupContent(VIEW_TRIAL_DAYS_LEFT,
464-
"trial user profile popup for logged out user");
465-
466-
// Close popup
467-
$profileButton.trigger('click');
468-
});
469-
470-
it("should show free branding for user without pro subscription (expired trial)", async function () {
471-
console.log("llgT: Starting desktop trial user test");
472-
473-
// Setup: No pro subscription + active trial (15 days)
474-
setupProUserMock(false);
475-
await setupExpiredTrial();
476-
477-
// Verify initial state (no pro branding)
478-
await verifyProBranding(false, "no pro branding to start with");
479-
480-
// Perform login
481-
await performFullLoginFlow();
482-
483-
// Verify pro branding remains after login
484-
await verifyProBranding(false, "after trial free user login");
485-
486-
// Check profile popup shows free plan status
487-
const $profileButton = testWindow.$("#user-profile-button");
488-
$profileButton.trigger('click');
489-
await popupToAppear(PROFILE_POPUP);
490-
await verifyProfilePopupContent(VIEW_PHOENIX_FREE,
491-
"free plan user profile popup for logged in user");
492-
493-
// Close popup
494-
$profileButton.trigger('click');
495-
496-
// Perform logout
497-
await performFullLogoutFlow();
498-
499-
// Verify pro branding remains after logout (trial continues)
500-
await verifyProBranding(false, "Trial branding to remain after logout");
501-
502-
// Check profile popup still shows free plan status as trial expired
503-
$profileButton.trigger('click');
504-
await popupToAppear(SIGNIN_POPUP);
505-
// not logged in user, we wont show free plan tag as base editor is always free.
506-
expect(testWindow.$(`.profile-popup .trial-plan-info`).length).toBe(0);
507-
508-
// Close popup
509-
$profileButton.trigger('click');
510-
});
353+
LoginShared.setupSharedTests();
511354
});
512355
});
513356
});

0 commit comments

Comments
 (0)