message.spec.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 {Message} from 'sentry/components/events/interfaces/message';
  5. import {OrganizationContext} from 'sentry/views/organizationContext';
  6. import {RouteContext} from 'sentry/views/routeContext';
  7. describe('Message entry', 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. entries: [
  19. {
  20. type: 'message',
  21. data: {
  22. formatted: null,
  23. },
  24. },
  25. ],
  26. _meta: {
  27. entries: {
  28. 0: {
  29. data: {
  30. formatted: {'': {rem: [['organization:0', 'x']]}},
  31. },
  32. },
  33. },
  34. },
  35. };
  36. render(
  37. <OrganizationContext.Provider value={organization}>
  38. <RouteContext.Provider
  39. value={{
  40. router,
  41. location: router.location,
  42. params: {},
  43. routes: [],
  44. }}
  45. >
  46. <Message data={{formatted: null}} event={event} />
  47. </RouteContext.Provider>
  48. </OrganizationContext.Provider>
  49. );
  50. expect(screen.getByText(/redacted/)).toBeInTheDocument();
  51. userEvent.hover(screen.getByText(/redacted/));
  52. expect(
  53. await screen.findByText(
  54. textWithMarkupMatcher(
  55. 'Removed because of the PII rule [Replace] [Password fields] with [Scrubbed] from [password] in the settings of the organization org-slug'
  56. )
  57. )
  58. ).toBeInTheDocument(); // tooltip description
  59. expect(
  60. screen.getByRole('link', {
  61. name: '[Replace] [Password fields] with [Scrubbed] from [password]',
  62. })
  63. ).toHaveAttribute(
  64. 'href',
  65. '/settings/org-slug/security-and-privacy/#advanced-data-scrubbing'
  66. );
  67. expect(screen.getByRole('link', {name: 'org-slug'})).toHaveAttribute(
  68. 'href',
  69. '/settings/org-slug/security-and-privacy/#advanced-data-scrubbing'
  70. );
  71. });
  72. });