projectPluginRow.spec.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {PluginFixture} from 'sentry-fixture/plugin';
  3. import {ProjectFixture} from 'sentry-fixture/project';
  4. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  5. import ProjectPluginRow from 'sentry/views/settings/projectPlugins/projectPluginRow';
  6. describe('ProjectPluginRow', function () {
  7. const plugin = PluginFixture();
  8. const org = OrganizationFixture();
  9. const project = ProjectFixture();
  10. const params = {orgId: org.slug, projectId: project.slug};
  11. it('calls `onChange` when clicked', async function () {
  12. const onChange = jest.fn();
  13. render(
  14. <ProjectPluginRow
  15. params={{}}
  16. routes={[]}
  17. {...params}
  18. {...plugin}
  19. onChange={onChange}
  20. project={project}
  21. />
  22. );
  23. await userEvent.click(screen.getByRole('checkbox'));
  24. expect(onChange).toHaveBeenCalledWith('amazon-sqs', true);
  25. });
  26. it('can not enable/disable or configure plugin without `project:write`', async function () {
  27. const onChange = jest.fn();
  28. render(
  29. <ProjectPluginRow
  30. params={{}}
  31. routes={[]}
  32. {...params}
  33. {...plugin}
  34. onChange={onChange}
  35. project={project}
  36. />,
  37. {
  38. organization: OrganizationFixture({access: []}),
  39. }
  40. );
  41. await userEvent.click(screen.getByRole('checkbox'));
  42. expect(onChange).not.toHaveBeenCalled();
  43. });
  44. });