mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-24 21:12:38 -04:00
aa480a2663
[web] migrate from window attributes to getMeta GitOrigin-RevId: 3dcf1ab6b01155e5e4abeb3e78d0fa9053e055bc
45 lines
1.1 KiB
TypeScript
45 lines
1.1 KiB
TypeScript
import {
|
|
fireEvent,
|
|
screen,
|
|
waitForElementToBeRemoved,
|
|
render,
|
|
} from '@testing-library/react'
|
|
|
|
import LeaveSection from '../../../../../frontend/js/features/settings/components/leave-section'
|
|
import getMeta from '@/utils/meta'
|
|
|
|
describe('<LeaveSection />', function () {
|
|
beforeEach(function () {
|
|
window.metaAttributesCache.set('ol-usersEmail', 'foo@bar.com')
|
|
Object.assign(getMeta('ol-ExposedSettings'), { isOverleaf: true })
|
|
window.metaAttributesCache.set('ol-hasPassword', true)
|
|
})
|
|
|
|
it('opens modal', async function () {
|
|
render(<LeaveSection />)
|
|
|
|
const button = screen.getByRole('button', {
|
|
name: 'Delete your account',
|
|
})
|
|
|
|
fireEvent.click(button)
|
|
await screen.findByText('Delete Account')
|
|
})
|
|
|
|
it('closes modal', async function () {
|
|
render(<LeaveSection />)
|
|
fireEvent.click(
|
|
screen.getByRole('button', {
|
|
name: 'Delete your account',
|
|
})
|
|
)
|
|
|
|
const cancelButton = screen.getByRole('button', {
|
|
name: 'Close',
|
|
})
|
|
|
|
fireEvent.click(cancelButton)
|
|
|
|
await waitForElementToBeRemoved(() => screen.getByText('Delete Account'))
|
|
})
|
|
})
|