projectUserFeedback.spec.tsx 1.3 KB

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