index.spec.tsx 2.7 KB

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