pluginNavigation.integration.spec.jsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import React from 'react';
  2. import {mount} from 'enzyme';
  3. import ProjectPlugins from 'app/views/projectPlugins';
  4. import PluginNavigation from 'app/views/projectSettings/pluginNavigation';
  5. jest.mock('app/api');
  6. describe('PluginNavigation Integration', function() {
  7. let wrapper;
  8. let routerContext = TestStubs.routerContext();
  9. let org = routerContext.context.organization;
  10. let project = routerContext.context.project;
  11. let plugins = TestStubs.Plugins();
  12. beforeEach(function() {
  13. MockApiClient.addMockResponse({
  14. url: `/organizations/${org.slug}/integrations/`,
  15. method: 'GET',
  16. body: [],
  17. });
  18. MockApiClient.addMockResponse({
  19. url: `/organizations/${org.slug}/`,
  20. method: 'GET',
  21. body: {organization: org},
  22. });
  23. MockApiClient.addMockResponse({
  24. url: `/projects/${org.slug}/${project.slug}/plugins/`,
  25. method: 'GET',
  26. body: plugins,
  27. });
  28. MockApiClient.addMockResponse({
  29. url: `/projects/${org.slug}/${project.slug}/plugins/amazon-sqs/`,
  30. method: 'POST',
  31. });
  32. MockApiClient.addMockResponse({
  33. url: `/projects/${org.slug}/${project.slug}/plugins/github/`,
  34. method: 'DELETE',
  35. });
  36. });
  37. // Integration test with PluginNavigation
  38. describe('with PluginNavigation', function() {
  39. beforeEach(function() {
  40. let params = {orgId: org.slug, projectId: project.slug};
  41. let organization = {...org, id: org.slug, features: []};
  42. wrapper = mount(
  43. <div>
  44. <ProjectPlugins params={params} organization={organization} />
  45. <PluginNavigation organization={organization} urlRoot="/" />
  46. </div>,
  47. TestStubs.routerContext()
  48. );
  49. });
  50. it('has no items in <PluginNavigation />', function() {
  51. expect(wrapper.find('PluginNavigation a')).toHaveLength(0);
  52. });
  53. /**
  54. * This tests that ProjectPlugins and PluginNavigation respond to the same store
  55. */
  56. it('has Amazon in <PluginNavigation /> after enabling', async function() {
  57. await tick();
  58. wrapper.update();
  59. wrapper
  60. .find('Switch')
  61. .first()
  62. .simulate('click');
  63. await tick();
  64. wrapper.update();
  65. expect(wrapper.find('PluginNavigation').find('a')).toHaveLength(1);
  66. });
  67. });
  68. });