2022-04-06 06:14:43 -04:00
|
|
|
import { EditorProviders } from '../../helpers/editor-providers'
|
2023-02-21 09:34:35 -05:00
|
|
|
import DetachCompileButtonWrapper from '../../../../frontend/js/features/pdf-preview/components/detach-compile-button-wrapper'
|
2022-04-06 06:14:43 -04:00
|
|
|
import { mockScope } from './scope'
|
2023-01-09 07:52:11 -05:00
|
|
|
import { testDetachChannel } from '../../helpers/detach-channel'
|
2022-04-06 06:14:43 -04:00
|
|
|
|
2023-02-21 09:34:35 -05:00
|
|
|
describe('<DetachCompileButtonWrapper />', function () {
|
2022-04-06 06:14:43 -04:00
|
|
|
beforeEach(function () {
|
|
|
|
cy.interceptEvents()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('detacher mode and not linked: does not show button ', function () {
|
2023-03-06 07:50:17 -05:00
|
|
|
cy.interceptCompile()
|
|
|
|
|
2022-04-06 06:14:43 -04:00
|
|
|
cy.window().then(win => {
|
2024-06-18 06:01:37 -04:00
|
|
|
win.metaAttributesCache.set('ol-detachRole', 'detacher')
|
2022-04-06 06:14:43 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
const scope = mockScope()
|
|
|
|
|
2022-06-08 03:39:09 -04:00
|
|
|
cy.mount(
|
2022-04-06 06:14:43 -04:00
|
|
|
<EditorProviders scope={scope}>
|
2023-02-21 09:34:35 -05:00
|
|
|
<DetachCompileButtonWrapper />
|
2022-04-06 06:14:43 -04:00
|
|
|
</EditorProviders>
|
|
|
|
)
|
|
|
|
|
2023-03-06 07:50:17 -05:00
|
|
|
cy.waitForCompile()
|
|
|
|
|
2022-04-06 06:14:43 -04:00
|
|
|
cy.findByRole('button', { name: 'Recompile' }).should('not.exist')
|
|
|
|
})
|
|
|
|
|
2023-01-09 07:52:11 -05:00
|
|
|
it('detacher mode and linked: show button', function () {
|
2023-03-06 07:50:17 -05:00
|
|
|
cy.interceptCompile()
|
|
|
|
|
2022-04-06 06:14:43 -04:00
|
|
|
cy.window().then(win => {
|
2024-06-18 06:01:37 -04:00
|
|
|
win.metaAttributesCache.set('ol-detachRole', 'detacher')
|
2022-04-06 06:14:43 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
const scope = mockScope()
|
|
|
|
|
2022-06-08 03:39:09 -04:00
|
|
|
cy.mount(
|
2022-04-06 06:14:43 -04:00
|
|
|
<EditorProviders scope={scope}>
|
2023-02-21 09:34:35 -05:00
|
|
|
<DetachCompileButtonWrapper />
|
2022-04-06 06:14:43 -04:00
|
|
|
</EditorProviders>
|
2023-01-09 07:52:11 -05:00
|
|
|
)
|
|
|
|
|
2023-03-06 07:50:17 -05:00
|
|
|
cy.waitForCompile()
|
|
|
|
|
2023-01-09 07:52:11 -05:00
|
|
|
cy.wrap(null).then(() => {
|
|
|
|
testDetachChannel.postMessage({
|
2022-04-06 06:14:43 -04:00
|
|
|
role: 'detached',
|
|
|
|
event: 'connected',
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.findByRole('button', { name: 'Recompile' })
|
|
|
|
})
|
|
|
|
|
|
|
|
it('not detacher mode and linked: does not show button ', function () {
|
2023-03-06 07:50:17 -05:00
|
|
|
cy.interceptCompile()
|
|
|
|
|
2022-04-06 06:14:43 -04:00
|
|
|
cy.window().then(win => {
|
2024-06-18 06:01:37 -04:00
|
|
|
win.metaAttributesCache.set('ol-detachRole', 'detached')
|
2022-04-06 06:14:43 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
const scope = mockScope()
|
|
|
|
|
2022-06-08 03:39:09 -04:00
|
|
|
cy.mount(
|
2022-04-06 06:14:43 -04:00
|
|
|
<EditorProviders scope={scope}>
|
2023-02-21 09:34:35 -05:00
|
|
|
<DetachCompileButtonWrapper />
|
2022-04-06 06:14:43 -04:00
|
|
|
</EditorProviders>
|
2023-01-09 07:52:11 -05:00
|
|
|
)
|
|
|
|
|
2023-03-06 07:50:17 -05:00
|
|
|
cy.waitForCompile()
|
|
|
|
|
2023-01-09 07:52:11 -05:00
|
|
|
cy.wrap(null).then(() => {
|
|
|
|
testDetachChannel.postMessage({
|
2022-04-06 06:14:43 -04:00
|
|
|
role: 'detacher',
|
|
|
|
event: 'connected',
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
cy.findByRole('button', { name: 'Recompile' }).should('not.exist')
|
|
|
|
})
|
|
|
|
})
|