message.spec.tsx 1.8 KB

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