projectPlugins.spec.tsx 1.4 KB

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