organizationUserFeedback.spec.jsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import React from 'react';
  2. import {mount} from 'enzyme';
  3. import {OrganizationUserFeedback} from 'app/views/userFeedback/organizationUserFeedback';
  4. describe('OrganizationUserFeedback', function() {
  5. let organization, routerContext;
  6. beforeEach(function() {
  7. const pageLinks =
  8. '<https://sentry.io/api/0/organizations/sentry/user-feedback/?statsPeriod=14d&cursor=0:0:1>; rel="previous"; results="false"; cursor="0:0:1", ' +
  9. '<https://sentry.io/api/0/organizations/sentry/user-feedback/?statsPeriod=14d&cursor=0:100:0>; rel="next"; results="true"; cursor="0:100:0"';
  10. MockApiClient.addMockResponse({
  11. url: '/organizations/org-slug/user-feedback/',
  12. body: [TestStubs.UserFeedback()],
  13. headers: {Link: pageLinks},
  14. });
  15. MockApiClient.addMockResponse({
  16. url: '/organizations/org-slug/environments/',
  17. body: TestStubs.Environments(),
  18. });
  19. organization = TestStubs.Organization();
  20. routerContext = TestStubs.routerContext([
  21. {
  22. organization,
  23. router: {
  24. ...TestStubs.router(),
  25. params: {
  26. orgId: organization.slug,
  27. },
  28. },
  29. },
  30. ]);
  31. });
  32. it('renders', function() {
  33. const params = {
  34. organization: TestStubs.Organization({features: ['sentry10']}),
  35. location: {query: {}, search: ''},
  36. params: {
  37. orgId: organization.slug,
  38. },
  39. };
  40. const wrapper = mount(<OrganizationUserFeedback {...params} />, routerContext);
  41. expect(wrapper).toMatchSnapshot();
  42. });
  43. it('no access', function() {
  44. const params = {
  45. organization: TestStubs.Organization(),
  46. location: {query: {}, search: ''},
  47. params: {
  48. orgId: 'org-slug',
  49. },
  50. };
  51. const wrapper = mount(
  52. <OrganizationUserFeedback {...params} />,
  53. TestStubs.routerContext()
  54. );
  55. expect(wrapper.text()).toBe("You don't have access to this feature");
  56. });
  57. });