integrationRow.spec.jsx 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. import {mountWithTheme} from 'sentry-test/enzyme';
  2. import {Client} from 'sentry/api';
  3. import IntegrationRow from 'sentry/views/organizationIntegrations/integrationRow';
  4. describe('IntegrationRow', function () {
  5. beforeEach(function () {
  6. Client.clearMockResponses();
  7. });
  8. const org = TestStubs.Organization();
  9. describe('SentryApp', function () {
  10. it('is an internal SentryApp', function () {
  11. const wrapper = mountWithTheme(
  12. <IntegrationRow
  13. organization={org}
  14. type="sentryApp"
  15. slug="my-headband-washer-289499"
  16. displayName="My Headband Washer"
  17. status="Installed"
  18. publishStatus="internal"
  19. configurations={0}
  20. data-test-id="integration-row"
  21. />
  22. );
  23. expect(wrapper.find('PluginIcon').props().pluginId).toEqual(
  24. 'my-headband-washer-289499'
  25. );
  26. expect(wrapper.find('IntegrationName').props().children).toEqual(
  27. 'My Headband Washer'
  28. );
  29. expect(wrapper.find('IntegrationName').props().to).toEqual(
  30. `/settings/${org.slug}/developer-settings/my-headband-washer-289499/`
  31. );
  32. expect(wrapper.find('IntegrationStatus').props().status).toEqual('Installed');
  33. expect(wrapper.find('PublishStatus').props().status).toEqual('internal');
  34. });
  35. it('is a published SentryApp', function () {
  36. const wrapper = mountWithTheme(
  37. <IntegrationRow
  38. organization={org}
  39. type="sentryApp"
  40. slug="clickup"
  41. displayName="ClickUp"
  42. status="Not Installed"
  43. publishStatus="published"
  44. configurations={0}
  45. data-test-id="integration-row"
  46. />
  47. );
  48. expect(wrapper.find('PluginIcon').props().pluginId).toEqual('clickup');
  49. expect(wrapper.find('IntegrationName').props().children).toEqual('ClickUp');
  50. expect(wrapper.find('IntegrationName').props().to).toEqual(
  51. `/settings/${org.slug}/sentry-apps/clickup/`
  52. );
  53. expect(wrapper.find('IntegrationStatus').props().status).toEqual('Not Installed');
  54. expect(wrapper.find('PublishStatus').exists()).toEqual(false);
  55. });
  56. });
  57. describe('First Party Integration', function () {
  58. it('has been installed (1 configuration)', function () {
  59. const wrapper = mountWithTheme(
  60. <IntegrationRow
  61. organization={org}
  62. type="firstParty"
  63. slug="bitbucket"
  64. displayName="Bitbucket"
  65. status="Installed"
  66. publishStatus="published"
  67. configurations={1}
  68. data-test-id="integration-row"
  69. />
  70. );
  71. expect(wrapper.find('PluginIcon').props().pluginId).toEqual('bitbucket');
  72. expect(wrapper.find('IntegrationName').props().children).toEqual('Bitbucket');
  73. expect(wrapper.find('IntegrationName').props().to).toEqual(
  74. `/settings/${org.slug}/integrations/bitbucket/`
  75. );
  76. expect(wrapper.find('IntegrationStatus').props().status).toEqual('Installed');
  77. expect(wrapper.find('PublishStatus').exists()).toEqual(false);
  78. expect(wrapper.find('StyledLink').props().children).toEqual('1 Configuration');
  79. });
  80. it('has been installed (3 configurations)', function () {
  81. const wrapper = mountWithTheme(
  82. <IntegrationRow
  83. organization={org}
  84. type="firstParty"
  85. slug="bitbucket"
  86. displayName="Bitbucket"
  87. status="Installed"
  88. publishStatus="published"
  89. configurations={3}
  90. data-test-id="integration-row"
  91. />
  92. );
  93. expect(wrapper.find('PluginIcon').props().pluginId).toEqual('bitbucket');
  94. expect(wrapper.find('IntegrationName').props().children).toEqual('Bitbucket');
  95. expect(wrapper.find('IntegrationName').props().to).toEqual(
  96. `/settings/${org.slug}/integrations/bitbucket/`
  97. );
  98. expect(wrapper.find('IntegrationStatus').props().status).toEqual('Installed');
  99. expect(wrapper.find('PublishStatus').exists()).toEqual(false);
  100. expect(wrapper.find('StyledLink').props().children).toEqual('3 Configurations');
  101. });
  102. it('has not been installed', function () {
  103. const wrapper = mountWithTheme(
  104. <IntegrationRow
  105. organization={org}
  106. type="firstParty"
  107. slug="github"
  108. displayName="Github"
  109. status="Not Installed"
  110. publishStatus="published"
  111. configurations={0}
  112. data-test-id="integration-row"
  113. />
  114. );
  115. expect(wrapper.find('PluginIcon').props().pluginId).toEqual('github');
  116. expect(wrapper.find('IntegrationName').props().children).toEqual('Github');
  117. expect(wrapper.find('IntegrationName').props().to).toEqual(
  118. `/settings/${org.slug}/integrations/github/`
  119. );
  120. expect(wrapper.find('IntegrationStatus').props().status).toEqual('Not Installed');
  121. expect(wrapper.find('PublishStatus').exists()).toEqual(false);
  122. expect(wrapper.find('StyledLink').exists()).toEqual(false);
  123. });
  124. });
  125. describe('Plugin', function () {
  126. it('has been installed (1 project)', function () {
  127. const wrapper = mountWithTheme(
  128. <IntegrationRow
  129. organization={org}
  130. type="plugin"
  131. slug="twilio"
  132. displayName="Twilio (SMS) "
  133. status="Installed"
  134. publishStatus="published"
  135. configurations={1}
  136. data-test-id="integration-row"
  137. />
  138. );
  139. expect(wrapper.find('PluginIcon').props().pluginId).toEqual('twilio');
  140. expect(wrapper.find('IntegrationName').props().children).toEqual('Twilio (SMS) ');
  141. expect(wrapper.find('IntegrationName').props().to).toEqual(
  142. `/settings/${org.slug}/plugins/twilio/`
  143. );
  144. expect(wrapper.find('IntegrationStatus').props().status).toEqual('Installed');
  145. expect(wrapper.find('PublishStatus').exists()).toEqual(false);
  146. expect(wrapper.find('StyledLink').props().children).toEqual('1 Configuration');
  147. });
  148. it('has been installed (3 projects)', function () {
  149. const wrapper = mountWithTheme(
  150. <IntegrationRow
  151. organization={org}
  152. type="plugin"
  153. slug="twilio"
  154. displayName="Twilio (SMS) "
  155. status="Installed"
  156. publishStatus="published"
  157. configurations={3}
  158. data-test-id="integration-row"
  159. />
  160. );
  161. expect(wrapper.find('PluginIcon').props().pluginId).toEqual('twilio');
  162. expect(wrapper.find('IntegrationName').props().children).toEqual('Twilio (SMS) ');
  163. expect(wrapper.find('IntegrationName').props().to).toEqual(
  164. `/settings/${org.slug}/plugins/twilio/`
  165. );
  166. expect(wrapper.find('IntegrationStatus').props().status).toEqual('Installed');
  167. expect(wrapper.find('PublishStatus').exists()).toEqual(false);
  168. expect(wrapper.find('StyledLink').props().children).toEqual('3 Configurations');
  169. });
  170. it('has not been installed', function () {
  171. const wrapper = mountWithTheme(
  172. <IntegrationRow
  173. organization={org}
  174. type="plugin"
  175. slug="amazon-sqs"
  176. displayName="Amazon SQS"
  177. status="Not Installed"
  178. publishStatus="published"
  179. configurations={0}
  180. data-test-id="integration-row"
  181. />
  182. );
  183. expect(wrapper.find('PluginIcon').props().pluginId).toEqual('amazon-sqs');
  184. expect(wrapper.find('IntegrationName').props().children).toEqual('Amazon SQS');
  185. expect(wrapper.find('IntegrationStatus').props().status).toEqual('Not Installed');
  186. expect(wrapper.find('PublishStatus').exists()).toEqual(false);
  187. expect(wrapper.find('StyledLink').exists()).toEqual(false);
  188. });
  189. });
  190. });