index.spec.tsx 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  2. import {BrowserEventContext} from 'sentry/components/events/contexts/browser';
  3. export const browserMockData = {
  4. version: '83.0.4103',
  5. type: 'browser',
  6. name: '',
  7. };
  8. export const browserMetaMockData = {
  9. name: {
  10. '': {
  11. chunks: [
  12. {
  13. remark: 'x',
  14. rule_id: 'project:0',
  15. text: '',
  16. type: 'redaction',
  17. },
  18. ],
  19. len: 7,
  20. rem: [['project:0', 'x', 0, 0]],
  21. },
  22. },
  23. };
  24. const event = {
  25. ...TestStubs.Event(),
  26. _meta: {
  27. contexts: {
  28. browser: browserMetaMockData,
  29. },
  30. },
  31. };
  32. describe('browser event context', function () {
  33. it('display redacted data', async function () {
  34. render(<BrowserEventContext event={event} data={browserMockData} />);
  35. expect(screen.getByText('Name')).toBeInTheDocument(); // subject
  36. expect(screen.getByText(/redacted/)).toBeInTheDocument(); // value
  37. userEvent.hover(screen.getByText(/redacted/));
  38. expect(
  39. await screen.findByText('Removed because of PII rule "project:0"')
  40. ).toBeInTheDocument(); // tooltip description
  41. });
  42. });