state.spec.tsx 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  2. import {textWithMarkupMatcher} from 'sentry-test/utils';
  3. import {StateEventContext} from 'sentry/components/events/contexts/state';
  4. describe('StateContext', function () {
  5. it('renders', function () {
  6. render(
  7. <StateEventContext
  8. data={{
  9. state: {
  10. type: 'redux',
  11. value: {
  12. a: 'abc',
  13. },
  14. },
  15. otherState: {
  16. value: {
  17. b: 'bcd',
  18. },
  19. },
  20. }}
  21. event={TestStubs.Event()}
  22. />
  23. );
  24. expect(screen.getByText('State (Redux)')).toBeInTheDocument();
  25. expect(screen.getByText('otherState')).toBeInTheDocument();
  26. expect(screen.getByText(textWithMarkupMatcher('{a: abc}'))).toBeInTheDocument();
  27. expect(screen.getByText(textWithMarkupMatcher('{b: bcd}'))).toBeInTheDocument();
  28. });
  29. it('display redacted data', async function () {
  30. const event = {
  31. ...TestStubs.Event(),
  32. _meta: {
  33. contexts: {
  34. state: {
  35. state: {
  36. value: {
  37. '': {
  38. rem: [['project:1', 's', 0, 0]],
  39. len: 25,
  40. },
  41. },
  42. },
  43. },
  44. },
  45. },
  46. };
  47. render(
  48. <StateEventContext
  49. data={{
  50. state: {
  51. type: 'redux',
  52. value: null,
  53. },
  54. otherState: {
  55. value: {
  56. b: 'bcd',
  57. },
  58. },
  59. }}
  60. event={event}
  61. />
  62. );
  63. expect(screen.getByText('State (Redux)')).toBeInTheDocument();
  64. userEvent.hover(screen.getByText('None'));
  65. expect(
  66. await screen.findByText('Replaced because of PII rule "project:1"')
  67. ).toBeInTheDocument(); // tooltip description
  68. });
  69. });