index.spec.tsx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import ProjectSecurityAndPrivacy from 'sentry/views/settings/projectSecurityAndPrivacy';
  4. describe('projectSecurityAndPrivacy', function () {
  5. it('renders form fields', function () {
  6. const {organization} = initializeOrg();
  7. const project = TestStubs.ProjectDetails();
  8. render(<ProjectSecurityAndPrivacy project={project} organization={organization} />);
  9. expect(
  10. screen.getByRole('checkbox', {
  11. name: 'Enable server-side data scrubbing',
  12. })
  13. ).not.toBeChecked();
  14. expect(
  15. screen.getByRole('checkbox', {
  16. name: 'Enable to apply default scrubbers to prevent things like passwords and credit cards from being stored',
  17. })
  18. ).not.toBeChecked();
  19. expect(
  20. screen.getByRole('checkbox', {
  21. name: 'Enable to prevent IP addresses from being stored for new events',
  22. })
  23. ).not.toBeChecked();
  24. expect(
  25. screen.getByRole('textbox', {
  26. name: 'Enter field names which data scrubbers should ignore. Separate multiple entries with a newline',
  27. })
  28. ).toHaveValue('business-email\ncompany');
  29. expect(
  30. screen.getByRole('textbox', {
  31. name: 'Enter additional field names to match against when scrubbing data. Separate multiple entries with a newline',
  32. })
  33. ).toHaveValue('creditcard\nssn');
  34. expect(
  35. screen.getByRole('textbox', {
  36. name: 'Enter additional field names to match against when scrubbing data. Separate multiple entries with a newline',
  37. })
  38. ).toHaveValue('creditcard\nssn');
  39. });
  40. it('disables field when equivalent org setting is true', function () {
  41. const {organization} = initializeOrg();
  42. const project = TestStubs.ProjectDetails();
  43. organization.dataScrubber = true;
  44. organization.scrubIPAddresses = false;
  45. MockApiClient.addMockResponse({
  46. url: `/projects/${organization.slug}/${project.slug}/`,
  47. method: 'GET',
  48. body: project,
  49. });
  50. render(<ProjectSecurityAndPrivacy project={project} organization={organization} />);
  51. expect(
  52. screen.getByRole('checkbox', {
  53. name: 'Enable to prevent IP addresses from being stored for new events',
  54. })
  55. ).toBeEnabled();
  56. expect(
  57. screen.getByRole('checkbox', {
  58. name: 'Enable to prevent IP addresses from being stored for new events',
  59. })
  60. ).not.toBeChecked();
  61. expect(
  62. screen.getByRole('checkbox', {name: 'Enable server-side data scrubbing'})
  63. ).toBeDisabled();
  64. expect(
  65. screen.getByRole('checkbox', {name: 'Enable server-side data scrubbing'})
  66. ).toBeChecked();
  67. });
  68. });