ajoute un test e2e pour la génération de PDF de demande de mobilité

pull/1134/head
Johan Girod 2020-09-23 15:55:13 +02:00
parent 7fc7af2029
commit 05808479fc
13 changed files with 147 additions and 8 deletions

View File

@ -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 lexactitude 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()
})
})

View File

@ -14,6 +14,7 @@
// ***********************************************************
// Import commands.js using ES2015 syntax:
import 'cypress-plugin-tab'
import './commands'
// Alternatively you can use CommonJS syntax:

View File

@ -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",

View File

@ -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({
)}
<DateStyledInput
className="ui__ input"
id={id}
type="date"
value={dateValue}
onChange={handleDateChange}

View File

@ -11,6 +11,7 @@ export default function Input({
onChange,
onSubmit,
dottedName,
id,
value,
defaultValue,
autoFocus,
@ -34,7 +35,7 @@ export default function Input({
<NumberFormat
autoFocus={autoFocus}
className="suffixed ui__"
id={'step-' + dottedName}
id={id}
placeholder={defaultValue?.nodeValue ?? defaultValue}
thousandSeparator={thousandSeparator}
decimalSeparator={decimalSeparator}

View File

@ -5,6 +5,7 @@ export default function ParagrapheInput({
onChange,
dottedName,
value,
id,
defaultValue,
autoFocus
}) {
@ -17,7 +18,7 @@ export default function ParagrapheInput({
className="ui__"
rows={6}
style={{ resize: 'none' }}
id={'step-' + dottedName}
id={id}
placeholder={(defaultValue?.nodeValue ?? defaultValue)?.replace(
'\\n',
'\n'

View File

@ -23,6 +23,7 @@ export type RuleInputProps<Name extends string = DottedName> = {
useSwitch?: boolean
isTarget?: boolean
autoFocus?: boolean
id?: string
value?: Value
className?: string
onSubmit?: (source: string) => void
@ -38,6 +39,7 @@ export default function RuleInput<Name extends string = DottedName>({
onChange,
value,
useSwitch = false,
id,
isTarget = false,
autoFocus = false,
className,
@ -55,6 +57,7 @@ export default function RuleInput<Name extends string = DottedName>({
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<Name extends string = DottedName>({
if (rule.API && rule.API === 'commune')
return <SelectCommune {...commonProps} />
if (rule.API && rule.API === 'pays européen')
return <SelectEuropeCountry {...commonProps} onSubmit={onSubmit} />
return <SelectEuropeCountry {...commonProps} />
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<Name extends string = DottedName>({
if (rule.type === 'date') {
return (
<DateInput
{...commonProps}
value={commonProps.value}
onChange={commonProps.onChange}
onSubmit={onSubmit}

View File

@ -6,6 +6,7 @@ export default function TextInput({
onChange,
dottedName,
value,
id,
defaultValue,
autoFocus
}) {
@ -17,7 +18,7 @@ export default function TextInput({
autoFocus={autoFocus}
className="ui__"
type="text"
id={'step-' + dottedName}
id={id}
placeholder={defaultValue?.nodeValue ?? defaultValue}
onChange={({ target }) => {
debouncedOnChange(`'${target.value}'`)

View File

@ -46,7 +46,7 @@ async function searchCommunes(input: string): Promise<Array<Commune> | 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 | Array<Commune>>(
null
@ -150,6 +150,7 @@ export default function Select({ onChange, value }) {
<input
role="combobox"
type="search"
id={id}
aria-autocomplete="list"
onBlur={submitFocusedElem}
aria-readonly="true"

View File

@ -33,11 +33,12 @@ const STATES = [
'Suisse'
] as const
export default function SelectEuropeCountry({ value, onChange, onSubmit }) {
export default function SelectEuropeCountry({ value, onChange, id }) {
return (
<div>
<select
name="country"
id={id}
className="ui__"
defaultValue={value?.slice(1, -1)}
onChange={e => onChange(`'${e.target.value}'`)}

View File

@ -137,7 +137,7 @@ function FormulairePublicodes({ engine }) {
</>
) : (
<>
<label htmlFor={`step-${field.dottedName}`}>
<label htmlFor={field.dottedName}>
{field.question ? (
<span
css={`
@ -157,6 +157,7 @@ function FormulairePublicodes({ engine }) {
</Explicable>
)}
<RuleInput
id={field.dottedName}
dottedName={field.dottedName}
rules={engine.getParsedRules()}
value={situation[field.dottedName]}

View File

@ -81,7 +81,7 @@ function SimpleField({ dottedName }: SimpleFieldProps) {
<Animate.appear unless={initialRender}>
<div className="main">
<div className="header">
<label htmlFor={`step-${dottedName}`}>
<label htmlFor={dottedName}>
<span className="optionTitle">{rule.question || rule.titre}</span>
<p className="ui__ notice">{rule.résumé}</p>
</label>

View File

@ -2026,6 +2026,14 @@ ajv@^6.1.0, ajv@^6.10.0, ajv@^6.10.2, ajv@^6.12.2, ajv@^6.12.3:
json-schema-traverse "^0.4.1"
uri-js "^4.2.2"
ally.js@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/ally.js/-/ally.js-1.4.1.tgz#9fb7e6ba58efac4ee9131cb29aa9ee3b540bcf1e"
integrity sha1-n7fmuljvrE7pExyymqnuO1QLzx4=
dependencies:
css.escape "^1.5.0"
platform "1.3.3"
alphanum-sort@^1.0.1, alphanum-sort@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/alphanum-sort/-/alphanum-sort-1.0.2.tgz#97a1119649b211ad33691d9f9f486a8ec9fbe0a3"
@ -3881,6 +3889,11 @@ css-what@2.1:
resolved "https://registry.yarnpkg.com/css-what/-/css-what-2.1.3.tgz#a6d7604573365fe74686c3f311c56513d88285f2"
integrity sha512-a+EPoD+uZiNfh+5fxw2nO9QwFa6nJe2Or35fGY6Ipw1R3R4AGz1d1TEZrCegvw2YTmZ0jXirGYlzxxpYSHwpEg==
css.escape@^1.5.0:
version "1.5.1"
resolved "https://registry.yarnpkg.com/css.escape/-/css.escape-1.5.1.tgz#42e27d4fa04ae32f931a4b4d4191fa9cddee97cb"
integrity sha1-QuJ9T6BK4y+TGktNQZH6nN3ul8s=
cssesc@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-3.0.0.tgz#37741919903b868565e1c09ea747445cd18983ee"
@ -3962,6 +3975,13 @@ cyclist@^1.0.1:
resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9"
integrity sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk=
cypress-plugin-tab@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/cypress-plugin-tab/-/cypress-plugin-tab-1.0.5.tgz#a40714148104004bb05ed62b1bf46bb544f8eb4a"
integrity sha512-QtTJcifOVwwbeMP3hsOzQOKf3EqKsLyjtg9ZAGlYDntrCRXrsQhe4ZQGIthRMRLKpnP6/tTk6G0gJ2sZUfRliQ==
dependencies:
ally.js "^1.4.1"
cypress@^3.6.1:
version "3.8.3"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-3.8.3.tgz#e921f5482f1cbe5814891c878f26e704bbffd8f4"
@ -9189,6 +9209,11 @@ pkg-dir@^4.1.0:
dependencies:
find-up "^4.0.0"
platform@1.3.3:
version "1.3.3"
resolved "https://registry.yarnpkg.com/platform/-/platform-1.3.3.tgz#646c77011899870b6a0903e75e997e8e51da7461"
integrity sha1-ZGx3ARiZhwtqCQPnXpl+jlHadGE=
pn@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb"