modulesOnboarding.spec.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {render, screen, waitForElementToBeRemoved} from 'sentry-test/reactTestingLibrary';
  3. import {MutableSearch} from 'sentry/utils/tokenizeSearch';
  4. import {ModulesOnboarding} from './modulesOnboarding';
  5. describe('ModulesOnboarding', () => {
  6. const organization = OrganizationFixture();
  7. afterEach(() => {
  8. jest.resetAllMocks();
  9. });
  10. it('renders children correctly', async () => {
  11. const eventsMock = MockApiClient.addMockResponse({
  12. url: `/organizations/${organization.slug}/events/`,
  13. method: 'GET',
  14. body: {data: [{'count()': 1}]},
  15. });
  16. render(
  17. <ModulesOnboarding
  18. moduleQueryFilter={new MutableSearch('')}
  19. onboardingContent={<div>Start collecting Insights!</div>}
  20. referrer=""
  21. >
  22. <div>Module Content</div>
  23. </ModulesOnboarding>
  24. );
  25. expect(eventsMock).toHaveBeenCalled();
  26. await waitForElementToBeRemoved(() => screen.queryAllByTestId('loading-indicator'));
  27. await screen.getByText('Module Content');
  28. });
  29. it('renders onboarding content correctly', async () => {
  30. const eventsMock = MockApiClient.addMockResponse({
  31. url: `/organizations/${organization.slug}/events/`,
  32. method: 'GET',
  33. body: {data: []},
  34. });
  35. render(
  36. <ModulesOnboarding
  37. moduleQueryFilter={new MutableSearch('')}
  38. onboardingContent={<div>Start collecting Insights!</div>}
  39. referrer=""
  40. >
  41. <div>Module Content</div>
  42. </ModulesOnboarding>
  43. );
  44. expect(eventsMock).toHaveBeenCalled();
  45. await waitForElementToBeRemoved(() => screen.queryAllByTestId('loading-indicator'));
  46. await screen.findByText('Start collecting Insights!');
  47. });
  48. });