app.spec.jsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import {render, screen} from 'sentry-test/reactTestingLibrary';
  2. import ConfigStore from 'sentry/stores/configStore';
  3. import App from 'sentry/views/app';
  4. describe('App', function () {
  5. beforeEach(function () {
  6. MockApiClient.addMockResponse({
  7. url: '/organizations/',
  8. body: [TestStubs.Organization({slug: 'billy-org', name: 'billy org'})],
  9. });
  10. MockApiClient.addMockResponse({
  11. url: '/internal/health/',
  12. body: {
  13. problems: [],
  14. },
  15. });
  16. MockApiClient.addMockResponse({
  17. url: '/assistant/',
  18. body: [],
  19. });
  20. MockApiClient.addMockResponse({
  21. url: '/internal/options/?query=is:required',
  22. body: TestStubs.InstallWizard(),
  23. });
  24. });
  25. it('renders', function () {
  26. render(
  27. <App params={{orgId: 'org-slug'}}>
  28. <div>placeholder content</div>
  29. </App>
  30. );
  31. expect(screen.getByText('placeholder content')).toBeInTheDocument();
  32. });
  33. it('renders NewsletterConsent', async function () {
  34. const user = ConfigStore.get('user');
  35. user.flags.newsletter_consent_prompt = true;
  36. render(
  37. <App params={{orgId: 'org-slug'}}>
  38. <div>placeholder content</div>
  39. </App>
  40. );
  41. const updatesViaEmail = await screen.findByText(
  42. 'Yes, I would like to receive updates via email'
  43. );
  44. expect(updatesViaEmail).toBeInTheDocument();
  45. user.flags.newsletter_consent_prompt = false;
  46. });
  47. it('renders InstallWizard', async function () {
  48. ConfigStore.get('user').isSuperuser = true;
  49. ConfigStore.set('needsUpgrade', true);
  50. ConfigStore.set('version', {current: '1.33.7'});
  51. render(
  52. <App params={{orgId: 'org-slug'}}>
  53. <div>placeholder content</div>
  54. </App>
  55. );
  56. const completeSetup = await screen.findByText(
  57. 'Complete setup by filling out the required configuration.'
  58. );
  59. expect(completeSetup).toBeInTheDocument();
  60. });
  61. });