index.spec.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import ConfigStore from 'sentry/stores/configStore';
  4. import RelocationOnboardingContainer from './index';
  5. const fakePublicKey = `-----BEGIN PUBLIC KEY-----
  6. MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw5Or1zsGE1XJTL4q+1c4
  7. Ztu8+7SC/exrnEYlWH+LVLI8TVyuGwDTAXrgKHGwaMM5ZnjijP5i8+ph8lfLrybT
  8. l+2D81qPIqagEtNMDaHqUDm5Tq7I2qvxkJ5YuDLawRUPccKMwWlIDR2Gvfe3efce
  9. 870EicPsExz4uPOkNXGHJZ/FwCQrLo87MXFeqrqj+0Cf+qwCQSCW9qFWe5cj+zqt
  10. eeJa0qflcHHQzxK4/EKKpl/hkt4zi0aE/PuJgvJz2KB+X3+LzekTy90LzW3VhR4y
  11. IAxCAaGQJVsg9dhKOORjAf4XK9aXHvy/jUSyT43opj6AgNqXlKEQjb1NBA8qbJJS
  12. 8wIDAQAB
  13. -----END PUBLIC KEY-----`;
  14. describe('Relocation Onboarding Container', function () {
  15. beforeEach(function () {
  16. MockApiClient.asyncDelay = undefined;
  17. MockApiClient.clearMockResponses();
  18. MockApiClient.addMockResponse({
  19. url: '/publickeys/relocations/',
  20. body: {
  21. public_key: fakePublicKey,
  22. },
  23. });
  24. // The tests fail because we have a "component update was not wrapped in act" error. It should
  25. // be safe to ignore this error, but we should remove the mock once we move to react testing
  26. // library.
  27. //
  28. jest.spyOn(console, 'error').mockImplementation(jest.fn());
  29. });
  30. it('should render if feature enabled', function () {
  31. const {routerProps, router, organization} = initializeOrg({
  32. router: {
  33. params: {step: '1'},
  34. },
  35. });
  36. ConfigStore.set('features', new Set(['relocation:enabled']));
  37. render(<RelocationOnboardingContainer {...routerProps} />, {
  38. router,
  39. organization,
  40. });
  41. expect(
  42. screen.queryByText("You don't have access to this feature")
  43. ).not.toBeInTheDocument();
  44. });
  45. it('should not render if feature disabled', function () {
  46. const {routerProps, router, organization} = initializeOrg({
  47. router: {
  48. params: {step: '1'},
  49. },
  50. });
  51. ConfigStore.set('features', new Set([]));
  52. render(<RelocationOnboardingContainer {...routerProps} />, {
  53. router,
  54. organization,
  55. });
  56. expect(screen.getByText("You don't have access to this feature")).toBeInTheDocument();
  57. });
  58. });