frameVariables.spec.tsx 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 {FrameVariables} from 'sentry/components/events/interfaces/frame/frameVariables';
  5. import ProjectsStore from 'sentry/stores/projectsStore';
  6. describe('Frame Variables', function () {
  7. it('renders', async function () {
  8. const project = TestStubs.Project({
  9. id: '0',
  10. relayPiiConfig: JSON.stringify(TestStubs.DataScrubbingRelayPiiConfig()),
  11. });
  12. const {organization, router, routerContext} = initializeOrg({
  13. ...initializeOrg(),
  14. router: {
  15. location: {query: {project: '0'}},
  16. },
  17. project: '0',
  18. projects: [project],
  19. });
  20. ProjectsStore.loadInitialData([project]);
  21. render(
  22. <FrameVariables
  23. data={{
  24. "'client'": '',
  25. "'data'": null,
  26. "'k'": '',
  27. "'options'": {
  28. "'data'": null,
  29. "'tags'": null,
  30. },
  31. }}
  32. meta={{
  33. "'client'": {
  34. '': {
  35. rem: [['project:0', 's', 0, 0]],
  36. len: 41,
  37. chunks: [
  38. {
  39. type: 'redaction',
  40. text: '',
  41. rule_id: 'project:0',
  42. remark: 's',
  43. },
  44. ],
  45. },
  46. },
  47. "'k'": {
  48. '': {
  49. rem: [['project:0', 's', 0, 0]],
  50. len: 12,
  51. chunks: [
  52. {
  53. type: 'redaction',
  54. text: '',
  55. rule_id: 'project:0',
  56. remark: 's',
  57. },
  58. ],
  59. },
  60. },
  61. }}
  62. />,
  63. {organization, router, context: routerContext}
  64. );
  65. expect(screen.getAllByText(/redacted/)).toHaveLength(2);
  66. userEvent.hover(screen.getAllByText(/redacted/)[0]);
  67. expect(
  68. await screen.findByText(
  69. textWithMarkupMatcher(
  70. 'Replaced because of the data scrubbing rule [Replace] [Password fields] with [Scrubbed] from [password] in the settings of the project project-slug'
  71. )
  72. )
  73. ).toBeInTheDocument(); // tooltip description
  74. expect(
  75. screen.getByRole('link', {
  76. name: '[Replace] [Password fields] with [Scrubbed] from [password]',
  77. })
  78. ).toHaveAttribute(
  79. 'href',
  80. '/settings/org-slug/projects/project-slug/security-and-privacy/advanced-data-scrubbing/0/'
  81. );
  82. expect(screen.getByRole('link', {name: 'project-slug'})).toHaveAttribute(
  83. 'href',
  84. '/settings/org-slug/projects/project-slug/security-and-privacy/'
  85. );
  86. });
  87. });