Merge pull request #15798 from overleaf/mj-features-page-teardown
[web] Tear down features-page split test GitOrigin-RevId: 346064bea8775033d226f4405843717b380085fd
This commit is contained in:
committed by
Copybot
parent
9ca43ebc4e
commit
7c8014d791
+12
-34
@@ -246,12 +246,7 @@ describe('<CurrentPlanWidget />', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('features page split test', function () {
|
||||
const variants = [
|
||||
{ name: 'default', link: '/learn/how-to/Overleaf_premium_features' },
|
||||
{ name: 'new', link: '/about/features-overview' },
|
||||
]
|
||||
|
||||
describe('features page', function () {
|
||||
const plans = [
|
||||
{ type: 'free' },
|
||||
{
|
||||
@@ -281,38 +276,21 @@ describe('<CurrentPlanWidget />', function () {
|
||||
},
|
||||
]
|
||||
|
||||
for (const variant of variants) {
|
||||
describe(`${variant.name} variant`, function () {
|
||||
beforeEach(function () {
|
||||
window.metaAttributesCache.set('ol-splitTestVariants', {
|
||||
'features-page': variant.name,
|
||||
})
|
||||
})
|
||||
afterEach(function () {
|
||||
window.metaAttributesCache.delete('ol-splitTestVariants')
|
||||
for (const plan of plans) {
|
||||
it(`links to features page on ${plan.type} plan`, function () {
|
||||
window.metaAttributesCache.set('ol-usersBestSubscription', {
|
||||
...plan,
|
||||
})
|
||||
render(<CurrentPlanWidget />)
|
||||
|
||||
for (const plan of plans) {
|
||||
it(`links to ${variant.name} features page on ${plan.type} plan and sends analytics event`, function () {
|
||||
window.metaAttributesCache.set('ol-usersBestSubscription', {
|
||||
...plan,
|
||||
})
|
||||
render(<CurrentPlanWidget />)
|
||||
const links = screen.getAllByRole('link')
|
||||
expect(links[0].getAttribute('href')).to.equal(
|
||||
'/learn/how-to/Overleaf_premium_features'
|
||||
)
|
||||
|
||||
const links = screen.getAllByRole('link')
|
||||
expect(links[0].getAttribute('href')).to.equal(variant.link)
|
||||
fireEvent.click(links[0])
|
||||
|
||||
fireEvent.click(links[0])
|
||||
expect(sendMBSpy).to.be.calledOnce
|
||||
expect(sendMBSpy).calledWith('features-page-link', {
|
||||
splitTest: 'features-page',
|
||||
splitTestVariant: variant.name,
|
||||
page: '/',
|
||||
})
|
||||
|
||||
window.metaAttributesCache.delete('ol-usersBestSubscription')
|
||||
})
|
||||
}
|
||||
window.metaAttributesCache.delete('ol-usersBestSubscription')
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
-62
@@ -1,62 +0,0 @@
|
||||
import { expect } from 'chai'
|
||||
import sinon from 'sinon'
|
||||
import { fireEvent, render, screen, within } from '@testing-library/react'
|
||||
import * as eventTracking from '../../../../../../frontend/js/infrastructure/event-tracking'
|
||||
import PremiumFeaturesLink from '../../../../../../frontend/js/features/subscription/components/dashboard/premium-features-link'
|
||||
import * as useLocationModule from '../../../../../../frontend/js/shared/hooks/use-location'
|
||||
|
||||
describe('<PremiumFeaturesLink />', function () {
|
||||
const originalLocation = window.location
|
||||
|
||||
let sendMBSpy: sinon.SinonSpy
|
||||
|
||||
const variants = [
|
||||
{ name: 'default', link: '/learn/how-to/Overleaf_premium_features' },
|
||||
{ name: 'new', link: '/about/features-overview' },
|
||||
]
|
||||
|
||||
beforeEach(function () {
|
||||
window.metaAttributesCache = new Map()
|
||||
sendMBSpy = sinon.spy(eventTracking, 'sendMB')
|
||||
this.locationStub = sinon.stub(useLocationModule, 'useLocation').returns({
|
||||
assign: sinon.stub(),
|
||||
reload: sinon.stub(),
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
window.metaAttributesCache = new Map()
|
||||
sendMBSpy.restore()
|
||||
this.locationStub.restore()
|
||||
})
|
||||
|
||||
for (const variant of variants) {
|
||||
describe(`${variant.name} variant`, function () {
|
||||
beforeEach(function () {
|
||||
window.metaAttributesCache.set('ol-splitTestVariants', {
|
||||
'features-page': variant.name,
|
||||
})
|
||||
})
|
||||
afterEach(function () {
|
||||
window.metaAttributesCache.delete('ol-splitTestVariants')
|
||||
})
|
||||
|
||||
it('renders the premium features link and sends analytics event', function () {
|
||||
render(<PremiumFeaturesLink />)
|
||||
const premiumText = screen.getByText('Get the most out of your', {
|
||||
exact: false,
|
||||
})
|
||||
const link = within(premiumText).getByRole('link')
|
||||
|
||||
fireEvent.click(link)
|
||||
|
||||
expect(sendMBSpy).to.be.calledOnce
|
||||
expect(sendMBSpy).calledWith('features-page-link', {
|
||||
splitTest: 'features-page',
|
||||
splitTestVariant: variant.name,
|
||||
page: originalLocation.pathname,
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
+1
-1
@@ -33,7 +33,7 @@ describe('<SubscriptionDashboard />', function () {
|
||||
|
||||
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',
|
||||
'Get the most out of your Overleaf subscription by checking out',
|
||||
{ exact: false }
|
||||
)
|
||||
})
|
||||
|
||||
+3
-5
@@ -41,7 +41,7 @@ describe('successful subscription page', function () {
|
||||
/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(
|
||||
/get the most out of your .* subscription by checking out the list of .*’s premium features/i
|
||||
/get the most out of your .* subscription by checking out .*’s features/i
|
||||
)
|
||||
expect(
|
||||
screen
|
||||
@@ -70,11 +70,9 @@ describe('successful subscription page', function () {
|
||||
)
|
||||
|
||||
const helpLink = screen.getByRole('link', {
|
||||
name: /.*’s premium features/i,
|
||||
name: /.*’s features/i,
|
||||
})
|
||||
expect(helpLink.getAttribute('href')).to.equal(
|
||||
'/learn/how-to/Overleaf_premium_features'
|
||||
)
|
||||
expect(helpLink.getAttribute('href')).to.equal('/about/features-overview')
|
||||
|
||||
const backToYourProjectsLink = screen.getByRole('link', {
|
||||
name: /back to your projects/i,
|
||||
|
||||
Reference in New Issue
Block a user