index.spec.tsx 2.0 KB

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