projectUserFeedback.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 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. 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. });