openInContextLine.spec.tsx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import {GroupFixture} from 'sentry-fixture/group';
  2. import {SentryAppInstallationFixture} from 'sentry-fixture/sentryAppInstallation';
  3. import {render, screen} from 'sentry-test/reactTestingLibrary';
  4. import {OpenInContextLine} from 'sentry/components/events/interfaces/frame/openInContextLine';
  5. import type {SentryAppComponent, SentryAppSchemaStacktraceLink} from 'sentry/types';
  6. import {addQueryParamsToExistingUrl} from 'sentry/utils/queryString';
  7. describe('OpenInContextLine', function () {
  8. const filename = '/sentry/app.py';
  9. const group = GroupFixture();
  10. const install = SentryAppInstallationFixture();
  11. const components: SentryAppComponent<SentryAppSchemaStacktraceLink>[] = [
  12. {
  13. uuid: 'ed517da4-a324-44c0-aeea-1894cd9923fb',
  14. type: 'stacktrace-link',
  15. schema: {
  16. uri: '/redirection',
  17. url: `http://localhost:5000/redirection?installationId=${install.uuid}&projectSlug=${group.project.slug}`,
  18. type: 'stacktrace-link',
  19. },
  20. sentryApp: {
  21. uuid: 'b468fed3-afba-4917-80d6-bdac99c1ec05',
  22. slug: 'foo',
  23. name: 'Foo',
  24. avatars: [],
  25. },
  26. },
  27. {
  28. uuid: 'dd9cc6d7-17f9-4d25-9017-4802821e694f',
  29. type: 'stacktrace-link',
  30. schema: {
  31. url: 'http://localhost:4000/something?installationId=25d10adb-7b89-45ac-99b5-edaa714341ba&projectSlug=internal',
  32. type: 'stacktrace-link',
  33. params: ['project', 'filename', 'lineno'],
  34. uri: '/something',
  35. },
  36. sentryApp: {
  37. uuid: '92cd01e6-0ca0-4bfc-8dcd-38fdc8960cf6',
  38. name: 'Tesla',
  39. slug: 'tesla',
  40. avatars: [],
  41. },
  42. },
  43. ];
  44. const lineNo = 233;
  45. describe('with stacktrace-link component', function () {
  46. it('renders multiple buttons', function () {
  47. render(
  48. <OpenInContextLine filename={filename} lineNo={lineNo} components={components} />
  49. );
  50. const baseUrl = 'http://localhost:5000/redirection';
  51. const queryParams = {
  52. installationId: install.uuid,
  53. projectSlug: group.project.slug,
  54. lineNo,
  55. filename,
  56. };
  57. const url = addQueryParamsToExistingUrl(baseUrl, queryParams);
  58. expect(screen.getByRole('link', {name: 'Foo'})).toHaveAttribute('href', url);
  59. expect(screen.getByRole('link', {name: 'Tesla'})).toHaveAttribute(
  60. 'href',
  61. 'http://localhost:4000/something?filename=%2Fsentry%2Fapp.py&installationId=25d10adb-7b89-45ac-99b5-edaa714341ba&lineNo=233&projectSlug=internal'
  62. );
  63. expect(screen.getByRole('link', {name: 'Foo'})).toHaveTextContent('');
  64. expect(screen.getByRole('link', {name: 'Tesla'})).toHaveTextContent('');
  65. });
  66. });
  67. });