pluginDetailedView.spec.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {
  3. render,
  4. renderGlobalModal,
  5. screen,
  6. userEvent,
  7. } from 'sentry-test/reactTestingLibrary';
  8. import {Organization} from 'sentry/types';
  9. import PluginDetailedView from 'sentry/views/settings/organizationIntegrations/pluginDetailedView';
  10. function renderMockRequests(orgSlug: Organization['slug']) {
  11. const configs = MockApiClient.addMockResponse({
  12. url: `/organizations/${orgSlug}/plugins/configs/?plugins=pagerduty`,
  13. method: 'GET',
  14. statusCode: 200,
  15. body: [
  16. {
  17. status: 'unknown',
  18. description: 'Send alerts to PagerDuty.',
  19. isTestable: true,
  20. isHidden: true,
  21. hasConfiguration: true,
  22. features: [],
  23. shortName: 'PagerDuty',
  24. id: 'pagerduty',
  25. assets: [],
  26. featureDescriptions: [],
  27. name: 'PagerDuty',
  28. author: {url: 'https://github.com/getsentry/sentry', name: 'Sentry Team'},
  29. contexts: [],
  30. doc: '',
  31. resourceLinks: [
  32. {url: 'https://github.com/getsentry/sentry/issues', title: 'Report Issue'},
  33. {
  34. url: 'https://github.com/getsentry/sentry/tree/master/src/sentry_plugins',
  35. title: 'View Source',
  36. },
  37. ],
  38. slug: 'pagerduty',
  39. projectList: [
  40. {
  41. projectId: 2,
  42. configured: true,
  43. enabled: true,
  44. projectSlug: 'javascript',
  45. projectPlatform: 'javascript',
  46. projectName: 'JavaScript',
  47. },
  48. ],
  49. version: '10.1.0.dev0',
  50. canDisable: true,
  51. type: 'notification',
  52. metadata: {},
  53. },
  54. ],
  55. });
  56. return {configs};
  57. }
  58. describe('PluginDetailedView', function () {
  59. it('shows the Integration name and install status', async function () {
  60. const {route, router, organization} = initializeOrg();
  61. renderMockRequests(organization.slug);
  62. render(
  63. <PluginDetailedView
  64. params={{integrationSlug: 'pagerduty'}}
  65. route={route}
  66. routes={[]}
  67. routeParams={{}}
  68. router={router}
  69. location={router.location}
  70. />
  71. );
  72. expect(await screen.findByText('PagerDuty (Legacy)')).toBeInTheDocument();
  73. expect(screen.getByText('Installed')).toBeInTheDocument();
  74. await userEvent.click(screen.getByRole('button', {name: 'Add to Project'}));
  75. renderGlobalModal();
  76. expect(await screen.findByRole('dialog')).toBeInTheDocument();
  77. });
  78. it('view configurations', function () {
  79. const {route, router, organization} = initializeOrg({
  80. router: {location: {query: {tab: 'configurations'}}},
  81. });
  82. renderMockRequests(organization.slug);
  83. render(
  84. <PluginDetailedView
  85. params={{integrationSlug: 'pagerduty'}}
  86. route={route}
  87. routes={[]}
  88. routeParams={{}}
  89. router={router}
  90. location={router.location}
  91. />
  92. );
  93. expect(screen.getByTestId('installed-plugin')).toBeInTheDocument();
  94. });
  95. });