index.spec.tsx 1.2 KB

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