helpSearch.spec.jsx 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import React from 'react';
  2. import {mountWithTheme} from 'sentry-test/enzyme';
  3. import HelpSearch from 'app/components/helpSearch';
  4. const mockResults = [
  5. {
  6. site: 'docs',
  7. name: 'Documentation',
  8. hits: [
  9. {
  10. id: 'SitePage /platforms/native/guides/minidumps/',
  11. site: 'docs',
  12. url: 'https://docs.sentry.io/platforms/native/guides/minidumps/',
  13. context: {context1: 'Platforms > Native > Guides > Minidumps'},
  14. title: 'Minidumps',
  15. text:
  16. 'Sentry can process Minidump crash reports, a memory <mark>dump</mark> used on Windows and by\nopen …',
  17. },
  18. {
  19. id: 'SitePage /product/discover-queries/query-builder/',
  20. site: 'docs',
  21. url: 'https://docs.sentry.io/product/discover-queries/query-builder/',
  22. context: {context1: 'Product > Discover Queries > Query Builder'},
  23. title: 'Query Builder',
  24. text:
  25. '… conditions, see Using OR & AND Conditions . Tag <mark>Summ</mark>ary Filters Every event has a list of …',
  26. },
  27. ],
  28. },
  29. {
  30. site: 'help-center',
  31. name: 'Help Center',
  32. hits: [],
  33. },
  34. {
  35. site: 'develop',
  36. name: 'Developer Documentation',
  37. hits: [
  38. {
  39. id: 'eee2b51a-7594-5f86-91db-267c15db5ef6',
  40. site: 'develop',
  41. url: 'https://develop.sentry.dev/services/digests/',
  42. context: {context1: 'Services > Digests'},
  43. title: 'Notification Digests',
  44. text:
  45. '… operation, especially on large data sets. Backends <mark>Dumm</mark>y Backend The <mark>dumm</mark>y backend disables digest scheduling …',
  46. },
  47. ],
  48. },
  49. {
  50. site: 'blog',
  51. name: 'Blog Posts',
  52. hits: [
  53. {
  54. id: 'ae61cfd6d4b462d24dd4622b8b7db274',
  55. site: 'blog',
  56. context: {context1: 'Building Sentry: Symbolicator'},
  57. url: 'https://blog.sentry.io/2019/06/13/building-a-sentry-symbolicator/',
  58. title: 'Stacking your cards frames',
  59. text:
  60. '… traces. Since iOS is particularly restrictive, we <mark>dump</mark>ed this information into a temporary location and …',
  61. },
  62. ],
  63. },
  64. ];
  65. jest.mock('@sentry-internal/global-search', () => ({
  66. SentryGlobalSearch: jest
  67. .fn()
  68. .mockImplementation(() => ({query: () => Promise.resolve(mockResults)})),
  69. }));
  70. describe('HelpSearch', function () {
  71. it('produces search results', async function () {
  72. const wrapper = mountWithTheme(
  73. <HelpSearch
  74. entryPoint="sidebar_help"
  75. renderInput={({getInputProps}) => <input {...getInputProps({type: 'text'})} />}
  76. />
  77. );
  78. wrapper.find('input').simulate('change', {target: {value: 'dummy'}});
  79. await tick();
  80. wrapper.update();
  81. expect(wrapper.find('SectionHeading')).toHaveLength(4);
  82. expect(wrapper.find('SearchResultWrapper')).toHaveLength(4);
  83. expect(wrapper.find('HighlightMarker')).toHaveLength(5);
  84. });
  85. });