diff --git a/src/components/Connection/ConnectionFormLogin.tsx b/src/components/Connection/ConnectionFormLogin.tsx index 5f1116848ae4b08a12a78a0934980c687b7f218f..8829530c155058564085324d5ae071c5039eaf66 100644 --- a/src/components/Connection/ConnectionFormLogin.tsx +++ b/src/components/Connection/ConnectionFormLogin.tsx @@ -8,7 +8,7 @@ import AccountService from 'services/account.service' import ConnectionService from 'services/connection.service' import StyledIconButton from 'components/CommonKit/IconButton/StyledIconButton' -import MuiButton from '@material-ui/core/Button' +import Button from '@material-ui/core/Button' import TrailingIcon from 'assets/icons/ico/trailing-icon.svg' import iconGRDFLogo from 'assets/icons/visu/grdf-logo.svg' @@ -206,7 +206,7 @@ const ConnectionFormLogin: React.FC<ConnectionFormLoginProps> = ({ <div className="form-message">{error === '' ? null : error}</div> <div className="kloginauthform"> <div className="kloginauthform-button"> - <MuiButton + <Button type="submit" aria-label={t('auth.accessibility.button_connect')} disabled={loading} @@ -224,7 +224,7 @@ const ConnectionFormLogin: React.FC<ConnectionFormLoginProps> = ({ <div>{t('auth.' + konnectorSlug + '.connect.label2')}</div> </div> </div> - </MuiButton> + </Button> </div> <div className="kloginauthform-text text-16-bold"> <div className="text-16-bold"> @@ -235,7 +235,7 @@ const ConnectionFormLogin: React.FC<ConnectionFormLoginProps> = ({ </div> </div> - <MuiButton + <Button disabled={loading} aria-label={t('auth.accessibility.button_create_account')} onClick={() => window.open(siteLink, '_blank')} @@ -245,7 +245,7 @@ const ConnectionFormLogin: React.FC<ConnectionFormLoginProps> = ({ }} > {t('auth.' + konnectorSlug + '.create_account')} - </MuiButton> + </Button> </div> </form> ) diff --git a/src/components/Connection/ConnectionFormOAuth.tsx b/src/components/Connection/ConnectionFormOAuth.tsx index 74b190355e772e827d3a8008a9cc2e93d72951b0..1db3979710bdf66063cdd111839624e01cc54e94 100644 --- a/src/components/Connection/ConnectionFormOAuth.tsx +++ b/src/components/Connection/ConnectionFormOAuth.tsx @@ -6,7 +6,7 @@ import './connectionFormOAuth.scss' import { Konnector, Trigger, FluidStatus, FluidConnection } from 'models' import OAuthForm from 'components/Connection/OAuthForm' -import MuiButton from '@material-ui/core/Button' +import Button from '@material-ui/core/Button' import AccountService from 'services/account.service' import TriggerService from 'services/triggers.service' import { updatedFluidConnection } from 'store/global/global.actions' @@ -87,7 +87,7 @@ const ConnectionFormOAuth: React.FC<ConnectionFormOAuthProps> = ({ </div> </div> <div className="koauthform-button"> - <MuiButton + <Button aria-label={t('auth.accessibility.button_create_account')} onClick={() => window.open(siteLink, '_blank')} classes={{ @@ -96,7 +96,7 @@ const ConnectionFormOAuth: React.FC<ConnectionFormOAuthProps> = ({ }} > {t('auth.' + konnectorSlug + '.create_account')} - </MuiButton> + </Button> </div> </div> ) diff --git a/src/components/Connection/ConnectionNotFound.spec.tsx b/src/components/Connection/ConnectionNotFound.spec.tsx index 53c2bca3ca289d492aff09482c95da89de148a1d..359fa90e027a6913ab4bc59b12feb699e83c8c55 100644 --- a/src/components/Connection/ConnectionNotFound.spec.tsx +++ b/src/components/Connection/ConnectionNotFound.spec.tsx @@ -1,38 +1,38 @@ -import React from 'react' -import { shallow, mount } from 'enzyme' -import ConnectionNotFound from './ConnectionNotFound' -import MuiButton from '@material-ui/core/Button' - -jest.mock('cozy-ui/transpiled/react/I18n', () => { - return { - useI18n: jest.fn(() => { - return { - t: (str: string) => str, - } - }), - } -}) - -describe('ConnectionNotFound component test', () => { - const konnectorSlug = 'enedisgrandlyon' - - it('should correctly render connection not found', () => { - const result = shallow( - <ConnectionNotFound konnectorSlug={konnectorSlug} /> - ).getElement() - expect(result).toMatchSnapshot() - }) - - it('should open konnector url when button is clicked', () => { - global.open = jest.fn() - - const wrapper = mount(<ConnectionNotFound konnectorSlug={konnectorSlug} />) - const submitStyledButton = wrapper.find(MuiButton) - submitStyledButton.simulate('click') - - expect(global.open).toHaveBeenCalledWith( - 'http://localhost/#/discover/enedisgrandlyon', - '_blank' - ) - }) -}) +import React from 'react' +import { shallow, mount } from 'enzyme' +import ConnectionNotFound from './ConnectionNotFound' +import Button from '@material-ui/core/Button' + +jest.mock('cozy-ui/transpiled/react/I18n', () => { + return { + useI18n: jest.fn(() => { + return { + t: (str: string) => str, + } + }), + } +}) + +describe('ConnectionNotFound component test', () => { + const konnectorSlug = 'enedisgrandlyon' + + it('should correctly render connection not found', () => { + const result = shallow( + <ConnectionNotFound konnectorSlug={konnectorSlug} /> + ).getElement() + expect(result).toMatchSnapshot() + }) + + it('should open konnector url when button is clicked', () => { + global.open = jest.fn() + + const wrapper = mount(<ConnectionNotFound konnectorSlug={konnectorSlug} />) + const submitStyledButton = wrapper.find(Button) + submitStyledButton.simulate('click') + + expect(global.open).toHaveBeenCalledWith( + 'http://localhost/#/discover/enedisgrandlyon', + '_blank' + ) + }) +}) diff --git a/src/components/Connection/OAuthForm.tsx b/src/components/Connection/OAuthForm.tsx index fbaffc1bb1b4dfdbfd47e54175b66c7244415ec8..b4595c252eea371a7ac90bf09e80d9c29d786752 100644 --- a/src/components/Connection/OAuthForm.tsx +++ b/src/components/Connection/OAuthForm.tsx @@ -10,7 +10,7 @@ import { OAuthWindow } from 'cozy-harvest-lib/dist/components/OAuthWindow' import iconEnedisLogo from 'assets/icons/visu/enedis-logo.svg' import iconGrdfLogo from 'assets/icons/visu/grdf-logo.svg' import iconEglLogo from 'assets/icons/visu/egl-logo.svg' -import MuiButton from '@material-ui/core/Button' +import Button from '@material-ui/core/Button' import StyledIcon from 'components/CommonKit/Icon/StyledIcon' import StyledBlackSpinner from 'components/CommonKit/Spinner/StyledBlackSpinner' import ModalGRDF from './ModalGRDF' @@ -70,7 +70,7 @@ const OAuthForm: React.FC<OAuthFormProps> = ({ const isWaiting = status === WAITING return !konnector ? null : ( <> - <MuiButton + <Button aria-label={t('auth.accessibility.button_connect')} onClick={ konnector.slug === fluidconfig[FluidType.GAS].konnectorConfig.slug @@ -96,7 +96,7 @@ const OAuthForm: React.FC<OAuthFormProps> = ({ <div>{t('auth.' + konnector.slug + '.connect.label2')}</div> </div> </div> - </MuiButton> + </Button> {isWaiting && ( <OAuthWindow client={client}