autofixSetupWriteAccessModal.spec.tsx 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. import {act, renderGlobalModal, screen} from 'sentry-test/reactTestingLibrary';
  2. import {openModal} from 'sentry/actionCreators/modal';
  3. import {AutofixSetupWriteAccessModal} from 'sentry/components/events/autofix/autofixSetupWriteAccessModal';
  4. describe('AutofixSetupWriteAccessModal', function () {
  5. it('displays help text when repos are not all installed', async function () {
  6. MockApiClient.addMockResponse({
  7. url: '/issues/1/autofix/setup/?check_write_access=true',
  8. body: {
  9. genAIConsent: {ok: false},
  10. integration: {ok: true},
  11. githubWriteIntegration: {
  12. ok: false,
  13. repos: [
  14. {
  15. provider: 'integrations:github',
  16. owner: 'getsentry',
  17. name: 'sentry',
  18. external_id: '123',
  19. ok: true,
  20. },
  21. {
  22. provider: 'integrations:github',
  23. owner: 'getsentry',
  24. name: 'seer',
  25. external_id: '235',
  26. ok: false,
  27. },
  28. ],
  29. },
  30. },
  31. });
  32. const closeModal = jest.fn();
  33. renderGlobalModal();
  34. act(() => {
  35. openModal(
  36. modalProps => <AutofixSetupWriteAccessModal {...modalProps} groupId="1" />,
  37. {
  38. onClose: closeModal,
  39. }
  40. );
  41. });
  42. expect(screen.getByText(/In order to create pull requests/i)).toBeInTheDocument();
  43. expect(await screen.findByText('getsentry/sentry')).toBeInTheDocument();
  44. expect(screen.getByText('getsentry/seer')).toBeInTheDocument();
  45. expect(
  46. screen.getByRole('button', {name: 'Install the Autofix GitHub App'})
  47. ).toHaveAttribute('href', 'https://github.com/apps/sentry-autofix/installations/new');
  48. });
  49. it('displays success text when installed repos for github app text', async function () {
  50. MockApiClient.addMockResponse({
  51. url: '/issues/1/autofix/setup/?check_write_access=true',
  52. body: {
  53. genAIConsent: {ok: false},
  54. integration: {ok: true},
  55. githubWriteIntegration: {
  56. ok: true,
  57. repos: [
  58. {
  59. provider: 'integrations:github',
  60. owner: 'getsentry',
  61. name: 'sentry',
  62. external_id: '123',
  63. ok: true,
  64. },
  65. {
  66. provider: 'integrations:github',
  67. owner: 'getsentry',
  68. name: 'seer',
  69. external_id: '235',
  70. ok: true,
  71. },
  72. ],
  73. },
  74. },
  75. });
  76. const closeModal = jest.fn();
  77. renderGlobalModal();
  78. act(() => {
  79. openModal(
  80. modalProps => <AutofixSetupWriteAccessModal {...modalProps} groupId="1" />,
  81. {onClose: closeModal}
  82. );
  83. });
  84. expect(
  85. await screen.findByText("You've successfully configured write access!")
  86. ).toBeInTheDocument();
  87. // Footer with actions should no longer be visible
  88. expect(screen.queryByRole('button', {name: /install/i})).not.toBeInTheDocument();
  89. });
  90. });