pluginDetailedView.spec.jsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import * as modal from 'sentry/actionCreators/modal';
  3. import {Client} from 'sentry/api';
  4. import PluginDetailedView from 'sentry/views/organizationIntegrations/pluginDetailedView';
  5. const mockResponse = mocks => {
  6. mocks.forEach(([url, body]) =>
  7. Client.addMockResponse({
  8. url,
  9. body,
  10. })
  11. );
  12. };
  13. describe('PluginDetailedView', function () {
  14. const org = TestStubs.Organization();
  15. let wrapper;
  16. beforeEach(() => {
  17. Client.clearMockResponses();
  18. mockResponse([
  19. [
  20. `/organizations/${org.slug}/plugins/configs/?plugins=pagerduty`,
  21. [
  22. {
  23. status: 'unknown',
  24. description: 'Send alerts to PagerDuty.',
  25. isTestable: true,
  26. isHidden: true,
  27. hasConfiguration: true,
  28. features: [],
  29. shortName: 'PagerDuty',
  30. id: 'pagerduty',
  31. assets: [],
  32. featureDescriptions: [],
  33. name: 'PagerDuty',
  34. author: {url: 'https://github.com/getsentry/sentry', name: 'Sentry Team'},
  35. contexts: [],
  36. doc: '',
  37. resourceLinks: [
  38. {url: 'https://github.com/getsentry/sentry/issues', title: 'Report Issue'},
  39. {
  40. url: 'https://github.com/getsentry/sentry/tree/master/src/sentry_plugins',
  41. title: 'View Source',
  42. },
  43. ],
  44. slug: 'pagerduty',
  45. projectList: [
  46. {
  47. projectId: 2,
  48. configured: true,
  49. enabled: true,
  50. projectSlug: 'javascript',
  51. projectPlatform: 'javascript',
  52. projectName: 'JavaScript',
  53. },
  54. ],
  55. version: '10.1.0.dev0',
  56. canDisable: true,
  57. type: 'notification',
  58. metadata: {},
  59. },
  60. ],
  61. ],
  62. ]);
  63. wrapper = mountWithTheme(
  64. <PluginDetailedView
  65. params={{integrationSlug: 'pagerduty', orgId: org.slug}}
  66. location={{query: {}}}
  67. />
  68. );
  69. });
  70. it('shows the Integration name and install status', function () {
  71. expect(wrapper.find('Name').props().children).toEqual('PagerDuty (Legacy)');
  72. expect(wrapper.find('IntegrationStatus').props().status).toEqual('Installed');
  73. });
  74. it('shows the Add to Project button', function () {
  75. expect(wrapper.find('AddButton').props().disabled).toEqual(false);
  76. expect(wrapper.find('AddButton').props().children).toEqual('Add to Project');
  77. });
  78. it('onClick', function () {
  79. modal.openModal = jest.fn();
  80. wrapper.find('AddButton').simulate('click');
  81. expect(modal.openModal).toHaveBeenCalled();
  82. });
  83. it('view configurations', function () {
  84. wrapper = mountWithTheme(
  85. <PluginDetailedView
  86. params={{integrationSlug: 'pagerduty', orgId: org.slug}}
  87. location={{query: {tab: 'configurations'}}}
  88. />
  89. );
  90. expect(wrapper.find('InstalledPlugin')).toHaveLength(1);
  91. });
  92. });