index.spec.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. // eslint-disable-next-line no-console
  29. jest.spyOn(console, 'error').mockImplementation(jest.fn());
  30. });
  31. it('should render if feature enabled', function () {
  32. const {routerProps, router, organization} = initializeOrg({
  33. router: {
  34. params: {step: '1'},
  35. },
  36. });
  37. ConfigStore.set('features', new Set(['relocation:enabled']));
  38. render(<RelocationOnboardingContainer {...routerProps} />, {
  39. router,
  40. organization,
  41. });
  42. expect(
  43. screen.queryByText("You don't have access to this feature")
  44. ).not.toBeInTheDocument();
  45. });
  46. it('should not render if feature disabled', async function () {
  47. const {routerProps, router, organization} = initializeOrg({
  48. router: {
  49. params: {step: '1'},
  50. },
  51. });
  52. ConfigStore.set('features', new Set([]));
  53. render(<RelocationOnboardingContainer {...routerProps} />, {
  54. router,
  55. organization,
  56. });
  57. expect(
  58. await screen.queryByText("You don't have access to this feature")
  59. ).toBeInTheDocument();
  60. });
  61. });