message.spec.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  2. import {textWithMarkupMatcher} from 'sentry-test/utils';
  3. import {Message} from 'sentry/components/events/interfaces/message';
  4. describe('Message entry', function () {
  5. it('display redacted data', async function () {
  6. const event = {
  7. ...TestStubs.Event(),
  8. entries: [
  9. {
  10. type: 'message',
  11. data: {
  12. formatted: null,
  13. },
  14. },
  15. ],
  16. _meta: {
  17. entries: {
  18. 0: {
  19. data: {
  20. formatted: {'': {rem: [['organization:0', 'x']]}},
  21. },
  22. },
  23. },
  24. },
  25. };
  26. render(<Message data={{formatted: null}} event={event} />, {
  27. organization: {
  28. relayPiiConfig: JSON.stringify(TestStubs.DataScrubbingRelayPiiConfig()),
  29. },
  30. });
  31. expect(screen.getByText(/redacted/)).toBeInTheDocument();
  32. userEvent.hover(screen.getByText(/redacted/));
  33. expect(
  34. await screen.findByText(
  35. textWithMarkupMatcher(
  36. "Removed because of the data scrubbing rule [Replace] [Password fields] with [Scrubbed] from [password] in your organization's settings"
  37. )
  38. )
  39. ).toBeInTheDocument(); // tooltip description
  40. expect(
  41. screen.getByRole('link', {
  42. name: '[Replace] [Password fields] with [Scrubbed] from [password]',
  43. })
  44. ).toHaveAttribute(
  45. 'href',
  46. '/settings/org-slug/security-and-privacy/advanced-data-scrubbing/0/'
  47. );
  48. expect(screen.getByRole('link', {name: "organization's settings"})).toHaveAttribute(
  49. 'href',
  50. '/settings/org-slug/security-and-privacy/'
  51. );
  52. });
  53. });