index.spec.tsx 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 {OperatingSystemEventContext} from 'sentry/components/events/contexts/operatingSystem';
  6. export const operatingSystemMockData = {
  7. name: 'Mac OS X 10.14.0',
  8. version: '',
  9. raw_description: '',
  10. build: '',
  11. kernel_version: '',
  12. };
  13. export const operatingSystemMetaMockData = {
  14. raw_description: {
  15. '': {
  16. chunks: [
  17. {
  18. remark: 'x',
  19. rule_id: 'project:0',
  20. text: '',
  21. type: 'redaction',
  22. },
  23. ],
  24. len: 9,
  25. rem: [['organization:0', 'x', 0, 0]],
  26. },
  27. },
  28. };
  29. const event = EventFixture({
  30. _meta: {
  31. contexts: {
  32. os: operatingSystemMetaMockData,
  33. },
  34. },
  35. });
  36. describe('operating system event context', function () {
  37. it('display redacted data', async function () {
  38. render(<OperatingSystemEventContext event={event} data={operatingSystemMockData} />, {
  39. organization: {
  40. relayPiiConfig: JSON.stringify(DataScrubbingRelayPiiConfigFixture()),
  41. },
  42. });
  43. expect(screen.getByText('Raw Description')).toBeInTheDocument(); // subject
  44. await userEvent.hover(screen.getByText(/redacted/));
  45. expect(
  46. await screen.findByText(
  47. textWithMarkupMatcher(
  48. "Removed because of the data scrubbing rule [Replace] [Password fields] with [Scrubbed] from [password] in your organization's settings"
  49. )
  50. )
  51. ).toBeInTheDocument(); // tooltip description
  52. });
  53. });