overleaf/services/web/test/frontend/features/settings/components/security-section.test.tsx
Jakob Ackermann aa480a2663 Merge pull request #18898 from overleaf/jpa-no-window
[web] migrate from window attributes to getMeta

GitOrigin-RevId: 3dcf1ab6b01155e5e4abeb3e78d0fa9053e055bc
2024-06-19 08:04:21 +00:00

40 lines
1.1 KiB
TypeScript

import SecuritySection from '@/features/settings/components/security-section'
import { expect } from 'chai'
import { screen, render } from '@testing-library/react'
import fetchMock from 'fetch-mock'
describe('<SecuritySection />', function () {
afterEach(function () {
fetchMock.reset()
})
it('shows Group SSO rows in security section', async function () {
window.metaAttributesCache.set('ol-memberOfSSOEnabledGroups', [
{
groupId: 'abc123abc123',
linked: true,
},
{
groupId: 'fff999fff999',
linked: false,
},
])
render(<SecuritySection />)
expect(screen.getAllByText('Single Sign-On (SSO)').length).to.equal(2)
const link = screen.getByRole('link', {
name: /Set up SSO/i,
})
expect(link).to.exist
expect(link.getAttribute('href')).to.equal(
'/subscription/fff999fff999/sso_enrollment'
)
})
it('does not show the security section with no groups with SSO enabled', async function () {
window.metaAttributesCache.set('ol-memberOfSSOEnabledGroups', [])
render(<SecuritySection />)
expect(screen.queryByText('Security')).to.not.exist
})
})