index.spec.tsx 2.8 KB

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