packageData.spec.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  3. import {textWithMarkupMatcher} from 'sentry-test/utils';
  4. import {EventPackageData} from 'sentry/components/events/packageData';
  5. import {OrganizationContext} from 'sentry/views/organizationContext';
  6. import {RouteContext} from 'sentry/views/routeContext';
  7. describe('EventPackageData', function () {
  8. it('display redacted data', async function () {
  9. const {organization, router} = initializeOrg({
  10. ...initializeOrg(),
  11. organization: {
  12. ...initializeOrg().organization,
  13. relayPiiConfig: JSON.stringify(TestStubs.DataScrubbingRelayPiiConfig()),
  14. },
  15. });
  16. const event = {
  17. ...TestStubs.Event(),
  18. packages: {
  19. certifi: '',
  20. pip: '18.0',
  21. python: '2.7.15',
  22. 'sentry-sdk': '0.3.1',
  23. setuptools: '40.0.0',
  24. urllib3: '1.23',
  25. wheel: '0.31.1',
  26. wsgiref: '0.1.2',
  27. },
  28. _meta: {
  29. packages: {
  30. certifi: {'': {rem: [['organization:1', 'x']]}},
  31. },
  32. },
  33. };
  34. render(
  35. <OrganizationContext.Provider value={organization}>
  36. <RouteContext.Provider
  37. value={{
  38. router,
  39. location: router.location,
  40. params: {},
  41. routes: [],
  42. }}
  43. >
  44. <EventPackageData event={event} />
  45. </RouteContext.Provider>
  46. </OrganizationContext.Provider>
  47. );
  48. expect(screen.getByText(/redacted/)).toBeInTheDocument();
  49. userEvent.hover(screen.getByText(/redacted/));
  50. expect(
  51. await screen.findByText(
  52. textWithMarkupMatcher(
  53. 'Removed because of the PII rule [Mask] [Credit card numbers] from [$message] in the settings of the organization org-slug'
  54. )
  55. )
  56. ).toBeInTheDocument(); // tooltip description
  57. });
  58. });