sanitizePath.spec.tsx 2.9 KB

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