overleaf/services/web/test/frontend/components/pdf-preview/detach-compile-button.spec.tsx
Tim Down e60885aa88 Merge pull request #19347 from overleaf/td-bs5-cypress-css
Move CSS loading in Cypress to individual test spec files

GitOrigin-RevId: 92bb5167cfa81b0bd54acc724efb23b397421ccb
2024-07-25 08:05:16 +00:00

85 lines
2 KiB
TypeScript

import '../../helpers/bootstrap-3'
import { EditorProviders } from '../../helpers/editor-providers'
import DetachCompileButtonWrapper from '../../../../frontend/js/features/pdf-preview/components/detach-compile-button-wrapper'
import { mockScope } from './scope'
import { testDetachChannel } from '../../helpers/detach-channel'
describe('<DetachCompileButtonWrapper />', function () {
beforeEach(function () {
cy.interceptEvents()
})
it('detacher mode and not linked: does not show button ', function () {
cy.interceptCompile()
cy.window().then(win => {
win.metaAttributesCache.set('ol-detachRole', 'detacher')
})
const scope = mockScope()
cy.mount(
<EditorProviders scope={scope}>
<DetachCompileButtonWrapper />
</EditorProviders>
)
cy.waitForCompile()
cy.findByRole('button', { name: 'Recompile' }).should('not.exist')
})
it('detacher mode and linked: show button', function () {
cy.interceptCompile()
cy.window().then(win => {
win.metaAttributesCache.set('ol-detachRole', 'detacher')
})
const scope = mockScope()
cy.mount(
<EditorProviders scope={scope}>
<DetachCompileButtonWrapper />
</EditorProviders>
)
cy.waitForCompile()
cy.wrap(null).then(() => {
testDetachChannel.postMessage({
role: 'detached',
event: 'connected',
})
})
cy.findByRole('button', { name: 'Recompile' })
})
it('not detacher mode and linked: does not show button ', function () {
cy.interceptCompile()
cy.window().then(win => {
win.metaAttributesCache.set('ol-detachRole', 'detached')
})
const scope = mockScope()
cy.mount(
<EditorProviders scope={scope}>
<DetachCompileButtonWrapper />
</EditorProviders>
)
cy.waitForCompile()
cy.wrap(null).then(() => {
testDetachChannel.postMessage({
role: 'detacher',
event: 'connected',
})
})
cy.findByRole('button', { name: 'Recompile' }).should('not.exist')
})
})