index.spec.tsx 1.5 KB

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