From 0428ee559df079b0290c15d7322fbec338c7464c Mon Sep 17 00:00:00 2001 From: Alexis Date: Tue, 25 Jul 2023 14:41:29 +1000 Subject: [PATCH 1/4] docs(ErrorModal): add stories --- .../IDE/components/ErrorModal.stories.jsx | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 client/modules/IDE/components/ErrorModal.stories.jsx diff --git a/client/modules/IDE/components/ErrorModal.stories.jsx b/client/modules/IDE/components/ErrorModal.stories.jsx new file mode 100644 index 0000000000..0266a6d52d --- /dev/null +++ b/client/modules/IDE/components/ErrorModal.stories.jsx @@ -0,0 +1,47 @@ +import React from 'react'; + +import ErrorModal from './ErrorModal'; + +export default { + title: 'IDE/ErrorModal', + component: ErrorModal, + argTypes: { + type: { + options: [ + 'forceAuthentication', + 'staleSession', + 'staleProject', + 'oauthError' + ], + control: { type: 'select' } + }, + service: { + options: ['google', 'github'], + control: { type: 'select' } + }, + closeModal: { action: 'closed' } + } +}; + +const Template = (args) => ; + +export const ForceAuthenticationErrorModal = Template.bind({}); +ForceAuthenticationErrorModal.args = { + type: 'forceAuthentication' +}; + +export const StaleSessionErrorModal = Template.bind({}); +StaleSessionErrorModal.args = { + type: 'staleSession' +}; + +export const StaleProjectErrorModal = Template.bind({}); +StaleProjectErrorModal.args = { + type: 'staleProject' +}; + +export const OauthErrorModal = Template.bind({}); +OauthErrorModal.args = { + type: 'oauthError', + service: 'google' +}; From ecbfbee4fa6433035e824068e0698279db581e23 Mon Sep 17 00:00:00 2001 From: Alexis Date: Tue, 25 Jul 2023 14:41:55 +1000 Subject: [PATCH 2/4] test(ErrorModal): add spec file --- .../IDE/components/ErrorModal.unit.test.jsx | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 client/modules/IDE/components/ErrorModal.unit.test.jsx 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(); + }); +}); From 754c84108f38581b6a4b49cc9a626a4771ea9209 Mon Sep 17 00:00:00 2001 From: Alexis Date: Wed, 26 Jul 2023 10:59:08 +1000 Subject: [PATCH 3/4] fix(ErrorModal): add proptypes --- client/modules/IDE/components/ErrorModal.jsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 = { From f9c4800586baac3a47762f2e469bf89689494c61 Mon Sep 17 00:00:00 2001 From: Alexis Date: Wed, 26 Jul 2023 10:59:49 +1000 Subject: [PATCH 4/4] docs(ErrorModal): remove redundant config --- .../IDE/components/ErrorModal.stories.jsx | 49 ++++++------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/client/modules/IDE/components/ErrorModal.stories.jsx b/client/modules/IDE/components/ErrorModal.stories.jsx index 0266a6d52d..6019633906 100644 --- a/client/modules/IDE/components/ErrorModal.stories.jsx +++ b/client/modules/IDE/components/ErrorModal.stories.jsx @@ -1,47 +1,30 @@ -import React from 'react'; - import ErrorModal from './ErrorModal'; export default { title: 'IDE/ErrorModal', component: ErrorModal, argTypes: { - type: { - options: [ - 'forceAuthentication', - 'staleSession', - 'staleProject', - 'oauthError' - ], - control: { type: 'select' } - }, - service: { - options: ['google', 'github'], - control: { type: 'select' } - }, closeModal: { action: 'closed' } } }; -const Template = (args) => ; - -export const ForceAuthenticationErrorModal = Template.bind({}); -ForceAuthenticationErrorModal.args = { - type: 'forceAuthentication' +export const ForceAuthenticationErrorModal = { + args: { + type: 'forceAuthentication' + } }; - -export const StaleSessionErrorModal = Template.bind({}); -StaleSessionErrorModal.args = { - type: 'staleSession' +export const StaleSessionErrorModal = { + args: { + type: 'staleSession' + } }; - -export const StaleProjectErrorModal = Template.bind({}); -StaleProjectErrorModal.args = { - type: 'staleProject' +export const StaleProjectErrorModal = { + args: { + type: 'staleProject' + } }; - -export const OauthErrorModal = Template.bind({}); -OauthErrorModal.args = { - type: 'oauthError', - service: 'google' +export const OauthErrorModal = { + args: { + type: 'oauthError' + } };