diff --git a/jam-ui/cypress/e2e/account/account-subscription-page.cy.js b/jam-ui/cypress/e2e/account/account-subscription-page.cy.js index f9490f6a0..99ed6544f 100644 --- a/jam-ui/cypress/e2e/account/account-subscription-page.cy.js +++ b/jam-ui/cypress/e2e/account/account-subscription-page.cy.js @@ -82,13 +82,33 @@ describe('User subscribe to a plan', () => { remaining_monthly_play_time: null } } - }); + }).as('getSubscription'); + + cy.intercept('GET', /\S+\/get_subscription/, { + statusCode: 200, + body: { + past_due: false, + has_billing_info: true, + plan_code: '', + desired_plan_code: '', + admin_overide_plan_code: null, + admin_overide_ends_at: null, + in_trial: false, + trial_ends_at: null, + subscription: { + + }, + subscription_rules: { + remaining_monthly_play_time: null + } + } + }).as('getSubscriptionWithNoPlan'); }); it('should display the current plan', () => { cy.visit('/account/subscription'); - + cy.wait('@getSubscription') // Assert that the current plan is displayed cy.get('[data-testid=changeSubscriptionForm]').within($form => { cy.get('label').contains('Subscription Plan'); @@ -105,9 +125,28 @@ describe('User subscribe to a plan', () => { }); }); + it.only('should display the current plan when no plan', () => { + cy.visit('/account/subscription'); + cy.wait('@getSubscriptionWithNoPlan') + // Assert that the current plan is displayed + cy.get('[data-testid=changeSubscriptionForm]').within($form => { + cy.get('label').contains('Subscription Plan'); + cy.get('.select-plan__single-value').should('contain', 'Free ($0.00/month)'); + cy.get('input[type=submit]').should('have.value', 'Save Plan').should('be.disabled'); + }); + + cy.get('[data-testid=playtime]').within($playtime => { + cy.get('label').contains('You have unlimited play time'); + }); + + cy.get('[data-testid=subscription-explanation]').within($expl => { + cy.get('.alert').contains('You are currently on the Free (monthly) plan.'); + }); + }); + it('change plan', () => { cy.visit('/account/subscription'); - + cy.wait('@getSubscription') cy.get('[data-testid=changeSubscriptionForm]').within($form => { cy.get('.select-plan__control').click(); cy.get('.select-plan__option').contains('Platinum ($19.99/month)').click();