index.spec.tsx 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  2. import {textWithMarkupMatcher} from 'sentry-test/utils';
  3. import {GPUEventContext} from 'sentry/components/events/contexts/gpu';
  4. import {GPUData} from 'sentry/components/events/contexts/gpu/types';
  5. export const gpuMockData: GPUData = {
  6. name: '',
  7. id: 0,
  8. vendor_id: 0,
  9. vendor_name: 'Apple',
  10. memory_size: 4096,
  11. api_type: '',
  12. multi_threaded_rendering: true,
  13. version: 'Metal',
  14. npot_support: 'Full',
  15. };
  16. export const gpuMetaMockData = {
  17. api_type: {
  18. '': {
  19. rem: [['organization:0', 's', 0, 0]],
  20. len: 5,
  21. },
  22. },
  23. name: {
  24. '': {
  25. rem: [['organization:0', 's', 0, 0]],
  26. len: 18,
  27. },
  28. },
  29. };
  30. const event = {
  31. ...TestStubs.Event(),
  32. _meta: {
  33. contexts: {
  34. gpu: gpuMetaMockData,
  35. },
  36. },
  37. };
  38. describe('gpu event context', function () {
  39. it('display redacted data', async function () {
  40. render(<GPUEventContext event={event} data={gpuMockData} />, {
  41. organization: {
  42. relayPiiConfig: JSON.stringify(TestStubs.DataScrubbingRelayPiiConfig()),
  43. },
  44. });
  45. expect(screen.getByText('API Type')).toBeInTheDocument(); // subject
  46. userEvent.hover(screen.getAllByText(/redacted/)[0]);
  47. expect(
  48. await screen.findByText(
  49. textWithMarkupMatcher(
  50. "Replaced because of the data scrubbing rule [Replace] [Password fields] with [Scrubbed] from [password] in your organization's settings"
  51. )
  52. )
  53. ).toBeInTheDocument(); // tooltip description
  54. expect(screen.getByText('Name')).toBeInTheDocument(); // subject
  55. userEvent.hover(screen.getAllByText(/redacted/)[1]);
  56. expect(
  57. await screen.findByText(
  58. textWithMarkupMatcher(
  59. "Replaced because of the data scrubbing rule [Replace] [Password fields] with [Scrubbed] from [password] in your organization's settings"
  60. )
  61. )
  62. ).toBeInTheDocument(); // tooltip description
  63. });
  64. });