onboarding.spec.jsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import OrganizationStore from 'sentry/stores/organizationStore';
  4. import {PersistedStoreProvider} from 'sentry/stores/persistedStore';
  5. import ProjectsStore from 'sentry/stores/projectsStore';
  6. import Onboarding from 'sentry/views/onboarding/onboarding';
  7. describe('Onboarding', function () {
  8. afterEach(function () {
  9. MockApiClient.clearMockResponses();
  10. });
  11. it('renders the welcome page', function () {
  12. const {router, routerContext} = initializeOrg({
  13. router: {
  14. params: {
  15. step: 'welcome',
  16. },
  17. },
  18. });
  19. render(
  20. <PersistedStoreProvider>
  21. <Onboarding {...router} />
  22. </PersistedStoreProvider>,
  23. {
  24. context: routerContext,
  25. }
  26. );
  27. expect(screen.getByLabelText('Start')).toBeInTheDocument();
  28. expect(screen.getByLabelText('Invite Team')).toBeInTheDocument();
  29. });
  30. it('renders the select platform step', async () => {
  31. const {organization, router, routerContext} = initializeOrg({
  32. router: {
  33. params: {
  34. step: 'select-platform',
  35. },
  36. },
  37. });
  38. MockApiClient.addMockResponse({
  39. url: `/organizations/${organization.slug}/client-state/`,
  40. body: {},
  41. });
  42. OrganizationStore.onUpdate(organization);
  43. render(
  44. <PersistedStoreProvider>
  45. <Onboarding {...router} />
  46. </PersistedStoreProvider>,
  47. {
  48. context: routerContext,
  49. }
  50. );
  51. expect(
  52. await screen.findByText('Select the platforms you want to monitor')
  53. ).toBeInTheDocument();
  54. });
  55. it('renders the setup docs step', async () => {
  56. const projects = [
  57. TestStubs.Project({
  58. platform: 'javascript-react',
  59. id: '4',
  60. slug: 'javascript-reactslug',
  61. }),
  62. TestStubs.Project({platform: 'ruby', id: '5', slug: 'ruby-slug'}),
  63. TestStubs.Project({
  64. platform: 'javascript-nextjs',
  65. id: '6',
  66. slug: 'javascript-nextslug',
  67. }),
  68. ];
  69. const {organization, router, routerContext} = initializeOrg({
  70. projects,
  71. router: {
  72. params: {
  73. step: 'setup-docs',
  74. },
  75. },
  76. });
  77. MockApiClient.addMockResponse({
  78. url: `/organizations/${organization.slug}/client-state/`,
  79. body: {
  80. onboarding: {
  81. platformToProjectIdMap: {
  82. 'javascript-react': projects[0].slug,
  83. ruby: projects[1].slug,
  84. 'javascript-nextjs': projects[2].slug,
  85. },
  86. selectedPlatforms: ['ruby', 'javascript-nextjs'],
  87. },
  88. },
  89. });
  90. MockApiClient.addMockResponse({
  91. url: `/projects/${organization.slug}/ruby-slug/`,
  92. body: {
  93. firstEvent: false,
  94. },
  95. });
  96. MockApiClient.addMockResponse({
  97. url: `/projects/${organization.slug}/javascript-nextslug/docs/javascript-nextjs/`,
  98. body: null,
  99. });
  100. MockApiClient.addMockResponse({
  101. url: `/projects/${organization.slug}/ruby-slug/docs/ruby/`,
  102. body: null,
  103. });
  104. MockApiClient.addMockResponse({
  105. url: `/projects/${organization.slug}/ruby-slug/issues/`,
  106. body: [],
  107. });
  108. ProjectsStore.loadInitialData(projects);
  109. OrganizationStore.onUpdate(organization);
  110. render(
  111. <PersistedStoreProvider>
  112. <Onboarding {...router} />
  113. </PersistedStoreProvider>,
  114. {
  115. context: routerContext,
  116. }
  117. );
  118. expect(await screen.findAllByTestId('sidebar-error-indicator')).toHaveLength(2);
  119. });
  120. });