projectUserFeedback.spec.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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/project/projectUserFeedback';
  5. describe('ProjectUserFeedback', 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 sentry branding option', async function () {
  22. render(
  23. <ProjectUserFeedback
  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. // Click Regenerate Token
  37. await userEvent.click(screen.getByRole('checkbox', {name: 'Show Sentry Branding'}));
  38. expect(mock).toHaveBeenCalledWith(
  39. url,
  40. expect.objectContaining({
  41. method: 'PUT',
  42. data: {
  43. options: {'feedback:branding': true},
  44. },
  45. })
  46. );
  47. });
  48. });