projectUserFeedbackProcessing.spec.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import {ProjectFixture} from 'sentry-fixture/project';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  4. import ProjectUserFeedbackProcessing from 'sentry/views/settings/project/projectUserFeedbackProcessing';
  5. describe('ProjectUserFeedbackProcessing', function () {
  6. const {routerProps, organization, project, routerContext} = initializeOrg();
  7. const url = `/projects/${organization.slug}/${project.slug}/`;
  8. beforeEach(function () {
  9. MockApiClient.clearMockResponses();
  10. MockApiClient.addMockResponse({
  11. url,
  12. method: 'GET',
  13. body: ProjectFixture(),
  14. });
  15. MockApiClient.addMockResponse({
  16. url: `${url}keys/`,
  17. method: 'GET',
  18. body: [],
  19. });
  20. });
  21. it('can toggle spam detection', async function () {
  22. render(
  23. <ProjectUserFeedbackProcessing
  24. {...routerProps}
  25. organization={organization}
  26. project={project}
  27. />,
  28. {
  29. context: routerContext,
  30. }
  31. );
  32. const mock = MockApiClient.addMockResponse({
  33. url,
  34. method: 'PUT',
  35. });
  36. await userEvent.click(screen.getByRole('checkbox', {name: 'Enable Spam Detection'}));
  37. expect(mock).toHaveBeenCalledWith(
  38. url,
  39. expect.objectContaining({
  40. method: 'PUT',
  41. data: {
  42. options: {'sentry:feedback_ai_spam_detection': true},
  43. },
  44. })
  45. );
  46. });
  47. });