default.spec.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 {Default} from 'sentry/components/events/interfaces/breadcrumbs/breadcrumb/data/default';
  5. import ProjectsStore from 'sentry/stores/projectsStore';
  6. import {BreadcrumbLevelType, BreadcrumbType} from 'sentry/types/breadcrumbs';
  7. describe('Breadcrumb Data Default', function () {
  8. const project = TestStubs.Project({
  9. id: '0',
  10. relayPiiConfig: JSON.stringify(TestStubs.DataScrubbingRelayPiiConfig()),
  11. });
  12. const {organization, router} = initializeOrg({
  13. router: {
  14. location: {query: {project: '0'}},
  15. },
  16. project: '0',
  17. projects: [project],
  18. });
  19. ProjectsStore.loadInitialData([project]);
  20. it('display redacted message', async function () {
  21. render(
  22. <Default
  23. meta={{
  24. message: {
  25. '': {
  26. rem: [['project:0', 's', 0, 0]],
  27. len: 19,
  28. chunks: [
  29. {
  30. type: 'redaction',
  31. text: '',
  32. rule_id: 'project:0',
  33. remark: 's',
  34. },
  35. ],
  36. },
  37. },
  38. }}
  39. event={TestStubs.Event()}
  40. orgSlug="org-slug"
  41. searchTerm=""
  42. breadcrumb={{
  43. type: BreadcrumbType.DEBUG,
  44. timestamp: '2017-08-04T07:52:11Z',
  45. level: BreadcrumbLevelType.INFO,
  46. message: '',
  47. category: 'started',
  48. data: {
  49. controller: '<sentry_ios_cocoapods.ViewController: 0x100e09ec0>',
  50. },
  51. event_id: null,
  52. }}
  53. />,
  54. {
  55. organization,
  56. router,
  57. }
  58. );
  59. expect(
  60. screen.getByText('<sentry_ios_cocoapods.ViewController: 0x100e09ec0>')
  61. ).toBeInTheDocument();
  62. await userEvent.hover(screen.getByText(/redacted/));
  63. expect(
  64. await screen.findByText(
  65. textWithMarkupMatcher(
  66. 'Replaced because of the data scrubbing rule [Replace] [Password fields] with [Scrubbed] from [password] in the settings of the project project-slug'
  67. )
  68. )
  69. ).toBeInTheDocument(); // tooltip description
  70. });
  71. it('display redacted data', async function () {
  72. render(
  73. <Default
  74. meta={{
  75. data: {
  76. '': {
  77. rem: [['project:0', 'x']],
  78. },
  79. },
  80. }}
  81. event={TestStubs.Event()}
  82. orgSlug="org-slug"
  83. searchTerm=""
  84. breadcrumb={{
  85. type: BreadcrumbType.DEBUG,
  86. timestamp: '2017-08-04T07:52:11Z',
  87. level: BreadcrumbLevelType.INFO,
  88. message: '',
  89. category: 'started',
  90. data: null,
  91. event_id: null,
  92. }}
  93. />,
  94. {organization, router}
  95. );
  96. expect(
  97. screen.queryByText('<sentry_ios_cocoapods.ViewController: 0x100e09ec0>')
  98. ).not.toBeInTheDocument();
  99. await userEvent.hover(screen.getByText(/redacted/));
  100. expect(
  101. await screen.findByText(
  102. textWithMarkupMatcher(
  103. 'Removed because of the data scrubbing rule [Replace] [Password fields] with [Scrubbed] from [password] in the settings of the project project-slug'
  104. )
  105. )
  106. ).toBeInTheDocument(); // tooltip description
  107. });
  108. });