diff --git a/docker/cozy-app-dev-with-app.sh b/docker/cozy-app-dev-with-app.sh index 45571eb6b3c450fb6ed9499f7e581cc19c447c90..7241afc62e6bf017281e74dbb28ddf3a17b8b2f3 100755 --- a/docker/cozy-app-dev-with-app.sh +++ b/docker/cozy-app-dev-with-app.sh @@ -215,9 +215,9 @@ do_install_app() { # echo "Removing konnector enedisgrandlyon..." # cozy-stack konnectors uninstall --domain cozy.tools:8080 enedisgrandlyon # fi - if cozy-stack konnectors ls | grep 'enedis-sge-grandlyon'; then - echo "Removing konnector enedis-sge-grandlyon..." - cozy-stack konnectors uninstall --domain cozy.tools:8080 enedis-sge-grandlyon + if cozy-stack konnectors ls | grep 'enedissgegrandlyon'; then + echo "Removing konnector enedissgegrandlyon..." + cozy-stack konnectors uninstall --domain cozy.tools:8080 enedissgegrandlyon fi if cozy-stack konnectors ls | grep 'grdfgrandlyon'; then echo "Removing konnector grdfgrandlyon..." @@ -228,7 +228,7 @@ do_install_app() { cozy-stack konnectors uninstall --domain cozy.tools:8080 eglgrandlyon fi # cozy-stack konnectors install --domain cozy.tools:8080 enedisgrandlyon git://forge.grandlyon.com/web-et-numerique/llle_project/enedis-konnector.git#build - cozy-stack konnectors install --domain cozy.tools:8080 enedis-sge-grandlyon git://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector.git#build + cozy-stack konnectors install --domain cozy.tools:8080 enedissgegrandlyon git://forge.grandlyon.com/web-et-numerique/llle_project/enedis-sge-konnector.git#build cozy-stack konnectors install --domain cozy.tools:8080 grdfgrandlyon git://forge.grandlyon.com/web-et-numerique/llle_project/grdf-konnector.git#build cozy-stack konnectors install --domain cozy.tools:8080 eglgrandlyon git://forge.grandlyon.com/web-et-numerique/llle_project/egl-konnector.git#build } diff --git a/scripts/createConnections.js b/scripts/createConnections.js index 85fcbdaac31defc1a5cb1a5198cde10ebd823c5a..c857d3f6fac014027eb3f1af41151dd75c7a3e41 100644 --- a/scripts/createConnections.js +++ b/scripts/createConnections.js @@ -10,7 +10,7 @@ const headers = { } const dataEnedisAccount = JSON.stringify({ - account_type: 'enedis-sge-grandlyon', + account_type: 'enedissgegrandlyon', name: '', auth: { address: '6 Rue Vaillant Couturier', @@ -22,6 +22,7 @@ const dataEnedisAccount = JSON.stringify({ }, data: { consentId: 43, + expirationDate: '2023-09-26', }, id: '70e68b8450cee09fe2f077610901094d', identifier: 'address', @@ -65,7 +66,7 @@ const dataEnedisTrigger = JSON.stringify({ options: null, message: { account: '70e68b8450cee09fe2f077610901094d', - konnector: 'enedis-sge-grandlyon', + konnector: 'enedissgegrandlyon', }, cozyMetadata: { doctypeVersion: '1', diff --git a/src/components/Connection/ConnectionNotFound.spec.tsx b/src/components/Connection/ConnectionNotFound.spec.tsx index fec1c0bf1dc7f0c37812b43a5474da5a2119d514..a2b02027cfe45ae4a19a47dc8ebc6d2dca8ab8c1 100644 --- a/src/components/Connection/ConnectionNotFound.spec.tsx +++ b/src/components/Connection/ConnectionNotFound.spec.tsx @@ -14,7 +14,7 @@ jest.mock('cozy-ui/transpiled/react/I18n', () => { }) describe('ConnectionNotFound component test', () => { - const konnectorSlug = 'enedis-sge-grandlyon' + const konnectorSlug = 'enedissgegrandlyon' it('should correctly render connection not found', () => { const result = shallow( @@ -31,7 +31,7 @@ describe('ConnectionNotFound component test', () => { submitStyledButton.simulate('click') expect(global.open).toHaveBeenCalledWith( - 'http://localhost/#/discover/enedis-sge-grandlyon', + 'http://localhost/#/discover/enedissgegrandlyon', '_blank' ) }) diff --git a/src/components/Connection/ConnectionResult.tsx b/src/components/Connection/ConnectionResult.tsx index d3cc6b05d47894ccd5c85b5b44fbb68da22c8d56..7d04c229d14c8ccecc20e8709697b7dae90115be 100644 --- a/src/components/Connection/ConnectionResult.tsx +++ b/src/components/Connection/ConnectionResult.tsx @@ -7,7 +7,13 @@ import { useClient } from 'cozy-client' import { useI18n } from 'cozy-ui/transpiled/react/I18n' import { FluidState, FluidType } from 'enum/fluid.enum' import { DateTime } from 'luxon' -import { Account, FluidConnection, FluidStatus, Trigger } from 'models' +import { + Account, + AccountSgeData, + FluidConnection, + FluidStatus, + Trigger, +} from 'models' import React, { useCallback, useEffect, useState } from 'react' import { useDispatch } from 'react-redux' import AccountService from 'services/account.service' @@ -16,6 +22,7 @@ import TriggerService from 'services/triggers.service' import { setShouldRefreshConsent, updatedFluidConnection, + updateSgeStore, } from 'store/global/global.actions' import { getKonnectorUpdateError } from 'utils/utils' import './connectionResult.scss' @@ -108,10 +115,33 @@ const ConnectionResult: React.FC<ConnectionResultProps> = ({ } }, [lastExecutionDate]) - const handleRefreshConsent = useCallback(() => { - deleteAccountsAndTriggers() - dispatch(setShouldRefreshConsent(true)) - }, [deleteAccountsAndTriggers, dispatch]) + const handleRefreshConsent = useCallback( + (fluidType: FluidType) => { + if (fluidType == FluidType.ELECTRICITY) { + const accountData = fluidStatus.connection.account + ?.auth as AccountSgeData + //store the previous account data since the onDelete will remove account from DB + dispatch( + updateSgeStore({ + currentStep: 0, + firstName: accountData.firstname, + lastName: accountData.lastname, + pdl: parseInt(accountData.pointId), + address: accountData.address, + zipCode: parseInt(accountData.postalCode), + city: accountData.city, + dataConsent: true, + pdlConfirm: true, + shouldLaunchAccount: true, + }) + ) + } else { + deleteAccountsAndTriggers() + } + dispatch(setShouldRefreshConsent(true)) + }, + [deleteAccountsAndTriggers, dispatch, fluidStatus.connection.account?.auth] + ) useEffect(() => { if (fluidStatus.connection.triggerState?.last_success) { @@ -268,7 +298,7 @@ const ConnectionResult: React.FC<ConnectionResultProps> = ({ aria-label={t('konnector_form.accessibility.button_update')} onClick={ konnectorError === 'error_update_oauth' - ? handleRefreshConsent + ? () => handleRefreshConsent(fluidType) : updateKonnector } disabled={updating || deleting} diff --git a/src/components/Connection/ExpiredConsentModal.spec.tsx b/src/components/Connection/ExpiredConsentModal.spec.tsx index b52ebe5644ccd1d9d1152c00cb57763d9339c2e8..4dd3fb84520227f1de56debcc40c86b70e6e706b 100644 --- a/src/components/Connection/ExpiredConsentModal.spec.tsx +++ b/src/components/Connection/ExpiredConsentModal.spec.tsx @@ -8,6 +8,7 @@ import { Provider } from 'react-redux' import configureStore from 'redux-mock-store' import { Button } from '@material-ui/core' import * as reactRedux from 'react-redux' +import { fluidStatusConnectedData } from '../../../tests/__mocks__/fluidStatusData.mock' jest.mock('cozy-ui/transpiled/react/I18n', () => { return { @@ -25,6 +26,8 @@ jest.mock('react-router-dom', () => ({ push: mockHistoryPush, }), })) +const mockToggleModal = jest.fn() +const mockHandleCloseClick = jest.fn() const mockStore = configureStore([]) describe('ExpiredConsentModal component', () => { @@ -33,6 +36,9 @@ describe('ExpiredConsentModal component', () => { global: globalStateData, }, }) + beforeEach(() => { + mockHistoryPush.mockReset() + }) it('should be rendered correctly', () => { const component = mount( <Provider store={store}> @@ -40,12 +46,13 @@ describe('ExpiredConsentModal component', () => { open={true} handleCloseClick={jest.fn()} fluidType={FluidType.ELECTRICITY} + toggleModal={mockToggleModal} /> </Provider> ) expect(toJson(component)).toMatchSnapshot() }) - it('should launch the update consent process', () => { + it('should launch the update consent process for GRDF', () => { const useDispatchSpy = jest.spyOn(reactRedux, 'useDispatch') useDispatchSpy.mockReturnValue(jest.fn()) @@ -55,6 +62,7 @@ describe('ExpiredConsentModal component', () => { open={true} handleCloseClick={jest.fn()} fluidType={FluidType.GAS} + toggleModal={mockToggleModal} /> </Provider> ) @@ -62,4 +70,37 @@ describe('ExpiredConsentModal component', () => { expect(useDispatchSpy).toHaveBeenCalledTimes(1) expect(mockHistoryPush).toHaveBeenCalledTimes(1) }) + it('should launch the update consent process for Enedis', () => { + const useDispatchSpy = jest.spyOn(reactRedux, 'useDispatch') + useDispatchSpy.mockReturnValue(jest.fn()) + const useSelectorSpy = jest.spyOn(reactRedux, 'useSelector') + useSelectorSpy.mockReturnValue({ fluidStatus: fluidStatusConnectedData }) + const component = mount( + <Provider store={store}> + <ExpiredConsentModal + open={true} + handleCloseClick={jest.fn()} + fluidType={FluidType.ELECTRICITY} + toggleModal={mockToggleModal} + /> + </Provider> + ) + component.find(Button).at(1).simulate('click') + expect(useDispatchSpy).toHaveBeenCalledTimes(2) + expect(mockHistoryPush).toHaveBeenCalledTimes(1) + }) + it('should click on close modal', () => { + const component = mount( + <Provider store={store}> + <ExpiredConsentModal + open={true} + handleCloseClick={mockHandleCloseClick} + fluidType={FluidType.ELECTRICITY} + toggleModal={mockToggleModal} + /> + </Provider> + ) + component.find(Button).at(0).simulate('click') + expect(mockHandleCloseClick).toHaveBeenCalled() + }) }) diff --git a/src/components/Connection/ExpiredConsentModal.tsx b/src/components/Connection/ExpiredConsentModal.tsx index 117fd283935295a3af8f30a516bf56d48d20d5b2..afc9c95e99d5b0ad8fa54251e6c65cf3706ac1d6 100644 --- a/src/components/Connection/ExpiredConsentModal.tsx +++ b/src/components/Connection/ExpiredConsentModal.tsx @@ -9,33 +9,61 @@ import { Button, IconButton } from '@material-ui/core' import { FluidType } from 'enum/fluid.enum' import './expiredConsentModal.scss' import { useHistory } from 'react-router-dom' -import { useDispatch } from 'react-redux' -import { setShouldRefreshConsent } from 'store/global/global.actions' +import { useDispatch, useSelector } from 'react-redux' +import { + setShouldRefreshConsent, + updateSgeStore, +} from 'store/global/global.actions' +import { AppStore } from 'store' +import { AccountSgeData } from 'models' interface ExpiredConsentModalProps { open: boolean handleCloseClick: () => void fluidType: FluidType + toggleModal: () => void } const ExpiredConsentModal: React.FC<ExpiredConsentModalProps> = ({ open, handleCloseClick, fluidType, + toggleModal, }: ExpiredConsentModalProps) => { const { t } = useI18n() const history = useHistory() const dispatch = useDispatch() + const { fluidStatus } = useSelector((state: AppStore) => state.ecolyo.global) const launchUpdateConsent = useCallback(() => { - dispatch(setShouldRefreshConsent(true)) + if (fluidType === FluidType.ELECTRICITY) { + const accountData = fluidStatus[FluidType.ELECTRICITY].connection.account + ?.auth as AccountSgeData + //store the previous account data since the onDelete will remove account from DB + dispatch( + updateSgeStore({ + currentStep: 0, + firstName: accountData.firstname, + lastName: accountData.lastname, + pdl: parseInt(accountData.pointId), + address: accountData.address, + zipCode: parseInt(accountData.postalCode), + city: accountData.city, + dataConsent: true, + pdlConfirm: true, + shouldLaunchAccount: true, + }) + ) + } + toggleModal() history.push(`/consumption/${FluidType[fluidType].toLocaleLowerCase()}`) - }, [dispatch, fluidType, history]) + dispatch(setShouldRefreshConsent(true)) + }, [dispatch, fluidStatus, fluidType, history, toggleModal]) return ( <Dialog open={open} - onClose={handleCloseClick} + onClose={toggleModal} aria-labelledby={'accessibility-title'} classes={{ root: 'modal-root', @@ -48,7 +76,7 @@ const ExpiredConsentModal: React.FC<ExpiredConsentModalProps> = ({ <IconButton aria-label={t('consumption_visualizer.modal.close')} className="modal-paper-close-button" - onClick={handleCloseClick} + onClick={toggleModal} > <Icon icon={CloseIcon} size={16} /> </IconButton> @@ -61,9 +89,7 @@ const ExpiredConsentModal: React.FC<ExpiredConsentModalProps> = ({ </div> <div - className={`text-20-normal title ${FluidType[ - fluidType - ].toLowerCase()}`} + className={`text-20-bold title ${FluidType[fluidType].toLowerCase()}`} > {t(`consent_outdated.title.${fluidType}`)} </div> @@ -82,7 +108,9 @@ const ExpiredConsentModal: React.FC<ExpiredConsentModalProps> = ({ label: 'text-16-normal', }} > - {t('consent_outdated.later')} + {fluidType === FluidType.ELECTRICITY + ? t('consent_outdated.no') + : t('consent_outdated.later')} </Button> <Button aria-label={t('consent_outdated.go')} @@ -92,7 +120,9 @@ const ExpiredConsentModal: React.FC<ExpiredConsentModalProps> = ({ label: 'text-16-bold', }} > - {t('consent_outdated.go')} + {fluidType === FluidType.ELECTRICITY + ? t('consent_outdated.yes') + : t('consent_outdated.go')} </Button> </div> </div> diff --git a/src/components/Connection/SGEConnect/SgeInit.tsx b/src/components/Connection/SGEConnect/SgeInit.tsx index 594a42eb06f44fab9806203d1f9e2420bb4930dd..b2a55732edc70b0db64b6de7a96fa7502d4312b7 100644 --- a/src/components/Connection/SGEConnect/SgeInit.tsx +++ b/src/components/Connection/SGEConnect/SgeInit.tsx @@ -9,7 +9,10 @@ import { useHistory } from 'react-router-dom' import { useDispatch, useSelector } from 'react-redux' import { AppStore } from 'store' import useKonnectorAuth from 'components/Hooks/useKonnectorAuth' -import { updateSgeStore } from 'store/global/global.actions' +import { + setShouldRefreshConsent, + updateSgeStore, +} from 'store/global/global.actions' interface SgeInitProps { fluidStatus: FluidStatus } @@ -20,6 +23,7 @@ const SgeInit: React.FC<SgeInitProps> = ({ fluidStatus }: SgeInitProps) => { const konnectorSlug: string = fluidStatus.connection.konnectorConfig.slug const account: Account | null = fluidStatus.connection.account const { sgeConnect } = useSelector((state: AppStore) => state.ecolyo.global) + const dispatch = useDispatch() const [connect, update] = useKonnectorAuth(fluidStatus) @@ -27,6 +31,7 @@ const SgeInit: React.FC<SgeInitProps> = ({ fluidStatus }: SgeInitProps) => { async function launchConnect() { if (sgeConnect.shouldLaunchAccount) { dispatch(updateSgeStore({ ...sgeConnect, shouldLaunchAccount: false })) + dispatch(setShouldRefreshConsent(false)) if (!account) { await connect() } else { diff --git a/src/components/Connection/SGEConnect/SgeModalHint.tsx b/src/components/Connection/SGEConnect/SgeModalHint.tsx index f11c911e9034570c677efb52213629112d08bb7a..005a0a1ec45ef19d2d429782f19ea2545a958c2d 100644 --- a/src/components/Connection/SGEConnect/SgeModalHint.tsx +++ b/src/components/Connection/SGEConnect/SgeModalHint.tsx @@ -41,12 +41,12 @@ const SgeModalHint: React.FC<SgeModalHintProps> = ({ </IconButton> <div className="sgeHintModal"> <div className="title text-20-bold"> - {t('auth.enedis-sge-grandlyon.modalHint.title')} + {t('auth.enedissgegrandlyon.modalHint.title')} </div> <Icon icon={PdlImage} width={240} height={385} /> <Button aria-label={t( - 'auth.enedis-sge-grandlyon.modalHint.button-accessibility' + 'auth.enedissgegrandlyon.modalHint.button-accessibility' )} onClick={handleCloseClick} classes={{ @@ -55,7 +55,7 @@ const SgeModalHint: React.FC<SgeModalHintProps> = ({ }} style={{ height: '40px' }} > - {t('auth.enedis-sge-grandlyon.modalHint.button')} + {t('auth.enedissgegrandlyon.modalHint.button')} </Button> </div> </Dialog> diff --git a/src/components/Connection/SGEConnect/StepAddress.tsx b/src/components/Connection/SGEConnect/StepAddress.tsx index 6bc09cad76533dd33e972baf59910f4ce25d68c9..c5265592c3f82126e1332df5d3d8c2f3aab6a94a 100644 --- a/src/components/Connection/SGEConnect/StepAddress.tsx +++ b/src/components/Connection/SGEConnect/StepAddress.tsx @@ -15,10 +15,10 @@ const StepAddress: React.FC<StepAddressProps> = ({ return ( <div className="sge-step-container stepAddress"> <div className="title text-22-bold"> - {t('auth.enedis-sge-grandlyon.addressTitle')} + {t('auth.enedissgegrandlyon.addressTitle')} </div> <label htmlFor="address" className="text-16-normal"> - {t('auth.enedis-sge-grandlyon.address')} + {t('auth.enedissgegrandlyon.address')} </label> <input type="text" @@ -30,7 +30,7 @@ const StepAddress: React.FC<StepAddressProps> = ({ } /> <label htmlFor="zipCode" className="text-16-normal"> - {t('auth.enedis-sge-grandlyon.zipCode')} + {t('auth.enedissgegrandlyon.zipCode')} </label> <input type="number" @@ -44,7 +44,7 @@ const StepAddress: React.FC<StepAddressProps> = ({ /> <label htmlFor="city" className="text-16-normal"> - {t('auth.enedis-sge-grandlyon.city')} + {t('auth.enedissgegrandlyon.city')} </label> <input type="text" diff --git a/src/components/Connection/SGEConnect/StepConsent.tsx b/src/components/Connection/SGEConnect/StepConsent.tsx index 4386d90ff99aa1c6f9327800eb612a273ff51345..198e33268c04ae69cf49e66515da8ed93730ad54 100644 --- a/src/components/Connection/SGEConnect/StepConsent.tsx +++ b/src/components/Connection/SGEConnect/StepConsent.tsx @@ -17,16 +17,16 @@ const StepConsent: React.FC<StepConsentProps> = ({ return ( <div className="sge-step-container stepConsent"> <div className="head text-16-normal"> - {t('auth.enedis-sge-grandlyon.headConsent')} + {t('auth.enedissgegrandlyon.headConsent')} </div> <div className="title text-22-bold"> - {t('auth.enedis-sge-grandlyon.textConsent')} + {t('auth.enedissgegrandlyon.textConsent')} </div> <ul className="text-16-normal"> - <li>{t('auth.enedis-sge-grandlyon.consentLi1')}</li> - <li>{t('auth.enedis-sge-grandlyon.consentLi2')}</li> - <li>{t('auth.enedis-sge-grandlyon.consentLi3')}</li> - <li>{t('auth.enedis-sge-grandlyon.consentLi4')}</li> + <li>{t('auth.enedissgegrandlyon.consentLi1')}</li> + <li>{t('auth.enedissgegrandlyon.consentLi2')}</li> + <li>{t('auth.enedissgegrandlyon.consentLi3')}</li> + <li>{t('auth.enedissgegrandlyon.consentLi4')}</li> </ul> <hr /> <label @@ -43,7 +43,7 @@ const StepConsent: React.FC<StepConsentProps> = ({ } checked={sgeState.dataConsent} /> - <span>{decoreText(t('auth.enedis-sge-grandlyon.consentCheck1'))}</span> + <span>{decoreText(t('auth.enedissgegrandlyon.consentCheck1'))}</span> </label> <label className={classNames('checkbox', { @@ -59,7 +59,7 @@ const StepConsent: React.FC<StepConsentProps> = ({ } checked={sgeState.pdlConfirm} /> - {decoreText(t('auth.enedis-sge-grandlyon.consentCheck2'))} + {decoreText(t('auth.enedissgegrandlyon.consentCheck2'))} </label> </div> ) diff --git a/src/components/Connection/SGEConnect/StepIdentityAndPdl.tsx b/src/components/Connection/SGEConnect/StepIdentityAndPdl.tsx index 2eb3f7d8033f71c9ec49be90fc4d86e0e53154c1..e545c2b98c080839c01abc5537c179fb8a6c9776 100644 --- a/src/components/Connection/SGEConnect/StepIdentityAndPdl.tsx +++ b/src/components/Connection/SGEConnect/StepIdentityAndPdl.tsx @@ -21,10 +21,10 @@ const StepIdentityAndPdl: React.FC<StepIdentityAndPdlProps> = ({ return ( <div className="sge-step-container stepIdentity"> <div className="title text-22-bold"> - {t('auth.enedis-sge-grandlyon.identityTitle')} + {t('auth.enedissgegrandlyon.identityTitle')} </div> <label htmlFor="firstName" className="text-16-normal"> - {t('auth.enedis-sge-grandlyon.firstName')} + {t('auth.enedissgegrandlyon.firstName')} </label> <input type="text" @@ -37,7 +37,7 @@ const StepIdentityAndPdl: React.FC<StepIdentityAndPdlProps> = ({ required /> <label htmlFor="lastName" className="text-16-normal"> - {t('auth.enedis-sge-grandlyon.lastName')} + {t('auth.enedissgegrandlyon.lastName')} </label> <input type="text" @@ -50,10 +50,10 @@ const StepIdentityAndPdl: React.FC<StepIdentityAndPdlProps> = ({ required /> <div className="title text-22-bold"> - {t('auth.enedis-sge-grandlyon.pdlTitle')} + {t('auth.enedissgegrandlyon.pdlTitle')} </div> <label htmlFor="pdl" className="text-16-normal"> - {t('auth.enedis-sge-grandlyon.pdlLabel')} + {t('auth.enedissgegrandlyon.pdlLabel')} </label> <input id="pdl" @@ -68,7 +68,7 @@ const StepIdentityAndPdl: React.FC<StepIdentityAndPdlProps> = ({ required /> <div onClick={toggleModal} className="pdl-hint text-16-normal"> - {t('auth.enedis-sge-grandlyon.pdlHint')} + {t('auth.enedissgegrandlyon.pdlHint')} </div> <SgeModalHint open={openHintModal} handleCloseClick={toggleModal} /> </div> diff --git a/src/components/Connection/SGEConnect/__snapshots__/SgeConnectView.spec.tsx.snap b/src/components/Connection/SGEConnect/__snapshots__/SgeConnectView.spec.tsx.snap index c47420eacd7e593f218a26ec238f703776ae266f..1aa26c6a5c185ed36a3f4852e907a444658e193b 100644 --- a/src/components/Connection/SGEConnect/__snapshots__/SgeConnectView.spec.tsx.snap +++ b/src/components/Connection/SGEConnect/__snapshots__/SgeConnectView.spec.tsx.snap @@ -652,13 +652,13 @@ exports[`SgeConnectView component should be rendered correctly 1`] = ` <div className="title text-22-bold" > - auth.enedis-sge-grandlyon.identityTitle + auth.enedissgegrandlyon.identityTitle </div> <label className="text-16-normal" htmlFor="firstName" > - auth.enedis-sge-grandlyon.firstName + auth.enedissgegrandlyon.firstName </label> <input id="firstName" @@ -672,7 +672,7 @@ exports[`SgeConnectView component should be rendered correctly 1`] = ` className="text-16-normal" htmlFor="lastName" > - auth.enedis-sge-grandlyon.lastName + auth.enedissgegrandlyon.lastName </label> <input id="lastName" @@ -685,13 +685,13 @@ exports[`SgeConnectView component should be rendered correctly 1`] = ` <div className="title text-22-bold" > - auth.enedis-sge-grandlyon.pdlTitle + auth.enedissgegrandlyon.pdlTitle </div> <label className="text-16-normal" htmlFor="pdl" > - auth.enedis-sge-grandlyon.pdlLabel + auth.enedissgegrandlyon.pdlLabel </label> <input id="pdl" @@ -706,7 +706,7 @@ exports[`SgeConnectView component should be rendered correctly 1`] = ` className="pdl-hint text-16-normal" onClick={[Function]} > - auth.enedis-sge-grandlyon.pdlHint + auth.enedissgegrandlyon.pdlHint </div> <SgeModalHint handleCloseClick={[Function]} diff --git a/src/components/Connection/SGEConnect/__snapshots__/SgeInit.spec.tsx.snap b/src/components/Connection/SGEConnect/__snapshots__/SgeInit.spec.tsx.snap index 0d99d65786b86084707cb9581e5e5c31393a774d..1427c5b554adf3591873040e3b3ed47f441172ec 100644 --- a/src/components/Connection/SGEConnect/__snapshots__/SgeInit.spec.tsx.snap +++ b/src/components/Connection/SGEConnect/__snapshots__/SgeInit.spec.tsx.snap @@ -25,7 +25,7 @@ exports[`SgeInit component should be rendered correctly 1`] = ` "name": "", "oauth": false, "siteLink": "", - "slug": "enedis-sge-grandlyon", + "slug": "enedissgegrandlyon", }, "shouldLaunchKonnector": false, "trigger": null, @@ -42,9 +42,9 @@ exports[`SgeInit component should be rendered correctly 1`] = ` className="kloginform sge-connect" > <p - className="kloginform-title enedis-sge-grandlyon text-20-bold" + className="kloginform-title enedissgegrandlyon text-20-bold" > - auth.enedis-sge-grandlyon.title + auth.enedissgegrandlyon.title </p> <StyledIcon icon="test-file-stub" @@ -78,15 +78,15 @@ exports[`SgeInit component should be rendered correctly 1`] = ` </Icon> </StyledIcon> <p - className="sge-subtitle enedis-sge-grandlyon text-16-regular" + className="sge-subtitle enedissgegrandlyon text-16-regular" > - auth.enedis-sge-grandlyon.bill + auth.enedissgegrandlyon.bill </p> <div className="kloginform-button" > <WithStyles(ForwardRef(Button)) - aria-label="auth.enedis-sge-grandlyon.accessibility.connect" + aria-label="auth.enedissgegrandlyon.accessibility.connect" classes={ Object { "label": "text-16-bold", @@ -96,7 +96,7 @@ exports[`SgeInit component should be rendered correctly 1`] = ` onClick={[Function]} > <ForwardRef(Button) - aria-label="auth.enedis-sge-grandlyon.accessibility.connect" + aria-label="auth.enedissgegrandlyon.accessibility.connect" classes={ Object { "colorInherit": "MuiButton-colorInherit", @@ -133,7 +133,7 @@ exports[`SgeInit component should be rendered correctly 1`] = ` onClick={[Function]} > <WithStyles(ForwardRef(ButtonBase)) - aria-label="auth.enedis-sge-grandlyon.accessibility.connect" + aria-label="auth.enedissgegrandlyon.accessibility.connect" className="MuiButton-root btn-highlight MuiButton-text" component="button" disabled={false} @@ -143,7 +143,7 @@ exports[`SgeInit component should be rendered correctly 1`] = ` type="button" > <ForwardRef(ButtonBase) - aria-label="auth.enedis-sge-grandlyon.accessibility.connect" + aria-label="auth.enedissgegrandlyon.accessibility.connect" className="MuiButton-root btn-highlight MuiButton-text" classes={ Object { @@ -160,7 +160,7 @@ exports[`SgeInit component should be rendered correctly 1`] = ` type="button" > <button - aria-label="auth.enedis-sge-grandlyon.accessibility.connect" + aria-label="auth.enedissgegrandlyon.accessibility.connect" className="MuiButtonBase-root MuiButton-root btn-highlight MuiButton-text" disabled={false} onBlur={[Function]} @@ -181,7 +181,7 @@ exports[`SgeInit component should be rendered correctly 1`] = ` <span className="MuiButton-label text-16-bold" > - auth.enedis-sge-grandlyon.connect + auth.enedissgegrandlyon.connect </span> <WithStyles(memo) center={false} diff --git a/src/components/Connection/SGEConnect/__snapshots__/SgeModalHint.spec.tsx.snap b/src/components/Connection/SGEConnect/__snapshots__/SgeModalHint.spec.tsx.snap index 322986326ee5c10286b79c6e0cd73606677f9067..dd4fb2be651ede0b6b401b7109acf6a54b07dfa5 100644 --- a/src/components/Connection/SGEConnect/__snapshots__/SgeModalHint.spec.tsx.snap +++ b/src/components/Connection/SGEConnect/__snapshots__/SgeModalHint.spec.tsx.snap @@ -451,7 +451,7 @@ exports[`SgeModalHint component should be rendered correctly 1`] = ` <div class="title text-20-bold" > - auth.enedis-sge-grandlyon.modalHint.title + auth.enedissgegrandlyon.modalHint.title </div> <svg class="styles__icon___23x3R" @@ -463,7 +463,7 @@ exports[`SgeModalHint component should be rendered correctly 1`] = ` /> </svg> <button - aria-label="auth.enedis-sge-grandlyon.modalHint.button-accessibility" + aria-label="auth.enedissgegrandlyon.modalHint.button-accessibility" class="MuiButtonBase-root MuiButton-root btn-highlight MuiButton-text" style="height: 40px;" tabindex="0" @@ -472,7 +472,7 @@ exports[`SgeModalHint component should be rendered correctly 1`] = ` <span class="MuiButton-label text-16-bold" > - auth.enedis-sge-grandlyon.modalHint.button + auth.enedissgegrandlyon.modalHint.button </span> <span class="MuiTouchRipple-root" @@ -822,7 +822,7 @@ exports[`SgeModalHint component should be rendered correctly 1`] = ` <div className="title text-20-bold" > - auth.enedis-sge-grandlyon.modalHint.title + auth.enedissgegrandlyon.modalHint.title </div> <Icon height={385} @@ -849,7 +849,7 @@ exports[`SgeModalHint component should be rendered correctly 1`] = ` </Component> </Icon> <WithStyles(ForwardRef(Button)) - aria-label="auth.enedis-sge-grandlyon.modalHint.button-accessibility" + aria-label="auth.enedissgegrandlyon.modalHint.button-accessibility" classes={ Object { "label": "text-16-bold", @@ -864,7 +864,7 @@ exports[`SgeModalHint component should be rendered correctly 1`] = ` } > <ForwardRef(Button) - aria-label="auth.enedis-sge-grandlyon.modalHint.button-accessibility" + aria-label="auth.enedissgegrandlyon.modalHint.button-accessibility" classes={ Object { "colorInherit": "MuiButton-colorInherit", @@ -906,7 +906,7 @@ exports[`SgeModalHint component should be rendered correctly 1`] = ` } > <WithStyles(ForwardRef(ButtonBase)) - aria-label="auth.enedis-sge-grandlyon.modalHint.button-accessibility" + aria-label="auth.enedissgegrandlyon.modalHint.button-accessibility" className="MuiButton-root btn-highlight MuiButton-text" component="button" disabled={false} @@ -921,7 +921,7 @@ exports[`SgeModalHint component should be rendered correctly 1`] = ` type="button" > <ForwardRef(ButtonBase) - aria-label="auth.enedis-sge-grandlyon.modalHint.button-accessibility" + aria-label="auth.enedissgegrandlyon.modalHint.button-accessibility" className="MuiButton-root btn-highlight MuiButton-text" classes={ Object { @@ -943,7 +943,7 @@ exports[`SgeModalHint component should be rendered correctly 1`] = ` type="button" > <button - aria-label="auth.enedis-sge-grandlyon.modalHint.button-accessibility" + aria-label="auth.enedissgegrandlyon.modalHint.button-accessibility" className="MuiButtonBase-root MuiButton-root btn-highlight MuiButton-text" disabled={false} onBlur={[Function]} @@ -969,7 +969,7 @@ exports[`SgeModalHint component should be rendered correctly 1`] = ` <span className="MuiButton-label text-16-bold" > - auth.enedis-sge-grandlyon.modalHint.button + auth.enedissgegrandlyon.modalHint.button </span> <WithStyles(memo) center={false} diff --git a/src/components/Connection/SGEConnect/__snapshots__/StepAddress.spec.tsx.snap b/src/components/Connection/SGEConnect/__snapshots__/StepAddress.spec.tsx.snap index 3414e107bd883a271544835f8f9e3b8394fde859..bffbbf9d0daf4c604fe6515786a9fa9d54a83c71 100644 --- a/src/components/Connection/SGEConnect/__snapshots__/StepAddress.spec.tsx.snap +++ b/src/components/Connection/SGEConnect/__snapshots__/StepAddress.spec.tsx.snap @@ -36,13 +36,13 @@ exports[`StepAddress component should be rendered correctly 1`] = ` <div className="title text-22-bold" > - auth.enedis-sge-grandlyon.addressTitle + auth.enedissgegrandlyon.addressTitle </div> <label className="text-16-normal" htmlFor="address" > - auth.enedis-sge-grandlyon.address + auth.enedissgegrandlyon.address </label> <input id="address" @@ -55,7 +55,7 @@ exports[`StepAddress component should be rendered correctly 1`] = ` className="text-16-normal" htmlFor="zipCode" > - auth.enedis-sge-grandlyon.zipCode + auth.enedissgegrandlyon.zipCode </label> <input id="zipCode" @@ -68,7 +68,7 @@ exports[`StepAddress component should be rendered correctly 1`] = ` className="text-16-normal" htmlFor="city" > - auth.enedis-sge-grandlyon.city + auth.enedissgegrandlyon.city </label> <input id="city" diff --git a/src/components/Connection/SGEConnect/__snapshots__/StepConsent.spec.tsx.snap b/src/components/Connection/SGEConnect/__snapshots__/StepConsent.spec.tsx.snap index 87b0a995e47e4a216dd64121cb2f595a02117a14..ae2a3ae75c32bc99b19d0150bf843cd930829f14 100644 --- a/src/components/Connection/SGEConnect/__snapshots__/StepConsent.spec.tsx.snap +++ b/src/components/Connection/SGEConnect/__snapshots__/StepConsent.spec.tsx.snap @@ -36,27 +36,27 @@ exports[`StepConsent component should be rendered correctly 1`] = ` <div className="head text-16-normal" > - auth.enedis-sge-grandlyon.headConsent + auth.enedissgegrandlyon.headConsent </div> <div className="title text-22-bold" > - auth.enedis-sge-grandlyon.textConsent + auth.enedissgegrandlyon.textConsent </div> <ul className="text-16-normal" > <li> - auth.enedis-sge-grandlyon.consentLi1 + auth.enedissgegrandlyon.consentLi1 </li> <li> - auth.enedis-sge-grandlyon.consentLi2 + auth.enedissgegrandlyon.consentLi2 </li> <li> - auth.enedis-sge-grandlyon.consentLi3 + auth.enedissgegrandlyon.consentLi3 </li> <li> - auth.enedis-sge-grandlyon.consentLi4 + auth.enedissgegrandlyon.consentLi4 </li> </ul> <hr /> @@ -71,7 +71,7 @@ exports[`StepConsent component should be rendered correctly 1`] = ` type="checkbox" /> <span> - auth.enedis-sge-grandlyon.consentCheck1 + auth.enedissgegrandlyon.consentCheck1 </span> </label> <label @@ -84,7 +84,7 @@ exports[`StepConsent component should be rendered correctly 1`] = ` onChange={[Function]} type="checkbox" /> - auth.enedis-sge-grandlyon.consentCheck2 + auth.enedissgegrandlyon.consentCheck2 </label> </div> </StepConsent> diff --git a/src/components/Connection/SGEConnect/__snapshots__/StepIdentityAndPdl.spec.tsx.snap b/src/components/Connection/SGEConnect/__snapshots__/StepIdentityAndPdl.spec.tsx.snap index 6b069ff7f702427d9ad77b0a345bdc6560a63fd5..e5fd436186347e2a50eaf39f652ef27a388c17ae 100644 --- a/src/components/Connection/SGEConnect/__snapshots__/StepIdentityAndPdl.spec.tsx.snap +++ b/src/components/Connection/SGEConnect/__snapshots__/StepIdentityAndPdl.spec.tsx.snap @@ -36,13 +36,13 @@ exports[`StepIdentityAndPdl component should be rendered correctly 1`] = ` <div className="title text-22-bold" > - auth.enedis-sge-grandlyon.identityTitle + auth.enedissgegrandlyon.identityTitle </div> <label className="text-16-normal" htmlFor="firstName" > - auth.enedis-sge-grandlyon.firstName + auth.enedissgegrandlyon.firstName </label> <input id="firstName" @@ -56,7 +56,7 @@ exports[`StepIdentityAndPdl component should be rendered correctly 1`] = ` className="text-16-normal" htmlFor="lastName" > - auth.enedis-sge-grandlyon.lastName + auth.enedissgegrandlyon.lastName </label> <input id="lastName" @@ -69,13 +69,13 @@ exports[`StepIdentityAndPdl component should be rendered correctly 1`] = ` <div className="title text-22-bold" > - auth.enedis-sge-grandlyon.pdlTitle + auth.enedissgegrandlyon.pdlTitle </div> <label className="text-16-normal" htmlFor="pdl" > - auth.enedis-sge-grandlyon.pdlLabel + auth.enedissgegrandlyon.pdlLabel </label> <input id="pdl" @@ -90,7 +90,7 @@ exports[`StepIdentityAndPdl component should be rendered correctly 1`] = ` className="pdl-hint text-16-normal" onClick={[Function]} > - auth.enedis-sge-grandlyon.pdlHint + auth.enedissgegrandlyon.pdlHint </div> <SgeModalHint handleCloseClick={[Function]} diff --git a/src/components/Connection/__snapshots__/Connection.spec.tsx.snap b/src/components/Connection/__snapshots__/Connection.spec.tsx.snap index 080b18b8e1cacca0d5fc4f4417638d0594c694ba..c3cfe15733de7039743ecb266d67ad749fc67a60 100644 --- a/src/components/Connection/__snapshots__/Connection.spec.tsx.snap +++ b/src/components/Connection/__snapshots__/Connection.spec.tsx.snap @@ -17,7 +17,18 @@ exports[`Connection component test should call ConnectionLogin 1`] = ` fluidStatus={ Object { "connection": Object { - "account": null, + "account": Object { + "_id": "test", + "account_type": "test", + "auth": Object { + "address": "address", + "city": "Lyon", + "firstname": "Jane", + "lastname": "Doe", + "pointId": "testid", + "postalCode": "69200", + }, + }, "isUpdating": false, "konnector": null, "konnectorConfig": Object { @@ -25,7 +36,7 @@ exports[`Connection component test should call ConnectionLogin 1`] = ` "name": "", "oauth": false, "siteLink": "", - "slug": "enedis-sge-grandlyon", + "slug": "enedissgegrandlyon", }, "shouldLaunchKonnector": false, "trigger": null, @@ -45,7 +56,18 @@ exports[`Connection component test should call ConnectionLogin 1`] = ` fluidStatus={ Object { "connection": Object { - "account": null, + "account": Object { + "_id": "test", + "account_type": "test", + "auth": Object { + "address": "address", + "city": "Lyon", + "firstname": "Jane", + "lastname": "Doe", + "pointId": "testid", + "postalCode": "69200", + }, + }, "isUpdating": false, "konnector": null, "konnectorConfig": Object { @@ -53,7 +75,7 @@ exports[`Connection component test should call ConnectionLogin 1`] = ` "name": "", "oauth": false, "siteLink": "", - "slug": "enedis-sge-grandlyon", + "slug": "enedissgegrandlyon", }, "shouldLaunchKonnector": false, "trigger": null, @@ -70,9 +92,9 @@ exports[`Connection component test should call ConnectionLogin 1`] = ` className="kloginform sge-connect" > <p - className="kloginform-title enedis-sge-grandlyon text-20-bold" + className="kloginform-title enedissgegrandlyon text-20-bold" > - auth.enedis-sge-grandlyon.title + auth.enedissgegrandlyon.title </p> <StyledIcon icon="test-file-stub" @@ -106,15 +128,15 @@ exports[`Connection component test should call ConnectionLogin 1`] = ` </Icon> </StyledIcon> <p - className="sge-subtitle enedis-sge-grandlyon text-16-regular" + className="sge-subtitle enedissgegrandlyon text-16-regular" > - auth.enedis-sge-grandlyon.bill + auth.enedissgegrandlyon.bill </p> <div className="kloginform-button" > <WithStyles(ForwardRef(Button)) - aria-label="auth.enedis-sge-grandlyon.accessibility.connect" + aria-label="auth.enedissgegrandlyon.accessibility.connect" classes={ Object { "label": "text-16-bold", @@ -124,7 +146,7 @@ exports[`Connection component test should call ConnectionLogin 1`] = ` onClick={[Function]} > <ForwardRef(Button) - aria-label="auth.enedis-sge-grandlyon.accessibility.connect" + aria-label="auth.enedissgegrandlyon.accessibility.connect" classes={ Object { "colorInherit": "MuiButton-colorInherit", @@ -161,7 +183,7 @@ exports[`Connection component test should call ConnectionLogin 1`] = ` onClick={[Function]} > <WithStyles(ForwardRef(ButtonBase)) - aria-label="auth.enedis-sge-grandlyon.accessibility.connect" + aria-label="auth.enedissgegrandlyon.accessibility.connect" className="MuiButton-root btn-highlight MuiButton-text" component="button" disabled={false} @@ -171,7 +193,7 @@ exports[`Connection component test should call ConnectionLogin 1`] = ` type="button" > <ForwardRef(ButtonBase) - aria-label="auth.enedis-sge-grandlyon.accessibility.connect" + aria-label="auth.enedissgegrandlyon.accessibility.connect" className="MuiButton-root btn-highlight MuiButton-text" classes={ Object { @@ -188,7 +210,7 @@ exports[`Connection component test should call ConnectionLogin 1`] = ` type="button" > <button - aria-label="auth.enedis-sge-grandlyon.accessibility.connect" + aria-label="auth.enedissgegrandlyon.accessibility.connect" className="MuiButtonBase-root MuiButton-root btn-highlight MuiButton-text" disabled={false} onBlur={[Function]} @@ -209,7 +231,7 @@ exports[`Connection component test should call ConnectionLogin 1`] = ` <span className="MuiButton-label text-16-bold" > - auth.enedis-sge-grandlyon.connect + auth.enedissgegrandlyon.connect </span> <WithStyles(memo) center={false} diff --git a/src/components/Connection/__snapshots__/ExpiredConsentModal.spec.tsx.snap b/src/components/Connection/__snapshots__/ExpiredConsentModal.spec.tsx.snap index 1ee47a975ce6cb8a834d5af119c0ba4d7379f568..4288ee9d7a22a3dfc207be38ea715fca1ae4b6cd 100644 --- a/src/components/Connection/__snapshots__/ExpiredConsentModal.spec.tsx.snap +++ b/src/components/Connection/__snapshots__/ExpiredConsentModal.spec.tsx.snap @@ -17,6 +17,7 @@ exports[`ExpiredConsentModal component should be rendered correctly 1`] = ` fluidType={0} handleCloseClick={[MockFunction]} open={true} + toggleModal={[MockFunction]} > <WithStyles(ForwardRef(Dialog)) aria-labelledby="accessibility-title" @@ -461,7 +462,7 @@ exports[`ExpiredConsentModal component should be rendered correctly 1`] = ` </svg> </div> <div - class="text-20-normal title electricity" + class="text-20-bold title electricity" > consent_outdated.title.0 </div> @@ -487,7 +488,7 @@ exports[`ExpiredConsentModal component should be rendered correctly 1`] = ` <span class="MuiButton-label text-16-normal" > - consent_outdated.later + consent_outdated.no </span> <span class="MuiTouchRipple-root" @@ -502,7 +503,7 @@ exports[`ExpiredConsentModal component should be rendered correctly 1`] = ` <span class="MuiButton-label text-16-bold" > - consent_outdated.go + consent_outdated.yes </span> <span class="MuiTouchRipple-root" @@ -878,7 +879,7 @@ exports[`ExpiredConsentModal component should be rendered correctly 1`] = ` </Icon> </div> <div - className="text-20-normal title electricity" + className="text-20-bold title electricity" > consent_outdated.title.0 </div> @@ -991,7 +992,7 @@ exports[`ExpiredConsentModal component should be rendered correctly 1`] = ` <span className="MuiButton-label text-16-normal" > - consent_outdated.later + consent_outdated.no </span> <WithStyles(memo) center={false} @@ -1122,7 +1123,7 @@ exports[`ExpiredConsentModal component should be rendered correctly 1`] = ` <span className="MuiButton-label text-16-bold" > - consent_outdated.go + consent_outdated.yes </span> <WithStyles(memo) center={false} diff --git a/src/components/Connection/connectionLogin.scss b/src/components/Connection/connectionLogin.scss index 7f7b8d508ba6cddaca6b97859483d1e4cd47cb8a..6cd0f09f422f3bf8df53e2fd3feca5480aa59dae 100644 --- a/src/components/Connection/connectionLogin.scss +++ b/src/components/Connection/connectionLogin.scss @@ -8,7 +8,7 @@ text-align: center; margin-bottom: 0; padding: 0 1rem; - &.enedis-sge-grandlyon { + &.enedissgegrandlyon { color: $elec-color; } &.grdfgrandlyon { diff --git a/src/components/Home/ConsumptionView.spec.tsx b/src/components/Home/ConsumptionView.spec.tsx index 839e1eb6652327f4501e7b3d9144414752d0315f..8f43dca34dedbc5d211e3bbab6e3ba8678264448 100644 --- a/src/components/Home/ConsumptionView.spec.tsx +++ b/src/components/Home/ConsumptionView.spec.tsx @@ -5,6 +5,7 @@ import * as reactRedux from 'react-redux' import { createMockStore, mockExpiredElec, + mockExpiredGas, mockInitialEcolyoState, } from '../../../tests/__mocks__/store' import * as chartActions from 'store/chart/chart.actions' @@ -54,10 +55,6 @@ jest.mock( () => 'mock-partnersissuemodal' ) jest.mock('components/CustomPopup/CustomPopupModal', () => 'mock-custompopup') -jest.mock( - 'components/Connection/ExpiredConsentModal', - () => 'mock-expiredconsentmodal' -) const useSelectorSpy = jest.spyOn(reactRedux, 'useSelector') const useDispatchSpy = jest.spyOn(reactRedux, 'useDispatch') @@ -202,26 +199,26 @@ describe('ConsumptionView component', () => { ) expect(wrapper.find('mock-partnersissuemodal').exists()).toBeTruthy() }) - it('should render customPopup Modal', async () => { + it('should show expired modal when a GRDF consent is expired', () => { const updatedStatus: FluidStatus[] = mockInitialEcolyoState.global.fluidStatus - updatedStatus[0] = mockExpiredElec + updatedStatus[0] = mockExpiredGas useSelectorSpy.mockReturnValue({ currentTimeStep: TimeStep.WEEK, loading: true, fluidStatus: updatedStatus, releaseNotes: mockInitialEcolyoState.global.releaseNotes, + openPartnersIssueModal: false, }) useDispatchSpy.mockReturnValue(jest.fn()) - mockUpdateProfile.mockResolvedValue(mockTestProfile1) const wrapper = mount( <Provider store={store}> - <ConsumptionView fluidType={FluidType.ELECTRICITY} /> + <ConsumptionView fluidType={FluidType.MULTIFLUID} /> </Provider> ) - expect(wrapper.find('mock-custompopup').exists()).toBeTruthy() + expect(wrapper.find('.title').text()).toBe('consent_outdated.title.2') }) - it('should show expired modal when a fluid oauth is expired', () => { + it('should show expired modal when a Enedis consent is expired', () => { const updatedStatus: FluidStatus[] = mockInitialEcolyoState.global.fluidStatus updatedStatus[0] = mockExpiredElec @@ -237,6 +234,26 @@ describe('ConsumptionView component', () => { <ConsumptionView fluidType={FluidType.MULTIFLUID} /> </Provider> ) - expect(wrapper.find('mock-expiredconsentmodal').exists()).toBeTruthy() + + expect(wrapper.find('.title').text()).toBe('consent_outdated.title.0') + }) + it('should render customPopup Modal', async () => { + const updatedStatus: FluidStatus[] = + mockInitialEcolyoState.global.fluidStatus + updatedStatus[0] = mockExpiredElec + useSelectorSpy.mockReturnValue({ + currentTimeStep: TimeStep.WEEK, + loading: true, + fluidStatus: updatedStatus, + releaseNotes: mockInitialEcolyoState.global.releaseNotes, + }) + useDispatchSpy.mockReturnValue(jest.fn()) + mockUpdateProfile.mockResolvedValue(mockTestProfile1) + const wrapper = mount( + <Provider store={store}> + <ConsumptionView fluidType={FluidType.ELECTRICITY} /> + </Provider> + ) + expect(wrapper.find('mock-custompopup').exists()).toBeTruthy() }) }) diff --git a/src/components/Home/ConsumptionView.tsx b/src/components/Home/ConsumptionView.tsx index 3937386c5031c25da7a6e8b6fafa1f12bf776c73..d6d41e519c4f686117b614a5e32cab199c657a13 100644 --- a/src/components/Home/ConsumptionView.tsx +++ b/src/components/Home/ConsumptionView.tsx @@ -127,17 +127,15 @@ const ConsumptionView: React.FC<ConsumptionViewProps> = ({ useEffect(() => { let subscribed = true + const expiredConsents: FluidType[] = [] //Check if some fluids have expired consent error - const expiredConsents = [] for (const fluid of fluidStatus) { - if ( - fluid.connection.triggerState?.last_error && - getKonnectorUpdateError(fluid.connection.triggerState.last_error) === - 'error_update_oauth' - ) { + const error = fluid.connection.triggerState?.last_error + if (error && getKonnectorUpdateError(error) === 'error_update_oauth') { expiredConsents.push(fluid.fluidType) } } + if (subscribed) setconsentExpiredFluids(expiredConsents) return () => { subscribed = false @@ -227,6 +225,7 @@ const ConsumptionView: React.FC<ConsumptionViewProps> = ({ open={openExpiredConsentModal} handleCloseClick={() => setopenExpiredConsentModal(false)} fluidType={fluid} + toggleModal={() => setopenExpiredConsentModal(prev => !prev)} /> ) })} diff --git a/src/components/Konnector/KonnectorViewerCard.tsx b/src/components/Konnector/KonnectorViewerCard.tsx index 73473e27e531c9bf0d63721fd4469fb31b939878..c160dc6332b4f0f4b35bfd1cb950caf39af4f93a 100644 --- a/src/components/Konnector/KonnectorViewerCard.tsx +++ b/src/components/Konnector/KonnectorViewerCard.tsx @@ -411,6 +411,18 @@ const KonnectorViewerCard: React.FC<KonnectorViewerCardProps> = ({ t, ]) + // If user has selected accept button on Expired consent modal, then delete its account + useEffect(() => { + async function deleteAccountForConsentRefresh() { + if (shouldRefreshConsent && account) { + const accountService = new AccountService(client) + await accountService.deleteAccount(account) + await handleAccountDeletion() + } + } + deleteAccountForConsentRefresh() + }, [account, client, handleAccountDeletion, shouldRefreshConsent]) + useEffect(() => { let subscribed = true async function getData() { @@ -441,7 +453,7 @@ const KonnectorViewerCard: React.FC<KonnectorViewerCardProps> = ({ }) } } - getData() + !shouldRefreshConsent && getData() const dateChartService = new DateChartService() setIsOutdatedData( dateChartService.isDataOutdated(fluidStatus.lastDataDate, fluidType) @@ -464,20 +476,9 @@ const KonnectorViewerCard: React.FC<KonnectorViewerCardProps> = ({ sendUsageEventError, fluidSlug, sendUsageEventSuccess, + shouldRefreshConsent, ]) - useEffect(() => { - // If user has selected accept button on Expired consent modal, then delete its account - async function deleteAccountForConsentRefresh() { - if (shouldRefreshConsent && account) { - const accountService = new AccountService(client) - await accountService.deleteAccount(account) - await handleAccountDeletion() - } - } - deleteAccountForConsentRefresh() - }, [account, client, handleAccountDeletion, shouldRefreshConsent]) - return ( <> {!isDisconnected ? ( diff --git a/src/components/PartnersIssue/__snapshots__/PartnersIssueModal.spec.tsx.snap b/src/components/PartnersIssue/__snapshots__/PartnersIssueModal.spec.tsx.snap index 78f3938af3847753a705996f3986ebf8e17bc63c..4da8c4e6889a12c8b55fffeb912ed50bac6fec2f 100644 --- a/src/components/PartnersIssue/__snapshots__/PartnersIssueModal.spec.tsx.snap +++ b/src/components/PartnersIssue/__snapshots__/PartnersIssueModal.spec.tsx.snap @@ -26,7 +26,7 @@ exports[`PartnersIssueModal component should render correctly 1`] = ` "name": "", "oauth": false, "siteLink": "", - "slug": "enedis-sge-grandlyon", + "slug": "enedissgegrandlyon", }, "shouldLaunchKonnector": false, "trigger": null, diff --git a/src/constants/config.json b/src/constants/config.json index 581709801bba25a1ea6ed4c852a5c231c656e56f..de666adb9fbb5954cd558d2a562b9401db62a5ea 100644 --- a/src/constants/config.json +++ b/src/constants/config.json @@ -9,7 +9,7 @@ "konnectorConfig": { "name": "Enedis", "oauth": false, - "slug": "enedis-sge-grandlyon", + "slug": "enedissgegrandlyon", "siteLink": "https://mon-compte-client.enedis.fr/", "activation": "https://mon-compte-particulier.enedis.fr/donnees/" } diff --git a/src/enum/fluidSlug.enum.ts b/src/enum/fluidSlug.enum.ts index 46404243550a7dde4574bf97b3e9ad2ee944f553..6f9ec91414be1866c7d071a6e02e880c5d07c36f 100644 --- a/src/enum/fluidSlug.enum.ts +++ b/src/enum/fluidSlug.enum.ts @@ -1,5 +1,5 @@ export enum FluidSlugType { - ELECTRICITY = 'enedis-sge-grandlyon', + ELECTRICITY = 'enedissgegrandlyon', WATER = 'eglgrandlyon', GAS = 'grdfgrandlyon', } diff --git a/src/locales/fr.json b/src/locales/fr.json index 700556882c5b616b6b4856decfe4f71cf4cd81fb..8297703c9141082301214e4cd1998d328d5b14f0 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -136,7 +136,7 @@ "text5": "Cette puissance varie d'un mois à l'autre, regardez cette valeur sur l'ensemble de l'année pour vérifier si votre puissance souscrite correspond bien à votre usage." }, "auth": { - "enedis-sge-grandlyon": { + "enedissgegrandlyon": { "title": "Ecolyo doit se connecter à votre compte Enedis", "bill": "Munissez-vous d’une <span>facture d’électricité</span> pour valider la connexion", "connect": "Je me connecte à l'électricité", @@ -799,11 +799,13 @@ "2": "Veuillez re-donner votre accord pour que GRDF nous transmette vos données de consommation." }, "text2": { - "0": "Voulez-vous donner votre accord sur votre compte ENEDIS maintenant ?", + "0": "Souhaitez-vous renouveler votre accord dès maintenant pour un an ?", "2": "Voulez-vous donner votre accord sur votre compte GRDF maintenant ?" }, "later": "Plus tard", - "go": "J'y vais" + "go": "J'y vais", + "no": "Non", + "yes":"Oui" }, "delete_grdf_modal": { "text1": "La suppression de la connexion avec GRDF s’accompagne de la suppression de votre consentement à partager vos données gaz avec Ecolyo.", diff --git a/src/migrations/migration.data.ts b/src/migrations/migration.data.ts index 39a18c6d6fb75441c1114346c73f3ed22126fd55..dae45d0a19ebc27d011ab76f7b7039049466985c 100644 --- a/src/migrations/migration.data.ts +++ b/src/migrations/migration.data.ts @@ -537,7 +537,7 @@ export const migrations: Migration[] = [ appVersion: '1.11.0', description: 'Inform user of the new SGE konnector', releaseNotes: { - title: 'Vos connecteurs evoluent !', + title: 'Vos connecteurs évoluent\u00a0!', description: "Pour continuer à accéder à vos données, merci de vous reconnecter via ce nouveau parcours. Aucune donnée ne sera perdue, et vos données seront à nouveau mises à jour quotidiennement. <p>Pourquoi ce changement ?</p> Pour faciliter l'accès aux données de consommation au plus grand nombre. Plus besoin de se créer un compte Enedis, l'accès aux données en est facilité. N'hésitez pas à en parler autour de vous ! :)", }, diff --git a/src/models/account.model.ts b/src/models/account.model.ts index c3ae32e01a1938ee4deaaea0ae7c6b0fb712c70b..87b5d1ee8aed46020552ccfd97c48c2207f8517d 100644 --- a/src/models/account.model.ts +++ b/src/models/account.model.ts @@ -6,6 +6,10 @@ export interface Account extends AccountAttributes { _type?: string cozyMetadata?: Record<string, any> } +export interface SgeConsentData { + consentId: number + expirationDate: string +} export interface AccountAttributes { account_type: string @@ -14,6 +18,7 @@ export interface AccountAttributes { identifier?: string state?: string | null name?: string + data?: SgeConsentData oauth_callback_results?: Record<string, any> } @@ -30,7 +35,6 @@ export interface AccountOAuthData { token_type?: string } -//Temporary model export interface AccountSgeData { pointId: string address: string diff --git a/src/services/account.service.spec.ts b/src/services/account.service.spec.ts index 26eb9eee1f200e121b0641297fced61dc99cb879..c52dfac07ef6af8d05f3d14f6d6da1b07b62ade5 100644 --- a/src/services/account.service.spec.ts +++ b/src/services/account.service.spec.ts @@ -86,7 +86,7 @@ describe('Account service', () => { expect(result).toBe(null) }) it('should return the account linked to oldest trigger when several account', async () => { - const mockType = 'enedis-sge-grandlyon' + const mockType = 'enedissgegrandlyon' const mockAccounts = accountsData mockAccounts[1].account_type = mockType mockAccounts[2].account_type = mockType @@ -107,7 +107,7 @@ describe('Account service', () => { describe('getAccountsByType method', () => { it('should return all accounts for a type when several account', async () => { - const mockType = 'enedis-sge-grandlyon' + const mockType = 'enedissgegrandlyon' const mockAccounts = accountsData mockAccounts[1].account_type = mockType mockAccounts[2].account_type = mockType diff --git a/src/services/fluid.service.spec.ts b/src/services/fluid.service.spec.ts index e20c2f3fec6fe82f5afa41a1e64ab84f916a3f38..3386a9e185d6e3a7a0cfcccb9d015aa4e4f676bd 100644 --- a/src/services/fluid.service.spec.ts +++ b/src/services/fluid.service.spec.ts @@ -94,7 +94,7 @@ describe('FLuid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedis-sge-grandlyon', + slug: 'enedissgegrandlyon', siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, @@ -180,7 +180,7 @@ describe('FLuid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedis-sge-grandlyon', + slug: 'enedissgegrandlyon', siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, @@ -266,7 +266,7 @@ describe('FLuid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedis-sge-grandlyon', + slug: 'enedissgegrandlyon', siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, @@ -352,7 +352,7 @@ describe('FLuid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedis-sge-grandlyon', + slug: 'enedissgegrandlyon', siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, @@ -439,7 +439,7 @@ describe('FLuid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedis-sge-grandlyon', + slug: 'enedissgegrandlyon', siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, @@ -534,7 +534,7 @@ describe('FLuid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedis-sge-grandlyon', + slug: 'enedissgegrandlyon', siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, @@ -568,7 +568,7 @@ describe('FLuid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedis-sge-grandlyon', + slug: 'enedissgegrandlyon', siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, @@ -602,7 +602,7 @@ describe('FLuid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedis-sge-grandlyon', + slug: 'enedissgegrandlyon', siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, @@ -636,7 +636,7 @@ describe('FLuid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedis-sge-grandlyon', + slug: 'enedissgegrandlyon', siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, @@ -674,7 +674,7 @@ describe('FLuid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedis-sge-grandlyon', + slug: 'enedissgegrandlyon', siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, @@ -731,7 +731,7 @@ describe('FLuid service', () => { konnectorConfig: { name: 'Enedis', oauth: false, - slug: 'enedis-sge-grandlyon', + slug: 'enedissgegrandlyon', siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, diff --git a/src/services/konnector.service.spec.ts b/src/services/konnector.service.spec.ts index 053c06e2de7a3aef9287170768d20050d16f08e9..2e72db7c9615093a8c421e29dca55f409462391e 100644 --- a/src/services/konnector.service.spec.ts +++ b/src/services/konnector.service.spec.ts @@ -30,7 +30,7 @@ describe('KonnectorService service', () => { skip: 0, } mockClient.query.mockResolvedValueOnce(mockQueryResult) - const result = await konnectorService.getKonnector('enedis-sge-grandlyon') + const result = await konnectorService.getKonnector('enedissgegrandlyon') expect(result).toEqual(konnectorsData[0]) }) @@ -42,7 +42,7 @@ describe('KonnectorService service', () => { skip: 0, } mockClient.query.mockResolvedValueOnce(mockQueryResult) - const result = await konnectorService.getKonnector('enedis-sge-grandlyon') + const result = await konnectorService.getKonnector('enedissgegrandlyon') expect(result).toBeNull() }) }) diff --git a/src/store/global/global.reducer.spec.ts b/src/store/global/global.reducer.spec.ts index 3a6399f2e2b10b22aeec1b7a9fed02a9155e19cc..b2fcbc29422955ce7a94b48902f5422d87921056 100644 --- a/src/store/global/global.reducer.spec.ts +++ b/src/store/global/global.reducer.spec.ts @@ -143,7 +143,7 @@ describe('global reducer', () => { konnectorConfig: { name: 'Enedis', oauth: true, - slug: 'enedis-sge-grandlyon', + slug: 'enedissgegrandlyon', siteLink: 'https://mon-compte-particulier.enedis.fr/donnees/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, diff --git a/src/utils/picto.spec.ts b/src/utils/picto.spec.ts index 1e8838e7626615cdb4882cbf9f18dcfe06f45255..29258cd1f3fa72e1fa161772f2963c19bd50bac8 100644 --- a/src/utils/picto.spec.ts +++ b/src/utils/picto.spec.ts @@ -115,11 +115,11 @@ describe('picto utilis test', () => { describe('getPartnerPicto test', () => { it('should return enedis logo icon', () => { - const result = getPartnerPicto('enedis-sge-grandlyon', false) + const result = getPartnerPicto('enedissgegrandlyon', false) expect(result).toBe(iconEnedisLogo) }) it('should return white enedis logo icon', () => { - const result = getPartnerPicto('enedis-sge-grandlyon', true) + const result = getPartnerPicto('enedissgegrandlyon', true) expect(result).toBe(iconEnedisWhiteLogo) }) it('should return egl logo icon', () => { diff --git a/tests/__mocks__/accountsData.mock.ts b/tests/__mocks__/accountsData.mock.ts index f79d94eef56e4c66723c8695915b12a1d944b55b..7b0a6ea948ef619c4360e29ea7525413433db07e 100644 --- a/tests/__mocks__/accountsData.mock.ts +++ b/tests/__mocks__/accountsData.mock.ts @@ -1,10 +1,11 @@ +/* eslint-disable camelcase */ import { Account } from 'models' export const accountsData: Account[] = [ { _id: '88e68b8450cee09fe2f077610901094d', _rev: '1-88e68b8450cee09fe2f077610901094d', - account_type: 'enedis-sge-grandlyon', + account_type: 'enedissgegrandlyon', name: '', oauth: { access_token: 'MY_ACCESS_TOCKEN', diff --git a/tests/__mocks__/fluidStatusData.mock.ts b/tests/__mocks__/fluidStatusData.mock.ts index eed87db3203e78b254cdccc0ce585689ac49ab40..e9c340eba480380d237fdcc29665989eeab09d5b 100644 --- a/tests/__mocks__/fluidStatusData.mock.ts +++ b/tests/__mocks__/fluidStatusData.mock.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import { FluidState } from 'enum/fluid.enum' import { FluidSlugType } from 'enum/fluidSlug.enum' import { DateTime } from 'luxon' @@ -108,7 +109,18 @@ export const fluidStatusConnectedData: FluidStatus[] = [ shouldLaunchKonnector: false, isUpdating: false, konnector: null, - account: null, + account: { + _id: 'test', + account_type: 'test', + auth: { + pointId: 'testid', + address: 'address', + firstname: 'Jane', + lastname: 'Doe', + postalCode: '69200', + city: 'Lyon', + }, + }, trigger: null, triggerState: null, konnectorConfig: { @@ -187,7 +199,7 @@ export const SgeStatusWithAccout: FluidStatus = { account: { _id: '88e68b8450cee09fe2f077610901094d', _rev: '1-88e68b8450cee09fe2f077610901094d', - account_type: 'enedis-sge-grandlyon', + account_type: 'enedissgegrandlyon', name: '', oauth: { access_token: 'MY_ACCESS_TOCKEN', diff --git a/tests/__mocks__/konnectorsData.mock.ts b/tests/__mocks__/konnectorsData.mock.ts index f0671c57702ff4a945a9df22a596ca03731d688a..455fcb57b49f3f907162b69386df2ecd6d0e1515 100644 --- a/tests/__mocks__/konnectorsData.mock.ts +++ b/tests/__mocks__/konnectorsData.mock.ts @@ -2,9 +2,9 @@ import { Konnector } from 'models' export const konnectorsData: Konnector[] = [ { - _id: 'io.cozy.konnectors/enedis-sge-grandlyon', + _id: 'io.cozy.konnectors/enedissgegrandlyon', name: 'Enedis', - slug: 'enedis-sge-grandlyon', + slug: 'enedissgegrandlyon', state: 'ready', }, { diff --git a/tests/__mocks__/mockConfig.mock.ts b/tests/__mocks__/mockConfig.mock.ts index 0a09c66984c13ef33654064323155375debf0f21..a972bca615479316b7db30ca771cab53f5ddd25f 100644 --- a/tests/__mocks__/mockConfig.mock.ts +++ b/tests/__mocks__/mockConfig.mock.ts @@ -10,7 +10,7 @@ const mockConfig = { konnectorConfig: { name: 'Enedis', oauth: true, - slug: 'enedis-sge-grandlyon', + slug: 'enedissgegrandlyon', siteLink: 'https://mon-compte-client.enedis.fr/', activation: 'https://mon-compte-particulier.enedis.fr/donnees/', }, diff --git a/tests/__mocks__/store.ts b/tests/__mocks__/store.ts index 57c37166b8bdb94ce7f8191986f15d4677a46ea4..509c4242e1b3d2473b6b076602252e7bfd3d40cf 100644 --- a/tests/__mocks__/store.ts +++ b/tests/__mocks__/store.ts @@ -1,3 +1,4 @@ +/* eslint-disable camelcase */ import { FluidState, FluidType } from 'enum/fluid.enum' import { FluidSlugType } from 'enum/fluidSlug.enum' import { @@ -134,7 +135,14 @@ export const mockExpiredElec: FluidStatus = { shouldLaunchKonnector: false, isUpdating: false, konnector: null, - account: null, + account: { + _id: '1', + account_type: 'test', + data: { + consentId: 1, + expirationDate: '1999-08-08', + }, + }, trigger: null, triggerState: { trigger_id: '0', @@ -154,6 +162,35 @@ export const mockExpiredElec: FluidStatus = { }, }, } +export const mockExpiredGas: FluidStatus = { + fluidType: FluidType.GAS, + status: FluidState.ERROR_LOGIN_FAILED, + firstDataDate: null, + lastDataDate: null, + connection: { + shouldLaunchKonnector: false, + isUpdating: false, + konnector: null, + account: null, + trigger: null, + triggerState: { + trigger_id: '0', + status: '', + last_executed_job_id: '', + last_execution: '', + last_manual_execution: '', + last_manual_job_id: '', + last_error: 'USER_ACTION_NEEDED.OAUTH_OUTDATED', + }, + konnectorConfig: { + name: '', + oauth: false, + slug: FluidSlugType.GAS, + siteLink: '', + activation: '', + }, + }, +} export const mockInitialProfileState: Profile = { id: '', diff --git a/tests/__mocks__/triggersData.mock.ts b/tests/__mocks__/triggersData.mock.ts index b24db384bb7381a226cfdf10a22a500a64228b46..5ca88daa41cbffb2be3f0048f47b99503051848f 100644 --- a/tests/__mocks__/triggersData.mock.ts +++ b/tests/__mocks__/triggersData.mock.ts @@ -12,7 +12,7 @@ export const triggersData: Trigger[] = [ options: null, message: { account: '88e68b8450cee09fe2f077610901094d', - konnector: 'enedis-sge-grandlyon', + konnector: 'enedissgegrandlyon', }, cozyMetadata: { doctypeVersion: '1', @@ -78,7 +78,7 @@ export const triggersEnedisData: Trigger[] = [ options: null, message: { account: '88e68b8450cee09fe2f077610901094d', - konnector: 'enedis-sge-grandlyon', + konnector: 'enedissgegrandlyon', }, cozyMetadata: { doctypeVersion: '1', @@ -99,7 +99,7 @@ export const triggersEnedisData: Trigger[] = [ options: null, message: { account: '90e68b8450cee09fe2f077610901094d', - konnector: 'enedis-sge-grandlyon', + konnector: 'enedissgegrandlyon', }, cozyMetadata: { doctypeVersion: '1', @@ -120,7 +120,7 @@ export const triggersEnedisData: Trigger[] = [ options: null, message: { account: '89e68b8450cee09fe2f077610901094d', - konnector: 'enedis-sge-grandlyon', + konnector: 'enedissgegrandlyon', }, cozyMetadata: { doctypeVersion: '1',