diff --git a/client/modules/IDE/components/ErrorModal.jsx b/client/modules/IDE/components/ErrorModal.jsx index 95be4e096a..db4a3aa1fc 100644 --- a/client/modules/IDE/components/ErrorModal.jsx +++ b/client/modules/IDE/components/ErrorModal.jsx @@ -69,9 +69,14 @@ const ErrorModal = ({ type, service, closeModal }) => { }; ErrorModal.propTypes = { - type: PropTypes.string.isRequired, + type: PropTypes.oneOf([ + 'forceAuthentication', + 'staleSession', + 'staleProject', + 'oauthError' + ]).isRequired, closeModal: PropTypes.func.isRequired, - service: PropTypes.string + service: PropTypes.oneOf(['google', 'github']) }; ErrorModal.defaultProps = { diff --git a/client/modules/IDE/components/ErrorModal.stories.jsx b/client/modules/IDE/components/ErrorModal.stories.jsx new file mode 100644 index 0000000000..6019633906 --- /dev/null +++ b/client/modules/IDE/components/ErrorModal.stories.jsx @@ -0,0 +1,30 @@ +import ErrorModal from './ErrorModal'; + +export default { + title: 'IDE/ErrorModal', + component: ErrorModal, + argTypes: { + closeModal: { action: 'closed' } + } +}; + +export const ForceAuthenticationErrorModal = { + args: { + type: 'forceAuthentication' + } +}; +export const StaleSessionErrorModal = { + args: { + type: 'staleSession' + } +}; +export const StaleProjectErrorModal = { + args: { + type: 'staleProject' + } +}; +export const OauthErrorModal = { + args: { + type: 'oauthError' + } +}; diff --git a/client/modules/IDE/components/ErrorModal.unit.test.jsx b/client/modules/IDE/components/ErrorModal.unit.test.jsx new file mode 100644 index 0000000000..541276193c --- /dev/null +++ b/client/modules/IDE/components/ErrorModal.unit.test.jsx @@ -0,0 +1,57 @@ +import React from 'react'; + +import { render, screen } from '../../../test-utils'; + +import ErrorModal from './ErrorModal'; + +jest.mock('../../../i18n'); + +describe('', () => { + it('renders type forceAuthentication', () => { + render(); + + expect(screen.getByText('Login')).toBeVisible(); + expect(screen.getByText('Sign Up')).toBeVisible(); + }); + + it('renders type staleSession', () => { + render(); + + expect(screen.getByText('log in')).toBeVisible(); + }); + + it('renders type staleProject', () => { + render(); + + expect( + screen.getByText( + 'The project you have attempted to save has been saved from another window', + { exact: false } + ) + ).toBeVisible(); + }); + + it('renders type oauthError with service google', () => { + render( + + ); + + expect( + screen.getByText('There was a problem linking your Google account', { + exact: false + }) + ).toBeVisible(); + }); + + it('renders type oauthError with service github', () => { + render( + + ); + + expect( + screen.getByText('There was a problem linking your GitHub account', { + exact: false + }) + ).toBeVisible(); + }); +});