overleaf/services/web/test/frontend/features/layout/components/switch-to-editor-button.spec.tsx
Alf Eaton b2fbc39930 Improve tests for layout components (#17518)
GitOrigin-RevId: 1d08224a5282482dcf153a2ebcff69a08be2eb58
2024-03-26 09:04:24 +00:00

38 lines
1.2 KiB
TypeScript

import { EditorProviders } from '../../../helpers/editor-providers'
import SwitchToEditorButton from '@/features/pdf-preview/components/switch-to-editor-button'
describe('<SwitchToEditorButton />', function () {
it('shows button in full screen pdf layout', function () {
cy.mount(
<EditorProviders ui={{ view: 'pdf', pdfLayout: 'flat', chatOpen: false }}>
<SwitchToEditorButton />
</EditorProviders>
)
cy.findByRole('button', { name: 'Switch to editor' })
})
it('does not show button in split screen layout', function () {
cy.mount(
<EditorProviders
ui={{ view: 'pdf', pdfLayout: 'sideBySide', chatOpen: false }}
>
<SwitchToEditorButton />
</EditorProviders>
)
cy.findByRole('button', { name: 'Switch to editor' }).should('not.exist')
})
it('does not show button when detached', function () {
window.metaAttributesCache.set('ol-detachRole', 'detacher')
cy.mount(
<EditorProviders ui={{ view: 'pdf', pdfLayout: 'flat', chatOpen: false }}>
<SwitchToEditorButton />
</EditorProviders>
)
cy.findByRole('button', { name: 'Switch to editor' }).should('not.exist')
})
})