* Update Compile timeout copy * Update Collaborator limit copy * Update Track changes copy * Update History copy and "Start free trial" button * Remove unnecessary children passed to StartFreeTrialButton * Update Dropbox copy * Update Github copy * Update Git copy * Update Reference managers copy * Update Symbol palette copy * Update Onboarding prompt copy * Update Subscriptions page (on free account) copy * `bin/run web npm run extract-translations` * Add split-test assignment in subscription page * Fix tests * Update services/web/modules/symbol-palette/frontend/js/components/symbol-palette-overlay.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update services/web/modules/onboarding/app/views/onboarding/try_premium.pug Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update services/web/modules/onboarding/app/views/onboarding/try_premium.pug Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Replace `Github` to `GitHub` in translations * Update "non Overleaf" to "non-Overleaf" --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> GitOrigin-RevId: 56ee2735899de18f820b229bc226249322ac0c87
109 lines
2.9 KiB
TypeScript
109 lines
2.9 KiB
TypeScript
import StartFreeTrialButton from '../../../../frontend/js/shared/components/start-free-trial-button'
|
|
import getMeta from '@/utils/meta'
|
|
import { SplitTestProvider } from '@/shared/context/split-test-context'
|
|
|
|
describe('start free trial button', function () {
|
|
beforeEach(function () {
|
|
cy.intercept('POST', '/event/paywall-prompt', {
|
|
statusCode: 204,
|
|
}).as('event-paywall-prompt')
|
|
cy.intercept('POST', '/event/paywall-click', {
|
|
statusCode: 204,
|
|
}).as('event-paywall-click')
|
|
|
|
getMeta('ol-ExposedSettings').isOverleaf = true
|
|
})
|
|
|
|
it('renders the button with default text', function () {
|
|
cy.mount(
|
|
<SplitTestProvider>
|
|
<StartFreeTrialButton source="cypress-test" />
|
|
</SplitTestProvider>
|
|
)
|
|
|
|
cy.wait('@event-paywall-prompt')
|
|
.its('request.body.paywall-type')
|
|
.should('eq', 'cypress-test')
|
|
|
|
cy.get('button').contains('Start Free Trial!')
|
|
})
|
|
|
|
it('renders the button with custom text', function () {
|
|
cy.mount(
|
|
<SplitTestProvider>
|
|
<StartFreeTrialButton source="cypress-test">
|
|
Some Custom Text
|
|
</StartFreeTrialButton>
|
|
</SplitTestProvider>
|
|
)
|
|
|
|
cy.wait('@event-paywall-prompt')
|
|
.its('request.body.paywall-type')
|
|
.should('eq', 'cypress-test')
|
|
|
|
cy.get('button').contains('Some Custom Text')
|
|
})
|
|
|
|
it('renders the button with styled button', function () {
|
|
cy.mount(
|
|
<SplitTestProvider>
|
|
<StartFreeTrialButton
|
|
source="cypress-test"
|
|
buttonProps={{
|
|
variant: 'danger',
|
|
size: 'lg',
|
|
}}
|
|
/>
|
|
</SplitTestProvider>
|
|
)
|
|
|
|
cy.wait('@event-paywall-prompt')
|
|
|
|
cy.get('button.btn.btn-danger.btn-lg').contains('Start Free Trial!')
|
|
})
|
|
|
|
it('renders the button with custom class', function () {
|
|
cy.mount(
|
|
<SplitTestProvider>
|
|
<StartFreeTrialButton
|
|
source="cypress-test"
|
|
buttonProps={{ className: 'ct-test-class' }}
|
|
/>
|
|
</SplitTestProvider>
|
|
)
|
|
|
|
cy.wait('@event-paywall-prompt')
|
|
.its('request.body.paywall-type')
|
|
.should('eq', 'cypress-test')
|
|
|
|
cy.get('.ct-test-class').contains('Start Free Trial!')
|
|
})
|
|
|
|
it('calls onClick callback and opens a new tab to the subscription page on click', function () {
|
|
const onClickStub = cy.stub()
|
|
cy.mount(
|
|
<SplitTestProvider>
|
|
<StartFreeTrialButton source="cypress-test" handleClick={onClickStub} />
|
|
</SplitTestProvider>
|
|
)
|
|
|
|
cy.wait('@event-paywall-prompt')
|
|
|
|
cy.window().then(win => {
|
|
cy.stub(win, 'open').as('Open')
|
|
})
|
|
cy.get('button.btn').contains('Start Free Trial!').click()
|
|
|
|
cy.wrap(null).then(() => {
|
|
cy.wait('@event-paywall-click')
|
|
.its('request.body.paywall-type')
|
|
.should('eq', 'cypress-test')
|
|
cy.get('@Open').should(
|
|
'have.been.calledOnceWithExactly',
|
|
'/user/subscription/choose-your-plan?itm_campaign=cypress-test'
|
|
)
|
|
expect(onClickStub).to.be.called
|
|
})
|
|
})
|
|
})
|