|
|
@@ -30,13 +30,17 @@ describe('<ChangePlan />', function () {
|
|
|
expect(container.firstChild).to.be.null
|
|
|
})
|
|
|
|
|
|
- it('renders the individual plans table', function () {
|
|
|
+ it('renders the individual plans table and group plans UI', async function () {
|
|
|
renderWithSubscriptionDashContext(
|
|
|
<ActiveSubscription subscription={annualActiveSubscription} />,
|
|
|
{
|
|
|
metaTags: [
|
|
|
{ name: 'ol-subscription', value: annualActiveSubscription },
|
|
|
plansMetaTag,
|
|
|
+ {
|
|
|
+ name: 'ol-recommendedCurrency',
|
|
|
+ value: 'USD',
|
|
|
+ },
|
|
|
],
|
|
|
}
|
|
|
)
|
|
|
@@ -44,6 +48,8 @@ describe('<ChangePlan />', function () {
|
|
|
const button = screen.getByRole('button', { name: 'Change plan' })
|
|
|
fireEvent.click(button)
|
|
|
|
|
|
+ await screen.findByText('Looking for multiple licenses?')
|
|
|
+
|
|
|
const changeToPlanButtons = screen.queryAllByRole('button', {
|
|
|
name: 'Change to this plan',
|
|
|
})
|
|
|
@@ -51,30 +57,17 @@ describe('<ChangePlan />', function () {
|
|
|
screen.getByText('Your plan')
|
|
|
|
|
|
const annualPlans = plans.filter(plan => plan.annual)
|
|
|
- expect(screen.getAllByText('/ year').length).to.equal(annualPlans.length)
|
|
|
- expect(screen.getAllByText('/ month').length).to.equal(
|
|
|
- plans.length - annualPlans.length
|
|
|
+ expect(screen.getAllByText('/ year', { exact: false }).length).to.equal(
|
|
|
+ annualPlans.length
|
|
|
)
|
|
|
- })
|
|
|
-
|
|
|
- it('renders the change to group plan UI', function () {
|
|
|
- renderWithSubscriptionDashContext(
|
|
|
- <ActiveSubscription subscription={annualActiveSubscription} />,
|
|
|
- {
|
|
|
- metaTags: [
|
|
|
- { name: 'ol-subscription', value: annualActiveSubscription },
|
|
|
- plansMetaTag,
|
|
|
- ],
|
|
|
- }
|
|
|
+ expect(screen.getAllByText('/ month', { exact: false }).length).to.equal(
|
|
|
+ plans.length - annualPlans.length
|
|
|
)
|
|
|
|
|
|
- const button = screen.getByRole('button', { name: 'Change plan' })
|
|
|
- fireEvent.click(button)
|
|
|
-
|
|
|
- screen.getByText('Looking for multiple licenses?')
|
|
|
+ expect(screen.queryByText('loading', { exact: false })).to.be.null
|
|
|
})
|
|
|
|
|
|
- it('renders "Your new plan" and "Keep current plan" when there is a pending plan change', function () {
|
|
|
+ it('renders "Your new plan" and "Keep current plan" when there is a pending plan change', async function () {
|
|
|
renderWithSubscriptionDashContext(
|
|
|
<ActiveSubscription subscription={pendingSubscriptionChange} />,
|
|
|
{
|
|
|
@@ -88,7 +81,7 @@ describe('<ChangePlan />', function () {
|
|
|
const button = screen.getByRole('button', { name: 'Change plan' })
|
|
|
fireEvent.click(button)
|
|
|
|
|
|
- screen.getByText('Your new plan')
|
|
|
+ await screen.findByText('Your new plan')
|
|
|
screen.getByRole('button', { name: 'Keep my current plan' })
|
|
|
})
|
|
|
|
|
|
@@ -104,4 +97,21 @@ describe('<ChangePlan />', function () {
|
|
|
)
|
|
|
expect(container).not.to.be.null
|
|
|
})
|
|
|
+
|
|
|
+ it('shows a loading message while still querying Recurly for prices', function () {
|
|
|
+ renderWithSubscriptionDashContext(
|
|
|
+ <ActiveSubscription subscription={pendingSubscriptionChange} />,
|
|
|
+ {
|
|
|
+ metaTags: [
|
|
|
+ { name: 'ol-subscription', value: pendingSubscriptionChange },
|
|
|
+ plansMetaTag,
|
|
|
+ ],
|
|
|
+ }
|
|
|
+ )
|
|
|
+
|
|
|
+ const button = screen.getByRole('button', { name: 'Change plan' })
|
|
|
+ fireEvent.click(button)
|
|
|
+
|
|
|
+ screen.findByText('Loading', { exact: false })
|
|
|
+ })
|
|
|
})
|