index.spec.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import {InstallWizardFixture} from 'sentry-fixture/installWizard';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import InstallWizard from 'sentry/views/admin/installWizard';
  4. describe('InstallWizard', function () {
  5. beforeEach(function () {
  6. MockApiClient.addMockResponse({
  7. url: '/internal/options/?query=is:required',
  8. body: InstallWizardFixture(),
  9. });
  10. });
  11. afterEach(function () {
  12. MockApiClient.clearMockResponses();
  13. });
  14. it('renders', function () {
  15. render(<InstallWizard onConfigured={jest.fn()} />);
  16. });
  17. it('has no option selected when beacon.anonymous is unset', async function () {
  18. MockApiClient.addMockResponse({
  19. url: '/internal/options/?query=is:required',
  20. body: InstallWizardFixture({
  21. 'beacon.anonymous': {
  22. field: {
  23. disabledReason: null,
  24. default: false,
  25. required: true,
  26. disabled: false,
  27. allowEmpty: true,
  28. isSet: false,
  29. },
  30. value: false,
  31. },
  32. }),
  33. });
  34. render(<InstallWizard onConfigured={jest.fn()} />);
  35. expect(await screen.findByTestId('loading-indicator')).not.toBeInTheDocument();
  36. expect(
  37. screen.getByRole('radio', {
  38. name: 'Please keep my usage information anonymous',
  39. })
  40. ).not.toBeChecked();
  41. expect(
  42. screen.getByRole('radio', {
  43. name: 'Send my contact information along with usage statistics',
  44. })
  45. ).not.toBeChecked();
  46. });
  47. it('has no option selected even when beacon.anonymous is set', async function () {
  48. MockApiClient.addMockResponse({
  49. url: '/internal/options/?query=is:required',
  50. body: InstallWizardFixture({
  51. 'beacon.anonymous': {
  52. field: {
  53. disabledReason: null,
  54. default: false,
  55. required: true,
  56. disabled: false,
  57. allowEmpty: true,
  58. isSet: true,
  59. },
  60. value: false,
  61. },
  62. }),
  63. });
  64. render(<InstallWizard onConfigured={jest.fn()} />);
  65. expect(await screen.findByTestId('loading-indicator')).not.toBeInTheDocument();
  66. expect(
  67. screen.getByRole('radio', {
  68. name: 'Please keep my usage information anonymous',
  69. })
  70. ).not.toBeChecked();
  71. expect(
  72. screen.getByRole('radio', {
  73. name: 'Send my contact information along with usage statistics',
  74. })
  75. ).not.toBeChecked();
  76. });
  77. });