useRecommendedSdkUpgrades.spec.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import {reactHooks} from 'sentry-test/reactTestingLibrary';
  2. import ProjectsStore from 'sentry/stores/projectsStore';
  3. import {ServerSideSamplingStore} from 'sentry/stores/serverSideSamplingStore';
  4. import {useRecommendedSdkUpgrades} from 'sentry/views/settings/project/server-side-sampling/utils/useRecommendedSdkUpgrades';
  5. import {mockedSamplingSdkVersions} from '../testUtils';
  6. describe('useRecommendedSdkUpgrades', function () {
  7. it('works', function () {
  8. ProjectsStore.loadInitialData([
  9. TestStubs.Project({id: '1', slug: 'sentry'}),
  10. TestStubs.Project({id: '2', slug: 'java'}),
  11. TestStubs.Project({id: '3', slug: 'angular'}),
  12. TestStubs.Project({id: '4', slug: 'javascript'}),
  13. ]);
  14. ServerSideSamplingStore.sdkVersionsRequestSuccess(mockedSamplingSdkVersions);
  15. const {result} = reactHooks.renderHook(useRecommendedSdkUpgrades, {
  16. initialProps: {organization: TestStubs.Organization(), projectId: '3'},
  17. });
  18. expect(result.current.recommendedSdkUpgrades.length).toBe(2);
  19. expect(result.current.recommendedSdkUpgrades).toEqual([
  20. {
  21. latestSDKName: 'sentry.java',
  22. latestSDKVersion: '1.0.2',
  23. project: expect.objectContaining({
  24. features: [],
  25. slug: 'java',
  26. }),
  27. },
  28. {
  29. latestSDKName: 'sentry.python',
  30. latestSDKVersion: '1.0.2',
  31. project: expect.objectContaining({
  32. features: [],
  33. slug: 'sentry',
  34. }),
  35. },
  36. ]);
  37. expect(result.current.incompatibleProjects.length).toBe(1);
  38. expect(result.current.incompatibleProjects).toEqual([
  39. expect.objectContaining({
  40. features: [],
  41. slug: 'angular',
  42. }),
  43. ]);
  44. expect(result.current.isProjectIncompatible).toBe(true);
  45. expect(result.current.affectedProjects.length).toBe(4);
  46. });
  47. });