sanitizePath.spec.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import {sanitizePath} from 'sentry/utils/requestError/sanitizePath';
  2. describe('sanitizePath', function () {
  3. test.each([
  4. // /organizations/ endpoints
  5. ['/organizations/sentry-test/issues/', '/organizations/{orgSlug}/issues/'],
  6. ['/organizations/sentry-test/issues/123/', '/organizations/{orgSlug}/issues/123/'],
  7. // https://github.com/getsentry/sentry/blob/8d4482f01aa2122c6f6670ab84f9263e6f021467/src/sentry/api/urls.py#L1004
  8. // r"^(?P<organization_slug>[^\/]+)/events/(?P<project_slug>[^\/]+):(?P<event_id>(?:\d+|[A-Fa-f0-9-]{32,36}))/$",
  9. [
  10. '/organizations/sentry-test/events/project-test:123/',
  11. '/organizations/{orgSlug}/events/{projectSlug}:123/',
  12. ],
  13. // https://github.com/getsentry/sentry/blob/8d4482f01aa2122c6f6670ab84f9263e6f021467/src/sentry/api/urls.py#L1235
  14. // r"^(?P<organization_slug>[^\/]+)/members/(?P<member_id>[^\/]+)/teams/(?P<team_slug>[^\/]+)/$",
  15. [
  16. '/organizations/sentry-test/members/123/teams/team-test/',
  17. '/organizations/{orgSlug}/members/123/teams/{teamSlug}/',
  18. ],
  19. [
  20. 'https://sentry.io/api/0/organizations/sentry-test/issues/123/',
  21. 'https://sentry.io/api/0/organizations/{orgSlug}/issues/123/',
  22. ],
  23. // /projects/ endpoints
  24. [
  25. '/projects/sentry-test/project-test/alert-rules/123/',
  26. '/projects/{orgSlug}/{projectSlug}/alert-rules/123/',
  27. ],
  28. [
  29. 'https://sentry.io/api/0/projects/sentry-test/project-test/alert-rules/123/',
  30. 'https://sentry.io/api/0/projects/{orgSlug}/{projectSlug}/alert-rules/123/',
  31. ],
  32. // https://github.com/getsentry/sentry/blob/8d4482f01aa2122c6f6670ab84f9263e6f021467/src/sentry/api/urls.py#L1894
  33. // r"^(?P<organization_slug>[^\/]+)/(?P<project_slug>[^\/]+)/teams/(?P<team_slug>[^\/]+)/$",
  34. [
  35. '/projects/sentry-test/project-test/teams/test-team/',
  36. '/projects/{orgSlug}/{projectSlug}/teams/{teamSlug}/',
  37. ],
  38. // XXX: This should probably be an organization endpoint...
  39. // https://github.com/getsentry/sentry/blob/8d4482f01aa2122c6f6670ab84f9263e6f021467/src/sentry/api/urls.py#L1595
  40. // r"^(?P<organization_slug>[^\/]+)/rule-conditions/$",
  41. ['/projects/sentry-test/rule-conditions/', '/projects/{orgSlug}/rule-conditions/'],
  42. [
  43. '/teams/sentry-test/team-test/release-count/',
  44. '/teams/{orgSlug}/{teamSlug}/release-count/',
  45. ],
  46. [
  47. 'https://sentry.io/api/0/teams/sentry-test/team-test/release-count/',
  48. 'https://sentry.io/api/0/teams/{orgSlug}/{teamSlug}/release-count/',
  49. ],
  50. // customers is org-like
  51. ['/customers/sentry-test/', '/customers/{orgSlug}/'],
  52. ['/customers/sentry-test/issues/', '/customers/{orgSlug}/issues/'],
  53. ['/customers/sentry-test/issues/123/', '/customers/{orgSlug}/issues/123/'],
  54. ])('sanitizes %s', (path, expected) => {
  55. expect(sanitizePath(path)).toBe(expected);
  56. });
  57. });