file-view-refresh-button.test.tsx 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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 { textFile } from '../util/files'
  11. describe('<FileViewRefreshButton />', function () {
  12. beforeEach(function () {
  13. fetchMock.removeRoutes().clearHistory()
  14. })
  15. // eslint-disable-next-line mocha/no-pending-tests
  16. it.skip('Changes text when the file is refreshing', async function () {
  17. fetchMock.post(
  18. 'express:/project/:project_id/linked_file/:file_id/refresh',
  19. {
  20. new_file_id: '5ff7418157b4e144321df5c4',
  21. }
  22. )
  23. renderWithEditorContext(
  24. <FileViewRefreshButton file={textFile} setRefreshError={sinon.stub()} />
  25. )
  26. fireEvent.click(screen.getByRole('button', { name: 'Refresh' }))
  27. await waitForElementToBeRemoved(() =>
  28. screen.getByText('Refreshing', { exact: false })
  29. )
  30. await screen.findByRole('button', { name: 'Refresh' })
  31. })
  32. })