pdf-preview-detached-root.spec.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import sysendTestHelper from '../../helpers/sysend'
  2. import PdfPreviewDetachedRoot from '../../../../frontend/js/features/pdf-preview/components/pdf-preview-detached-root'
  3. import { User } from '../../../../types/user'
  4. // https://github.com/overleaf/internal/issues/10080
  5. // eslint-disable-next-line mocha/no-skipped-tests
  6. describe.skip('<PdfPreviewDetachedRoot/>', function () {
  7. beforeEach(function () {
  8. window.user = { id: 'user1' } as User
  9. window.metaAttributesCache = new Map<string, unknown>([
  10. ['ol-user', window.user],
  11. ['ol-project_id', 'project1'],
  12. ['ol-detachRole', 'detached'],
  13. ['ol-projectName', 'Project Name'],
  14. ])
  15. cy.interceptCompile()
  16. cy.interceptEvents()
  17. })
  18. afterEach(function () {
  19. window.metaAttributesCache = new Map()
  20. sysendTestHelper.resetHistory()
  21. })
  22. it('syncs compiling state', function () {
  23. cy.mount(<PdfPreviewDetachedRoot />).then(() => {
  24. sysendTestHelper.receiveMessage({
  25. role: 'detacher',
  26. event: 'connected',
  27. })
  28. sysendTestHelper.receiveMessage({
  29. role: 'detacher',
  30. event: 'state-compiling',
  31. data: { value: true },
  32. })
  33. })
  34. cy.findByRole('button', { name: 'Compiling…' })
  35. cy.findByRole('button', { name: 'Recompile' })
  36. .should('not.exist')
  37. .then(() => {
  38. sysendTestHelper.receiveMessage({
  39. role: 'detacher',
  40. event: 'state-compiling',
  41. data: { value: false },
  42. })
  43. })
  44. cy.findByRole('button', { name: 'Recompile' })
  45. cy.findByRole('button', { name: 'Compiling…' }).should('not.exist')
  46. })
  47. it('sends a clear cache request when the button is pressed', function () {
  48. cy.mount(<PdfPreviewDetachedRoot />).then(() => {
  49. sysendTestHelper.receiveMessage({
  50. role: 'detacher',
  51. event: 'state-showLogs',
  52. data: { value: true },
  53. })
  54. })
  55. cy.findByRole('button', { name: 'Clear cached files' })
  56. .should('not.be.disabled')
  57. .click()
  58. .should(() => {
  59. expect(sysendTestHelper.getLastBroacastMessage()).to.deep.equal({
  60. role: 'detached',
  61. event: 'action-clearCache',
  62. data: {
  63. args: [],
  64. },
  65. })
  66. })
  67. })
  68. })