projectSecurityAndPrivacy.spec.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import {Organization} from 'sentry/types';
  3. import ProjectSecurityAndPrivacy from 'sentry/views/settings/projectSecurityAndPrivacy';
  4. const org = TestStubs.Organization();
  5. const project = TestStubs.ProjectDetails();
  6. function renderComponent(providedOrg?: Organization) {
  7. const organization = providedOrg ?? org;
  8. MockApiClient.addMockResponse({
  9. url: `/projects/${organization.slug}/${project.slug}/`,
  10. method: 'GET',
  11. body: project,
  12. });
  13. return mountWithTheme(
  14. <ProjectSecurityAndPrivacy
  15. {...TestStubs.routerContext().context}
  16. project={project}
  17. organization={organization}
  18. params={{orgId: organization.slug, projectId: project.slug}}
  19. />
  20. );
  21. }
  22. describe('projectSecurityAndPrivacy', function () {
  23. it('renders form fields', function () {
  24. const wrapper = renderComponent();
  25. expect(wrapper.find('Switch[name="dataScrubber"]').prop('isActive')).toBeFalsy();
  26. expect(
  27. wrapper.find('Switch[name="dataScrubberDefaults"]').prop('isActive')
  28. ).toBeFalsy();
  29. expect(wrapper.find('Switch[name="scrubIPAddresses"]').prop('isActive')).toBeFalsy();
  30. expect(wrapper.find('TextArea[name="sensitiveFields"]').prop('value')).toBe(
  31. 'creditcard\nssn'
  32. );
  33. expect(wrapper.find('TextArea[name="safeFields"]').prop('value')).toBe(
  34. 'business-email\ncompany'
  35. );
  36. });
  37. it('disables field when equivalent org setting is true', function () {
  38. const newOrganization = {...org};
  39. newOrganization.dataScrubber = true;
  40. newOrganization.scrubIPAddresses = false;
  41. const wrapper = renderComponent(newOrganization);
  42. expect(wrapper.find('Switch[name="scrubIPAddresses"]').prop('isDisabled')).toBe(
  43. false
  44. );
  45. expect(wrapper.find('Switch[name="scrubIPAddresses"]').prop('isActive')).toBeFalsy();
  46. expect(wrapper.find('Switch[name="dataScrubber"]').prop('isDisabled')).toBe(true);
  47. expect(wrapper.find('Switch[name="dataScrubber"]').prop('isActive')).toBe(true);
  48. });
  49. });