file-view-refresh-button.test.jsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import {
  2. screen,
  3. fireEvent,
  4. waitForElementToBeRemoved,
  5. } from '@testing-library/react'
  6. import fetchMock from 'fetch-mock'
  7. import sinon from 'sinon'
  8. import FileViewRefreshButton from '@/features/file-view/components/file-view-refresh-button'
  9. import { renderWithEditorContext } from '../../../helpers/render-with-context'
  10. import { USER_ID } from '../../../helpers/editor-providers'
  11. describe('<FileViewRefreshButton />', function () {
  12. const projectFile = {
  13. name: 'example.tex',
  14. linkedFileData: {
  15. v1_source_doc_id: 'v1-source-id',
  16. source_project_id: 'source-project-id',
  17. source_entity_path: '/source-entity-path.ext',
  18. provider: 'project_file',
  19. importer_id: USER_ID,
  20. },
  21. created: new Date(2021, 1, 17, 3, 24).toISOString(),
  22. }
  23. beforeEach(function () {
  24. fetchMock.removeRoutes().clearHistory()
  25. })
  26. // eslint-disable-next-line mocha/no-skipped-tests
  27. it.skip('Changes text when the file is refreshing', async function () {
  28. fetchMock.post(
  29. 'express:/project/:project_id/linked_file/:file_id/refresh',
  30. {
  31. new_file_id: '5ff7418157b4e144321df5c4',
  32. }
  33. )
  34. renderWithEditorContext(
  35. <FileViewRefreshButton
  36. file={projectFile}
  37. setRefreshError={sinon.stub()}
  38. />
  39. )
  40. fireEvent.click(screen.getByRole('button', { name: 'Refresh' }))
  41. await waitForElementToBeRemoved(() =>
  42. screen.getByText('Refreshing', { exact: false })
  43. )
  44. await screen.findByRole('button', { name: 'Refresh' })
  45. })
  46. })