From 05808479fc4c6d3cde82727e009019ca0a65a3c0 Mon Sep 17 00:00:00 2001 From: Johan Girod Date: Wed, 23 Sep 2020 15:55:13 +0200 Subject: [PATCH 1/2] =?UTF-8?q?:white=5Fcheck=5Fmark:=20ajoute=20un=20test?= =?UTF-8?q?=20e2e=20pour=20la=20g=C3=A9n=C3=A9ration=20de=20PDF=20de=20dem?= =?UTF-8?q?ande=20de=20mobilit=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../demande-mobilit\303\251.js" | 99 +++++++++++++++++++ mon-entreprise/cypress/support/index.js | 1 + mon-entreprise/package.json | 1 + .../components/conversation/DateInput.tsx | 3 + .../source/components/conversation/Input.tsx | 3 +- .../conversation/ParagrapheInput.tsx | 3 +- .../components/conversation/RuleInput.tsx | 6 +- .../components/conversation/TextInput.tsx | 3 +- .../conversation/select/SelectCommune.tsx | 3 +- .../select/SelectEuropeCountry.tsx | 3 +- .../G\303\251rer/DemandeMobilite/index.tsx" | 3 +- .../pages/Simulateurs/ArtisteAuteur.tsx | 2 +- yarn.lock | 25 +++++ 13 files changed, 147 insertions(+), 8 deletions(-) create mode 100644 "mon-entreprise/cypress/integration/mon-entreprise/demande-mobilit\303\251.js" diff --git "a/mon-entreprise/cypress/integration/mon-entreprise/demande-mobilit\303\251.js" "b/mon-entreprise/cypress/integration/mon-entreprise/demande-mobilit\303\251.js" new file mode 100644 index 0000000000..56265e4d20 --- /dev/null +++ "b/mon-entreprise/cypress/integration/mon-entreprise/demande-mobilit\303\251.js" @@ -0,0 +1,99 @@ +const fr = Cypress.env('language') === 'fr' + +describe('Formulaire demande mobilité', function() { + if (!fr) { + return + } + before(() => cy.visit('/gérer/demande-mobilité')) + it('should not crash', () => { + cy.contains('Demande de mobilité en Europe') + }) + it('should allow to complete "coordonnées" section', () => { + cy.contains('SIRET').click() + cy.focused() + .type('684 064 0011') + .tab() + .type('Deaux') + .tab() + .type('Jean') + .tab() + .type('Française') + cy.contains('sécurité sociale').click() + cy.focused() + .type('1 91 07 468 054 75') + .tab() + .type('1991-07-25') + .tab() + .type('Pouts') + .wait(500) + .type('{enter}') + .tab() + .type('3 rue de la Rhumerie') + .tab() + .type('Brest') + .wait(500) + .type('{enter}') + .tab() + .type('jean.deaux@gmail.com') + .tab() + .type('06 85 69 78 54') + .tab() + }) + it('should allow to complete "activité en France" section', () => { + cy.focused() + .type('Deaux & Fils') + .tab() + .type('14 chemin des Docks') + .tab() + .type('Bre') + .wait(500) + cy.contains('29240').click() + cy.contains('Organisme Urssaf').click() + cy.focused() + .type('Bretagne') + .tab() + .tab() + .type('Boulangerie') + }) + it('should allow to complete "votre demande" section', () => { + cy.contains('Oui').click() + cy.get("input[name='demande . infrastructure sauvegardée'][value='oui']") + .next() + .click() + cy.get("input[name='demande . activité semblable'][value='oui']") + .next() + .click() + cy.get("input[name='demande . date de fin connue'][value='oui']") + .next() + .click() + cy.get('label[for="détachement . pays"]') + .wait(500) + .click() + cy.focused() + .select('Irlande') + .tab() + .type('2020-11-06') + .tab() + .type('2021-04-09') + .tab() + .tab() + .type('Fabrications de gateaux bretons') + cy.get("input[name='détachement . base fixe'][value='non']") + .next() + .click() + cy.get( + "input[name='commentaires additionnels . commentaires'][value='non']" + ) + .next() + .click() + }) + it('should allow to download PDF', () => { + cy.contains( + 'Je certifie l’exactitude des informations communiquées ci-dessus' + ).click() + cy.contains('Fait à').click() + cy.focused().type('Plougastel') + cy.contains('Générer la demande').click() + cy.contains('Télécharger le fichier').click() + }) +}) diff --git a/mon-entreprise/cypress/support/index.js b/mon-entreprise/cypress/support/index.js index d68db96df2..46a58b9e49 100644 --- a/mon-entreprise/cypress/support/index.js +++ b/mon-entreprise/cypress/support/index.js @@ -14,6 +14,7 @@ // *********************************************************** // Import commands.js using ES2015 syntax: +import 'cypress-plugin-tab' import './commands' // Alternatively you can use CommonJS syntax: diff --git a/mon-entreprise/package.json b/mon-entreprise/package.json index 058efff446..1bcbd725d9 100644 --- a/mon-entreprise/package.json +++ b/mon-entreprise/package.json @@ -40,6 +40,7 @@ "autoprefixer": "^9.7.6", "babel-plugin-styled-components": "^1.10.7", "copy-webpack-plugin": "^4.5.2", + "cypress-plugin-tab": "^1.0.5", "enzyme-adapter-react-16": "^1.1.1", "eslint-plugin-react": "^7.12.4", "html-webpack-plugin": "^3.2.0", diff --git a/mon-entreprise/source/components/conversation/DateInput.tsx b/mon-entreprise/source/components/conversation/DateInput.tsx index 0ee20b6f26..8db6426af4 100644 --- a/mon-entreprise/source/components/conversation/DateInput.tsx +++ b/mon-entreprise/source/components/conversation/DateInput.tsx @@ -6,6 +6,7 @@ import InputSuggestions from './InputSuggestions' type DateInputProps = { onChange: RuleInputProps['onChange'] + id: RuleInputProps['id'] onSubmit: RuleInputProps['onSubmit'] value: RuleInputProps['value'] suggestions: Rule['suggestions'] @@ -14,6 +15,7 @@ type DateInputProps = { export default function DateInput({ suggestions, onChange, + id, onSubmit, value }: DateInputProps) { @@ -56,6 +58,7 @@ export default function DateInput({ )} = { useSwitch?: boolean isTarget?: boolean autoFocus?: boolean + id?: string value?: Value className?: string onSubmit?: (source: string) => void @@ -38,6 +39,7 @@ export default function RuleInput({ onChange, value, useSwitch = false, + id, isTarget = false, autoFocus = false, className, @@ -55,6 +57,7 @@ export default function RuleInput({ autoFocus, className, title: rule.title, + id: id ?? dottedName, question: rule.question, defaultValue: rule.defaultValue, suggestions: rule.suggestions, @@ -72,7 +75,7 @@ export default function RuleInput({ if (rule.API && rule.API === 'commune') return if (rule.API && rule.API === 'pays européen') - return + return if (rule.API) throw new Error("Les seules API implémentées sont 'commune'") if (rule.dottedName == 'contrat salarié . ATMP . taux collectif ATMP') @@ -81,6 +84,7 @@ export default function RuleInput({ if (rule.type === 'date') { return ( { debouncedOnChange(`'${target.value}'`) diff --git a/mon-entreprise/source/components/conversation/select/SelectCommune.tsx b/mon-entreprise/source/components/conversation/select/SelectCommune.tsx index 1220e5803f..db09d27eeb 100644 --- a/mon-entreprise/source/components/conversation/select/SelectCommune.tsx +++ b/mon-entreprise/source/components/conversation/select/SelectCommune.tsx @@ -46,7 +46,7 @@ async function searchCommunes(input: string): Promise | null> { .slice(0, 10) } -export default function Select({ onChange, value }) { +export default function Select({ onChange, value, id }) { const [name, setName] = useState(formatCommune(value)) const [searchResults, setSearchResults] = useState>( null @@ -150,6 +150,7 @@ export default function Select({ onChange, value }) {