platform.spec.tsx 2.0 KB

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