2023-01-18 09:38:51 -05:00
|
|
|
|
import { expect } from 'chai'
|
2023-02-07 10:38:20 -05:00
|
|
|
|
import { screen } from '@testing-library/react'
|
2023-01-18 09:38:35 -05:00
|
|
|
|
import SubscriptionDashboard from '../../../../../../frontend/js/features/subscription/components/dashboard/subscription-dashboard'
|
2023-02-07 10:38:20 -05:00
|
|
|
|
import {
|
|
|
|
|
cleanUpContext,
|
|
|
|
|
renderWithSubscriptionDashContext,
|
|
|
|
|
} from '../../helpers/render-with-subscription-dash-context'
|
2023-07-21 11:35:52 -04:00
|
|
|
|
import { groupPlans, plans } from '../../fixtures/plans'
|
|
|
|
|
import { annualActiveSubscription } from '../../fixtures/subscriptions'
|
2023-01-18 09:38:35 -05:00
|
|
|
|
|
|
|
|
|
describe('<SubscriptionDashboard />', function () {
|
|
|
|
|
afterEach(function () {
|
2023-02-07 10:38:20 -05:00
|
|
|
|
cleanUpContext()
|
2023-01-18 09:38:35 -05:00
|
|
|
|
})
|
|
|
|
|
|
2023-07-21 11:35:52 -04:00
|
|
|
|
describe('With an active subscription', function () {
|
|
|
|
|
beforeEach(function () {
|
|
|
|
|
renderWithSubscriptionDashContext(<SubscriptionDashboard />, {
|
|
|
|
|
metaTags: [
|
|
|
|
|
{ name: 'ol-plans', value: plans },
|
|
|
|
|
{
|
|
|
|
|
name: 'ol-groupPlans',
|
|
|
|
|
value: groupPlans,
|
|
|
|
|
},
|
|
|
|
|
{ name: 'ol-subscription', value: annualActiveSubscription },
|
|
|
|
|
{
|
|
|
|
|
name: 'ol-recommendedCurrency',
|
|
|
|
|
value: 'USD',
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('renders the "Get the most out of your" subscription text', function () {
|
|
|
|
|
screen.getByText(
|
|
|
|
|
'Get the most out of your Overleaf subscription by checking out the list of',
|
|
|
|
|
{ exact: false }
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
2023-01-18 09:38:51 -05:00
|
|
|
|
describe('Free Plan', function () {
|
2023-02-22 07:18:01 -05:00
|
|
|
|
beforeEach(function () {
|
2023-02-07 10:38:20 -05:00
|
|
|
|
renderWithSubscriptionDashContext(<SubscriptionDashboard />)
|
2023-02-22 07:18:01 -05:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('does not render the "Get the most out of your" subscription text', function () {
|
2023-01-18 09:38:51 -05:00
|
|
|
|
const text = screen.queryByText('Get the most out of your', {
|
|
|
|
|
exact: false,
|
|
|
|
|
})
|
|
|
|
|
expect(text).to.be.null
|
|
|
|
|
})
|
2023-02-22 07:18:01 -05:00
|
|
|
|
|
|
|
|
|
it('does not render the contact support message', function () {
|
|
|
|
|
const text = screen.queryByText(
|
|
|
|
|
`You’re on an Overleaf Paid plan. Contact`,
|
|
|
|
|
{
|
|
|
|
|
exact: false,
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
expect(text).to.be.null
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe('Custom subscription', function () {
|
|
|
|
|
it('renders the contact support message', function () {
|
|
|
|
|
renderWithSubscriptionDashContext(<SubscriptionDashboard />, {
|
|
|
|
|
metaTags: [
|
|
|
|
|
{
|
|
|
|
|
name: 'ol-currentInstitutionsWithLicence',
|
|
|
|
|
value: [],
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'ol-hasSubscription',
|
|
|
|
|
value: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
screen.getByText(`You’re on an Overleaf Paid plan.`, {
|
|
|
|
|
exact: false,
|
|
|
|
|
})
|
|
|
|
|
screen.getByText(`Contact support`, {
|
|
|
|
|
exact: false,
|
|
|
|
|
})
|
|
|
|
|
})
|
2023-01-18 09:38:35 -05:00
|
|
|
|
})
|
2023-02-23 11:51:19 -05:00
|
|
|
|
|
|
|
|
|
it('Show a warning when coming from plans page', function () {
|
|
|
|
|
renderWithSubscriptionDashContext(<SubscriptionDashboard />, {
|
|
|
|
|
metaTags: [
|
|
|
|
|
{
|
|
|
|
|
name: 'ol-fromPlansPage',
|
|
|
|
|
value: true,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
screen.getByText('You already have a subscription')
|
|
|
|
|
})
|
2023-01-18 09:38:35 -05:00
|
|
|
|
})
|