index.spec.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 ProjectUserFeedback from 'sentry/views/settings/projectUserFeedback';
  5. describe('ProjectUserFeedback', function () {
  6. const {routerProps, organization, project, router} = 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 sentry branding option', async function () {
  22. render(
  23. <ProjectUserFeedback
  24. {...routerProps}
  25. organization={organization}
  26. project={project}
  27. />,
  28. {
  29. router,
  30. }
  31. );
  32. const mock = MockApiClient.addMockResponse({
  33. url,
  34. method: 'PUT',
  35. });
  36. await userEvent.click(
  37. screen.getByRole('checkbox', {name: 'Show Sentry Branding in Crash Report Modal'})
  38. );
  39. expect(mock).toHaveBeenCalledWith(
  40. url,
  41. expect.objectContaining({
  42. method: 'PUT',
  43. data: {
  44. options: {'feedback:branding': true},
  45. },
  46. })
  47. );
  48. });
  49. });
  50. describe('ProjectUserFeedbackProcessing', function () {
  51. const {routerProps, organization, project, router} = initializeOrg();
  52. const url = `/projects/${organization.slug}/${project.slug}/`;
  53. beforeEach(function () {
  54. MockApiClient.clearMockResponses();
  55. MockApiClient.addMockResponse({
  56. url,
  57. method: 'GET',
  58. body: ProjectFixture(),
  59. });
  60. MockApiClient.addMockResponse({
  61. url: `${url}keys/`,
  62. method: 'GET',
  63. body: [],
  64. });
  65. });
  66. it('can toggle spam detection', async function () {
  67. render(
  68. <ProjectUserFeedback
  69. {...routerProps}
  70. organization={organization}
  71. project={project}
  72. />,
  73. {
  74. router,
  75. }
  76. );
  77. const mock = MockApiClient.addMockResponse({
  78. url,
  79. method: 'PUT',
  80. });
  81. await userEvent.click(screen.getByRole('checkbox', {name: 'Enable Spam Detection'}));
  82. expect(mock).toHaveBeenCalledWith(
  83. url,
  84. expect.objectContaining({
  85. method: 'PUT',
  86. data: {
  87. options: {'sentry:feedback_ai_spam_detection': true},
  88. },
  89. })
  90. );
  91. });
  92. });