mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-02 15:00:51 -05:00
c6b88085d5
[web] Migrate team invite to React GitOrigin-RevId: 32e968c3b512020aef9a396808c73a7b4859e6d1
48 lines
1.8 KiB
TypeScript
48 lines
1.8 KiB
TypeScript
import { expect } from 'chai'
|
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react'
|
|
import HasIndividualRecurlySubscription from '../../../../../../frontend/js/features/subscription/components/group-invite/has-individual-recurly-subscription'
|
|
import sinon from 'sinon'
|
|
import fetchMock from 'fetch-mock'
|
|
|
|
describe('group invite', function () {
|
|
describe('user has a personal subscription', function () {
|
|
afterEach(function () {
|
|
fetchMock.reset()
|
|
})
|
|
|
|
it('shows option to cancel subscription', async function () {
|
|
render(<HasIndividualRecurlySubscription setView={() => {}} />)
|
|
await screen.findByText(
|
|
'You already have an individual subscription, would you like us to cancel this first before joining the group licence?'
|
|
)
|
|
screen.getByRole('button', { name: 'Not now' })
|
|
screen.getByRole('button', { name: 'Cancel Your Subscription' })
|
|
})
|
|
|
|
it('handles subscription cancellation and calls to change invite view', async function () {
|
|
fetchMock.post('/user/subscription/cancel', 200)
|
|
const setView = sinon.stub()
|
|
render(<HasIndividualRecurlySubscription setView={setView} />)
|
|
const button = await screen.findByRole('button', {
|
|
name: 'Cancel Your Subscription',
|
|
})
|
|
fireEvent.click(button)
|
|
await waitFor(() => {
|
|
expect(setView).to.have.been.calledOnce
|
|
})
|
|
})
|
|
|
|
it('shows error message when cancelling subscription fails', async function () {
|
|
render(<HasIndividualRecurlySubscription setView={() => {}} />)
|
|
const button = await screen.findByRole('button', {
|
|
name: 'Cancel Your Subscription',
|
|
})
|
|
fireEvent.click(button)
|
|
await waitFor(() => {
|
|
screen.getByText(
|
|
'Something went wrong canceling your subscription. Please contact support.'
|
|
)
|
|
})
|
|
})
|
|
})
|
|
})
|