diff --git a/src/components/Action/ActionBegin/ActionBegin.spec.tsx b/src/components/Action/ActionBegin/ActionBegin.spec.tsx index 68c77e405bf58032d455c5e847fa934e0987fa9b..f4e0ba50d1ed2e4016e6142ab11685a0f3bf6ede 100644 --- a/src/components/Action/ActionBegin/ActionBegin.spec.tsx +++ b/src/components/Action/ActionBegin/ActionBegin.spec.tsx @@ -1,6 +1,5 @@ -import { Button } from '@material-ui/core' -import { mount } from 'enzyme' -import toJson from 'enzyme-to-json' +import { render, screen, waitFor } from '@testing-library/react' +import { userEvent } from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' import { @@ -13,18 +12,14 @@ import { mockGlobalState, mockProfileState, } from 'tests/__mocks__/store' -import { waitForComponentToPaint } from 'tests/__mocks__/testUtils' import { userChallengeData } from 'tests/__mocks__/userChallengeData.mock' -import ActionModal from '../ActionModal/ActionModal' import ActionBegin from './ActionBegin' -const mockgetCustomActions = jest.fn() -const mockgetDefaultActions = jest.fn() +const mockGetCustomActions = jest.fn() jest.mock('services/action.service', () => { return jest.fn(() => ({ - getCustomActions: mockgetCustomActions, - getDefaultActions: mockgetDefaultActions, + getCustomActions: mockGetCustomActions, })) }) @@ -35,7 +30,7 @@ describe('ActionBegin component', () => { profile: mockProfileState, }) - const wrapper = mount( + const { container } = render( <Provider store={store}> <ActionBegin action={defaultEcogestureData[1]} @@ -44,11 +39,11 @@ describe('ActionBegin component', () => { /> </Provider> ) - await waitForComponentToPaint(wrapper) - expect(toJson(wrapper)).toMatchSnapshot() + await waitFor(() => null, { container }) + expect(container).toMatchSnapshot() }) it('should render correctly with custom action', async () => { - mockgetCustomActions.mockResolvedValue([ + mockGetCustomActions.mockResolvedValue([ AllEcogestureData[0], AllEcogestureData[5], AllEcogestureData[2], @@ -57,7 +52,7 @@ describe('ActionBegin component', () => { global: { ...mockGlobalState, fluidTypes: [0, 1, 2] }, profile: { ...mockProfileState, isProfileTypeCompleted: true }, }) - const wrapper = mount( + const { container } = render( <Provider store={store}> <ActionBegin action={mockedEcogesturesData[1]} @@ -66,26 +61,9 @@ describe('ActionBegin component', () => { /> </Provider> ) - await waitForComponentToPaint(wrapper) - expect(wrapper.find('.action-title').text()).toBe('Coup de vent') - }) - it('should render chosen action', async () => { - const store = createMockEcolyoStore({ - global: { ...mockGlobalState, fluidTypes: [0, 1, 2] }, - profile: mockProfileState, - }) - - const wrapper = mount( - <Provider store={store}> - <ActionBegin - action={defaultEcogestureData[1]} - setShowList={jest.fn()} - userChallenge={userChallengeData[1]} - /> - </Provider> - ) - await waitForComponentToPaint(wrapper) - expect(wrapper.find(ActionBegin).exists()).toBeTruthy() + await waitFor(() => null, { container }) + const title = screen.getByRole('heading') + expect(title).toHaveTextContent('Coup de vent') }) it('should open launch Modal', async () => { const store = createMockEcolyoStore({ @@ -93,27 +71,7 @@ describe('ActionBegin component', () => { profile: mockProfileState, }) - const wrapper = mount( - <Provider store={store}> - <ActionBegin - action={defaultEcogestureData[1]} - setShowList={jest.fn()} - userChallenge={userChallengeData[1]} - /> - </Provider> - ) - await waitForComponentToPaint(wrapper) - wrapper.find(Button).first().simulate('click') - expect(wrapper.find(ActionModal).exists()).toBeTruthy() - expect(wrapper.find(ActionModal).prop('open')).toBeTruthy() - }) - it('should go to the list', async () => { - const store = createMockEcolyoStore({ - global: { ...mockGlobalState, fluidTypes: [0, 1, 2] }, - profile: mockProfileState, - }) - - const wrapper = mount( + render( <Provider store={store}> <ActionBegin action={defaultEcogestureData[1]} @@ -122,7 +80,7 @@ describe('ActionBegin component', () => { /> </Provider> ) - await waitForComponentToPaint(wrapper) - wrapper.find(Button).at(1).simulate('click') + await userEvent.click(await screen.findByText('action.apply')) + expect(await screen.findByRole('dialog')).toBeInTheDocument() }) }) diff --git a/src/components/Action/ActionBegin/ActionBegin.tsx b/src/components/Action/ActionBegin/ActionBegin.tsx index 7750f3b15c8989ee02789a15d8a84561152aba6a..50281d6965e06d6d98e6d0653ae37a159d685318 100644 --- a/src/components/Action/ActionBegin/ActionBegin.tsx +++ b/src/components/Action/ActionBegin/ActionBegin.tsx @@ -87,9 +87,7 @@ const ActionBegin = ({ result={userChallenge.progress.actionProgress} isQuizBegin={true} /> - <div className="action-title text-20-bold"> - {currentAction.shortName} - </div> + <h1 className="text-20-bold">{currentAction.shortName}</h1> <div className="action-duration text-18"> {t('action.duration', { smartCount: currentAction.actionDuration, diff --git a/src/components/Action/ActionBegin/__snapshots__/ActionBegin.spec.tsx.snap b/src/components/Action/ActionBegin/__snapshots__/ActionBegin.spec.tsx.snap index 38532ae8504f0068efbe0ca48f2719a2636cf3a6..8bf9c264ef663084bce0d1a421a4ecc092f8ae3b 100644 --- a/src/components/Action/ActionBegin/__snapshots__/ActionBegin.spec.tsx.snap +++ b/src/components/Action/ActionBegin/__snapshots__/ActionBegin.spec.tsx.snap @@ -1,1230 +1,133 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`ActionBegin component should render correctly 1`] = ` -<Provider - store={ - Object { - "clearActions": [Function], - "dispatch": [Function], - "getActions": [Function], - "getState": [Function], - "replaceReducer": [Function], - "subscribe": [Function], - } - } -> - <ActionBegin - action={ - Object { - "_id": "ECOGESTURE0014", - "action": true, - "actionDuration": 3, - "actionName": "J’attends que les plats chauds aient refroidi avant de les mettre au réfrigérateur et je les couvre.", - "difficulty": 1, - "doing": false, - "efficiency": 1, - "equipment": false, - "equipmentInstallation": true, - "equipmentType": Array [], - "fluidTypes": Array [ - 0, - ], - "id": "ECOGESTURE0014", - "impactLevel": 2, - "investment": null, - "longDescription": "En plaçant des plats chauds au réfrigérateur, vous réchauffez l’enceinte de l’appareil, ce qui entraîne une surconsommation. De plus, si les plats ne sont pas couverts, de la vapeur d’eau va se former et provoquer l’apparition du givre. Et couvrir les plats, c’est aussi éviter que les bactéries et les odeurs ne se répandent.", - "longName": "J’attends que les plats chauds aient refroidi avant de les mettre au réfrigérateur et je les couvre.", - "objective": false, - "room": Array [ - 2, - ], - "season": "Sans saison", - "shortName": "Chat échaudé", - "usage": 5, - "viewedInSelection": false, - } - } - setShowList={[MockFunction]} - userChallenge={ - Object { - "action": Object { - "ecogesture": null, - "startDate": null, - "state": 0, - }, - "description": "Description challenge 2", - "duel": Object { - "description": "Je parie un ours polaire que vous ne pouvez pas consommer moins que #CONSUMPTION € en 1 semaine", - "duration": "P30D", - "fluidTypes": Array [], - "id": "DUEL001", - "startDate": null, - "state": 0, - "threshold": 0, - "title": "Title DUEL001", - "userConsumption": 0, - }, - "endingDate": null, - "exploration": Object { - "complementary_description": "Refaire un tour dans son profil si déjà fait", - "date": null, - "description": "Avoir complété son profil", - "ecogesture_id": "", - "fluid_condition": Array [], - "id": "EXPLORATION001", - "message_success": "Vous avez complété votre profil ou refait un tour dans votre profil", - "progress": 0, - "state": 0, - "target": 1, - "type": 1, - }, - "id": "CHALLENGE0002", - "progress": Object { - "actionProgress": 0, - "explorationProgress": 0, - "quizProgress": 0, - }, - "quiz": Object { - "customQuestion": Object { - "interval": 20, - "period": Object {}, - "questionLabel": "Custom1", - "result": 0, - "singleFluid": false, - "timeStep": 20, - "type": 0, - }, - "id": "QUIZ001", - "questions": Array [ - Object { - "answers": Array [ - Object { - "answerLabel": "86 km", - "isTrue": true, - }, - Object { - "answerLabel": "78 km", - "isTrue": false, - }, - Object { - "answerLabel": "56 km", - "isTrue": false, - }, - ], - "explanation": "L’aqueduc du Gier est un des aqueducs antiques de Lyon desservant la ville antique de Lugdunum. Avec ses 86 km il est le plus long des quatre aqueducs ayant alimenté la ville en eau, et celui dont les structures sont le mieux conservées. Il doit son nom au fait qu'il puise aux sources du Gier, affluent du Rhône", - "questionLabel": "Quelle longueur faisait l’aqueduc du Gier pour acheminer l’eau sur Lyon à l’époque romaine ?", - "result": 0, - "source": "string", - }, - Object { - "answers": Array [ - Object { - "answerLabel": "1 point d’eau public pour 800 habitants.", - "isTrue": true, - }, - Object { - "answerLabel": "1 point d’eau public pour 400 habitants.", - "isTrue": false, - }, - Object { - "answerLabel": "1 point d’eau public pour 200 habitants.", - "isTrue": false, - }, - ], - "explanation": "string", - "questionLabel": "En 1800 à Lyon, combien de points d'eau y avait-il par habitants ?", - "result": 0, - "source": "string", - }, - Object { - "answers": Array [ - Object { - "answerLabel": "François Mitterrand", - "isTrue": false, - }, - Object { - "answerLabel": "Napoléon Ier", - "isTrue": true, - }, - Object { - "answerLabel": "Napoléon III", - "isTrue": false, - }, - ], - "explanation": "string", - "questionLabel": "Qui officialise la création de la Compagnie Générale des eaux ?", - "result": 0, - "source": "string", - }, - Object { - "answers": Array [ - Object { - "answerLabel": "string", - "isTrue": false, - }, - Object { - "answerLabel": "string", - "isTrue": false, - }, - Object { - "answerLabel": "Aristide Dumont", - "isTrue": true, - }, - ], - "explanation": "string", - "questionLabel": "Quel ingénieur est à l’origine du projet d’alimentation en eau en 1856 ?", - "result": 0, - "source": "string", - }, - ], - "result": 0, - "startDate": null, - "state": 0, - }, - "startDate": null, - "state": 4, - "success": 1, - "target": 15, - "title": "Challenge 2", - } - } +<div> + <div + class="action-begin" > <div - className="action-begin" + class="action-container" > <div - className="action-container" + class="action-begin-container" > <div - className="action-begin-container" + class="icon-container" > - <div - className="icon-container" + <svg + aria-hidden="true" + class="action-icon styles__icon___23x3R" + height="100" + width="100" > - <StyledIcon - className="action-icon" - icon="test-file-stub" - size={100} - > - <Icon - aria-hidden={true} - className="action-icon" - icon="test-file-stub" - size={100} - spin={false} - > - <Component - aria-hidden={true} - className="action-icon styles__icon___23x3R" - height={100} - style={Object {}} - width={100} - > - <svg - aria-hidden={true} - className="action-icon styles__icon___23x3R" - height={100} - style={Object {}} - width={100} - > - <use - xlinkHref="#test-file-stub" - /> - </svg> - </Component> - </Icon> - </StyledIcon> - </div> - <StarsContainer - isQuizBegin={true} - result={0} + <use + xlink:href="#test-file-stub" + /> + </svg> + </div> + <div + class="stars" + > + <svg + aria-hidden="true" + class="star styles__icon___23x3R" + height="25" + width="25" > - <div - className="stars" - > - <StyledIcon - className="star" - icon="test-file-stub" - key="1" - size={25} - > - <Icon - aria-hidden={true} - className="star" - icon="test-file-stub" - size={25} - spin={false} - > - <Component - aria-hidden={true} - className="star styles__icon___23x3R" - height={25} - style={Object {}} - width={25} - > - <svg - aria-hidden={true} - className="star styles__icon___23x3R" - height={25} - style={Object {}} - width={25} - > - <use - xlinkHref="#test-file-stub" - /> - </svg> - </Component> - </Icon> - </StyledIcon> - <StyledIcon - className="star" - icon="test-file-stub" - key="2" - size={25} - > - <Icon - aria-hidden={true} - className="star" - icon="test-file-stub" - size={25} - spin={false} - > - <Component - aria-hidden={true} - className="star styles__icon___23x3R" - height={25} - style={Object {}} - width={25} - > - <svg - aria-hidden={true} - className="star styles__icon___23x3R" - height={25} - style={Object {}} - width={25} - > - <use - xlinkHref="#test-file-stub" - /> - </svg> - </Component> - </Icon> - </StyledIcon> - <StyledIcon - className="star" - icon="test-file-stub" - key="3" - size={25} - > - <Icon - aria-hidden={true} - className="star" - icon="test-file-stub" - size={25} - spin={false} - > - <Component - aria-hidden={true} - className="star styles__icon___23x3R" - height={25} - style={Object {}} - width={25} - > - <svg - aria-hidden={true} - className="star styles__icon___23x3R" - height={25} - style={Object {}} - width={25} - > - <use - xlinkHref="#test-file-stub" - /> - </svg> - </Component> - </Icon> - </StyledIcon> - <StyledIcon - className="star" - icon="test-file-stub" - key="4" - size={25} - > - <Icon - aria-hidden={true} - className="star" - icon="test-file-stub" - size={25} - spin={false} - > - <Component - aria-hidden={true} - className="star styles__icon___23x3R" - height={25} - style={Object {}} - width={25} - > - <svg - aria-hidden={true} - className="star styles__icon___23x3R" - height={25} - style={Object {}} - width={25} - > - <use - xlinkHref="#test-file-stub" - /> - </svg> - </Component> - </Icon> - </StyledIcon> - <StyledIcon - className="star" - icon="test-file-stub" - key="5" - size={25} - > - <Icon - aria-hidden={true} - className="star" - icon="test-file-stub" - size={25} - spin={false} - > - <Component - aria-hidden={true} - className="star styles__icon___23x3R" - height={25} - style={Object {}} - width={25} - > - <svg - aria-hidden={true} - className="star styles__icon___23x3R" - height={25} - style={Object {}} - width={25} - > - <use - xlinkHref="#test-file-stub" - /> - </svg> - </Component> - </Icon> - </StyledIcon> - </div> - </StarsContainer> - <div - className="action-title text-20-bold" + <use + xlink:href="#test-file-stub" + /> + </svg> + <svg + aria-hidden="true" + class="star styles__icon___23x3R" + height="25" + width="25" > - Chat échaudé - </div> - <div - className="action-duration text-18" + <use + xlink:href="#test-file-stub" + /> + </svg> + <svg + aria-hidden="true" + class="star styles__icon___23x3R" + height="25" + width="25" > - action.duration - </div> - <div - className="action-text text-18-bold" + <use + xlink:href="#test-file-stub" + /> + </svg> + <svg + aria-hidden="true" + class="star styles__icon___23x3R" + height="25" + width="25" > - J’attends que les plats chauds aient refroidi avant de les mettre au réfrigérateur et je les couvre. - </div> - <div - className="action-buttons" + <use + xlink:href="#test-file-stub" + /> + </svg> + <svg + aria-hidden="true" + class="star styles__icon___23x3R" + height="25" + width="25" > - <WithStyles(ForwardRef(Button)) - className="btnSecondary" - onClick={[Function]} - > - <ForwardRef(Button) - className="btnSecondary" - classes={ - Object { - "colorInherit": "MuiButton-colorInherit", - "contained": "MuiButton-contained", - "containedPrimary": "MuiButton-containedPrimary", - "containedSecondary": "MuiButton-containedSecondary", - "containedSizeLarge": "MuiButton-containedSizeLarge", - "containedSizeSmall": "MuiButton-containedSizeSmall", - "disableElevation": "MuiButton-disableElevation", - "disabled": "Mui-disabled", - "endIcon": "MuiButton-endIcon", - "focusVisible": "Mui-focusVisible", - "fullWidth": "MuiButton-fullWidth", - "iconSizeLarge": "MuiButton-iconSizeLarge", - "iconSizeMedium": "MuiButton-iconSizeMedium", - "iconSizeSmall": "MuiButton-iconSizeSmall", - "label": "MuiButton-label", - "outlined": "MuiButton-outlined", - "outlinedPrimary": "MuiButton-outlinedPrimary", - "outlinedSecondary": "MuiButton-outlinedSecondary", - "outlinedSizeLarge": "MuiButton-outlinedSizeLarge", - "outlinedSizeSmall": "MuiButton-outlinedSizeSmall", - "root": "MuiButton-root", - "sizeLarge": "MuiButton-sizeLarge", - "sizeSmall": "MuiButton-sizeSmall", - "startIcon": "MuiButton-startIcon", - "text": "MuiButton-text", - "textPrimary": "MuiButton-textPrimary", - "textSecondary": "MuiButton-textSecondary", - "textSizeLarge": "MuiButton-textSizeLarge", - "textSizeSmall": "MuiButton-textSizeSmall", - } - } - onClick={[Function]} - > - <WithStyles(ForwardRef(ButtonBase)) - className="MuiButton-root MuiButton-text btnSecondary" - component="button" - disabled={false} - focusRipple={true} - focusVisibleClassName="Mui-focusVisible" - onClick={[Function]} - type="button" - > - <ForwardRef(ButtonBase) - className="MuiButton-root MuiButton-text btnSecondary" - classes={ - Object { - "disabled": "Mui-disabled", - "focusVisible": "Mui-focusVisible", - "root": "MuiButtonBase-root", - } - } - component="button" - disabled={false} - focusRipple={true} - focusVisibleClassName="Mui-focusVisible" - onClick={[Function]} - type="button" - > - <button - className="MuiButtonBase-root MuiButton-root MuiButton-text btnSecondary" - disabled={false} - onBlur={[Function]} - onClick={[Function]} - onDragLeave={[Function]} - onFocus={[Function]} - onKeyDown={[Function]} - onKeyUp={[Function]} - onMouseDown={[Function]} - onMouseLeave={[Function]} - onMouseUp={[Function]} - onTouchEnd={[Function]} - onTouchMove={[Function]} - onTouchStart={[Function]} - tabIndex={0} - type="button" - > - <span - className="MuiButton-label" - > - action.apply - </span> - <WithStyles(memo) - center={false} - > - <ForwardRef(TouchRipple) - center={false} - classes={ - Object { - "child": "MuiTouchRipple-child", - "childLeaving": "MuiTouchRipple-childLeaving", - "childPulsate": "MuiTouchRipple-childPulsate", - "ripple": "MuiTouchRipple-ripple", - "ripplePulsate": "MuiTouchRipple-ripplePulsate", - "rippleVisible": "MuiTouchRipple-rippleVisible", - "root": "MuiTouchRipple-root", - } - } - > - <span - className="MuiTouchRipple-root" - > - <TransitionGroup - childFactory={[Function]} - component={null} - exit={true} - /> - </span> - </ForwardRef(TouchRipple)> - </WithStyles(memo)> - </button> - </ForwardRef(ButtonBase)> - </WithStyles(ForwardRef(ButtonBase))> - </ForwardRef(Button)> - </WithStyles(ForwardRef(Button))> - <WithStyles(ForwardRef(Button)) - className="btnSecondary" - onClick={[Function]} - > - <ForwardRef(Button) - className="btnSecondary" - classes={ - Object { - "colorInherit": "MuiButton-colorInherit", - "contained": "MuiButton-contained", - "containedPrimary": "MuiButton-containedPrimary", - "containedSecondary": "MuiButton-containedSecondary", - "containedSizeLarge": "MuiButton-containedSizeLarge", - "containedSizeSmall": "MuiButton-containedSizeSmall", - "disableElevation": "MuiButton-disableElevation", - "disabled": "Mui-disabled", - "endIcon": "MuiButton-endIcon", - "focusVisible": "Mui-focusVisible", - "fullWidth": "MuiButton-fullWidth", - "iconSizeLarge": "MuiButton-iconSizeLarge", - "iconSizeMedium": "MuiButton-iconSizeMedium", - "iconSizeSmall": "MuiButton-iconSizeSmall", - "label": "MuiButton-label", - "outlined": "MuiButton-outlined", - "outlinedPrimary": "MuiButton-outlinedPrimary", - "outlinedSecondary": "MuiButton-outlinedSecondary", - "outlinedSizeLarge": "MuiButton-outlinedSizeLarge", - "outlinedSizeSmall": "MuiButton-outlinedSizeSmall", - "root": "MuiButton-root", - "sizeLarge": "MuiButton-sizeLarge", - "sizeSmall": "MuiButton-sizeSmall", - "startIcon": "MuiButton-startIcon", - "text": "MuiButton-text", - "textPrimary": "MuiButton-textPrimary", - "textSecondary": "MuiButton-textSecondary", - "textSizeLarge": "MuiButton-textSizeLarge", - "textSizeSmall": "MuiButton-textSizeSmall", - } - } - onClick={[Function]} - > - <WithStyles(ForwardRef(ButtonBase)) - className="MuiButton-root MuiButton-text btnSecondary" - component="button" - disabled={false} - focusRipple={true} - focusVisibleClassName="Mui-focusVisible" - onClick={[Function]} - type="button" - > - <ForwardRef(ButtonBase) - className="MuiButton-root MuiButton-text btnSecondary" - classes={ - Object { - "disabled": "Mui-disabled", - "focusVisible": "Mui-focusVisible", - "root": "MuiButtonBase-root", - } - } - component="button" - disabled={false} - focusRipple={true} - focusVisibleClassName="Mui-focusVisible" - onClick={[Function]} - type="button" - > - <button - className="MuiButtonBase-root MuiButton-root MuiButton-text btnSecondary" - disabled={false} - onBlur={[Function]} - onClick={[Function]} - onDragLeave={[Function]} - onFocus={[Function]} - onKeyDown={[Function]} - onKeyUp={[Function]} - onMouseDown={[Function]} - onMouseLeave={[Function]} - onMouseUp={[Function]} - onTouchEnd={[Function]} - onTouchMove={[Function]} - onTouchStart={[Function]} - tabIndex={0} - type="button" - > - <span - className="MuiButton-label" - > - action.other - </span> - <WithStyles(memo) - center={false} - > - <ForwardRef(TouchRipple) - center={false} - classes={ - Object { - "child": "MuiTouchRipple-child", - "childLeaving": "MuiTouchRipple-childLeaving", - "childPulsate": "MuiTouchRipple-childPulsate", - "ripple": "MuiTouchRipple-ripple", - "ripplePulsate": "MuiTouchRipple-ripplePulsate", - "rippleVisible": "MuiTouchRipple-rippleVisible", - "root": "MuiTouchRipple-root", - } - } - > - <span - className="MuiTouchRipple-root" - > - <TransitionGroup - childFactory={[Function]} - component={null} - exit={true} - /> - </span> - </ForwardRef(TouchRipple)> - </WithStyles(memo)> - </button> - </ForwardRef(ButtonBase)> - </WithStyles(ForwardRef(ButtonBase))> - </ForwardRef(Button)> - </WithStyles(ForwardRef(Button))> - </div> + <use + xlink:href="#test-file-stub" + /> + </svg> + </div> + <h1 + class="text-20-bold" + > + Chat échaudé + </h1> + <div + class="action-duration text-18" + > + action.duration </div> - <ActionModal - action={ - Object { - "_id": "ECOGESTURE0014", - "action": true, - "actionDuration": 3, - "actionName": "J’attends que les plats chauds aient refroidi avant de les mettre au réfrigérateur et je les couvre.", - "difficulty": 1, - "doing": false, - "efficiency": 1, - "equipment": false, - "equipmentInstallation": true, - "equipmentType": Array [], - "fluidTypes": Array [ - 0, - ], - "id": "ECOGESTURE0014", - "impactLevel": 2, - "investment": null, - "longDescription": "En plaçant des plats chauds au réfrigérateur, vous réchauffez l’enceinte de l’appareil, ce qui entraîne une surconsommation. De plus, si les plats ne sont pas couverts, de la vapeur d’eau va se former et provoquer l’apparition du givre. Et couvrir les plats, c’est aussi éviter que les bactéries et les odeurs ne se répandent.", - "longName": "J’attends que les plats chauds aient refroidi avant de les mettre au réfrigérateur et je les couvre.", - "objective": false, - "room": Array [ - 2, - ], - "season": "Sans saison", - "shortName": "Chat échaudé", - "usage": 5, - "viewedInSelection": false, - } - } - handleCloseClick={[Function]} - open={false} - userChallenge={ - Object { - "action": Object { - "ecogesture": null, - "startDate": null, - "state": 0, - }, - "description": "Description challenge 2", - "duel": Object { - "description": "Je parie un ours polaire que vous ne pouvez pas consommer moins que #CONSUMPTION € en 1 semaine", - "duration": "P30D", - "fluidTypes": Array [], - "id": "DUEL001", - "startDate": null, - "state": 0, - "threshold": 0, - "title": "Title DUEL001", - "userConsumption": 0, - }, - "endingDate": null, - "exploration": Object { - "complementary_description": "Refaire un tour dans son profil si déjà fait", - "date": null, - "description": "Avoir complété son profil", - "ecogesture_id": "", - "fluid_condition": Array [], - "id": "EXPLORATION001", - "message_success": "Vous avez complété votre profil ou refait un tour dans votre profil", - "progress": 0, - "state": 0, - "target": 1, - "type": 1, - }, - "id": "CHALLENGE0002", - "progress": Object { - "actionProgress": 0, - "explorationProgress": 0, - "quizProgress": 0, - }, - "quiz": Object { - "customQuestion": Object { - "interval": 20, - "period": Object {}, - "questionLabel": "Custom1", - "result": 0, - "singleFluid": false, - "timeStep": 20, - "type": 0, - }, - "id": "QUIZ001", - "questions": Array [ - Object { - "answers": Array [ - Object { - "answerLabel": "86 km", - "isTrue": true, - }, - Object { - "answerLabel": "78 km", - "isTrue": false, - }, - Object { - "answerLabel": "56 km", - "isTrue": false, - }, - ], - "explanation": "L’aqueduc du Gier est un des aqueducs antiques de Lyon desservant la ville antique de Lugdunum. Avec ses 86 km il est le plus long des quatre aqueducs ayant alimenté la ville en eau, et celui dont les structures sont le mieux conservées. Il doit son nom au fait qu'il puise aux sources du Gier, affluent du Rhône", - "questionLabel": "Quelle longueur faisait l’aqueduc du Gier pour acheminer l’eau sur Lyon à l’époque romaine ?", - "result": 0, - "source": "string", - }, - Object { - "answers": Array [ - Object { - "answerLabel": "1 point d’eau public pour 800 habitants.", - "isTrue": true, - }, - Object { - "answerLabel": "1 point d’eau public pour 400 habitants.", - "isTrue": false, - }, - Object { - "answerLabel": "1 point d’eau public pour 200 habitants.", - "isTrue": false, - }, - ], - "explanation": "string", - "questionLabel": "En 1800 à Lyon, combien de points d'eau y avait-il par habitants ?", - "result": 0, - "source": "string", - }, - Object { - "answers": Array [ - Object { - "answerLabel": "François Mitterrand", - "isTrue": false, - }, - Object { - "answerLabel": "Napoléon Ier", - "isTrue": true, - }, - Object { - "answerLabel": "Napoléon III", - "isTrue": false, - }, - ], - "explanation": "string", - "questionLabel": "Qui officialise la création de la Compagnie Générale des eaux ?", - "result": 0, - "source": "string", - }, - Object { - "answers": Array [ - Object { - "answerLabel": "string", - "isTrue": false, - }, - Object { - "answerLabel": "string", - "isTrue": false, - }, - Object { - "answerLabel": "Aristide Dumont", - "isTrue": true, - }, - ], - "explanation": "string", - "questionLabel": "Quel ingénieur est à l’origine du projet d’alimentation en eau en 1856 ?", - "result": 0, - "source": "string", - }, - ], - "result": 0, - "startDate": null, - "state": 0, - }, - "startDate": null, - "state": 4, - "success": 1, - "target": 15, - "title": "Challenge 2", - } - } + <div + class="action-text text-18-bold" > - <WithStyles(ForwardRef(Dialog)) - aria-labelledby="accessibility-title" - classes={ - Object { - "paper": "modal-paper", - "root": "modal-root", - } - } - onClose={[Function]} - open={false} + J’attends que les plats chauds aient refroidi avant de les mettre au réfrigérateur et je les couvre. + </div> + <div + class="action-buttons" + > + <button + class="MuiButtonBase-root MuiButton-root MuiButton-text btnSecondary" + tabindex="0" + type="button" + > + <span + class="MuiButton-label" + > + action.apply + </span> + <span + class="MuiTouchRipple-root" + /> + </button> + <button + class="MuiButtonBase-root MuiButton-root MuiButton-text btnSecondary" + tabindex="0" + type="button" > - <ForwardRef(Dialog) - aria-labelledby="accessibility-title" - classes={ - Object { - "container": "MuiDialog-container", - "paper": "MuiDialog-paper modal-paper", - "paperFullScreen": "MuiDialog-paperFullScreen", - "paperFullWidth": "MuiDialog-paperFullWidth", - "paperScrollBody": "MuiDialog-paperScrollBody", - "paperScrollPaper": "MuiDialog-paperScrollPaper", - "paperWidthFalse": "MuiDialog-paperWidthFalse", - "paperWidthLg": "MuiDialog-paperWidthLg", - "paperWidthMd": "MuiDialog-paperWidthMd", - "paperWidthSm": "MuiDialog-paperWidthSm", - "paperWidthXl": "MuiDialog-paperWidthXl", - "paperWidthXs": "MuiDialog-paperWidthXs", - "root": "MuiDialog-root modal-root", - "scrollBody": "MuiDialog-scrollBody", - "scrollPaper": "MuiDialog-scrollPaper", - } - } - onClose={[Function]} - open={false} + <span + class="MuiButton-label" > - <ForwardRef(Modal) - BackdropComponent={ - Object { - "$$typeof": Symbol(react.forward_ref), - "Naked": Object { - "$$typeof": Symbol(react.forward_ref), - "propTypes": Object { - "children": [Function], - "className": [Function], - "classes": [Function], - "invisible": [Function], - "open": [Function], - "transitionDuration": [Function], - }, - "render": [Function], - }, - "displayName": "WithStyles(ForwardRef(Backdrop))", - "options": Object { - "defaultTheme": Object { - "breakpoints": Object { - "between": [Function], - "down": [Function], - "keys": Array [ - "xs", - "sm", - "md", - "lg", - "xl", - ], - "only": [Function], - "up": [Function], - "values": Object { - "lg": 1280, - "md": 960, - "sm": 600, - "xl": 1920, - "xs": 0, - }, - "width": [Function], - }, - "direction": "ltr", - "mixins": Object { - "gutters": [Function], - "toolbar": Object { - "@media (min-width:0px) and (orientation: landscape)": Object { - "minHeight": 48, - }, - "@media (min-width:600px)": Object { - "minHeight": 64, - }, - "minHeight": 56, - }, - }, - "overrides": Object {}, - "palette": Object { - "action": Object { - "activatedOpacity": 0.12, - "active": "rgba(0, 0, 0, 0.54)", - "disabled": "rgba(0, 0, 0, 0.26)", - "disabledBackground": "rgba(0, 0, 0, 0.12)", - "disabledOpacity": 0.38, - "focus": "rgba(0, 0, 0, 0.12)", - "focusOpacity": 0.12, - "hover": "rgba(0, 0, 0, 0.04)", - "hoverOpacity": 0.04, - "selected": "rgba(0, 0, 0, 0.08)", - "selectedOpacity": 0.08, - }, - "augmentColor": [Function], - "background": Object { - "default": "#fafafa", - "paper": "#fff", - }, - "common": Object { - "black": "#000", - "white": "#fff", - }, - "contrastThreshold": 3, - "divider": "rgba(0, 0, 0, 0.12)", - "error": Object { - "contrastText": "#fff", - "dark": "#d32f2f", - "light": "#e57373", - "main": "#f44336", - }, - "getContrastText": [Function], - "grey": Object { - "100": "#f5f5f5", - "200": "#eeeeee", - "300": "#e0e0e0", - "400": "#bdbdbd", - "50": "#fafafa", - "500": "#9e9e9e", - "600": "#757575", - "700": "#616161", - "800": "#424242", - "900": "#212121", - "A100": "#d5d5d5", - "A200": "#aaaaaa", - "A400": "#303030", - "A700": "#616161", - }, - "info": Object { - "contrastText": "#fff", - "dark": "#1976d2", - "light": "#64b5f6", - "main": "#2196f3", - }, - "primary": Object { - "contrastText": "#fff", - "dark": "#303f9f", - "light": "#7986cb", - "main": "#3f51b5", - }, - "secondary": Object { - "contrastText": "#fff", - "dark": "#c51162", - "light": "#ff4081", - "main": "#f50057", - }, - "success": Object { - "contrastText": "rgba(0, 0, 0, 0.87)", - "dark": "#388e3c", - "light": "#81c784", - "main": "#4caf50", - }, - "text": Object { - "disabled": "rgba(0, 0, 0, 0.38)", - "hint": "rgba(0, 0, 0, 0.38)", - "primary": "rgba(0, 0, 0, 0.87)", - "secondary": "rgba(0, 0, 0, 0.54)", - }, - "tonalOffset": 0.2, - "type": "light", - "warning": Object { - "contrastText": "rgba(0, 0, 0, 0.87)", - "dark": "#f57c00", - "light": "#ffb74d", - "main": "#ff9800", - }, - }, - "props": Object {}, - "shadows": Array [ - "none", - "0px 2px 1px -1px rgba(0,0,0,0.2),0px 1px 1px 0px rgba(0,0,0,0.14),0px 1px 3px 0px rgba(0,0,0,0.12)", - "0px 3px 1px -2px rgba(0,0,0,0.2),0px 2px 2px 0px rgba(0,0,0,0.14),0px 1px 5px 0px rgba(0,0,0,0.12)", - "0px 3px 3px -2px rgba(0,0,0,0.2),0px 3px 4px 0px rgba(0,0,0,0.14),0px 1px 8px 0px rgba(0,0,0,0.12)", - "0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12)", - "0px 3px 5px -1px rgba(0,0,0,0.2),0px 5px 8px 0px rgba(0,0,0,0.14),0px 1px 14px 0px rgba(0,0,0,0.12)", - "0px 3px 5px -1px rgba(0,0,0,0.2),0px 6px 10px 0px rgba(0,0,0,0.14),0px 1px 18px 0px rgba(0,0,0,0.12)", - "0px 4px 5px -2px rgba(0,0,0,0.2),0px 7px 10px 1px rgba(0,0,0,0.14),0px 2px 16px 1px rgba(0,0,0,0.12)", - "0px 5px 5px -3px rgba(0,0,0,0.2),0px 8px 10px 1px rgba(0,0,0,0.14),0px 3px 14px 2px rgba(0,0,0,0.12)", - "0px 5px 6px -3px rgba(0,0,0,0.2),0px 9px 12px 1px rgba(0,0,0,0.14),0px 3px 16px 2px rgba(0,0,0,0.12)", - "0px 6px 6px -3px rgba(0,0,0,0.2),0px 10px 14px 1px rgba(0,0,0,0.14),0px 4px 18px 3px rgba(0,0,0,0.12)", - "0px 6px 7px -4px rgba(0,0,0,0.2),0px 11px 15px 1px rgba(0,0,0,0.14),0px 4px 20px 3px rgba(0,0,0,0.12)", - "0px 7px 8px -4px rgba(0,0,0,0.2),0px 12px 17px 2px rgba(0,0,0,0.14),0px 5px 22px 4px rgba(0,0,0,0.12)", - "0px 7px 8px -4px rgba(0,0,0,0.2),0px 13px 19px 2px rgba(0,0,0,0.14),0px 5px 24px 4px rgba(0,0,0,0.12)", - "0px 7px 9px -4px rgba(0,0,0,0.2),0px 14px 21px 2px rgba(0,0,0,0.14),0px 5px 26px 4px rgba(0,0,0,0.12)", - "0px 8px 9px -5px rgba(0,0,0,0.2),0px 15px 22px 2px rgba(0,0,0,0.14),0px 6px 28px 5px rgba(0,0,0,0.12)", - "0px 8px 10px -5px rgba(0,0,0,0.2),0px 16px 24px 2px rgba(0,0,0,0.14),0px 6px 30px 5px rgba(0,0,0,0.12)", - "0px 8px 11px -5px rgba(0,0,0,0.2),0px 17px 26px 2px rgba(0,0,0,0.14),0px 6px 32px 5px rgba(0,0,0,0.12)", - "0px 9px 11px -5px rgba(0,0,0,0.2),0px 18px 28px 2px rgba(0,0,0,0.14),0px 7px 34px 6px rgba(0,0,0,0.12)", - "0px 9px 12px -6px rgba(0,0,0,0.2),0px 19px 29px 2px rgba(0,0,0,0.14),0px 7px 36px 6px rgba(0,0,0,0.12)", - "0px 10px 13px -6px rgba(0,0,0,0.2),0px 20px 31px 3px rgba(0,0,0,0.14),0px 8px 38px 7px rgba(0,0,0,0.12)", - "0px 10px 13px -6px rgba(0,0,0,0.2),0px 21px 33px 3px rgba(0,0,0,0.14),0px 8px 40px 7px rgba(0,0,0,0.12)", - "0px 10px 14px -6px rgba(0,0,0,0.2),0px 22px 35px 3px rgba(0,0,0,0.14),0px 8px 42px 7px rgba(0,0,0,0.12)", - "0px 11px 14px -7px rgba(0,0,0,0.2),0px 23px 36px 3px rgba(0,0,0,0.14),0px 9px 44px 8px rgba(0,0,0,0.12)", - "0px 11px 15px -7px rgba(0,0,0,0.2),0px 24px 38px 3px rgba(0,0,0,0.14),0px 9px 46px 8px rgba(0,0,0,0.12)", - ], - "shape": Object { - "borderRadius": 4, - }, - "spacing": [Function], - "transitions": Object { - "create": [Function], - "duration": Object { - "complex": 375, - "enteringScreen": 225, - "leavingScreen": 195, - "short": 250, - "shorter": 200, - "shortest": 150, - "standard": 300, - }, - "easing": Object { - "easeIn": "cubic-bezier(0.4, 0, 1, 1)", - "easeInOut": "cubic-bezier(0.4, 0, 0.2, 1)", - "easeOut": "cubic-bezier(0.0, 0, 0.2, 1)", - "sharp": "cubic-bezier(0.4, 0, 0.6, 1)", - }, - "getAutoHeightDuration": [Function], - }, - "typography": Object { - "body1": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "1rem", - "fontWeight": 400, - "letterSpacing": "0.00938em", - "lineHeight": 1.5, - }, - "body2": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "0.875rem", - "fontWeight": 400, - "letterSpacing": "0.01071em", - "lineHeight": 1.43, - }, - "button": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "0.875rem", - "fontWeight": 500, - "letterSpacing": "0.02857em", - "lineHeight": 1.75, - "textTransform": "uppercase", - }, - "caption": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "0.75rem", - "fontWeight": 400, - "letterSpacing": "0.03333em", - "lineHeight": 1.66, - }, - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": 14, - "fontWeightBold": 700, - "fontWeightLight": 300, - "fontWeightMedium": 500, - "fontWeightRegular": 400, - "h1": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "6rem", - "fontWeight": 300, - "letterSpacing": "-0.01562em", - "lineHeight": 1.167, - }, - "h2": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "3.75rem", - "fontWeight": 300, - "letterSpacing": "-0.00833em", - "lineHeight": 1.2, - }, - "h3": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "3rem", - "fontWeight": 400, - "letterSpacing": "0em", - "lineHeight": 1.167, - }, - "h4": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "2.125rem", - "fontWeight": 400, - "letterSpacing": "0.00735em", - "lineHeight": 1.235, - }, - "h5": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "1.5rem", - "fontWeight": 400, - "letterSpacing": "0em", - "lineHeight": 1.334, - }, - "h6": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "1.25rem", - "fontWeight": 500, - "letterSpacing": "0.0075em", - "lineHeight": 1.6, - }, - "htmlFontSize": 16, - "overline": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "0.75rem", - "fontWeight": 400, - "letterSpacing": "0.08333em", - "lineHeight": 2.66, - "textTransform": "uppercase", - }, - "pxToRem": [Function], - "round": [Function], - "subtitle1": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "1rem", - "fontWeight": 400, - "letterSpacing": "0.00938em", - "lineHeight": 1.75, - }, - "subtitle2": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "0.875rem", - "fontWeight": 500, - "letterSpacing": "0.00714em", - "lineHeight": 1.57, - }, - }, - "zIndex": Object { - "appBar": 1100, - "drawer": 1200, - "mobileStepper": 1000, - "modal": 1300, - "snackbar": 1400, - "speedDial": 1050, - "tooltip": 1500, - }, - }, - "name": "MuiBackdrop", - }, - "propTypes": Object { - "classes": [Function], - "innerRef": [Function], - }, - "render": [Function], - "useStyles": [Function], - } - } - BackdropProps={ - Object { - "transitionDuration": Object { - "enter": 225, - "exit": 195, - }, - } - } - className="MuiDialog-root modal-root" - closeAfterTransition={true} - disableEscapeKeyDown={false} - onClose={[Function]} - open={false} - /> - </ForwardRef(Dialog)> - </WithStyles(ForwardRef(Dialog))> - </ActionModal> + action.other + </span> + <span + class="MuiTouchRipple-root" + /> + </button> + </div> </div> </div> - </ActionBegin> -</Provider> + </div> +</div> `; diff --git a/src/components/Action/ActionBegin/actionBegin.scss b/src/components/Action/ActionBegin/actionBegin.scss index 8f25e98d44f3ab866f9c330dbcf5240e81575dd8..36f0ca97ff68e2ce8b7532a227d8643b709b8abc 100644 --- a/src/components/Action/ActionBegin/actionBegin.scss +++ b/src/components/Action/ActionBegin/actionBegin.scss @@ -75,3 +75,7 @@ width: 100%; } } + +h1 { + color: $white; +} diff --git a/src/components/Action/ActionCard/ActionCard.spec.tsx b/src/components/Action/ActionCard/ActionCard.spec.tsx index fee4477b804e9af5d1fbc67c7d044293ecaa758e..6da3d6ac9cbbf3d88c792275d9ff1d3878f25f85 100644 --- a/src/components/Action/ActionCard/ActionCard.spec.tsx +++ b/src/components/Action/ActionCard/ActionCard.spec.tsx @@ -1,12 +1,9 @@ -import { Button } from '@material-ui/core' -import EcogestureModal from 'components/Ecogesture/EcogestureModal/EcogestureModal' -import { mount } from 'enzyme' -import toJson from 'enzyme-to-json' +import { render, screen, waitFor } from '@testing-library/react' +import { userEvent } from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' import { defaultEcogestureData } from 'tests/__mocks__/actionData.mock' import { createMockEcolyoStore } from 'tests/__mocks__/store' -import { waitForComponentToPaint } from 'tests/__mocks__/testUtils' import { userChallengeData } from 'tests/__mocks__/userChallengeData.mock' import ActionCard from './ActionCard' @@ -17,7 +14,7 @@ describe('ActionCard component', () => { }, }) it('should be rendered correctly', async () => { - const wrapper = mount( + const { container } = render( <Provider store={store}> <ActionCard setShowList={jest.fn()} @@ -26,11 +23,11 @@ describe('ActionCard component', () => { /> </Provider> ) - await waitForComponentToPaint(wrapper) - expect(toJson(wrapper)).toMatchSnapshot() + await waitFor(() => null, { container }) + expect(container).toMatchSnapshot() }) - it('should open modal', async () => { - const wrapper = mount( + it('should open Ecogesture modal', async () => { + render( <Provider store={store}> <ActionCard setShowList={jest.fn()} @@ -39,8 +36,7 @@ describe('ActionCard component', () => { /> </Provider> ) - await waitForComponentToPaint(wrapper) - wrapper.find(Button).first().simulate('click') - expect(wrapper.find(EcogestureModal).exists()).toBeTruthy() + await userEvent.click(await screen.findByRole('button')) + expect(await screen.findByRole('dialog')).toBeInTheDocument() }) }) diff --git a/src/components/Action/ActionCard/ActionCard.tsx b/src/components/Action/ActionCard/ActionCard.tsx index 7c4fa8b98a06bd6182b84a2ba640c7a0be66bd96..909829154ee4ead6e682b18a35d2b1b87c39c35b 100644 --- a/src/components/Action/ActionCard/ActionCard.tsx +++ b/src/components/Action/ActionCard/ActionCard.tsx @@ -22,10 +22,10 @@ const ActionCard = ({ setSelectedAction, setShowList, }: ActionCardProps) => { - const [actionIcon, setActionIcon] = useState<string>('') - const [openEcogestureModal, setOpenEcogestureModal] = useState<boolean>(false) const client = useClient() const { currentChallenge } = useAppSelector(state => state.ecolyo.challenge) + const [actionIcon, setActionIcon] = useState<string>('') + const [openEcogestureModal, setOpenEcogestureModal] = useState<boolean>(false) const toggleModal = useCallback(() => { setOpenEcogestureModal(prev => !prev) }, []) diff --git a/src/components/Action/ActionCard/__snapshots__/ActionCard.spec.tsx.snap b/src/components/Action/ActionCard/__snapshots__/ActionCard.spec.tsx.snap index c13a977776a73c81d568d62c49d558da4da21ff0..b18981baeba655d5ed392dd15b2de3cb7ae9b1fa 100644 --- a/src/components/Action/ActionCard/__snapshots__/ActionCard.spec.tsx.snap +++ b/src/components/Action/ActionCard/__snapshots__/ActionCard.spec.tsx.snap @@ -1,616 +1,34 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`ActionCard component should be rendered correctly 1`] = ` -<Provider - store={ - Object { - "clearActions": [Function], - "dispatch": [Function], - "getActions": [Function], - "getState": [Function], - "replaceReducer": [Function], - "subscribe": [Function], - } - } -> - <ActionCard - action={ - Object { - "_id": "ECOGESTURE0014", - "action": true, - "actionDuration": 3, - "actionName": "J’attends que les plats chauds aient refroidi avant de les mettre au réfrigérateur et je les couvre.", - "difficulty": 1, - "doing": false, - "efficiency": 1, - "equipment": false, - "equipmentInstallation": true, - "equipmentType": Array [], - "fluidTypes": Array [ - 0, - ], - "id": "ECOGESTURE0014", - "impactLevel": 2, - "investment": null, - "longDescription": "En plaçant des plats chauds au réfrigérateur, vous réchauffez l’enceinte de l’appareil, ce qui entraîne une surconsommation. De plus, si les plats ne sont pas couverts, de la vapeur d’eau va se former et provoquer l’apparition du givre. Et couvrir les plats, c’est aussi éviter que les bactéries et les odeurs ne se répandent.", - "longName": "J’attends que les plats chauds aient refroidi avant de les mettre au réfrigérateur et je les couvre.", - "objective": false, - "room": Array [ - 2, - ], - "season": "Sans saison", - "shortName": "Chat échaudé", - "usage": 5, - "viewedInSelection": false, - } - } - setSelectedAction={[MockFunction]} - setShowList={[MockFunction]} +<div> + <button + class="MuiButtonBase-root MuiButton-root MuiButton-text action-card" + tabindex="0" + type="button" > - <WithStyles(ForwardRef(Button)) - className="action-card" - key="ECOGESTURE0014" - onClick={[Function]} + <span + class="MuiButton-label" > - <ForwardRef(Button) - className="action-card" - classes={ - Object { - "colorInherit": "MuiButton-colorInherit", - "contained": "MuiButton-contained", - "containedPrimary": "MuiButton-containedPrimary", - "containedSecondary": "MuiButton-containedSecondary", - "containedSizeLarge": "MuiButton-containedSizeLarge", - "containedSizeSmall": "MuiButton-containedSizeSmall", - "disableElevation": "MuiButton-disableElevation", - "disabled": "Mui-disabled", - "endIcon": "MuiButton-endIcon", - "focusVisible": "Mui-focusVisible", - "fullWidth": "MuiButton-fullWidth", - "iconSizeLarge": "MuiButton-iconSizeLarge", - "iconSizeMedium": "MuiButton-iconSizeMedium", - "iconSizeSmall": "MuiButton-iconSizeSmall", - "label": "MuiButton-label", - "outlined": "MuiButton-outlined", - "outlinedPrimary": "MuiButton-outlinedPrimary", - "outlinedSecondary": "MuiButton-outlinedSecondary", - "outlinedSizeLarge": "MuiButton-outlinedSizeLarge", - "outlinedSizeSmall": "MuiButton-outlinedSizeSmall", - "root": "MuiButton-root", - "sizeLarge": "MuiButton-sizeLarge", - "sizeSmall": "MuiButton-sizeSmall", - "startIcon": "MuiButton-startIcon", - "text": "MuiButton-text", - "textPrimary": "MuiButton-textPrimary", - "textSecondary": "MuiButton-textSecondary", - "textSizeLarge": "MuiButton-textSizeLarge", - "textSizeSmall": "MuiButton-textSizeSmall", - } - } - onClick={[Function]} + <svg + aria-hidden="true" + class="action-icon styles__icon___23x3R" + height="100" + width="100" > - <WithStyles(ForwardRef(ButtonBase)) - className="MuiButton-root MuiButton-text action-card" - component="button" - disabled={false} - focusRipple={true} - focusVisibleClassName="Mui-focusVisible" - onClick={[Function]} - type="button" - > - <ForwardRef(ButtonBase) - className="MuiButton-root MuiButton-text action-card" - classes={ - Object { - "disabled": "Mui-disabled", - "focusVisible": "Mui-focusVisible", - "root": "MuiButtonBase-root", - } - } - component="button" - disabled={false} - focusRipple={true} - focusVisibleClassName="Mui-focusVisible" - onClick={[Function]} - type="button" - > - <button - className="MuiButtonBase-root MuiButton-root MuiButton-text action-card" - disabled={false} - onBlur={[Function]} - onClick={[Function]} - onDragLeave={[Function]} - onFocus={[Function]} - onKeyDown={[Function]} - onKeyUp={[Function]} - onMouseDown={[Function]} - onMouseLeave={[Function]} - onMouseUp={[Function]} - onTouchEnd={[Function]} - onTouchMove={[Function]} - onTouchStart={[Function]} - tabIndex={0} - type="button" - > - <span - className="MuiButton-label" - > - <StyledIcon - className="action-icon" - icon="test-file-stub" - size={100} - > - <Icon - aria-hidden={true} - className="action-icon" - icon="test-file-stub" - size={100} - spin={false} - > - <Component - aria-hidden={true} - className="action-icon styles__icon___23x3R" - height={100} - style={Object {}} - width={100} - > - <svg - aria-hidden={true} - className="action-icon styles__icon___23x3R" - height={100} - style={Object {}} - width={100} - > - <use - xlinkHref="#test-file-stub" - /> - </svg> - </Component> - </Icon> - </StyledIcon> - <div - className="action-title text-18-bold" - > - Chat échaudé - </div> - </span> - <WithStyles(memo) - center={false} - > - <ForwardRef(TouchRipple) - center={false} - classes={ - Object { - "child": "MuiTouchRipple-child", - "childLeaving": "MuiTouchRipple-childLeaving", - "childPulsate": "MuiTouchRipple-childPulsate", - "ripple": "MuiTouchRipple-ripple", - "ripplePulsate": "MuiTouchRipple-ripplePulsate", - "rippleVisible": "MuiTouchRipple-rippleVisible", - "root": "MuiTouchRipple-root", - } - } - > - <span - className="MuiTouchRipple-root" - > - <TransitionGroup - childFactory={[Function]} - component={null} - exit={true} - /> - </span> - </ForwardRef(TouchRipple)> - </WithStyles(memo)> - </button> - </ForwardRef(ButtonBase)> - </WithStyles(ForwardRef(ButtonBase))> - </ForwardRef(Button)> - </WithStyles(ForwardRef(Button))> - <EcogestureModal - ecogesture={ - Object { - "_id": "ECOGESTURE0014", - "action": true, - "actionDuration": 3, - "actionName": "J’attends que les plats chauds aient refroidi avant de les mettre au réfrigérateur et je les couvre.", - "difficulty": 1, - "doing": false, - "efficiency": 1, - "equipment": false, - "equipmentInstallation": true, - "equipmentType": Array [], - "fluidTypes": Array [ - 0, - ], - "id": "ECOGESTURE0014", - "impactLevel": 2, - "investment": null, - "longDescription": "En plaçant des plats chauds au réfrigérateur, vous réchauffez l’enceinte de l’appareil, ce qui entraîne une surconsommation. De plus, si les plats ne sont pas couverts, de la vapeur d’eau va se former et provoquer l’apparition du givre. Et couvrir les plats, c’est aussi éviter que les bactéries et les odeurs ne se répandent.", - "longName": "J’attends que les plats chauds aient refroidi avant de les mettre au réfrigérateur et je les couvre.", - "objective": false, - "room": Array [ - 2, - ], - "season": "Sans saison", - "shortName": "Chat échaudé", - "usage": 5, - "viewedInSelection": false, - } - } - handleCloseClick={[Function]} - isAction={true} - open={false} - selectEcogesture={[Function]} - > - <WithStyles(ForwardRef(Dialog)) - aria-labelledby="accessibility-title" - classes={ - Object { - "paper": "modal-paper no-padding blue-border", - "root": "modal-root", - } - } - onClose={[Function]} - open={false} + <use + xlink:href="#test-file-stub" + /> + </svg> + <div + class="action-title text-18-bold" > - <ForwardRef(Dialog) - aria-labelledby="accessibility-title" - classes={ - Object { - "container": "MuiDialog-container", - "paper": "MuiDialog-paper modal-paper no-padding blue-border", - "paperFullScreen": "MuiDialog-paperFullScreen", - "paperFullWidth": "MuiDialog-paperFullWidth", - "paperScrollBody": "MuiDialog-paperScrollBody", - "paperScrollPaper": "MuiDialog-paperScrollPaper", - "paperWidthFalse": "MuiDialog-paperWidthFalse", - "paperWidthLg": "MuiDialog-paperWidthLg", - "paperWidthMd": "MuiDialog-paperWidthMd", - "paperWidthSm": "MuiDialog-paperWidthSm", - "paperWidthXl": "MuiDialog-paperWidthXl", - "paperWidthXs": "MuiDialog-paperWidthXs", - "root": "MuiDialog-root modal-root", - "scrollBody": "MuiDialog-scrollBody", - "scrollPaper": "MuiDialog-scrollPaper", - } - } - onClose={[Function]} - open={false} - > - <ForwardRef(Modal) - BackdropComponent={ - Object { - "$$typeof": Symbol(react.forward_ref), - "Naked": Object { - "$$typeof": Symbol(react.forward_ref), - "propTypes": Object { - "children": [Function], - "className": [Function], - "classes": [Function], - "invisible": [Function], - "open": [Function], - "transitionDuration": [Function], - }, - "render": [Function], - }, - "displayName": "WithStyles(ForwardRef(Backdrop))", - "options": Object { - "defaultTheme": Object { - "breakpoints": Object { - "between": [Function], - "down": [Function], - "keys": Array [ - "xs", - "sm", - "md", - "lg", - "xl", - ], - "only": [Function], - "up": [Function], - "values": Object { - "lg": 1280, - "md": 960, - "sm": 600, - "xl": 1920, - "xs": 0, - }, - "width": [Function], - }, - "direction": "ltr", - "mixins": Object { - "gutters": [Function], - "toolbar": Object { - "@media (min-width:0px) and (orientation: landscape)": Object { - "minHeight": 48, - }, - "@media (min-width:600px)": Object { - "minHeight": 64, - }, - "minHeight": 56, - }, - }, - "overrides": Object {}, - "palette": Object { - "action": Object { - "activatedOpacity": 0.12, - "active": "rgba(0, 0, 0, 0.54)", - "disabled": "rgba(0, 0, 0, 0.26)", - "disabledBackground": "rgba(0, 0, 0, 0.12)", - "disabledOpacity": 0.38, - "focus": "rgba(0, 0, 0, 0.12)", - "focusOpacity": 0.12, - "hover": "rgba(0, 0, 0, 0.04)", - "hoverOpacity": 0.04, - "selected": "rgba(0, 0, 0, 0.08)", - "selectedOpacity": 0.08, - }, - "augmentColor": [Function], - "background": Object { - "default": "#fafafa", - "paper": "#fff", - }, - "common": Object { - "black": "#000", - "white": "#fff", - }, - "contrastThreshold": 3, - "divider": "rgba(0, 0, 0, 0.12)", - "error": Object { - "contrastText": "#fff", - "dark": "#d32f2f", - "light": "#e57373", - "main": "#f44336", - }, - "getContrastText": [Function], - "grey": Object { - "100": "#f5f5f5", - "200": "#eeeeee", - "300": "#e0e0e0", - "400": "#bdbdbd", - "50": "#fafafa", - "500": "#9e9e9e", - "600": "#757575", - "700": "#616161", - "800": "#424242", - "900": "#212121", - "A100": "#d5d5d5", - "A200": "#aaaaaa", - "A400": "#303030", - "A700": "#616161", - }, - "info": Object { - "contrastText": "#fff", - "dark": "#1976d2", - "light": "#64b5f6", - "main": "#2196f3", - }, - "primary": Object { - "contrastText": "#fff", - "dark": "#303f9f", - "light": "#7986cb", - "main": "#3f51b5", - }, - "secondary": Object { - "contrastText": "#fff", - "dark": "#c51162", - "light": "#ff4081", - "main": "#f50057", - }, - "success": Object { - "contrastText": "rgba(0, 0, 0, 0.87)", - "dark": "#388e3c", - "light": "#81c784", - "main": "#4caf50", - }, - "text": Object { - "disabled": "rgba(0, 0, 0, 0.38)", - "hint": "rgba(0, 0, 0, 0.38)", - "primary": "rgba(0, 0, 0, 0.87)", - "secondary": "rgba(0, 0, 0, 0.54)", - }, - "tonalOffset": 0.2, - "type": "light", - "warning": Object { - "contrastText": "rgba(0, 0, 0, 0.87)", - "dark": "#f57c00", - "light": "#ffb74d", - "main": "#ff9800", - }, - }, - "props": Object {}, - "shadows": Array [ - "none", - "0px 2px 1px -1px rgba(0,0,0,0.2),0px 1px 1px 0px rgba(0,0,0,0.14),0px 1px 3px 0px rgba(0,0,0,0.12)", - "0px 3px 1px -2px rgba(0,0,0,0.2),0px 2px 2px 0px rgba(0,0,0,0.14),0px 1px 5px 0px rgba(0,0,0,0.12)", - "0px 3px 3px -2px rgba(0,0,0,0.2),0px 3px 4px 0px rgba(0,0,0,0.14),0px 1px 8px 0px rgba(0,0,0,0.12)", - "0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12)", - "0px 3px 5px -1px rgba(0,0,0,0.2),0px 5px 8px 0px rgba(0,0,0,0.14),0px 1px 14px 0px rgba(0,0,0,0.12)", - "0px 3px 5px -1px rgba(0,0,0,0.2),0px 6px 10px 0px rgba(0,0,0,0.14),0px 1px 18px 0px rgba(0,0,0,0.12)", - "0px 4px 5px -2px rgba(0,0,0,0.2),0px 7px 10px 1px rgba(0,0,0,0.14),0px 2px 16px 1px rgba(0,0,0,0.12)", - "0px 5px 5px -3px rgba(0,0,0,0.2),0px 8px 10px 1px rgba(0,0,0,0.14),0px 3px 14px 2px rgba(0,0,0,0.12)", - "0px 5px 6px -3px rgba(0,0,0,0.2),0px 9px 12px 1px rgba(0,0,0,0.14),0px 3px 16px 2px rgba(0,0,0,0.12)", - "0px 6px 6px -3px rgba(0,0,0,0.2),0px 10px 14px 1px rgba(0,0,0,0.14),0px 4px 18px 3px rgba(0,0,0,0.12)", - "0px 6px 7px -4px rgba(0,0,0,0.2),0px 11px 15px 1px rgba(0,0,0,0.14),0px 4px 20px 3px rgba(0,0,0,0.12)", - "0px 7px 8px -4px rgba(0,0,0,0.2),0px 12px 17px 2px rgba(0,0,0,0.14),0px 5px 22px 4px rgba(0,0,0,0.12)", - "0px 7px 8px -4px rgba(0,0,0,0.2),0px 13px 19px 2px rgba(0,0,0,0.14),0px 5px 24px 4px rgba(0,0,0,0.12)", - "0px 7px 9px -4px rgba(0,0,0,0.2),0px 14px 21px 2px rgba(0,0,0,0.14),0px 5px 26px 4px rgba(0,0,0,0.12)", - "0px 8px 9px -5px rgba(0,0,0,0.2),0px 15px 22px 2px rgba(0,0,0,0.14),0px 6px 28px 5px rgba(0,0,0,0.12)", - "0px 8px 10px -5px rgba(0,0,0,0.2),0px 16px 24px 2px rgba(0,0,0,0.14),0px 6px 30px 5px rgba(0,0,0,0.12)", - "0px 8px 11px -5px rgba(0,0,0,0.2),0px 17px 26px 2px rgba(0,0,0,0.14),0px 6px 32px 5px rgba(0,0,0,0.12)", - "0px 9px 11px -5px rgba(0,0,0,0.2),0px 18px 28px 2px rgba(0,0,0,0.14),0px 7px 34px 6px rgba(0,0,0,0.12)", - "0px 9px 12px -6px rgba(0,0,0,0.2),0px 19px 29px 2px rgba(0,0,0,0.14),0px 7px 36px 6px rgba(0,0,0,0.12)", - "0px 10px 13px -6px rgba(0,0,0,0.2),0px 20px 31px 3px rgba(0,0,0,0.14),0px 8px 38px 7px rgba(0,0,0,0.12)", - "0px 10px 13px -6px rgba(0,0,0,0.2),0px 21px 33px 3px rgba(0,0,0,0.14),0px 8px 40px 7px rgba(0,0,0,0.12)", - "0px 10px 14px -6px rgba(0,0,0,0.2),0px 22px 35px 3px rgba(0,0,0,0.14),0px 8px 42px 7px rgba(0,0,0,0.12)", - "0px 11px 14px -7px rgba(0,0,0,0.2),0px 23px 36px 3px rgba(0,0,0,0.14),0px 9px 44px 8px rgba(0,0,0,0.12)", - "0px 11px 15px -7px rgba(0,0,0,0.2),0px 24px 38px 3px rgba(0,0,0,0.14),0px 9px 46px 8px rgba(0,0,0,0.12)", - ], - "shape": Object { - "borderRadius": 4, - }, - "spacing": [Function], - "transitions": Object { - "create": [Function], - "duration": Object { - "complex": 375, - "enteringScreen": 225, - "leavingScreen": 195, - "short": 250, - "shorter": 200, - "shortest": 150, - "standard": 300, - }, - "easing": Object { - "easeIn": "cubic-bezier(0.4, 0, 1, 1)", - "easeInOut": "cubic-bezier(0.4, 0, 0.2, 1)", - "easeOut": "cubic-bezier(0.0, 0, 0.2, 1)", - "sharp": "cubic-bezier(0.4, 0, 0.6, 1)", - }, - "getAutoHeightDuration": [Function], - }, - "typography": Object { - "body1": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "1rem", - "fontWeight": 400, - "letterSpacing": "0.00938em", - "lineHeight": 1.5, - }, - "body2": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "0.875rem", - "fontWeight": 400, - "letterSpacing": "0.01071em", - "lineHeight": 1.43, - }, - "button": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "0.875rem", - "fontWeight": 500, - "letterSpacing": "0.02857em", - "lineHeight": 1.75, - "textTransform": "uppercase", - }, - "caption": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "0.75rem", - "fontWeight": 400, - "letterSpacing": "0.03333em", - "lineHeight": 1.66, - }, - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": 14, - "fontWeightBold": 700, - "fontWeightLight": 300, - "fontWeightMedium": 500, - "fontWeightRegular": 400, - "h1": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "6rem", - "fontWeight": 300, - "letterSpacing": "-0.01562em", - "lineHeight": 1.167, - }, - "h2": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "3.75rem", - "fontWeight": 300, - "letterSpacing": "-0.00833em", - "lineHeight": 1.2, - }, - "h3": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "3rem", - "fontWeight": 400, - "letterSpacing": "0em", - "lineHeight": 1.167, - }, - "h4": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "2.125rem", - "fontWeight": 400, - "letterSpacing": "0.00735em", - "lineHeight": 1.235, - }, - "h5": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "1.5rem", - "fontWeight": 400, - "letterSpacing": "0em", - "lineHeight": 1.334, - }, - "h6": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "1.25rem", - "fontWeight": 500, - "letterSpacing": "0.0075em", - "lineHeight": 1.6, - }, - "htmlFontSize": 16, - "overline": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "0.75rem", - "fontWeight": 400, - "letterSpacing": "0.08333em", - "lineHeight": 2.66, - "textTransform": "uppercase", - }, - "pxToRem": [Function], - "round": [Function], - "subtitle1": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "1rem", - "fontWeight": 400, - "letterSpacing": "0.00938em", - "lineHeight": 1.75, - }, - "subtitle2": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "0.875rem", - "fontWeight": 500, - "letterSpacing": "0.00714em", - "lineHeight": 1.57, - }, - }, - "zIndex": Object { - "appBar": 1100, - "drawer": 1200, - "mobileStepper": 1000, - "modal": 1300, - "snackbar": 1400, - "speedDial": 1050, - "tooltip": 1500, - }, - }, - "name": "MuiBackdrop", - }, - "propTypes": Object { - "classes": [Function], - "innerRef": [Function], - }, - "render": [Function], - "useStyles": [Function], - } - } - BackdropProps={ - Object { - "transitionDuration": Object { - "enter": 225, - "exit": 195, - }, - } - } - className="MuiDialog-root modal-root" - closeAfterTransition={true} - disableEscapeKeyDown={false} - onClose={[Function]} - open={false} - /> - </ForwardRef(Dialog)> - </WithStyles(ForwardRef(Dialog))> - </EcogestureModal> - </ActionCard> -</Provider> + Chat échaudé + </div> + </span> + <span + class="MuiTouchRipple-root" + /> + </button> +</div> `; diff --git a/src/components/Action/ActionChoose/ActionChoose.spec.tsx b/src/components/Action/ActionChoose/ActionChoose.spec.tsx index 93f2bcdac3ccd81c76135f09db10b4a2ba320ef7..c7f251918247054dcc6f0eacbb711aa37269d06c 100644 --- a/src/components/Action/ActionChoose/ActionChoose.spec.tsx +++ b/src/components/Action/ActionChoose/ActionChoose.spec.tsx @@ -1,21 +1,29 @@ -import { mount } from 'enzyme' -import toJson from 'enzyme-to-json' +import { render, screen, waitFor } from '@testing-library/react' +import userEvent from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' +import { AllEcogestureData } from 'tests/__mocks__/actionData.mock' import { createMockEcolyoStore, + mockChallengeState, mockGlobalState, mockProfileState, } from 'tests/__mocks__/store' -import { waitForComponentToPaint } from 'tests/__mocks__/testUtils' import { userChallengeData } from 'tests/__mocks__/userChallengeData.mock' -import ActionBegin from '../ActionBegin/ActionBegin' import ActionChoose from './ActionChoose' -const mockGetEcogesturesByIds = jest.fn(() => []) jest.mock('services/ecogesture.service', () => { return jest.fn(() => ({ - getEcogesturesByIds: mockGetEcogesturesByIds, + getEcogesturesByIds: jest.fn(() => []), + })) +}) + +const mockGetDefaultActions = jest.fn() + +jest.mock('services/action.service', () => { + return jest.fn(() => ({ + getCustomActions: jest.fn(), + getDefaultActions: mockGetDefaultActions, })) }) @@ -25,20 +33,40 @@ describe('ActionChoose component', () => { profile: mockProfileState, }) it('should render correctly', async () => { - const wrapper = mount( + mockGetDefaultActions.mockResolvedValue([ + AllEcogestureData[0], + AllEcogestureData[5], + AllEcogestureData[2], + ]) + const { container } = render( <Provider store={store}> <ActionChoose userChallenge={userChallengeData[1]} /> </Provider> ) - await waitForComponentToPaint(wrapper) - expect(toJson(wrapper)).toMatchSnapshot() + await waitFor(() => null, { container }) + expect(container).toMatchSnapshot() }) - it('should render ActionBegin component', async () => { - const wrapper = mount( + + it('should go to the Action list', async () => { + const store = createMockEcolyoStore({ + challenge: mockChallengeState, + global: { ...mockGlobalState, fluidTypes: [0, 1, 2] }, + profile: mockProfileState, + }) + + mockGetDefaultActions.mockResolvedValue([ + AllEcogestureData[0], + AllEcogestureData[5], + AllEcogestureData[2], + ]) + + const { container } = render( <Provider store={store}> <ActionChoose userChallenge={userChallengeData[1]} /> </Provider> ) - expect(wrapper.find(ActionBegin).exists()).toBeTruthy() + await userEvent.click(await screen.findByText('action.other')) + const elements = container.getElementsByClassName('action-list-container') + expect(elements.item(0)).toBeInTheDocument() }) }) diff --git a/src/components/Action/ActionChoose/__snapshots__/ActionChoose.spec.tsx.snap b/src/components/Action/ActionChoose/__snapshots__/ActionChoose.spec.tsx.snap index 7110cbf34e9e6cb1444e6729042e460634500239..1d41b8754042458a3a1addbdfefd8e2a277e623d 100644 --- a/src/components/Action/ActionChoose/__snapshots__/ActionChoose.spec.tsx.snap +++ b/src/components/Action/ActionChoose/__snapshots__/ActionChoose.spec.tsx.snap @@ -1,313 +1,131 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`ActionChoose component should render correctly 1`] = ` -<Provider - store={ - Object { - "clearActions": [Function], - "dispatch": [Function], - "getActions": [Function], - "getState": [Function], - "replaceReducer": [Function], - "subscribe": [Function], - } - } -> - <ActionChoose - userChallenge={ - Object { - "action": Object { - "ecogesture": null, - "startDate": null, - "state": 0, - }, - "description": "Description challenge 2", - "duel": Object { - "description": "Je parie un ours polaire que vous ne pouvez pas consommer moins que #CONSUMPTION € en 1 semaine", - "duration": "P30D", - "fluidTypes": Array [], - "id": "DUEL001", - "startDate": null, - "state": 0, - "threshold": 0, - "title": "Title DUEL001", - "userConsumption": 0, - }, - "endingDate": null, - "exploration": Object { - "complementary_description": "Refaire un tour dans son profil si déjà fait", - "date": null, - "description": "Avoir complété son profil", - "ecogesture_id": "", - "fluid_condition": Array [], - "id": "EXPLORATION001", - "message_success": "Vous avez complété votre profil ou refait un tour dans votre profil", - "progress": 0, - "state": 0, - "target": 1, - "type": 1, - }, - "id": "CHALLENGE0002", - "progress": Object { - "actionProgress": 0, - "explorationProgress": 0, - "quizProgress": 0, - }, - "quiz": Object { - "customQuestion": Object { - "interval": 20, - "period": Object {}, - "questionLabel": "Custom1", - "result": 0, - "singleFluid": false, - "timeStep": 20, - "type": 0, - }, - "id": "QUIZ001", - "questions": Array [ - Object { - "answers": Array [ - Object { - "answerLabel": "86 km", - "isTrue": true, - }, - Object { - "answerLabel": "78 km", - "isTrue": false, - }, - Object { - "answerLabel": "56 km", - "isTrue": false, - }, - ], - "explanation": "L’aqueduc du Gier est un des aqueducs antiques de Lyon desservant la ville antique de Lugdunum. Avec ses 86 km il est le plus long des quatre aqueducs ayant alimenté la ville en eau, et celui dont les structures sont le mieux conservées. Il doit son nom au fait qu'il puise aux sources du Gier, affluent du Rhône", - "questionLabel": "Quelle longueur faisait l’aqueduc du Gier pour acheminer l’eau sur Lyon à l’époque romaine ?", - "result": 0, - "source": "string", - }, - Object { - "answers": Array [ - Object { - "answerLabel": "1 point d’eau public pour 800 habitants.", - "isTrue": true, - }, - Object { - "answerLabel": "1 point d’eau public pour 400 habitants.", - "isTrue": false, - }, - Object { - "answerLabel": "1 point d’eau public pour 200 habitants.", - "isTrue": false, - }, - ], - "explanation": "string", - "questionLabel": "En 1800 à Lyon, combien de points d'eau y avait-il par habitants ?", - "result": 0, - "source": "string", - }, - Object { - "answers": Array [ - Object { - "answerLabel": "François Mitterrand", - "isTrue": false, - }, - Object { - "answerLabel": "Napoléon Ier", - "isTrue": true, - }, - Object { - "answerLabel": "Napoléon III", - "isTrue": false, - }, - ], - "explanation": "string", - "questionLabel": "Qui officialise la création de la Compagnie Générale des eaux ?", - "result": 0, - "source": "string", - }, - Object { - "answers": Array [ - Object { - "answerLabel": "string", - "isTrue": false, - }, - Object { - "answerLabel": "string", - "isTrue": false, - }, - Object { - "answerLabel": "Aristide Dumont", - "isTrue": true, - }, - ], - "explanation": "string", - "questionLabel": "Quel ingénieur est à l’origine du projet d’alimentation en eau en 1856 ?", - "result": 0, - "source": "string", - }, - ], - "result": 0, - "startDate": null, - "state": 0, - }, - "startDate": null, - "state": 4, - "success": 1, - "target": 15, - "title": "Challenge 2", - } - } +<div> + <div + class="action-begin" > - <ActionBegin - setShowList={[Function]} - userChallenge={ - Object { - "action": Object { - "ecogesture": null, - "startDate": null, - "state": 0, - }, - "description": "Description challenge 2", - "duel": Object { - "description": "Je parie un ours polaire que vous ne pouvez pas consommer moins que #CONSUMPTION € en 1 semaine", - "duration": "P30D", - "fluidTypes": Array [], - "id": "DUEL001", - "startDate": null, - "state": 0, - "threshold": 0, - "title": "Title DUEL001", - "userConsumption": 0, - }, - "endingDate": null, - "exploration": Object { - "complementary_description": "Refaire un tour dans son profil si déjà fait", - "date": null, - "description": "Avoir complété son profil", - "ecogesture_id": "", - "fluid_condition": Array [], - "id": "EXPLORATION001", - "message_success": "Vous avez complété votre profil ou refait un tour dans votre profil", - "progress": 0, - "state": 0, - "target": 1, - "type": 1, - }, - "id": "CHALLENGE0002", - "progress": Object { - "actionProgress": 0, - "explorationProgress": 0, - "quizProgress": 0, - }, - "quiz": Object { - "customQuestion": Object { - "interval": 20, - "period": Object {}, - "questionLabel": "Custom1", - "result": 0, - "singleFluid": false, - "timeStep": 20, - "type": 0, - }, - "id": "QUIZ001", - "questions": Array [ - Object { - "answers": Array [ - Object { - "answerLabel": "86 km", - "isTrue": true, - }, - Object { - "answerLabel": "78 km", - "isTrue": false, - }, - Object { - "answerLabel": "56 km", - "isTrue": false, - }, - ], - "explanation": "L’aqueduc du Gier est un des aqueducs antiques de Lyon desservant la ville antique de Lugdunum. Avec ses 86 km il est le plus long des quatre aqueducs ayant alimenté la ville en eau, et celui dont les structures sont le mieux conservées. Il doit son nom au fait qu'il puise aux sources du Gier, affluent du Rhône", - "questionLabel": "Quelle longueur faisait l’aqueduc du Gier pour acheminer l’eau sur Lyon à l’époque romaine ?", - "result": 0, - "source": "string", - }, - Object { - "answers": Array [ - Object { - "answerLabel": "1 point d’eau public pour 800 habitants.", - "isTrue": true, - }, - Object { - "answerLabel": "1 point d’eau public pour 400 habitants.", - "isTrue": false, - }, - Object { - "answerLabel": "1 point d’eau public pour 200 habitants.", - "isTrue": false, - }, - ], - "explanation": "string", - "questionLabel": "En 1800 à Lyon, combien de points d'eau y avait-il par habitants ?", - "result": 0, - "source": "string", - }, - Object { - "answers": Array [ - Object { - "answerLabel": "François Mitterrand", - "isTrue": false, - }, - Object { - "answerLabel": "Napoléon Ier", - "isTrue": true, - }, - Object { - "answerLabel": "Napoléon III", - "isTrue": false, - }, - ], - "explanation": "string", - "questionLabel": "Qui officialise la création de la Compagnie Générale des eaux ?", - "result": 0, - "source": "string", - }, - Object { - "answers": Array [ - Object { - "answerLabel": "string", - "isTrue": false, - }, - Object { - "answerLabel": "string", - "isTrue": false, - }, - Object { - "answerLabel": "Aristide Dumont", - "isTrue": true, - }, - ], - "explanation": "string", - "questionLabel": "Quel ingénieur est à l’origine du projet d’alimentation en eau en 1856 ?", - "result": 0, - "source": "string", - }, - ], - "result": 0, - "startDate": null, - "state": 0, - }, - "startDate": null, - "state": 4, - "success": 1, - "target": 15, - "title": "Challenge 2", - } - } + <div + class="action-container" > <div - className="action-begin" - /> - </ActionBegin> - </ActionChoose> -</Provider> + class="action-begin-container" + > + <div + class="icon-container" + > + <svg + aria-hidden="true" + class="action-icon styles__icon___23x3R" + height="100" + width="100" + > + <use + xlink:href="#test-file-stub" + /> + </svg> + </div> + <div + class="stars" + > + <svg + aria-hidden="true" + class="star styles__icon___23x3R" + height="25" + width="25" + > + <use + xlink:href="#test-file-stub" + /> + </svg> + <svg + aria-hidden="true" + class="star styles__icon___23x3R" + height="25" + width="25" + > + <use + xlink:href="#test-file-stub" + /> + </svg> + <svg + aria-hidden="true" + class="star styles__icon___23x3R" + height="25" + width="25" + > + <use + xlink:href="#test-file-stub" + /> + </svg> + <svg + aria-hidden="true" + class="star styles__icon___23x3R" + height="25" + width="25" + > + <use + xlink:href="#test-file-stub" + /> + </svg> + <svg + aria-hidden="true" + class="star styles__icon___23x3R" + height="25" + width="25" + > + <use + xlink:href="#test-file-stub" + /> + </svg> + </div> + <h1 + class="text-20-bold" + > + Bonhomme de neige + </h1> + <div + class="action-duration text-18" + > + action.duration + </div> + <div + class="action-text text-18-bold" + /> + <div + class="action-buttons" + > + <button + class="MuiButtonBase-root MuiButton-root MuiButton-text btnSecondary" + tabindex="0" + type="button" + > + <span + class="MuiButton-label" + > + action.apply + </span> + <span + class="MuiTouchRipple-root" + /> + </button> + <button + class="MuiButtonBase-root MuiButton-root MuiButton-text btnSecondary" + tabindex="0" + type="button" + > + <span + class="MuiButton-label" + > + action.other + </span> + <span + class="MuiTouchRipple-root" + /> + </button> + </div> + </div> + </div> + </div> +</div> `; diff --git a/src/components/Action/ActionDone/ActionDone.spec.tsx b/src/components/Action/ActionDone/ActionDone.spec.tsx index 768da199887dc48d1a6ca651b3a44471b085fb8b..d293d094852cb135f96e457666bc624988e9cc67 100644 --- a/src/components/Action/ActionDone/ActionDone.spec.tsx +++ b/src/components/Action/ActionDone/ActionDone.spec.tsx @@ -1,12 +1,10 @@ -import { Button } from '@material-ui/core' -import { mount } from 'enzyme' -import toJson from 'enzyme-to-json' +import { render, screen } from '@testing-library/react' +import { userEvent } from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' import UsageEventService from 'services/usageEvent.service' import * as challengeActions from 'store/challenge/challenge.slice' import { createMockEcolyoStore } from 'tests/__mocks__/store' -import { waitForComponentToPaint } from 'tests/__mocks__/testUtils' import { userChallengeData } from 'tests/__mocks__/userChallengeData.mock' import ActionDone from './ActionDone' @@ -24,13 +22,12 @@ jest.mock('services/challenge.service', () => { describe('ActionDone component', () => { const store = createMockEcolyoStore() it('should be rendered correctly', async () => { - const wrapper = mount( + const { container } = render( <Provider store={store}> <ActionDone currentChallenge={userChallengeData[1]} /> </Provider> ) - await waitForComponentToPaint(wrapper) - expect(toJson(wrapper)).toMatchSnapshot() + expect(container).toMatchSnapshot() }) it('should click on button and update action to done', async () => { const updateChallengeSpy = jest.spyOn( @@ -38,13 +35,12 @@ describe('ActionDone component', () => { 'updateUserChallengeList' ) mockUpdateUserChallenge.mockResolvedValueOnce(userChallengeData[1]) - const wrapper = mount( + render( <Provider store={store}> <ActionDone currentChallenge={userChallengeData[1]} /> </Provider> ) - wrapper.find(Button).first().simulate('click') - await waitForComponentToPaint(wrapper) + await userEvent.click(await screen.findByText('action.ok')) expect(updateChallengeSpy).toHaveBeenCalledTimes(1) }) }) diff --git a/src/components/Action/ActionDone/ActionDone.tsx b/src/components/Action/ActionDone/ActionDone.tsx index 13c0a8f689213662ecb05ca6bda88966d7bcf007..39b6ccce33c1c025191f17e5b819ac131b9eca72 100644 --- a/src/components/Action/ActionDone/ActionDone.tsx +++ b/src/components/Action/ActionDone/ActionDone.tsx @@ -25,11 +25,10 @@ const ActionDone = ({ const navigate = useNavigate() const handleEndAction = useCallback(async () => { const challengeService = new ChallengeService(client) - const updatedChallenge: UserChallenge = - await challengeService.updateUserChallenge( - currentChallenge, - UserChallengeUpdateFlag.ACTION_DONE - ) + const updatedChallenge = await challengeService.updateUserChallenge( + currentChallenge, + UserChallengeUpdateFlag.ACTION_DONE + ) await UsageEventService.addEvent(client, { type: UsageEventType.ACTION_END_EVENT, target: currentChallenge.action.ecogesture diff --git a/src/components/Action/ActionDone/__snapshots__/ActionDone.spec.tsx.snap b/src/components/Action/ActionDone/__snapshots__/ActionDone.spec.tsx.snap index 050de29fb4a7ff0751636a39c810843994f4c143..87b0fe92d3e35faa3b3de410562cef4968a55709 100644 --- a/src/components/Action/ActionDone/__snapshots__/ActionDone.spec.tsx.snap +++ b/src/components/Action/ActionDone/__snapshots__/ActionDone.spec.tsx.snap @@ -1,349 +1,63 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`ActionDone component should be rendered correctly 1`] = ` -<Provider - store={ - Object { - "clearActions": [Function], - "dispatch": [Function], - "getActions": [Function], - "getState": [Function], - "replaceReducer": [Function], - "subscribe": [Function], - } - } -> - <ActionDone - currentChallenge={ - Object { - "action": Object { - "ecogesture": null, - "startDate": null, - "state": 0, - }, - "description": "Description challenge 2", - "duel": Object { - "description": "Je parie un ours polaire que vous ne pouvez pas consommer moins que #CONSUMPTION € en 1 semaine", - "duration": "P30D", - "fluidTypes": Array [], - "id": "DUEL001", - "startDate": null, - "state": 0, - "threshold": 0, - "title": "Title DUEL001", - "userConsumption": 0, - }, - "endingDate": null, - "exploration": Object { - "complementary_description": "Refaire un tour dans son profil si déjà fait", - "date": null, - "description": "Avoir complété son profil", - "ecogesture_id": "", - "fluid_condition": Array [], - "id": "EXPLORATION001", - "message_success": "Vous avez complété votre profil ou refait un tour dans votre profil", - "progress": 0, - "state": 0, - "target": 1, - "type": 1, - }, - "id": "CHALLENGE0002", - "progress": Object { - "actionProgress": 0, - "explorationProgress": 0, - "quizProgress": 0, - }, - "quiz": Object { - "customQuestion": Object { - "interval": 20, - "period": Object {}, - "questionLabel": "Custom1", - "result": 0, - "singleFluid": false, - "timeStep": 20, - "type": 0, - }, - "id": "QUIZ001", - "questions": Array [ - Object { - "answers": Array [ - Object { - "answerLabel": "86 km", - "isTrue": true, - }, - Object { - "answerLabel": "78 km", - "isTrue": false, - }, - Object { - "answerLabel": "56 km", - "isTrue": false, - }, - ], - "explanation": "L’aqueduc du Gier est un des aqueducs antiques de Lyon desservant la ville antique de Lugdunum. Avec ses 86 km il est le plus long des quatre aqueducs ayant alimenté la ville en eau, et celui dont les structures sont le mieux conservées. Il doit son nom au fait qu'il puise aux sources du Gier, affluent du Rhône", - "questionLabel": "Quelle longueur faisait l’aqueduc du Gier pour acheminer l’eau sur Lyon à l’époque romaine ?", - "result": 0, - "source": "string", - }, - Object { - "answers": Array [ - Object { - "answerLabel": "1 point d’eau public pour 800 habitants.", - "isTrue": true, - }, - Object { - "answerLabel": "1 point d’eau public pour 400 habitants.", - "isTrue": false, - }, - Object { - "answerLabel": "1 point d’eau public pour 200 habitants.", - "isTrue": false, - }, - ], - "explanation": "string", - "questionLabel": "En 1800 à Lyon, combien de points d'eau y avait-il par habitants ?", - "result": 0, - "source": "string", - }, - Object { - "answers": Array [ - Object { - "answerLabel": "François Mitterrand", - "isTrue": false, - }, - Object { - "answerLabel": "Napoléon Ier", - "isTrue": true, - }, - Object { - "answerLabel": "Napoléon III", - "isTrue": false, - }, - ], - "explanation": "string", - "questionLabel": "Qui officialise la création de la Compagnie Générale des eaux ?", - "result": 0, - "source": "string", - }, - Object { - "answers": Array [ - Object { - "answerLabel": "string", - "isTrue": false, - }, - Object { - "answerLabel": "string", - "isTrue": false, - }, - Object { - "answerLabel": "Aristide Dumont", - "isTrue": true, - }, - ], - "explanation": "string", - "questionLabel": "Quel ingénieur est à l’origine du projet d’alimentation en eau en 1856 ?", - "result": 0, - "source": "string", - }, - ], - "result": 0, - "startDate": null, - "state": 0, - }, - "startDate": null, - "state": 4, - "success": 1, - "target": 15, - "title": "Challenge 2", - } - } +<div> + <div + class="action-done-container" > <div - className="action-done-container" + class="action-done" > <div - className="action-done" + class="result-title" > - <div - className="result-title" - > - - action.finished - </div> - <div> - action.resultText1 - </div> - <div> - action.resultText2 - </div> - <div> - action.resultText3 - </div> - <div> - action.resultText4 - </div> - <div - className="stars" - > - <span> - 5 - </span> - <StyledIcon - icon="test-file-stub" - size={33} - > - <Icon - aria-hidden={true} - icon="test-file-stub" - size={33} - spin={false} - > - <Component - aria-hidden={true} - className="styles__icon___23x3R" - height={33} - style={Object {}} - width={33} - > - <svg - aria-hidden={true} - className="styles__icon___23x3R" - height={33} - style={Object {}} - width={33} - > - <use - xlinkHref="#test-file-stub" - /> - </svg> - </Component> - </Icon> - </StyledIcon> - </div> - <WithStyles(ForwardRef(Button)) - className="btnSecondary" - onClick={[Function]} + + action.finished + </div> + <div> + action.resultText1 + </div> + <div> + action.resultText2 + </div> + <div> + action.resultText3 + </div> + <div> + action.resultText4 + </div> + <div + class="stars" + > + <span> + 5 + </span> + <svg + aria-hidden="true" + class="styles__icon___23x3R" + height="33" + width="33" > - <ForwardRef(Button) - className="btnSecondary" - classes={ - Object { - "colorInherit": "MuiButton-colorInherit", - "contained": "MuiButton-contained", - "containedPrimary": "MuiButton-containedPrimary", - "containedSecondary": "MuiButton-containedSecondary", - "containedSizeLarge": "MuiButton-containedSizeLarge", - "containedSizeSmall": "MuiButton-containedSizeSmall", - "disableElevation": "MuiButton-disableElevation", - "disabled": "Mui-disabled", - "endIcon": "MuiButton-endIcon", - "focusVisible": "Mui-focusVisible", - "fullWidth": "MuiButton-fullWidth", - "iconSizeLarge": "MuiButton-iconSizeLarge", - "iconSizeMedium": "MuiButton-iconSizeMedium", - "iconSizeSmall": "MuiButton-iconSizeSmall", - "label": "MuiButton-label", - "outlined": "MuiButton-outlined", - "outlinedPrimary": "MuiButton-outlinedPrimary", - "outlinedSecondary": "MuiButton-outlinedSecondary", - "outlinedSizeLarge": "MuiButton-outlinedSizeLarge", - "outlinedSizeSmall": "MuiButton-outlinedSizeSmall", - "root": "MuiButton-root", - "sizeLarge": "MuiButton-sizeLarge", - "sizeSmall": "MuiButton-sizeSmall", - "startIcon": "MuiButton-startIcon", - "text": "MuiButton-text", - "textPrimary": "MuiButton-textPrimary", - "textSecondary": "MuiButton-textSecondary", - "textSizeLarge": "MuiButton-textSizeLarge", - "textSizeSmall": "MuiButton-textSizeSmall", - } - } - onClick={[Function]} - > - <WithStyles(ForwardRef(ButtonBase)) - className="MuiButton-root MuiButton-text btnSecondary" - component="button" - disabled={false} - focusRipple={true} - focusVisibleClassName="Mui-focusVisible" - onClick={[Function]} - type="button" - > - <ForwardRef(ButtonBase) - className="MuiButton-root MuiButton-text btnSecondary" - classes={ - Object { - "disabled": "Mui-disabled", - "focusVisible": "Mui-focusVisible", - "root": "MuiButtonBase-root", - } - } - component="button" - disabled={false} - focusRipple={true} - focusVisibleClassName="Mui-focusVisible" - onClick={[Function]} - type="button" - > - <button - className="MuiButtonBase-root MuiButton-root MuiButton-text btnSecondary" - disabled={false} - onBlur={[Function]} - onClick={[Function]} - onDragLeave={[Function]} - onFocus={[Function]} - onKeyDown={[Function]} - onKeyUp={[Function]} - onMouseDown={[Function]} - onMouseLeave={[Function]} - onMouseUp={[Function]} - onTouchEnd={[Function]} - onTouchMove={[Function]} - onTouchStart={[Function]} - tabIndex={0} - type="button" - > - <span - className="MuiButton-label" - > - action.ok - </span> - <WithStyles(memo) - center={false} - > - <ForwardRef(TouchRipple) - center={false} - classes={ - Object { - "child": "MuiTouchRipple-child", - "childLeaving": "MuiTouchRipple-childLeaving", - "childPulsate": "MuiTouchRipple-childPulsate", - "ripple": "MuiTouchRipple-ripple", - "ripplePulsate": "MuiTouchRipple-ripplePulsate", - "rippleVisible": "MuiTouchRipple-rippleVisible", - "root": "MuiTouchRipple-root", - } - } - > - <span - className="MuiTouchRipple-root" - > - <TransitionGroup - childFactory={[Function]} - component={null} - exit={true} - /> - </span> - </ForwardRef(TouchRipple)> - </WithStyles(memo)> - </button> - </ForwardRef(ButtonBase)> - </WithStyles(ForwardRef(ButtonBase))> - </ForwardRef(Button)> - </WithStyles(ForwardRef(Button))> + <use + xlink:href="#test-file-stub" + /> + </svg> </div> + <button + class="MuiButtonBase-root MuiButton-root MuiButton-text btnSecondary" + tabindex="0" + type="button" + > + <span + class="MuiButton-label" + > + action.ok + </span> + <span + class="MuiTouchRipple-root" + /> + </button> </div> - </ActionDone> -</Provider> + </div> +</div> `; diff --git a/src/components/Action/ActionList/ActionList.spec.tsx b/src/components/Action/ActionList/ActionList.spec.tsx index aad7a7a4c8c1a3be11d95e0535f18849194a303b..d18557624a55ff37a41dd51094a74d6b838c5c8e 100644 --- a/src/components/Action/ActionList/ActionList.spec.tsx +++ b/src/components/Action/ActionList/ActionList.spec.tsx @@ -1,4 +1,4 @@ -import { mount } from 'enzyme' +import { render, screen, waitFor } from '@testing-library/react' import React from 'react' import { Provider } from 'react-redux' import { defaultEcogestureData } from 'tests/__mocks__/actionData.mock' @@ -7,34 +7,31 @@ import { mockChallengeState, mockProfileState, } from 'tests/__mocks__/store' -import { waitForComponentToPaint } from 'tests/__mocks__/testUtils' -import ActionCard from '../ActionCard/ActionCard' import ActionList from './ActionList' -const mockGetCustomActions = jest.fn() const mockGetDefaultActions = jest.fn() jest.mock('services/action.service', () => { return jest.fn(() => ({ - getCustomActions: mockGetCustomActions, getDefaultActions: mockGetDefaultActions, })) }) describe('ActionList component', () => { - it('should be rendered correctly', async () => { + it('should match snapshot and render correctly 3 buttons', async () => { mockGetDefaultActions.mockResolvedValueOnce(defaultEcogestureData) const store = createMockEcolyoStore({ challenge: { ...mockChallengeState }, global: { fluidTypes: [0, 1, 2] }, profile: mockProfileState, }) - const wrapper = mount( + const { container } = render( <Provider store={store}> <ActionList setSelectedAction={jest.fn()} setShowList={jest.fn()} /> </Provider> ) - await waitForComponentToPaint(wrapper) - expect(wrapper.find(ActionCard)).toBeTruthy() + await waitFor(() => null, { container }) + expect(container).toMatchSnapshot() + expect((await screen.findAllByRole('button')).length).toBe(3) }) }) diff --git a/src/components/Action/ActionList/__snapshots__/ActionList.spec.tsx.snap b/src/components/Action/ActionList/__snapshots__/ActionList.spec.tsx.snap new file mode 100644 index 0000000000000000000000000000000000000000..0b0de6e974f935ad6a181f16e5c8c5081c12f75e --- /dev/null +++ b/src/components/Action/ActionList/__snapshots__/ActionList.spec.tsx.snap @@ -0,0 +1,94 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ActionList component should match snapshot and render correctly 3 buttons 1`] = ` +<div> + <div + class="action-list-container" + > + <button + class="MuiButtonBase-root MuiButton-root MuiButton-text action-card" + tabindex="0" + type="button" + > + <span + class="MuiButton-label" + > + <svg + aria-hidden="true" + class="action-icon styles__icon___23x3R" + height="100" + width="100" + > + <use + xlink:href="#test-file-stub" + /> + </svg> + <div + class="action-title text-18-bold" + > + Poings de glace + </div> + </span> + <span + class="MuiTouchRipple-root" + /> + </button> + <button + class="MuiButtonBase-root MuiButton-root MuiButton-text action-card" + tabindex="0" + type="button" + > + <span + class="MuiButton-label" + > + <svg + aria-hidden="true" + class="action-icon styles__icon___23x3R" + height="100" + width="100" + > + <use + xlink:href="#test-file-stub" + /> + </svg> + <div + class="action-title text-18-bold" + > + Chat échaudé + </div> + </span> + <span + class="MuiTouchRipple-root" + /> + </button> + <button + class="MuiButtonBase-root MuiButton-root MuiButton-text action-card" + tabindex="0" + type="button" + > + <span + class="MuiButton-label" + > + <svg + aria-hidden="true" + class="action-icon styles__icon___23x3R" + height="100" + width="100" + > + <use + xlink:href="#test-file-stub" + /> + </svg> + <div + class="action-title text-18-bold" + > + Reine du Puzzle + </div> + </span> + <span + class="MuiTouchRipple-root" + /> + </button> + </div> +</div> +`; diff --git a/src/components/Action/ActionModal/ActionModal.spec.tsx b/src/components/Action/ActionModal/ActionModal.spec.tsx index 4507b4c42146b6cae0d2cf481ba60fee067887fb..a3c59c54d2523c2f93e0c264740a6389efe9afd2 100644 --- a/src/components/Action/ActionModal/ActionModal.spec.tsx +++ b/src/components/Action/ActionModal/ActionModal.spec.tsx @@ -1,13 +1,10 @@ -import { Button } from '@material-ui/core' -import { mount } from 'enzyme' -import toJson from 'enzyme-to-json' +import { render, screen } from '@testing-library/react' +import userEvent from '@testing-library/user-event' import React from 'react' import { Provider } from 'react-redux' -import UsageEventService from 'services/usageEvent.service' import * as challengeActions from 'store/challenge/challenge.slice' import { defaultEcogestureData } from 'tests/__mocks__/actionData.mock' import { createMockEcolyoStore } from 'tests/__mocks__/store' -import { waitForComponentToPaint } from 'tests/__mocks__/testUtils' import { userChallengeData } from 'tests/__mocks__/userChallengeData.mock' import ActionModal from './ActionModal' @@ -17,14 +14,11 @@ jest.mock('services/challenge.service', () => { updateUserChallenge: mockUpdateUserChallenge, })) }) -jest.mock('services/usageEvent.service') -const mockAddEvent = jest.fn() -UsageEventService.addEvent = mockAddEvent describe('ActionModal component', () => { const store = createMockEcolyoStore() it('should render correctly', async () => { - const wrapper = mount( + const { baseElement } = render( <Provider store={store}> <ActionModal open={true} @@ -34,8 +28,7 @@ describe('ActionModal component', () => { /> </Provider> ) - await waitForComponentToPaint(wrapper) - expect(toJson(wrapper)).toMatchSnapshot() + expect(baseElement).toMatchSnapshot() }) it('should click on button and update action to ongoing', async () => { const updateChallengeSpy = jest.spyOn( @@ -44,7 +37,7 @@ describe('ActionModal component', () => { ) mockUpdateUserChallenge.mockResolvedValueOnce(userChallengeData[1]) - const wrapper = mount( + render( <Provider store={store}> <ActionModal open={true} @@ -54,8 +47,7 @@ describe('ActionModal component', () => { /> </Provider> ) - wrapper.find(Button).first().simulate('click') - await waitForComponentToPaint(wrapper) + await userEvent.click(await screen.findByText('action_modal.accept')) expect(updateChallengeSpy).toHaveBeenCalledTimes(1) }) }) diff --git a/src/components/Action/ActionModal/ActionModal.tsx b/src/components/Action/ActionModal/ActionModal.tsx index bcb5d019f257d63757f2bcebbfd25cd74a0c261b..8cd832e88df0deb8dbaf0598c1f83e2fbe282f69 100644 --- a/src/components/Action/ActionModal/ActionModal.tsx +++ b/src/components/Action/ActionModal/ActionModal.tsx @@ -30,14 +30,13 @@ const ActionModal = ({ const dispatch = useAppDispatch() const launchAction = useCallback(async () => { const challengeService = new ChallengeService(client) - const updatedChallenge: UserChallenge = - await challengeService.updateUserChallenge( - userChallenge, - UserChallengeUpdateFlag.ACTION_START, - undefined, - undefined, - action - ) + const updatedChallenge = await challengeService.updateUserChallenge( + userChallenge, + UserChallengeUpdateFlag.ACTION_START, + undefined, + undefined, + action + ) dispatch(updateUserChallengeList(updatedChallenge)) }, [action, client, dispatch, userChallenge]) diff --git a/src/components/Action/ActionModal/__snapshots__/ActionModal.spec.tsx.snap b/src/components/Action/ActionModal/__snapshots__/ActionModal.spec.tsx.snap index 9e1d70dc3f92d0209b60d30796276111d63e12ce..2825edc3a9a03ccf4537cc5e822eafeab09ec7d3 100644 --- a/src/components/Action/ActionModal/__snapshots__/ActionModal.spec.tsx.snap +++ b/src/components/Action/ActionModal/__snapshots__/ActionModal.spec.tsx.snap @@ -1,1179 +1,105 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`ActionModal component should render correctly 1`] = ` -<Provider - store={ - Object { - "clearActions": [Function], - "dispatch": [Function], - "getActions": [Function], - "getState": [Function], - "replaceReducer": [Function], - "subscribe": [Function], - } - } +<body + style="padding-right: 0px; overflow: hidden;" > - <ActionModal - action={ - Object { - "_id": "ECOGESTURE0014", - "action": true, - "actionDuration": 3, - "actionName": "J’attends que les plats chauds aient refroidi avant de les mettre au réfrigérateur et je les couvre.", - "difficulty": 1, - "doing": false, - "efficiency": 1, - "equipment": false, - "equipmentInstallation": true, - "equipmentType": Array [], - "fluidTypes": Array [ - 0, - ], - "id": "ECOGESTURE0014", - "impactLevel": 2, - "investment": null, - "longDescription": "En plaçant des plats chauds au réfrigérateur, vous réchauffez l’enceinte de l’appareil, ce qui entraîne une surconsommation. De plus, si les plats ne sont pas couverts, de la vapeur d’eau va se former et provoquer l’apparition du givre. Et couvrir les plats, c’est aussi éviter que les bactéries et les odeurs ne se répandent.", - "longName": "J’attends que les plats chauds aient refroidi avant de les mettre au réfrigérateur et je les couvre.", - "objective": false, - "room": Array [ - 2, - ], - "season": "Sans saison", - "shortName": "Chat échaudé", - "usage": 5, - "viewedInSelection": false, - } - } - handleCloseClick={[MockFunction]} - open={true} - userChallenge={ - Object { - "action": Object { - "ecogesture": null, - "startDate": null, - "state": 0, - }, - "description": "Description challenge 2", - "duel": Object { - "description": "Je parie un ours polaire que vous ne pouvez pas consommer moins que #CONSUMPTION € en 1 semaine", - "duration": "P30D", - "fluidTypes": Array [], - "id": "DUEL001", - "startDate": null, - "state": 0, - "threshold": 0, - "title": "Title DUEL001", - "userConsumption": 0, - }, - "endingDate": null, - "exploration": Object { - "complementary_description": "Refaire un tour dans son profil si déjà fait", - "date": null, - "description": "Avoir complété son profil", - "ecogesture_id": "", - "fluid_condition": Array [], - "id": "EXPLORATION001", - "message_success": "Vous avez complété votre profil ou refait un tour dans votre profil", - "progress": 0, - "state": 0, - "target": 1, - "type": 1, - }, - "id": "CHALLENGE0002", - "progress": Object { - "actionProgress": 0, - "explorationProgress": 0, - "quizProgress": 0, - }, - "quiz": Object { - "customQuestion": Object { - "interval": 20, - "period": Object {}, - "questionLabel": "Custom1", - "result": 0, - "singleFluid": false, - "timeStep": 20, - "type": 0, - }, - "id": "QUIZ001", - "questions": Array [ - Object { - "answers": Array [ - Object { - "answerLabel": "86 km", - "isTrue": true, - }, - Object { - "answerLabel": "78 km", - "isTrue": false, - }, - Object { - "answerLabel": "56 km", - "isTrue": false, - }, - ], - "explanation": "L’aqueduc du Gier est un des aqueducs antiques de Lyon desservant la ville antique de Lugdunum. Avec ses 86 km il est le plus long des quatre aqueducs ayant alimenté la ville en eau, et celui dont les structures sont le mieux conservées. Il doit son nom au fait qu'il puise aux sources du Gier, affluent du Rhône", - "questionLabel": "Quelle longueur faisait l’aqueduc du Gier pour acheminer l’eau sur Lyon à l’époque romaine ?", - "result": 0, - "source": "string", - }, - Object { - "answers": Array [ - Object { - "answerLabel": "1 point d’eau public pour 800 habitants.", - "isTrue": true, - }, - Object { - "answerLabel": "1 point d’eau public pour 400 habitants.", - "isTrue": false, - }, - Object { - "answerLabel": "1 point d’eau public pour 200 habitants.", - "isTrue": false, - }, - ], - "explanation": "string", - "questionLabel": "En 1800 à Lyon, combien de points d'eau y avait-il par habitants ?", - "result": 0, - "source": "string", - }, - Object { - "answers": Array [ - Object { - "answerLabel": "François Mitterrand", - "isTrue": false, - }, - Object { - "answerLabel": "Napoléon Ier", - "isTrue": true, - }, - Object { - "answerLabel": "Napoléon III", - "isTrue": false, - }, - ], - "explanation": "string", - "questionLabel": "Qui officialise la création de la Compagnie Générale des eaux ?", - "result": 0, - "source": "string", - }, - Object { - "answers": Array [ - Object { - "answerLabel": "string", - "isTrue": false, - }, - Object { - "answerLabel": "string", - "isTrue": false, - }, - Object { - "answerLabel": "Aristide Dumont", - "isTrue": true, - }, - ], - "explanation": "string", - "questionLabel": "Quel ingénieur est à l’origine du projet d’alimentation en eau en 1856 ?", - "result": 0, - "source": "string", - }, - ], - "result": 0, - "startDate": null, - "state": 0, - }, - "startDate": null, - "state": 4, - "success": 1, - "target": 15, - "title": "Challenge 2", - } - } + <div + aria-hidden="true" + /> + <div + class="MuiDialog-root modal-root" + role="presentation" + style="position: fixed; z-index: 1300; right: 0px; bottom: 0px; top: 0px; left: 0px;" > - <WithStyles(ForwardRef(Dialog)) - aria-labelledby="accessibility-title" - classes={ - Object { - "paper": "modal-paper", - "root": "modal-root", - } - } - onClose={[MockFunction]} - open={true} + <div + aria-hidden="true" + class="MuiBackdrop-root" + style="opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;" + /> + <div + data-test="sentinelStart" + tabindex="0" + /> + <div + class="MuiDialog-container MuiDialog-scrollPaper" + role="none presentation" + style="opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;" + tabindex="-1" > - <ForwardRef(Dialog) + <div aria-labelledby="accessibility-title" - classes={ - Object { - "container": "MuiDialog-container", - "paper": "MuiDialog-paper modal-paper", - "paperFullScreen": "MuiDialog-paperFullScreen", - "paperFullWidth": "MuiDialog-paperFullWidth", - "paperScrollBody": "MuiDialog-paperScrollBody", - "paperScrollPaper": "MuiDialog-paperScrollPaper", - "paperWidthFalse": "MuiDialog-paperWidthFalse", - "paperWidthLg": "MuiDialog-paperWidthLg", - "paperWidthMd": "MuiDialog-paperWidthMd", - "paperWidthSm": "MuiDialog-paperWidthSm", - "paperWidthXl": "MuiDialog-paperWidthXl", - "paperWidthXs": "MuiDialog-paperWidthXs", - "root": "MuiDialog-root modal-root", - "scrollBody": "MuiDialog-scrollBody", - "scrollPaper": "MuiDialog-scrollPaper", - } - } - onClose={[MockFunction]} - open={true} + class="MuiPaper-root MuiDialog-paper modal-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthSm MuiPaper-elevation24 MuiPaper-rounded" + role="dialog" > - <ForwardRef(Modal) - BackdropComponent={ - Object { - "$$typeof": Symbol(react.forward_ref), - "Naked": Object { - "$$typeof": Symbol(react.forward_ref), - "propTypes": Object { - "children": [Function], - "className": [Function], - "classes": [Function], - "invisible": [Function], - "open": [Function], - "transitionDuration": [Function], - }, - "render": [Function], - }, - "displayName": "WithStyles(ForwardRef(Backdrop))", - "options": Object { - "defaultTheme": Object { - "breakpoints": Object { - "between": [Function], - "down": [Function], - "keys": Array [ - "xs", - "sm", - "md", - "lg", - "xl", - ], - "only": [Function], - "up": [Function], - "values": Object { - "lg": 1280, - "md": 960, - "sm": 600, - "xl": 1920, - "xs": 0, - }, - "width": [Function], - }, - "direction": "ltr", - "mixins": Object { - "gutters": [Function], - "toolbar": Object { - "@media (min-width:0px) and (orientation: landscape)": Object { - "minHeight": 48, - }, - "@media (min-width:600px)": Object { - "minHeight": 64, - }, - "minHeight": 56, - }, - }, - "overrides": Object {}, - "palette": Object { - "action": Object { - "activatedOpacity": 0.12, - "active": "rgba(0, 0, 0, 0.54)", - "disabled": "rgba(0, 0, 0, 0.26)", - "disabledBackground": "rgba(0, 0, 0, 0.12)", - "disabledOpacity": 0.38, - "focus": "rgba(0, 0, 0, 0.12)", - "focusOpacity": 0.12, - "hover": "rgba(0, 0, 0, 0.04)", - "hoverOpacity": 0.04, - "selected": "rgba(0, 0, 0, 0.08)", - "selectedOpacity": 0.08, - }, - "augmentColor": [Function], - "background": Object { - "default": "#fafafa", - "paper": "#fff", - }, - "common": Object { - "black": "#000", - "white": "#fff", - }, - "contrastThreshold": 3, - "divider": "rgba(0, 0, 0, 0.12)", - "error": Object { - "contrastText": "#fff", - "dark": "#d32f2f", - "light": "#e57373", - "main": "#f44336", - }, - "getContrastText": [Function], - "grey": Object { - "100": "#f5f5f5", - "200": "#eeeeee", - "300": "#e0e0e0", - "400": "#bdbdbd", - "50": "#fafafa", - "500": "#9e9e9e", - "600": "#757575", - "700": "#616161", - "800": "#424242", - "900": "#212121", - "A100": "#d5d5d5", - "A200": "#aaaaaa", - "A400": "#303030", - "A700": "#616161", - }, - "info": Object { - "contrastText": "#fff", - "dark": "#1976d2", - "light": "#64b5f6", - "main": "#2196f3", - }, - "primary": Object { - "contrastText": "#fff", - "dark": "#303f9f", - "light": "#7986cb", - "main": "#3f51b5", - }, - "secondary": Object { - "contrastText": "#fff", - "dark": "#c51162", - "light": "#ff4081", - "main": "#f50057", - }, - "success": Object { - "contrastText": "rgba(0, 0, 0, 0.87)", - "dark": "#388e3c", - "light": "#81c784", - "main": "#4caf50", - }, - "text": Object { - "disabled": "rgba(0, 0, 0, 0.38)", - "hint": "rgba(0, 0, 0, 0.38)", - "primary": "rgba(0, 0, 0, 0.87)", - "secondary": "rgba(0, 0, 0, 0.54)", - }, - "tonalOffset": 0.2, - "type": "light", - "warning": Object { - "contrastText": "rgba(0, 0, 0, 0.87)", - "dark": "#f57c00", - "light": "#ffb74d", - "main": "#ff9800", - }, - }, - "props": Object {}, - "shadows": Array [ - "none", - "0px 2px 1px -1px rgba(0,0,0,0.2),0px 1px 1px 0px rgba(0,0,0,0.14),0px 1px 3px 0px rgba(0,0,0,0.12)", - "0px 3px 1px -2px rgba(0,0,0,0.2),0px 2px 2px 0px rgba(0,0,0,0.14),0px 1px 5px 0px rgba(0,0,0,0.12)", - "0px 3px 3px -2px rgba(0,0,0,0.2),0px 3px 4px 0px rgba(0,0,0,0.14),0px 1px 8px 0px rgba(0,0,0,0.12)", - "0px 2px 4px -1px rgba(0,0,0,0.2),0px 4px 5px 0px rgba(0,0,0,0.14),0px 1px 10px 0px rgba(0,0,0,0.12)", - "0px 3px 5px -1px rgba(0,0,0,0.2),0px 5px 8px 0px rgba(0,0,0,0.14),0px 1px 14px 0px rgba(0,0,0,0.12)", - "0px 3px 5px -1px rgba(0,0,0,0.2),0px 6px 10px 0px rgba(0,0,0,0.14),0px 1px 18px 0px rgba(0,0,0,0.12)", - "0px 4px 5px -2px rgba(0,0,0,0.2),0px 7px 10px 1px rgba(0,0,0,0.14),0px 2px 16px 1px rgba(0,0,0,0.12)", - "0px 5px 5px -3px rgba(0,0,0,0.2),0px 8px 10px 1px rgba(0,0,0,0.14),0px 3px 14px 2px rgba(0,0,0,0.12)", - "0px 5px 6px -3px rgba(0,0,0,0.2),0px 9px 12px 1px rgba(0,0,0,0.14),0px 3px 16px 2px rgba(0,0,0,0.12)", - "0px 6px 6px -3px rgba(0,0,0,0.2),0px 10px 14px 1px rgba(0,0,0,0.14),0px 4px 18px 3px rgba(0,0,0,0.12)", - "0px 6px 7px -4px rgba(0,0,0,0.2),0px 11px 15px 1px rgba(0,0,0,0.14),0px 4px 20px 3px rgba(0,0,0,0.12)", - "0px 7px 8px -4px rgba(0,0,0,0.2),0px 12px 17px 2px rgba(0,0,0,0.14),0px 5px 22px 4px rgba(0,0,0,0.12)", - "0px 7px 8px -4px rgba(0,0,0,0.2),0px 13px 19px 2px rgba(0,0,0,0.14),0px 5px 24px 4px rgba(0,0,0,0.12)", - "0px 7px 9px -4px rgba(0,0,0,0.2),0px 14px 21px 2px rgba(0,0,0,0.14),0px 5px 26px 4px rgba(0,0,0,0.12)", - "0px 8px 9px -5px rgba(0,0,0,0.2),0px 15px 22px 2px rgba(0,0,0,0.14),0px 6px 28px 5px rgba(0,0,0,0.12)", - "0px 8px 10px -5px rgba(0,0,0,0.2),0px 16px 24px 2px rgba(0,0,0,0.14),0px 6px 30px 5px rgba(0,0,0,0.12)", - "0px 8px 11px -5px rgba(0,0,0,0.2),0px 17px 26px 2px rgba(0,0,0,0.14),0px 6px 32px 5px rgba(0,0,0,0.12)", - "0px 9px 11px -5px rgba(0,0,0,0.2),0px 18px 28px 2px rgba(0,0,0,0.14),0px 7px 34px 6px rgba(0,0,0,0.12)", - "0px 9px 12px -6px rgba(0,0,0,0.2),0px 19px 29px 2px rgba(0,0,0,0.14),0px 7px 36px 6px rgba(0,0,0,0.12)", - "0px 10px 13px -6px rgba(0,0,0,0.2),0px 20px 31px 3px rgba(0,0,0,0.14),0px 8px 38px 7px rgba(0,0,0,0.12)", - "0px 10px 13px -6px rgba(0,0,0,0.2),0px 21px 33px 3px rgba(0,0,0,0.14),0px 8px 40px 7px rgba(0,0,0,0.12)", - "0px 10px 14px -6px rgba(0,0,0,0.2),0px 22px 35px 3px rgba(0,0,0,0.14),0px 8px 42px 7px rgba(0,0,0,0.12)", - "0px 11px 14px -7px rgba(0,0,0,0.2),0px 23px 36px 3px rgba(0,0,0,0.14),0px 9px 44px 8px rgba(0,0,0,0.12)", - "0px 11px 15px -7px rgba(0,0,0,0.2),0px 24px 38px 3px rgba(0,0,0,0.14),0px 9px 46px 8px rgba(0,0,0,0.12)", - ], - "shape": Object { - "borderRadius": 4, - }, - "spacing": [Function], - "transitions": Object { - "create": [Function], - "duration": Object { - "complex": 375, - "enteringScreen": 225, - "leavingScreen": 195, - "short": 250, - "shorter": 200, - "shortest": 150, - "standard": 300, - }, - "easing": Object { - "easeIn": "cubic-bezier(0.4, 0, 1, 1)", - "easeInOut": "cubic-bezier(0.4, 0, 0.2, 1)", - "easeOut": "cubic-bezier(0.0, 0, 0.2, 1)", - "sharp": "cubic-bezier(0.4, 0, 0.6, 1)", - }, - "getAutoHeightDuration": [Function], - }, - "typography": Object { - "body1": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "1rem", - "fontWeight": 400, - "letterSpacing": "0.00938em", - "lineHeight": 1.5, - }, - "body2": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "0.875rem", - "fontWeight": 400, - "letterSpacing": "0.01071em", - "lineHeight": 1.43, - }, - "button": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "0.875rem", - "fontWeight": 500, - "letterSpacing": "0.02857em", - "lineHeight": 1.75, - "textTransform": "uppercase", - }, - "caption": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "0.75rem", - "fontWeight": 400, - "letterSpacing": "0.03333em", - "lineHeight": 1.66, - }, - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": 14, - "fontWeightBold": 700, - "fontWeightLight": 300, - "fontWeightMedium": 500, - "fontWeightRegular": 400, - "h1": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "6rem", - "fontWeight": 300, - "letterSpacing": "-0.01562em", - "lineHeight": 1.167, - }, - "h2": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "3.75rem", - "fontWeight": 300, - "letterSpacing": "-0.00833em", - "lineHeight": 1.2, - }, - "h3": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "3rem", - "fontWeight": 400, - "letterSpacing": "0em", - "lineHeight": 1.167, - }, - "h4": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "2.125rem", - "fontWeight": 400, - "letterSpacing": "0.00735em", - "lineHeight": 1.235, - }, - "h5": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "1.5rem", - "fontWeight": 400, - "letterSpacing": "0em", - "lineHeight": 1.334, - }, - "h6": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "1.25rem", - "fontWeight": 500, - "letterSpacing": "0.0075em", - "lineHeight": 1.6, - }, - "htmlFontSize": 16, - "overline": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "0.75rem", - "fontWeight": 400, - "letterSpacing": "0.08333em", - "lineHeight": 2.66, - "textTransform": "uppercase", - }, - "pxToRem": [Function], - "round": [Function], - "subtitle1": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "1rem", - "fontWeight": 400, - "letterSpacing": "0.00938em", - "lineHeight": 1.75, - }, - "subtitle2": Object { - "fontFamily": "\\"Roboto\\", \\"Helvetica\\", \\"Arial\\", sans-serif", - "fontSize": "0.875rem", - "fontWeight": 500, - "letterSpacing": "0.00714em", - "lineHeight": 1.57, - }, - }, - "zIndex": Object { - "appBar": 1100, - "drawer": 1200, - "mobileStepper": 1000, - "modal": 1300, - "snackbar": 1400, - "speedDial": 1050, - "tooltip": 1500, - }, - }, - "name": "MuiBackdrop", - }, - "propTypes": Object { - "classes": [Function], - "innerRef": [Function], - }, - "render": [Function], - "useStyles": [Function], - } - } - BackdropProps={ - Object { - "transitionDuration": Object { - "enter": 225, - "exit": 195, - }, - } - } - className="MuiDialog-root modal-root" - closeAfterTransition={true} - disableEscapeKeyDown={false} - onClose={[MockFunction]} - open={true} + <div + id="accessibility-title" > - <ForwardRef(Portal) - disablePortal={false} + action_modal.accessibility.window_title + </div> + <div + class="action-modal" + > + <svg + class="styles__icon___23x3R" + height="75" + width="75" + > + <use + xlink:href="#test-file-stub" + /> + </svg> + <div + class="action-title text-16-normal" + > + action.duration + </div> + <div + class="action-text text-16-normal" > - <Portal - containerInfo={ - <body - style="padding-right: 0px; overflow: hidden;" - > - <div - class="MuiDialog-root modal-root" - role="presentation" - style="position: fixed; z-index: 1300; right: 0px; bottom: 0px; top: 0px; left: 0px;" - > - <div - aria-hidden="true" - class="MuiBackdrop-root" - style="opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;" - /> - <div - data-test="sentinelStart" - tabindex="0" - /> - <div - class="MuiDialog-container MuiDialog-scrollPaper" - role="none presentation" - style="opacity: 1; webkit-transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms; transition: opacity 225ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;" - tabindex="-1" - > - <div - aria-labelledby="accessibility-title" - class="MuiPaper-root MuiDialog-paper modal-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthSm MuiPaper-elevation24 MuiPaper-rounded" - role="dialog" - > - <div - id="accessibility-title" - > - action_modal.accessibility.window_title - </div> - <div - class="action-modal" - > - <svg - class="styles__icon___23x3R" - height="75" - width="75" - > - <use - xlink:href="#test-file-stub" - /> - </svg> - <div - class="action-title text-16-normal" - > - action.duration - </div> - <div - class="action-text text-16-normal" - > - J’attends que les plats chauds aient refroidi avant de les mettre au réfrigérateur et je les couvre. - </div> - <div - class="buttons" - > - <button - aria-label="action_modal.accessibility.button_accept" - class="MuiButtonBase-root MuiButton-root MuiButton-text btnSecondary" - tabindex="0" - type="button" - > - <span - class="MuiButton-label" - > - action_modal.accept - </span> - <span - class="MuiTouchRipple-root" - /> - </button> - <button - aria-label="action_modal.accessibility.button_refuse" - class="MuiButtonBase-root MuiButton-root MuiButton-text btnSecondary" - tabindex="0" - type="button" - > - <span - class="MuiButton-label" - > - action_modal.refuse - </span> - <span - class="MuiTouchRipple-root" - /> - </button> - </div> - </div> - </div> - </div> - <div - data-test="sentinelEnd" - tabindex="0" - /> - </div> - </body> - } + J’attends que les plats chauds aient refroidi avant de les mettre au réfrigérateur et je les couvre. + </div> + <div + class="buttons" + > + <button + aria-label="action_modal.accessibility.button_accept" + class="MuiButtonBase-root MuiButton-root MuiButton-text btnSecondary" + tabindex="0" + type="button" + > + <span + class="MuiButton-label" + > + action_modal.accept + </span> + <span + class="MuiTouchRipple-root" + /> + </button> + <button + aria-label="action_modal.accessibility.button_refuse" + class="MuiButtonBase-root MuiButton-root MuiButton-text btnSecondary" + tabindex="0" + type="button" > - <div - className="MuiDialog-root modal-root" - onKeyDown={[Function]} - role="presentation" - style={ - Object { - "bottom": 0, - "left": 0, - "position": "fixed", - "right": 0, - "top": 0, - "zIndex": 1300, - } - } + <span + class="MuiButton-label" > - <WithStyles(ForwardRef(Backdrop)) - onClick={[Function]} - open={true} - transitionDuration={ - Object { - "enter": 225, - "exit": 195, - } - } - > - <ForwardRef(Backdrop) - classes={ - Object { - "invisible": "MuiBackdrop-invisible", - "root": "MuiBackdrop-root", - } - } - onClick={[Function]} - open={true} - transitionDuration={ - Object { - "enter": 225, - "exit": 195, - } - } - > - <ForwardRef(Fade) - in={true} - onClick={[Function]} - timeout={ - Object { - "enter": 225, - "exit": 195, - } - } - > - <Transition - appear={true} - enter={true} - exit={true} - in={true} - mountOnEnter={false} - onClick={[Function]} - onEnter={[Function]} - onEntered={[Function]} - onEntering={[Function]} - onExit={[Function]} - onExited={[Function]} - onExiting={[Function]} - timeout={ - Object { - "enter": 225, - "exit": 195, - } - } - unmountOnExit={false} - > - <div - aria-hidden={true} - className="MuiBackdrop-root" - onClick={[Function]} - style={ - Object { - "opacity": 1, - "visibility": undefined, - } - } - /> - </Transition> - </ForwardRef(Fade)> - </ForwardRef(Backdrop)> - </WithStyles(ForwardRef(Backdrop))> - <Unstable_TrapFocus - disableAutoFocus={false} - disableEnforceFocus={false} - disableRestoreFocus={false} - getDoc={[Function]} - isEnabled={[Function]} - open={true} - > - <div - data-test="sentinelStart" - tabIndex={0} - /> - <ForwardRef(Fade) - appear={true} - in={true} - onEnter={[Function]} - onExited={[Function]} - role="none presentation" - tabIndex="-1" - timeout={ - Object { - "enter": 225, - "exit": 195, - } - } - > - <Transition - appear={true} - enter={true} - exit={true} - in={true} - mountOnEnter={false} - onEnter={[Function]} - onEntered={[Function]} - onEntering={[Function]} - onExit={[Function]} - onExited={[Function]} - onExiting={[Function]} - role="none presentation" - tabIndex="-1" - timeout={ - Object { - "enter": 225, - "exit": 195, - } - } - unmountOnExit={false} - > - <div - className="MuiDialog-container MuiDialog-scrollPaper" - onMouseDown={[Function]} - onMouseUp={[Function]} - role="none presentation" - style={ - Object { - "opacity": 1, - "visibility": undefined, - } - } - tabIndex="-1" - > - <WithStyles(ForwardRef(Paper)) - aria-labelledby="accessibility-title" - className="MuiDialog-paper modal-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthSm" - elevation={24} - role="dialog" - > - <ForwardRef(Paper) - aria-labelledby="accessibility-title" - className="MuiDialog-paper modal-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthSm" - classes={ - Object { - "elevation0": "MuiPaper-elevation0", - "elevation1": "MuiPaper-elevation1", - "elevation10": "MuiPaper-elevation10", - "elevation11": "MuiPaper-elevation11", - "elevation12": "MuiPaper-elevation12", - "elevation13": "MuiPaper-elevation13", - "elevation14": "MuiPaper-elevation14", - "elevation15": "MuiPaper-elevation15", - "elevation16": "MuiPaper-elevation16", - "elevation17": "MuiPaper-elevation17", - "elevation18": "MuiPaper-elevation18", - "elevation19": "MuiPaper-elevation19", - "elevation2": "MuiPaper-elevation2", - "elevation20": "MuiPaper-elevation20", - "elevation21": "MuiPaper-elevation21", - "elevation22": "MuiPaper-elevation22", - "elevation23": "MuiPaper-elevation23", - "elevation24": "MuiPaper-elevation24", - "elevation3": "MuiPaper-elevation3", - "elevation4": "MuiPaper-elevation4", - "elevation5": "MuiPaper-elevation5", - "elevation6": "MuiPaper-elevation6", - "elevation7": "MuiPaper-elevation7", - "elevation8": "MuiPaper-elevation8", - "elevation9": "MuiPaper-elevation9", - "outlined": "MuiPaper-outlined", - "root": "MuiPaper-root", - "rounded": "MuiPaper-rounded", - } - } - elevation={24} - role="dialog" - > - <div - aria-labelledby="accessibility-title" - className="MuiPaper-root MuiDialog-paper modal-paper MuiDialog-paperScrollPaper MuiDialog-paperWidthSm MuiPaper-elevation24 MuiPaper-rounded" - role="dialog" - > - <div - id="accessibility-title" - > - action_modal.accessibility.window_title - </div> - <div - className="action-modal" - > - <Icon - icon="test-file-stub" - size={75} - spin={false} - > - <Component - className="styles__icon___23x3R" - height={75} - style={Object {}} - width={75} - > - <svg - className="styles__icon___23x3R" - height={75} - style={Object {}} - width={75} - > - <use - xlinkHref="#test-file-stub" - /> - </svg> - </Component> - </Icon> - <div - className="action-title text-16-normal" - > - action.duration - </div> - <div - className="action-text text-16-normal" - > - J’attends que les plats chauds aient refroidi avant de les mettre au réfrigérateur et je les couvre. - </div> - <div - className="buttons" - > - <WithStyles(ForwardRef(Button)) - aria-label="action_modal.accessibility.button_accept" - className="btnSecondary" - onClick={[Function]} - > - <ForwardRef(Button) - aria-label="action_modal.accessibility.button_accept" - className="btnSecondary" - classes={ - Object { - "colorInherit": "MuiButton-colorInherit", - "contained": "MuiButton-contained", - "containedPrimary": "MuiButton-containedPrimary", - "containedSecondary": "MuiButton-containedSecondary", - "containedSizeLarge": "MuiButton-containedSizeLarge", - "containedSizeSmall": "MuiButton-containedSizeSmall", - "disableElevation": "MuiButton-disableElevation", - "disabled": "Mui-disabled", - "endIcon": "MuiButton-endIcon", - "focusVisible": "Mui-focusVisible", - "fullWidth": "MuiButton-fullWidth", - "iconSizeLarge": "MuiButton-iconSizeLarge", - "iconSizeMedium": "MuiButton-iconSizeMedium", - "iconSizeSmall": "MuiButton-iconSizeSmall", - "label": "MuiButton-label", - "outlined": "MuiButton-outlined", - "outlinedPrimary": "MuiButton-outlinedPrimary", - "outlinedSecondary": "MuiButton-outlinedSecondary", - "outlinedSizeLarge": "MuiButton-outlinedSizeLarge", - "outlinedSizeSmall": "MuiButton-outlinedSizeSmall", - "root": "MuiButton-root", - "sizeLarge": "MuiButton-sizeLarge", - "sizeSmall": "MuiButton-sizeSmall", - "startIcon": "MuiButton-startIcon", - "text": "MuiButton-text", - "textPrimary": "MuiButton-textPrimary", - "textSecondary": "MuiButton-textSecondary", - "textSizeLarge": "MuiButton-textSizeLarge", - "textSizeSmall": "MuiButton-textSizeSmall", - } - } - onClick={[Function]} - > - <WithStyles(ForwardRef(ButtonBase)) - aria-label="action_modal.accessibility.button_accept" - className="MuiButton-root MuiButton-text btnSecondary" - component="button" - disabled={false} - focusRipple={true} - focusVisibleClassName="Mui-focusVisible" - onClick={[Function]} - type="button" - > - <ForwardRef(ButtonBase) - aria-label="action_modal.accessibility.button_accept" - className="MuiButton-root MuiButton-text btnSecondary" - classes={ - Object { - "disabled": "Mui-disabled", - "focusVisible": "Mui-focusVisible", - "root": "MuiButtonBase-root", - } - } - component="button" - disabled={false} - focusRipple={true} - focusVisibleClassName="Mui-focusVisible" - onClick={[Function]} - type="button" - > - <button - aria-label="action_modal.accessibility.button_accept" - className="MuiButtonBase-root MuiButton-root MuiButton-text btnSecondary" - disabled={false} - onBlur={[Function]} - onClick={[Function]} - onDragLeave={[Function]} - onFocus={[Function]} - onKeyDown={[Function]} - onKeyUp={[Function]} - onMouseDown={[Function]} - onMouseLeave={[Function]} - onMouseUp={[Function]} - onTouchEnd={[Function]} - onTouchMove={[Function]} - onTouchStart={[Function]} - tabIndex={0} - type="button" - > - <span - className="MuiButton-label" - > - action_modal.accept - </span> - <WithStyles(memo) - center={false} - > - <ForwardRef(TouchRipple) - center={false} - classes={ - Object { - "child": "MuiTouchRipple-child", - "childLeaving": "MuiTouchRipple-childLeaving", - "childPulsate": "MuiTouchRipple-childPulsate", - "ripple": "MuiTouchRipple-ripple", - "ripplePulsate": "MuiTouchRipple-ripplePulsate", - "rippleVisible": "MuiTouchRipple-rippleVisible", - "root": "MuiTouchRipple-root", - } - } - > - <span - className="MuiTouchRipple-root" - > - <TransitionGroup - childFactory={[Function]} - component={null} - exit={true} - /> - </span> - </ForwardRef(TouchRipple)> - </WithStyles(memo)> - </button> - </ForwardRef(ButtonBase)> - </WithStyles(ForwardRef(ButtonBase))> - </ForwardRef(Button)> - </WithStyles(ForwardRef(Button))> - <WithStyles(ForwardRef(Button)) - aria-label="action_modal.accessibility.button_refuse" - className="btnSecondary" - onClick={[MockFunction]} - > - <ForwardRef(Button) - aria-label="action_modal.accessibility.button_refuse" - className="btnSecondary" - classes={ - Object { - "colorInherit": "MuiButton-colorInherit", - "contained": "MuiButton-contained", - "containedPrimary": "MuiButton-containedPrimary", - "containedSecondary": "MuiButton-containedSecondary", - "containedSizeLarge": "MuiButton-containedSizeLarge", - "containedSizeSmall": "MuiButton-containedSizeSmall", - "disableElevation": "MuiButton-disableElevation", - "disabled": "Mui-disabled", - "endIcon": "MuiButton-endIcon", - "focusVisible": "Mui-focusVisible", - "fullWidth": "MuiButton-fullWidth", - "iconSizeLarge": "MuiButton-iconSizeLarge", - "iconSizeMedium": "MuiButton-iconSizeMedium", - "iconSizeSmall": "MuiButton-iconSizeSmall", - "label": "MuiButton-label", - "outlined": "MuiButton-outlined", - "outlinedPrimary": "MuiButton-outlinedPrimary", - "outlinedSecondary": "MuiButton-outlinedSecondary", - "outlinedSizeLarge": "MuiButton-outlinedSizeLarge", - "outlinedSizeSmall": "MuiButton-outlinedSizeSmall", - "root": "MuiButton-root", - "sizeLarge": "MuiButton-sizeLarge", - "sizeSmall": "MuiButton-sizeSmall", - "startIcon": "MuiButton-startIcon", - "text": "MuiButton-text", - "textPrimary": "MuiButton-textPrimary", - "textSecondary": "MuiButton-textSecondary", - "textSizeLarge": "MuiButton-textSizeLarge", - "textSizeSmall": "MuiButton-textSizeSmall", - } - } - onClick={[MockFunction]} - > - <WithStyles(ForwardRef(ButtonBase)) - aria-label="action_modal.accessibility.button_refuse" - className="MuiButton-root MuiButton-text btnSecondary" - component="button" - disabled={false} - focusRipple={true} - focusVisibleClassName="Mui-focusVisible" - onClick={[MockFunction]} - type="button" - > - <ForwardRef(ButtonBase) - aria-label="action_modal.accessibility.button_refuse" - className="MuiButton-root MuiButton-text btnSecondary" - classes={ - Object { - "disabled": "Mui-disabled", - "focusVisible": "Mui-focusVisible", - "root": "MuiButtonBase-root", - } - } - component="button" - disabled={false} - focusRipple={true} - focusVisibleClassName="Mui-focusVisible" - onClick={[MockFunction]} - type="button" - > - <button - aria-label="action_modal.accessibility.button_refuse" - className="MuiButtonBase-root MuiButton-root MuiButton-text btnSecondary" - disabled={false} - onBlur={[Function]} - onClick={[MockFunction]} - onDragLeave={[Function]} - onFocus={[Function]} - onKeyDown={[Function]} - onKeyUp={[Function]} - onMouseDown={[Function]} - onMouseLeave={[Function]} - onMouseUp={[Function]} - onTouchEnd={[Function]} - onTouchMove={[Function]} - onTouchStart={[Function]} - tabIndex={0} - type="button" - > - <span - className="MuiButton-label" - > - action_modal.refuse - </span> - <WithStyles(memo) - center={false} - > - <ForwardRef(TouchRipple) - center={false} - classes={ - Object { - "child": "MuiTouchRipple-child", - "childLeaving": "MuiTouchRipple-childLeaving", - "childPulsate": "MuiTouchRipple-childPulsate", - "ripple": "MuiTouchRipple-ripple", - "ripplePulsate": "MuiTouchRipple-ripplePulsate", - "rippleVisible": "MuiTouchRipple-rippleVisible", - "root": "MuiTouchRipple-root", - } - } - > - <span - className="MuiTouchRipple-root" - > - <TransitionGroup - childFactory={[Function]} - component={null} - exit={true} - /> - </span> - </ForwardRef(TouchRipple)> - </WithStyles(memo)> - </button> - </ForwardRef(ButtonBase)> - </WithStyles(ForwardRef(ButtonBase))> - </ForwardRef(Button)> - </WithStyles(ForwardRef(Button))> - </div> - </div> - </div> - </ForwardRef(Paper)> - </WithStyles(ForwardRef(Paper))> - </div> - </Transition> - </ForwardRef(Fade)> - <div - data-test="sentinelEnd" - tabIndex={0} - /> - </Unstable_TrapFocus> - </div> - </Portal> - </ForwardRef(Portal)> - </ForwardRef(Modal)> - </ForwardRef(Dialog)> - </WithStyles(ForwardRef(Dialog))> - </ActionModal> -</Provider> + action_modal.refuse + </span> + <span + class="MuiTouchRipple-root" + /> + </button> + </div> + </div> + </div> + </div> + <div + data-test="sentinelEnd" + tabindex="0" + /> + </div> +</body> `; diff --git a/src/components/Action/ActionOnGoing/ActionOnGoing.spec.tsx b/src/components/Action/ActionOnGoing/ActionOnGoing.spec.tsx index de69a0814379f8b24950e6235fc664908603cf8c..899e6e3cdeb3b9216ac26e2433901bf913bc08cb 100644 --- a/src/components/Action/ActionOnGoing/ActionOnGoing.spec.tsx +++ b/src/components/Action/ActionOnGoing/ActionOnGoing.spec.tsx @@ -1,22 +1,21 @@ -import { Button } from '@material-ui/core' -import EcogestureModal from 'components/Ecogesture/EcogestureModal/EcogestureModal' +import { render, screen, waitFor } from '@testing-library/react' +import { userEvent } from '@testing-library/user-event' import { UserActionState } from 'enums' -import { mount } from 'enzyme' -import toJson from 'enzyme-to-json' import { DateTime } from 'luxon' import { UserAction } from 'models' import React from 'react' import { Provider } from 'react-redux' -import { defaultEcogestureData } from 'tests/__mocks__/actionData.mock' +import { + defaultEcogestureData, + ecogestureDefault, +} from 'tests/__mocks__/actionData.mock' import { createMockEcolyoStore } from 'tests/__mocks__/store' -import { waitForComponentToPaint } from 'tests/__mocks__/testUtils' import ActionOnGoing from './ActionOnGoing' describe('ActionOnGoing component', () => { const store = createMockEcolyoStore() const userAction: UserAction = { - // TODO if ecogesture is null snapshot test is useless - ecogesture: null, + ecogesture: ecogestureDefault, startDate: DateTime.local(2020, 1, 1) .setZone('utc', { keepLocalTime: true, @@ -25,13 +24,13 @@ describe('ActionOnGoing component', () => { state: UserActionState.ONGOING, } it('should render correctly', async () => { - const wrapper = mount( + const { container } = render( <Provider store={store}> <ActionOnGoing userAction={userAction} /> </Provider> ) - await waitForComponentToPaint(wrapper) - expect(toJson(wrapper)).toMatchSnapshot() + await waitFor(() => null, { container }) + expect(container).toMatchSnapshot() }) it('should click on button open ecogesture Modal', async () => { const userAction1: UserAction = { @@ -40,13 +39,13 @@ describe('ActionOnGoing component', () => { state: UserActionState.ONGOING, } - const wrapper = mount( + const { container } = render( <Provider store={store}> <ActionOnGoing userAction={userAction1} /> </Provider> ) - await waitForComponentToPaint(wrapper) - wrapper.find(Button).first().simulate('click') - expect(wrapper.find(EcogestureModal).exists()).toBeTruthy() + await waitFor(() => null, { container }) + await userEvent.click(await screen.findByText('action.details')) + expect(screen.findByRole('dialog')).toBeTruthy() }) }) diff --git a/src/components/Action/ActionOnGoing/__snapshots__/ActionOnGoing.spec.tsx.snap b/src/components/Action/ActionOnGoing/__snapshots__/ActionOnGoing.spec.tsx.snap index bb9fa52a80a3e3659e68e396e173ac96dc8ffde6..e86fdfe3d246cad1efe9072557c48bb824fd1461 100644 --- a/src/components/Action/ActionOnGoing/__snapshots__/ActionOnGoing.spec.tsx.snap +++ b/src/components/Action/ActionOnGoing/__snapshots__/ActionOnGoing.spec.tsx.snap @@ -1,30 +1,62 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`ActionOnGoing component should render correctly 1`] = ` -<Provider - store={ - Object { - "clearActions": [Function], - "dispatch": [Function], - "getActions": [Function], - "getState": [Function], - "replaceReducer": [Function], - "subscribe": [Function], - } - } -> - <ActionOnGoing - userAction={ - Object { - "ecogesture": null, - "startDate": "2020-01-01T00:00:00.000Z", - "state": 1, - } - } +<div> + <div + class="action-ongoing" > <div - className="action-ongoing" - /> - </ActionOnGoing> -</Provider> + class="duration text-18-normal" + > + action.duration + </div> + <div + class="description text-18-bold" + > + Je me lave les mains à l'eau froide. + </div> + <div + class="duration-image" + > + <svg + aria-hidden="true" + class="duration-icon styles__icon___23x3R" + height="230" + width="230" + > + <use + xlink:href="#test-file-stub" + /> + </svg> + <div + class="pie" + /> + </div> + <div + class="result-title text-18-bold" + > + + action.result + </div> + <div + class="result-date text-24-bold" + > + samedi 04 janvier + </div> + <button + class="MuiButtonBase-root MuiButton-root MuiButton-text btnSecondary" + tabindex="0" + type="button" + > + <span + class="MuiButton-label" + > + action.details + </span> + <span + class="MuiTouchRipple-root" + /> + </button> + </div> +</div> `;