http.spec.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 {Http} from 'sentry/components/events/interfaces/breadcrumbs/breadcrumb/data/http';
  5. import ProjectsStore from 'sentry/stores/projectsStore';
  6. import {BreadcrumbLevelType, BreadcrumbType} from 'sentry/types/breadcrumbs';
  7. describe('Breadcrumb Data Http', 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 url', async function () {
  21. render(
  22. <Http
  23. meta={{
  24. data: {
  25. url: {
  26. '': {
  27. rem: [['project:0', 's', 0, 0]],
  28. len: 19,
  29. chunks: [
  30. {
  31. type: 'redaction',
  32. text: '',
  33. rule_id: 'project:0',
  34. remark: 's',
  35. },
  36. ],
  37. },
  38. },
  39. },
  40. }}
  41. searchTerm=""
  42. breadcrumb={{
  43. type: BreadcrumbType.HTTP,
  44. level: BreadcrumbLevelType.INFO,
  45. data: {
  46. method: 'POST',
  47. url: '',
  48. status_code: 0,
  49. },
  50. }}
  51. />,
  52. {organization, router}
  53. );
  54. expect(screen.getByText('POST')).toBeInTheDocument();
  55. expect(screen.queryByText('http://example.com/foo')).not.toBeInTheDocument();
  56. await userEvent.hover(screen.getByText(/redacted/));
  57. expect(
  58. await screen.findByText(
  59. textWithMarkupMatcher(
  60. 'Replaced because of the data scrubbing rule [Replace] [Password fields] with [Scrubbed] from [password] in the settings of the project project-slug'
  61. )
  62. )
  63. ).toBeInTheDocument(); // tooltip description
  64. });
  65. it('display redacted data', async function () {
  66. render(
  67. <Http
  68. meta={{
  69. data: {
  70. '': {
  71. rem: [['project:0', 'x']],
  72. },
  73. },
  74. }}
  75. searchTerm=""
  76. breadcrumb={{
  77. type: BreadcrumbType.HTTP,
  78. level: BreadcrumbLevelType.INFO,
  79. data: null,
  80. }}
  81. />,
  82. {organization, router}
  83. );
  84. expect(screen.queryByText('http://example.com/foo')).not.toBeInTheDocument();
  85. await userEvent.hover(screen.getByText(/redacted/));
  86. expect(
  87. await screen.findByText(
  88. textWithMarkupMatcher(
  89. 'Removed because of the data scrubbing rule [Replace] [Password fields] with [Scrubbed] from [password] in the settings of the project project-slug'
  90. )
  91. )
  92. ).toBeInTheDocument(); // tooltip description
  93. });
  94. });