index.spec.tsx 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  3. import {TraceEventContext} from 'sentry/components/events/contexts/trace';
  4. import {OrganizationContext} from 'sentry/views/organizationContext';
  5. export const traceMockData = {
  6. trace_id: '61d2d7c5acf448ffa8e2f8f973e2cd36',
  7. span_id: 'a5702f287954a9ef',
  8. parent_span_id: 'b23703998ae619e7',
  9. op: 'something',
  10. status: 'unknown',
  11. type: 'trace',
  12. };
  13. export const traceContextMetaMockData = {
  14. op: {
  15. '': {
  16. rem: [['project:1', 's', 0, 0]],
  17. len: 9,
  18. },
  19. },
  20. };
  21. const event = {
  22. ...TestStubs.Event(),
  23. _meta: {
  24. contexts: {
  25. trace: traceContextMetaMockData,
  26. },
  27. },
  28. };
  29. describe('trace event context', function () {
  30. const {organization} = initializeOrg();
  31. const data = {
  32. tags: {
  33. url: 'https://github.com/getsentry/sentry/',
  34. },
  35. };
  36. it('renders text url as a link', function () {
  37. render(
  38. <OrganizationContext.Provider value={organization}>
  39. <TraceEventContext data={data} event={event} />
  40. </OrganizationContext.Provider>
  41. );
  42. expect(screen.getByRole('link', {name: 'Open link'})).toHaveAttribute(
  43. 'href',
  44. data.tags.url
  45. );
  46. });
  47. it('display redacted data', async function () {
  48. render(
  49. <OrganizationContext.Provider value={organization}>
  50. <TraceEventContext data={data} event={event} />
  51. </OrganizationContext.Provider>
  52. );
  53. expect(screen.getByText('Operation Name')).toBeInTheDocument(); // subject
  54. expect(screen.getByText(/redacted/)).toBeInTheDocument(); // value
  55. userEvent.hover(screen.getByText(/redacted/));
  56. expect(
  57. await screen.findByText('Replaced because of PII rule "project:1"')
  58. ).toBeInTheDocument(); // tooltip description
  59. });
  60. });