projectPlugins.spec.tsx 1.6 KB

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