mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-11 15:10:48 +02:00
Improve tests for layout components (#17518)
GitOrigin-RevId: 1d08224a5282482dcf153a2ebcff69a08be2eb58
This commit is contained in:
+38
@@ -0,0 +1,38 @@
|
||||
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')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,42 @@
|
||||
import SwitchToPDFButton from '@/features/source-editor/components/switch-to-pdf-button'
|
||||
import { EditorProviders } from '../../../helpers/editor-providers'
|
||||
|
||||
describe('<SwitchToPDFButton />', function () {
|
||||
it('shows button in full screen editor layout', function () {
|
||||
cy.mount(
|
||||
<EditorProviders
|
||||
ui={{ view: 'editor', pdfLayout: 'flat', chatOpen: false }}
|
||||
>
|
||||
<SwitchToPDFButton />
|
||||
</EditorProviders>
|
||||
)
|
||||
|
||||
cy.findByRole('button', { name: 'Switch to PDF' })
|
||||
})
|
||||
|
||||
it('does not show button in split screen layout', function () {
|
||||
cy.mount(
|
||||
<EditorProviders
|
||||
ui={{ view: 'editor', pdfLayout: 'sideBySide', chatOpen: false }}
|
||||
>
|
||||
<SwitchToPDFButton />
|
||||
</EditorProviders>
|
||||
)
|
||||
|
||||
cy.findByRole('button', { name: 'Switch to PDF' }).should('not.exist')
|
||||
})
|
||||
|
||||
it('does not show button when detached', function () {
|
||||
window.metaAttributesCache.set('ol-detachRole', 'detacher')
|
||||
|
||||
cy.mount(
|
||||
<EditorProviders
|
||||
ui={{ view: 'editor', pdfLayout: 'flat', chatOpen: false }}
|
||||
>
|
||||
<SwitchToPDFButton />
|
||||
</EditorProviders>
|
||||
)
|
||||
|
||||
cy.findByRole('button', { name: 'Switch to PDF' }).should('not.exist')
|
||||
})
|
||||
})
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
import { screen } from '@testing-library/react'
|
||||
import { expect } from 'chai'
|
||||
import { renderWithEditorContext } from '../../../helpers/render-with-context'
|
||||
import SwitchToPDFButton from '../../../../../frontend/js/features/source-editor/components/switch-to-pdf-button'
|
||||
|
||||
describe('<SwitchToPDFButton />', function () {
|
||||
beforeEach(function () {
|
||||
window.metaAttributesCache = new Map()
|
||||
})
|
||||
|
||||
afterEach(function () {
|
||||
window.metaAttributesCache = new Map()
|
||||
})
|
||||
|
||||
it('shows button in full screen layout', function () {
|
||||
renderWithEditorContext(<SwitchToPDFButton />, {
|
||||
ui: { view: 'editor', pdfLayout: 'flat' },
|
||||
})
|
||||
screen.getByRole('button', { name: 'Switch to PDF' })
|
||||
})
|
||||
|
||||
it('does not show button in split screen layout', function () {
|
||||
renderWithEditorContext(<SwitchToPDFButton />, {
|
||||
ui: { view: 'editor', pdfLayout: 'sideBySide' },
|
||||
})
|
||||
expect(screen.queryByRole('button', { name: 'Full screen' })).to.not.exist
|
||||
})
|
||||
|
||||
it('does not show button when detached', function () {
|
||||
window.metaAttributesCache.set('ol-detachRole', 'detacher')
|
||||
renderWithEditorContext(<SwitchToPDFButton />, {
|
||||
ui: { view: 'editor', pdfLayout: 'flat' },
|
||||
})
|
||||
expect(screen.queryByRole('button', { name: 'Full screen' })).to.not.exist
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user