index.spec.tsx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  2. import {GPUEventContext} from 'sentry/components/events/contexts/gpu';
  3. import {GPUData} from 'sentry/components/events/contexts/gpu/types';
  4. export const gpuMockData: GPUData = {
  5. name: '',
  6. id: 0,
  7. vendor_id: 0,
  8. vendor_name: 'Apple',
  9. memory_size: 4096,
  10. api_type: '',
  11. multi_threaded_rendering: true,
  12. version: 'Metal',
  13. npot_support: 'Full',
  14. };
  15. export const gpuMetaMockData = {
  16. api_type: {
  17. '': {
  18. rem: [['project:7', 's', 0, 0]],
  19. len: 5,
  20. },
  21. },
  22. name: {
  23. '': {
  24. rem: [['project:6', 's', 0, 0]],
  25. len: 18,
  26. },
  27. },
  28. };
  29. const event = {
  30. ...TestStubs.Event(),
  31. _meta: {
  32. contexts: {
  33. gpu: gpuMetaMockData,
  34. },
  35. },
  36. };
  37. describe('gpu event context', function () {
  38. it('display redacted data', async function () {
  39. render(<GPUEventContext event={event} data={gpuMockData} />);
  40. expect(screen.getByText('API Type')).toBeInTheDocument(); // subject
  41. userEvent.hover(screen.getAllByText(/redacted/)[0]);
  42. expect(
  43. await screen.findByText('Replaced because of PII rule "project:7"')
  44. ).toBeInTheDocument(); // tooltip description
  45. expect(screen.getByText('Name')).toBeInTheDocument(); // subject
  46. userEvent.hover(screen.getAllByText(/redacted/)[1]);
  47. expect(
  48. await screen.findByText('Replaced because of PII rule "project:6"')
  49. ).toBeInTheDocument(); // tooltip description
  50. });
  51. });