autofixSetupModal.spec.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import {act, renderGlobalModal, screen, userEvent} from 'sentry-test/reactTestingLibrary';
  2. import {openModal} from 'sentry/actionCreators/modal';
  3. import {AutofixSetupModal} from 'sentry/components/modals/autofixSetupModal';
  4. describe('AutofixSetupModal', function () {
  5. it('renders the integration setup instructions', async function () {
  6. MockApiClient.addMockResponse({
  7. url: '/issues/1/autofix/setup/',
  8. body: {
  9. genAIConsent: {ok: true},
  10. integration: {ok: false},
  11. },
  12. });
  13. const closeModal = jest.fn();
  14. renderGlobalModal();
  15. act(() => {
  16. openModal(modalProps => <AutofixSetupModal {...modalProps} groupId="1" />, {
  17. onClose: closeModal,
  18. });
  19. });
  20. expect(await screen.findByText('Install the GitHub Integration')).toBeInTheDocument();
  21. expect(
  22. screen.getByText(/Install the GitHub integration by navigating to/)
  23. ).toBeInTheDocument();
  24. });
  25. it('displays successful integration text when it is installed', async function () {
  26. MockApiClient.addMockResponse({
  27. url: '/issues/1/autofix/setup/',
  28. body: {
  29. genAIConsent: {ok: false},
  30. integration: {ok: true},
  31. },
  32. });
  33. const closeModal = jest.fn();
  34. renderGlobalModal();
  35. act(() => {
  36. openModal(modalProps => <AutofixSetupModal {...modalProps} groupId="1" />, {
  37. onClose: closeModal,
  38. });
  39. });
  40. expect(
  41. await screen.findByText(/The GitHub integration is already installed/)
  42. ).toBeInTheDocument();
  43. });
  44. it('shows success text when steps are done', async function () {
  45. MockApiClient.addMockResponse({
  46. url: '/issues/1/autofix/setup/',
  47. body: {
  48. genAIConsent: {ok: true},
  49. integration: {ok: true},
  50. },
  51. });
  52. const closeModal = jest.fn();
  53. renderGlobalModal();
  54. act(() => {
  55. openModal(modalProps => <AutofixSetupModal {...modalProps} groupId="1" />, {
  56. onClose: closeModal,
  57. });
  58. });
  59. expect(
  60. await screen.findByText("You've successfully configured Autofix!")
  61. ).toBeInTheDocument();
  62. await userEvent.click(screen.getByRole('button', {name: "Let's go"}));
  63. expect(closeModal).toHaveBeenCalled();
  64. });
  65. });