projectPluginDetails.spec.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {PluginFixture} from 'sentry-fixture/plugin';
  3. import {PluginsFixture} from 'sentry-fixture/plugins';
  4. import {ProjectFixture} from 'sentry-fixture/project';
  5. import {RouteComponentPropsFixture} from 'sentry-fixture/routeComponentPropsFixture';
  6. import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
  7. import * as indicators from 'sentry/actionCreators/indicator';
  8. import ProjectPluginDetailsContainer, {
  9. ProjectPluginDetails,
  10. } from 'sentry/views/settings/projectPlugins/details';
  11. describe('ProjectPluginDetails', function () {
  12. const organization = OrganizationFixture();
  13. const project = ProjectFixture();
  14. const plugins = PluginsFixture();
  15. const plugin = PluginFixture();
  16. const routerProps = RouteComponentPropsFixture();
  17. beforeAll(function () {
  18. jest.spyOn(console, 'info').mockImplementation(() => {});
  19. });
  20. beforeEach(function () {
  21. MockApiClient.addMockResponse({
  22. url: `/projects/${organization.slug}/${project.slug}/plugins/`,
  23. method: 'GET',
  24. body: plugins,
  25. });
  26. MockApiClient.addMockResponse({
  27. url: `/projects/${organization.slug}/${project.slug}/plugins/${plugin.id}/`,
  28. method: 'DELETE',
  29. });
  30. MockApiClient.addMockResponse({
  31. url: `/projects/${organization.slug}/${project.slug}/plugins/${plugin.id}/`,
  32. method: 'GET',
  33. body: plugin,
  34. });
  35. MockApiClient.addMockResponse({
  36. url: `/projects/${organization.slug}/${project.slug}/plugins/${plugin.id}/`,
  37. method: 'POST',
  38. body: {
  39. ...plugin,
  40. config: [{value: 'default'}],
  41. },
  42. });
  43. });
  44. it('renders', function () {
  45. render(
  46. <ProjectPluginDetailsContainer
  47. {...routerProps}
  48. organization={organization}
  49. project={project}
  50. params={{
  51. projectId: project.slug,
  52. pluginId: 'amazon-sqs',
  53. }}
  54. />
  55. );
  56. });
  57. it('resets plugin', async function () {
  58. jest.spyOn(indicators, 'addSuccessMessage');
  59. render(
  60. <ProjectPluginDetails
  61. {...routerProps}
  62. organization={organization}
  63. project={project}
  64. plugins={{plugins}}
  65. params={{
  66. projectId: project.slug,
  67. pluginId: 'amazon-sqs',
  68. }}
  69. />
  70. );
  71. await userEvent.click(screen.getByRole('button', {name: 'Reset Configuration'}));
  72. await waitFor(() =>
  73. expect(indicators.addSuccessMessage).toHaveBeenCalledWith('Plugin was reset')
  74. );
  75. });
  76. it('enables/disables plugin', async function () {
  77. jest.spyOn(indicators, 'addSuccessMessage');
  78. render(
  79. <ProjectPluginDetailsContainer
  80. {...routerProps}
  81. organization={organization}
  82. project={project}
  83. params={{
  84. projectId: project.slug,
  85. pluginId: 'amazon-sqs',
  86. }}
  87. />
  88. );
  89. await userEvent.click(screen.getByRole('button', {name: 'Enable Plugin'}));
  90. await waitFor(() =>
  91. expect(indicators.addSuccessMessage).toHaveBeenCalledWith('Plugin was enabled')
  92. );
  93. });
  94. });