openInContextLine.spec.jsx 2.3 KB

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