platform.spec.tsx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen, waitFor} from 'sentry-test/reactTestingLibrary';
  3. import {ProjectInstallPlatform} from 'sentry/views/projectInstall/platform';
  4. describe('ProjectInstallPlatform', function () {
  5. it('should render NotFound if no matching integration/platform', async function () {
  6. const routeParams = {
  7. projectId: TestStubs.Project().slug,
  8. platform: 'lua',
  9. };
  10. const {organization, router, route, project, routerContext} = initializeOrg({
  11. ...initializeOrg(),
  12. router: {
  13. location: {
  14. query: {},
  15. },
  16. params: routeParams,
  17. },
  18. });
  19. MockApiClient.addMockResponse({
  20. method: 'GET',
  21. url: '/organizations/org-slug/projects/',
  22. body: [project],
  23. });
  24. render(
  25. <ProjectInstallPlatform
  26. router={router}
  27. route={route}
  28. location={router.location}
  29. routeParams={routeParams}
  30. routes={router.routes}
  31. params={routeParams}
  32. />,
  33. {
  34. organization,
  35. context: routerContext,
  36. }
  37. );
  38. expect(await screen.findByText('Page Not Found')).toBeInTheDocument();
  39. });
  40. it('should redirect to if no matching platform', async function () {
  41. const routeParams = {
  42. projectId: TestStubs.Project().slug,
  43. platform: 'other',
  44. };
  45. const {organization, router, route, project, routerContext} = initializeOrg({
  46. ...initializeOrg(),
  47. router: {
  48. location: {
  49. query: {},
  50. },
  51. params: routeParams,
  52. },
  53. });
  54. MockApiClient.addMockResponse({
  55. method: 'GET',
  56. url: '/organizations/org-slug/projects/',
  57. body: [project],
  58. });
  59. render(
  60. <ProjectInstallPlatform
  61. router={router}
  62. route={route}
  63. location={router.location}
  64. routeParams={routeParams}
  65. routes={router.routes}
  66. params={routeParams}
  67. />,
  68. {
  69. organization,
  70. context: routerContext,
  71. }
  72. );
  73. await waitFor(() => {
  74. expect(router.push).toHaveBeenCalledTimes(1);
  75. });
  76. });
  77. });