index.spec.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import {DataScrubbingRelayPiiConfigFixture} from 'sentry-fixture/dataScrubbingRelayPiiConfig';
  2. import {EventFixture} from 'sentry-fixture/event';
  3. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  4. import {textWithMarkupMatcher} from 'sentry-test/utils';
  5. import {DeviceEventContext} from 'sentry/components/events/contexts/device';
  6. import type {DeviceContext} from 'sentry/types/event';
  7. export const deviceMockData: DeviceContext = {
  8. screen_resolution: '1136x768',
  9. orientation: 'portrait',
  10. family: 'Android',
  11. battery_level: 100,
  12. screen_dpi: 480,
  13. memory_size: 1055186944,
  14. timezone: 'America/Los_Angeles',
  15. external_storage_size: 534761472,
  16. external_free_storage: 534702080,
  17. screen_width_pixels: 768,
  18. low_memory: false,
  19. simulator: true,
  20. screen_height_pixels: 1136,
  21. free_memory: 658702336,
  22. online: true,
  23. screen_density: 3,
  24. type: 'device',
  25. charging: true,
  26. model_id: 'NYC',
  27. brand: 'google',
  28. storage_size: 817143808,
  29. boot_time: '2019-12-11T11:38:15Z',
  30. arch: 'x86',
  31. manufacturer: 'Google',
  32. name: '', // redacted
  33. free_storage: 508784640,
  34. model: 'Android SDK built for x86',
  35. };
  36. export const deviceContextMetaMockData = {
  37. name: {
  38. '': {
  39. rem: [['organization:0', 's', 0, 0]],
  40. len: 25,
  41. },
  42. },
  43. };
  44. const event = EventFixture({
  45. _meta: {
  46. contexts: {
  47. device: deviceContextMetaMockData,
  48. },
  49. },
  50. });
  51. describe('device event context', function () {
  52. it('display redacted data', async function () {
  53. render(<DeviceEventContext event={event} data={deviceMockData} />, {
  54. organization: {
  55. relayPiiConfig: JSON.stringify(DataScrubbingRelayPiiConfigFixture()),
  56. },
  57. });
  58. expect(screen.getByText('Name')).toBeInTheDocument(); // subject
  59. expect(screen.getByText(/redacted/)).toBeInTheDocument(); // value
  60. await userEvent.hover(screen.getByText(/redacted/));
  61. expect(
  62. await screen.findByText(
  63. textWithMarkupMatcher(
  64. "Replaced because of the data scrubbing rule [Replace] [Password fields] with [Scrubbed] from [password] in your organization's settings"
  65. )
  66. )
  67. ).toBeInTheDocument(); // tooltip description
  68. });
  69. });