mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
716f186fed
GitOrigin-RevId: 856c523a4ca34f8ccdc38067cef6fcd8a5c20250
101 lines
2.5 KiB
TypeScript
101 lines
2.5 KiB
TypeScript
import sysendTestHelper from '../../helpers/sysend'
|
|
import { EditorProviders } from '../../helpers/editor-providers'
|
|
import PdfPreviewHybridToolbar from '../../../../frontend/js/features/pdf-preview/components/pdf-preview-hybrid-toolbar'
|
|
|
|
describe('<PdfPreviewHybridToolbar/>', function () {
|
|
beforeEach(function () {
|
|
cy.interceptCompile()
|
|
cy.interceptEvents()
|
|
})
|
|
|
|
afterEach(function () {
|
|
window.metaAttributesCache = new Map()
|
|
sysendTestHelper.resetHistory()
|
|
})
|
|
|
|
it('shows normal mode', function () {
|
|
cy.mount(
|
|
<EditorProviders>
|
|
<PdfPreviewHybridToolbar />
|
|
</EditorProviders>
|
|
)
|
|
|
|
cy.findByRole('button', { name: 'Recompile' })
|
|
})
|
|
|
|
describe('orphan mode', function () {
|
|
it('shows connecting message on load', function () {
|
|
cy.window().then(win => {
|
|
win.metaAttributesCache = new Map([['ol-detachRole', 'detached']])
|
|
})
|
|
|
|
cy.mount(
|
|
<EditorProviders>
|
|
<PdfPreviewHybridToolbar />
|
|
</EditorProviders>
|
|
)
|
|
|
|
cy.contains('Connecting with the editor')
|
|
})
|
|
|
|
it('shows compile UI when connected', function () {
|
|
cy.window().then(win => {
|
|
win.metaAttributesCache = new Map([['ol-detachRole', 'detached']])
|
|
})
|
|
|
|
cy.mount(
|
|
<EditorProviders>
|
|
<PdfPreviewHybridToolbar />
|
|
</EditorProviders>
|
|
).then(() => {
|
|
sysendTestHelper.receiveMessage({
|
|
role: 'detacher',
|
|
event: 'connected',
|
|
})
|
|
})
|
|
|
|
cy.findByRole('button', { name: 'Recompile' })
|
|
})
|
|
|
|
it('shows connecting message when disconnected', function () {
|
|
cy.window().then(win => {
|
|
win.metaAttributesCache = new Map([['ol-detachRole', 'detached']])
|
|
})
|
|
|
|
cy.mount(
|
|
<EditorProviders>
|
|
<PdfPreviewHybridToolbar />
|
|
</EditorProviders>
|
|
).then(() => {
|
|
sysendTestHelper.receiveMessage({
|
|
role: 'detacher',
|
|
event: 'connected',
|
|
})
|
|
sysendTestHelper.receiveMessage({
|
|
role: 'detacher',
|
|
event: 'closed',
|
|
})
|
|
})
|
|
|
|
cy.contains('Connecting with the editor')
|
|
})
|
|
|
|
it('shows redirect button after timeout', function () {
|
|
cy.window().then(win => {
|
|
win.metaAttributesCache = new Map([['ol-detachRole', 'detached']])
|
|
})
|
|
|
|
cy.clock()
|
|
|
|
cy.mount(
|
|
<EditorProviders>
|
|
<PdfPreviewHybridToolbar />
|
|
</EditorProviders>
|
|
)
|
|
|
|
cy.tick(6000)
|
|
|
|
cy.findByRole('button', { name: 'Redirect to editor' })
|
|
})
|
|
})
|
|
})
|