From 990210e5bca30977b11b17900de7ea5bb76cf275 Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Mon, 31 Aug 2020 09:48:12 +0200 Subject: [PATCH] =?UTF-8?q?:green=5Fheart:=20r=C3=A9pare=20les=20tests=20E?= =?UTF-8?q?2E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../integration/mon-entreprise/simulateurs.js | 28 +++++++++---------- .../conversation/select/SelectCommune.tsx | 8 +++--- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/mon-entreprise/cypress/integration/mon-entreprise/simulateurs.js b/mon-entreprise/cypress/integration/mon-entreprise/simulateurs.js index c2270254f..839192e19 100644 --- a/mon-entreprise/cypress/integration/mon-entreprise/simulateurs.js +++ b/mon-entreprise/cypress/integration/mon-entreprise/simulateurs.js @@ -107,7 +107,19 @@ describe('Simulateur salarié', () => { } before(() => cy.visit('/simulateurs/salarié')) - it.skip('should save the current simulation', function() { + it('should ask for CDD motif directly after CDD is selected', function() { + cy.get(inputSelector) + .eq(1) + .type('{selectall}3000') + cy.wait(1000) + cy.get('.step') + .find('input[value="\'CDD\'"]') + .click({ force: true }) + cy.contains('Suivant').click() + cy.contains('Motifs classiques') + }) + + it('should save the current simulation', function() { cy.get(inputSelector) .first() .type('{selectall}2137') @@ -123,23 +135,11 @@ describe('Simulateur salarié', () => { .should('match', /2[\s]137/) }) - it('should ask for CDD motif directly after CDD is selected', function() { - cy.get(inputSelector) - .eq(1) - .type('{selectall}3000') - cy.wait(1000) - cy.get('.step') - .find('input[value="\'CDD\'"]') - .click({ force: true }) - cy.contains('Suivant').click() - cy.contains('Motifs classiques') - }) - it('should not crash when selecting localisation', function() { cy.contains('Commune').click() cy.get('fieldset input[type="search"]').type('Steenvoorde') cy.contains('Steenvoorde (59114)').click() - cy.wait(900) + cy.contains('Suivant').click() cy.contains('Voir ma situation').click() cy.contains('Steenvoorde (59114)') }) diff --git a/mon-entreprise/source/components/conversation/select/SelectCommune.tsx b/mon-entreprise/source/components/conversation/select/SelectCommune.tsx index 0ee32fe56..1220e5803 100644 --- a/mon-entreprise/source/components/conversation/select/SelectCommune.tsx +++ b/mon-entreprise/source/components/conversation/select/SelectCommune.tsx @@ -97,10 +97,10 @@ export default function Select({ onChange, value }) { const [focusedElem, setFocusedElem] = useState(0) const submitFocusedElem = useCallback(() => { - if (noResult) { + if (noResult || searchResults == null) { return } - handleSubmit((searchResults as Array)[focusedElem]) + handleSubmit(searchResults[focusedElem]) }, [searchResults, focusedElem, noResult, handleSubmit]) const handleChange = useCallback( @@ -122,12 +122,12 @@ export default function Select({ onChange, value }) { switch (e.key) { case 'ArrowDown': case 'ArrowUp': - if (noResult) { + if (noResult || searchResults == null) { return } setFocusedElem( (focusedElem + (e.key === 'ArrowDown' ? 1 : -1)) % - (searchResults as Array).length + searchResults.length ) e.preventDefault() break