relocation.spec.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import {initializeOrg} from 'sentry-test/initializeOrg';
  2. import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  3. import ConfigStore from 'sentry/stores/configStore';
  4. import Relocation from 'sentry/views/relocation/relocation';
  5. describe('Relocation', function () {
  6. function renderPage(step) {
  7. const routeParams = {
  8. step,
  9. };
  10. const {routerProps, routerContext, organization} = initializeOrg({
  11. router: {
  12. params: routeParams,
  13. },
  14. });
  15. return render(<Relocation {...routerProps} />, {
  16. context: routerContext,
  17. organization,
  18. });
  19. }
  20. describe('Get Started', function () {
  21. it('renders', async function () {
  22. renderPage('get-started');
  23. expect(
  24. await screen.findByText('Basic information needed to get started')
  25. ).toBeInTheDocument();
  26. expect(
  27. await screen.findByText('Organization slugs being relocated')
  28. ).toBeInTheDocument();
  29. expect(await screen.findByText('Choose a datacenter region')).toBeInTheDocument();
  30. });
  31. it('should prevent user from going to the next step if no org slugs or region are entered', function () {
  32. renderPage('get-started');
  33. expect(screen.getByRole('button', {name: 'Continue'})).toBeDisabled();
  34. });
  35. it('should be allowed to go to next step if org slug is entered and region is selected', async function () {
  36. renderPage('get-started');
  37. ConfigStore.set('regions', [{name: 'USA', url: 'https://example.com'}]);
  38. const orgSlugsInput = screen.getByLabelText('org-slugs');
  39. const continueButton = screen.getByRole('button', {name: 'Continue'});
  40. await userEvent.type(orgSlugsInput, 'test-org');
  41. await userEvent.type(screen.getByLabelText('region'), 'U');
  42. await userEvent.click(screen.getByRole('menuitemradio'));
  43. expect(continueButton).toBeEnabled();
  44. });
  45. });
  46. describe('Select Platform', function () {
  47. it('renders', async function () {
  48. renderPage('encrypt-backup');
  49. expect(
  50. await screen.findByText(
  51. 'Create an encrypted backup of current self-hosted instance'
  52. )
  53. ).toBeInTheDocument();
  54. expect(await screen.findByText('./sentry-admin.sh')).toBeInTheDocument();
  55. });
  56. });
  57. });