index.spec.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  2. import {textWithMarkupMatcher} from 'sentry-test/utils';
  3. import {AppEventContext} from 'sentry/components/events/contexts/app';
  4. import {AppData} from 'sentry/components/events/contexts/app/types';
  5. export const appMockData: AppData = {
  6. device_app_hash: '2421fae1ac9237a8131e74883e52b0f7034a143f',
  7. build_type: 'test',
  8. app_identifier: 'io.sentry.sample.iOS-Swift',
  9. app_name: '',
  10. app_version: '7.1.3',
  11. app_build: '1',
  12. app_id: '3145EA1A-0EAE-3F8C-969A-13A01394D3EA',
  13. type: 'app',
  14. };
  15. export const appMetaMockData = {
  16. app_name: {
  17. '': {
  18. chunks: [
  19. {
  20. remark: 'x',
  21. rule_id: 'organization:0',
  22. text: '',
  23. type: 'redaction',
  24. },
  25. ],
  26. len: 9,
  27. rem: [['organization:0', 'x', 0, 0]],
  28. },
  29. },
  30. };
  31. const event = {
  32. ...TestStubs.Event(),
  33. _meta: {
  34. contexts: {
  35. app: appMetaMockData,
  36. },
  37. },
  38. };
  39. describe('app event context', function () {
  40. it('display redacted data', async function () {
  41. render(<AppEventContext event={event} data={appMockData} />, {
  42. organization: {
  43. relayPiiConfig: JSON.stringify(TestStubs.DataScrubbingRelayPiiConfig()),
  44. },
  45. });
  46. expect(screen.getByText('Build Name')).toBeInTheDocument(); // subject
  47. expect(screen.getByText(/redacted/)).toBeInTheDocument(); // value
  48. userEvent.hover(screen.getByText(/redacted/));
  49. expect(
  50. await screen.findByText(
  51. textWithMarkupMatcher(
  52. "Removed because of the data scrubbing rule [Replace] [Password fields] with [Scrubbed] from [password] in your organization's settings"
  53. )
  54. )
  55. ).toBeInTheDocument(); // tooltip description
  56. });
  57. });