detach-compile-button.spec.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import sysendTestHelper from '../../helpers/sysend'
  2. import { EditorProviders } from '../../helpers/editor-providers'
  3. import DetachCompileButton from '../../../../frontend/js/features/pdf-preview/components/detach-compile-button'
  4. import { mockScope } from './scope'
  5. describe('<DetachCompileButton/>', function () {
  6. beforeEach(function () {
  7. cy.interceptCompile()
  8. cy.interceptEvents()
  9. })
  10. afterEach(function () {
  11. window.metaAttributesCache = new Map()
  12. sysendTestHelper.resetHistory()
  13. })
  14. it('detacher mode and not linked: does not show button ', function () {
  15. cy.window().then(win => {
  16. win.metaAttributesCache = new Map([['ol-detachRole', 'detacher']])
  17. })
  18. const scope = mockScope()
  19. cy.mount(
  20. <EditorProviders scope={scope}>
  21. <DetachCompileButton />
  22. </EditorProviders>
  23. )
  24. cy.findByRole('button', { name: 'Recompile' }).should('not.exist')
  25. })
  26. it('detacher mode and linked: show button ', function () {
  27. cy.window().then(win => {
  28. win.metaAttributesCache = new Map([['ol-detachRole', 'detacher']])
  29. })
  30. const scope = mockScope()
  31. cy.mount(
  32. <EditorProviders scope={scope}>
  33. <DetachCompileButton />
  34. </EditorProviders>
  35. ).then(() => {
  36. sysendTestHelper.receiveMessage({
  37. role: 'detached',
  38. event: 'connected',
  39. })
  40. })
  41. cy.findByRole('button', { name: 'Recompile' })
  42. })
  43. it('not detacher mode and linked: does not show button ', function () {
  44. cy.window().then(win => {
  45. win.metaAttributesCache = new Map([['ol-detachRole', 'detached']])
  46. })
  47. const scope = mockScope()
  48. cy.mount(
  49. <EditorProviders scope={scope}>
  50. <DetachCompileButton />
  51. </EditorProviders>
  52. ).then(() => {
  53. sysendTestHelper.receiveMessage({
  54. role: 'detacher',
  55. event: 'connected',
  56. })
  57. })
  58. cy.findByRole('button', { name: 'Recompile' }).should('not.exist')
  59. })
  60. })