helpSearchModal.spec.jsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import {initializeOrg} from 'sentry-test/initializeOrg';
  3. import {openHelpSearchModal} from 'sentry/actionCreators/modal';
  4. import App from 'sentry/views/app';
  5. describe('Docs Search Modal', function () {
  6. beforeEach(function () {
  7. MockApiClient.clearMockResponses();
  8. MockApiClient.addMockResponse({
  9. url: '/organizations/',
  10. body: [TestStubs.Organization({slug: 'billy-org', name: 'billy org'})],
  11. });
  12. MockApiClient.addMockResponse({
  13. url: '/organizations/org-slug/projects/',
  14. query: 'foo',
  15. body: [TestStubs.Project({slug: 'foo-project'})],
  16. });
  17. MockApiClient.addMockResponse({
  18. url: '/organizations/org-slug/teams/',
  19. query: 'foo',
  20. body: [TestStubs.Team({slug: 'foo-team'})],
  21. });
  22. MockApiClient.addMockResponse({
  23. url: '/organizations/org-slug/members/',
  24. query: 'foo',
  25. body: TestStubs.Members(),
  26. });
  27. MockApiClient.addMockResponse({
  28. url: '/organizations/org-slug/plugins/?plugins=_all',
  29. query: 'foo',
  30. body: [],
  31. });
  32. MockApiClient.addMockResponse({
  33. url: '/organizations/org-slug/config/integrations/',
  34. query: 'foo',
  35. body: [],
  36. });
  37. MockApiClient.addMockResponse({
  38. url: '/internal/health/',
  39. body: {
  40. problems: [],
  41. },
  42. });
  43. MockApiClient.addMockResponse({
  44. url: '/assistant/',
  45. body: [],
  46. });
  47. });
  48. it('can open help search modal', async function () {
  49. const {routerContext} = initializeOrg();
  50. const wrapper = mountWithTheme(
  51. <App params={{orgId: 'org-slug'}}>{<div>placeholder content</div>}</App>,
  52. routerContext
  53. );
  54. // No Modal
  55. expect(wrapper.find('Modal')).toHaveLength(0);
  56. openHelpSearchModal();
  57. await tick();
  58. await tick();
  59. wrapper.update();
  60. // Should have Modal + input
  61. expect(wrapper.find('Modal')).toHaveLength(1);
  62. expect(wrapper.find('HelpSearch')).toHaveLength(1);
  63. });
  64. });