projectPlugins.spec.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen, waitFor} from 'sentry-test/reactTestingLibrary';
  3. import ProjectPlugins from 'sentry/views/settings/projectPlugins/projectPlugins';
  4. describe('ProjectPlugins', function () {
  5. it('renders', async function () {
  6. const {organization, route, router, project} = initializeOrg();
  7. const {container} = render(
  8. <ProjectPlugins
  9. params={{
  10. orgId: organization.slug,
  11. }}
  12. project={project}
  13. onChange={jest.fn()}
  14. loading={false}
  15. error={undefined}
  16. plugins={TestStubs.Plugins()}
  17. router={router}
  18. routes={router.routes}
  19. route={route}
  20. location={router.location}
  21. routeParams={router.params}
  22. />
  23. );
  24. await waitFor(() =>
  25. expect(screen.queryByTestId('loading-indicator')).not.toBeInTheDocument()
  26. );
  27. expect(container).toSnapshot();
  28. });
  29. it('has error state when plugins=[]', async function () {
  30. const {organization, route, router, project} = initializeOrg();
  31. render(
  32. <ProjectPlugins
  33. params={{
  34. orgId: organization.slug,
  35. }}
  36. project={project}
  37. onChange={jest.fn()}
  38. loading={false}
  39. error={new Error('An error')}
  40. plugins={[]}
  41. router={router}
  42. routes={router.routes}
  43. route={route}
  44. location={router.location}
  45. routeParams={router.params}
  46. />
  47. );
  48. expect(await screen.findByText('Oops! Something went wrong')).toBeInTheDocument();
  49. });
  50. });