@@ -339,6 +339,116 @@ testAgainstRunningApps({ withEnv: [appConfigs.envs.withBilling] })('pricing tabl
339339 . locator ( 'xpath=..' )
340340 . getByText ( 'Upcoming' ) ,
341341 ) . toBeVisible ( ) ;
342+
343+ await u . po . page . goToRelative ( '/pricing-table' ) ;
344+ await u . po . pricingTable . waitForMounted ( ) ;
345+
346+ // Start checkout for a trial plan (assuming 'pro' has trial enabled in test env)
347+ await u . po . pricingTable . startCheckout ( { planSlug : 'trial' } ) ;
348+ await u . po . checkout . waitForMounted ( ) ;
349+
350+ // Verify checkout shows trial details
351+ await expect ( u . po . checkout . root . getByText ( 'Checkout' ) ) . toBeVisible ( ) ;
352+ await expect ( u . po . checkout . root . getByText ( 'Free trial' ) ) . toBeHidden ( ) ;
353+ await expect ( u . po . checkout . root . getByText ( 'Total Due after' ) ) . toBeHidden ( ) ;
354+ await expect ( u . po . checkout . root . getByText ( 'Total Due Today' ) ) . toBeVisible ( ) ;
355+
356+ await u . po . checkout . root . getByRole ( 'button' , { name : / ^ p a y \s \$ / i } ) . waitFor ( { state : 'visible' } ) ;
357+ await u . po . checkout . clickPayOrSubscribe ( ) ;
358+ await expect ( u . po . page . getByText ( 'Payment was successful!' ) ) . toBeVisible ( ) ;
359+ await u . po . checkout . confirmAndContinue ( ) ;
360+
361+ await u . po . page . goToRelative ( '/user' ) ;
362+ await u . po . userProfile . waitForMounted ( ) ;
363+ await u . po . userProfile . switchToBillingTab ( ) ;
364+
365+ await expect ( u . po . page . locator ( '.cl-profileSectionContent__subscriptionsList' ) . getByText ( / T r i a l / i) ) . toBeVisible ( {
366+ timeout : 5_000 ,
367+ } ) ;
368+
369+ await expect (
370+ u . po . page
371+ . locator ( '.cl-profileSectionContent__subscriptionsList' )
372+ . getByText ( / T r i a l / i)
373+ . locator ( 'xpath=..' )
374+ . getByText ( / F r e e t r i a l / i) ,
375+ ) . toBeHidden ( ) ;
376+
377+ // Verify the Free plan with Upcoming status exists
378+ await expect (
379+ u . po . page
380+ . locator ( '.cl-profileSectionContent__subscriptionsList' )
381+ . getByText ( 'Free' )
382+ . locator ( 'xpath=..' )
383+ . getByText ( 'Upcoming' ) ,
384+ ) . toBeHidden ( ) ;
385+ } finally {
386+ // Clean up the trial user
387+ await trialUser . deleteIfExists ( ) ;
388+ }
389+ } ) ;
390+
391+ test ( 'subscribing to other paid plans while on free trial is immediate cancellation' , async ( { page, context } ) => {
392+ const u = createTestUtils ( { app, page, context } ) ;
393+
394+ // Create a new user specifically for this trial test
395+ const trialUser = u . services . users . createFakeUser ( ) ;
396+ await u . services . users . createBapiUser ( trialUser ) ;
397+
398+ try {
399+ // Sign in the new user
400+ await u . po . signIn . goTo ( ) ;
401+ await u . po . signIn . signInWithEmailAndInstantPassword ( {
402+ email : trialUser . email ,
403+ password : trialUser . password ,
404+ } ) ;
405+
406+ // Navigate to pricing table
407+ await u . po . page . goToRelative ( '/pricing-table' ) ;
408+ await u . po . pricingTable . waitForMounted ( ) ;
409+
410+ // Verify trial plan is displayed with trial CTA
411+ // Note: This assumes there's a plan with trial enabled in the test environment
412+ // The button text should show "Start [X]-day free trial" for trial-enabled plans
413+ await expect ( u . po . page . getByText ( / S t a r t \d + - d a y f r e e t r i a l / i) ) . toBeVisible ( ) ;
414+
415+ // Start checkout for a trial plan (assuming 'pro' has trial enabled in test env)
416+ await u . po . pricingTable . startCheckout ( { planSlug : 'trial' } ) ;
417+ await u . po . checkout . waitForMounted ( ) ;
418+ await u . po . checkout . fillTestCard ( ) ;
419+ await u . po . checkout . clickPayOrSubscribe ( ) ;
420+ await u . po . checkout . confirmAndContinue ( ) ;
421+
422+ await u . po . page . goToRelative ( '/user' ) ;
423+ await u . po . userProfile . waitForMounted ( ) ;
424+ await u . po . userProfile . switchToBillingTab ( ) ;
425+
426+ await expect (
427+ u . po . page
428+ . locator ( '.cl-profileSectionContent__subscriptionsList' )
429+ . getByText ( / T r i a l / i)
430+ . locator ( 'xpath=..' )
431+ . getByText ( / F r e e t r i a l / i) ,
432+ ) . toBeVisible ( ) ;
433+
434+ await expect ( u . po . page . getByText ( / T r i a l e n d s / i) ) . toBeVisible ( ) ;
435+
436+ await u . po . page . goToRelative ( '/pricing-table' ) ;
437+ await u . po . pricingTable . waitForMounted ( ) ;
438+ // Start checkout for a trial plan (assuming 'pro' has trial enabled in test env)
439+ await u . po . pricingTable . startCheckout ( { planSlug : 'pro' } ) ;
440+ await u . po . checkout . waitForMounted ( ) ;
441+ await u . po . checkout . root . getByRole ( 'button' , { name : / ^ p a y \s \$ / i } ) . waitFor ( { state : 'visible' } ) ;
442+ await u . po . checkout . clickPayOrSubscribe ( ) ;
443+
444+ await u . po . page . goToRelative ( '/user' ) ;
445+ await u . po . userProfile . waitForMounted ( ) ;
446+ await u . po . userProfile . switchToBillingTab ( ) ;
447+
448+ await expect ( u . po . page . locator ( '.cl-profileSectionContent__subscriptionsList' ) . getByText ( / P r o / i) ) . toBeVisible ( {
449+ timeout : 5_000 ,
450+ } ) ;
451+ await expect ( u . po . page . locator ( '.cl-profileSectionContent__subscriptionsList' ) . getByText ( / T r i a l / i) ) . toBeHidden ( ) ;
342452 } finally {
343453 // Clean up the trial user
344454 await trialUser . deleteIfExists ( ) ;
0 commit comments