2023-03-01 04:32:55 -05:00
|
|
|
|
import { expect } from 'chai'
|
|
|
|
|
import { screen, within } from '@testing-library/react'
|
|
|
|
|
import SuccessfulSubscription from '../../../../../../frontend/js/features/subscription/components/successful-subscription/successful-subscription'
|
|
|
|
|
import { renderWithSubscriptionDashContext } from '../../helpers/render-with-subscription-dash-context'
|
|
|
|
|
import { annualActiveSubscription } from '../../fixtures/subscriptions'
|
|
|
|
|
|
|
|
|
|
describe('successful subscription page', function () {
|
|
|
|
|
it('renders the invoices link', function () {
|
|
|
|
|
const adminEmail = 'foo@example.com'
|
|
|
|
|
const options = {
|
|
|
|
|
metaTags: [
|
|
|
|
|
{
|
|
|
|
|
name: 'ol-ExposedSettings',
|
|
|
|
|
value: {
|
|
|
|
|
adminEmail,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{ name: 'ol-subscription', value: annualActiveSubscription },
|
|
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
renderWithSubscriptionDashContext(<SuccessfulSubscription />, options)
|
|
|
|
|
|
|
|
|
|
screen.getByRole('heading', { name: /thanks for subscribing/i })
|
|
|
|
|
const alert = screen.getByRole('alert')
|
|
|
|
|
within(alert).getByText(/to modify your subscription go to/i)
|
|
|
|
|
const manageSubscriptionLink = within(alert).getByRole('link', {
|
|
|
|
|
name: /manage subscription/i,
|
|
|
|
|
})
|
|
|
|
|
expect(manageSubscriptionLink.getAttribute('href')).to.equal(
|
|
|
|
|
'/user/subscription'
|
|
|
|
|
)
|
|
|
|
|
screen.getByText(
|
|
|
|
|
`Thank you for subscribing to the ${annualActiveSubscription.plan.name} plan.`,
|
|
|
|
|
{ exact: false }
|
|
|
|
|
)
|
|
|
|
|
screen.getByText(
|
|
|
|
|
/it’s support from people like yourself that allows .* to continue to grow and improve/i
|
|
|
|
|
)
|
|
|
|
|
expect(screen.getByText(/get the most out of your/i).textContent).to.match(
|
2023-11-20 05:24:16 -05:00
|
|
|
|
/get the most out of your .* subscription by checking out .*’s features/i
|
2023-03-01 04:32:55 -05:00
|
|
|
|
)
|
|
|
|
|
expect(
|
|
|
|
|
screen
|
|
|
|
|
.getByText(/if there is anything you ever/i)
|
|
|
|
|
.textContent?.replace(/\xA0/g, ' ')
|
|
|
|
|
).to.equal(
|
|
|
|
|
`If there is anything you ever need please feel free to contact us directly at ${adminEmail}.`
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const contactLink = screen.getByRole('link', {
|
|
|
|
|
name: adminEmail,
|
|
|
|
|
})
|
|
|
|
|
expect(contactLink.getAttribute('href')).to.equal(`mailto:${adminEmail}`)
|
|
|
|
|
|
|
|
|
|
expect(
|
|
|
|
|
screen.getByText(/if you would like to help us improve/i).textContent
|
|
|
|
|
).to.match(
|
|
|
|
|
/if you would like to help us improve .*, please take a moment to fill out this survey/i
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const surveyLink = screen.getByRole('link', {
|
|
|
|
|
name: /this survey/i,
|
|
|
|
|
})
|
|
|
|
|
expect(surveyLink.getAttribute('href')).to.equal(
|
|
|
|
|
'https://forms.gle/CdLNX9m6NLxkv1yr5'
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const helpLink = screen.getByRole('link', {
|
2023-11-20 05:24:16 -05:00
|
|
|
|
name: /.*’s features/i,
|
2023-03-01 04:32:55 -05:00
|
|
|
|
})
|
2023-11-20 05:24:16 -05:00
|
|
|
|
expect(helpLink.getAttribute('href')).to.equal('/about/features-overview')
|
2023-03-01 04:32:55 -05:00
|
|
|
|
|
|
|
|
|
const backToYourProjectsLink = screen.getByRole('link', {
|
|
|
|
|
name: /back to your projects/i,
|
|
|
|
|
})
|
|
|
|
|
expect(backToYourProjectsLink.getAttribute('href')).to.equal('/project')
|
|
|
|
|
})
|
|
|
|
|
})
|