Skip to content

Commit

Permalink
Merge pull request #1134 from betagouv/quickfix-johan
Browse files Browse the repository at this point in the history
✅ Ajoute un test e2e pour la génération de PDF demande mobilité
  • Loading branch information
johangirod authored Sep 23, 2020
2 parents 7fc7af2 + 04a50d8 commit 08034fa
Show file tree
Hide file tree
Showing 16 changed files with 156 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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(1000)
.type('{enter}')
.tab()
.type('3 rue de la Rhumerie')
.tab()
.type('Brest')
.wait(1000)
.type('{enter}')
.tab()
.type('[email protected]')
.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(1000)
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(1000)
.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()
})
})
2 changes: 1 addition & 1 deletion mon-entreprise/cypress/integration/publi.codes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Navigation', function() {
})
it('bac à sable should work', function() {
cy.contains('Bac à sable').click()
cy.wait(1000)
cy.wait(2000)
cy.contains('Dépenses primeur')
cy.contains('11,50')
})
Expand Down
1 change: 1 addition & 0 deletions mon-entreprise/cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// ***********************************************************

// Import commands.js using ES2015 syntax:
import 'cypress-plugin-tab'
import './commands'

// Alternatively you can use CommonJS syntax:
Expand Down
1 change: 1 addition & 0 deletions mon-entreprise/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 4 additions & 1 deletion mon-entreprise/source/components/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ export default function Notifications() {
const notifications = Object.values(engine.getParsedRules())
.filter(rule => rule['type'] === 'notification')
.filter(
notification => engine.evaluate(notification.dottedName).isApplicable
notification =>
![null, false].includes(
engine.evaluate(notification.dottedName).isApplicable
)
)

const inversionFail = useInversionFail()
Expand Down
3 changes: 3 additions & 0 deletions mon-entreprise/source/components/conversation/DateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand All @@ -14,6 +15,7 @@ type DateInputProps = {
export default function DateInput({
suggestions,
onChange,
id,
onSubmit,
value
}: DateInputProps) {
Expand Down Expand Up @@ -56,6 +58,7 @@ export default function DateInput({
)}
<DateStyledInput
className="ui__ input"
id={id}
type="date"
value={dateValue}
onChange={handleDateChange}
Expand Down
3 changes: 2 additions & 1 deletion mon-entreprise/source/components/conversation/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default function Input({
onChange,
onSubmit,
dottedName,
id,
value,
defaultValue,
autoFocus,
Expand All @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default function ParagrapheInput({
onChange,
dottedName,
value,
id,
defaultValue,
autoFocus
}) {
Expand All @@ -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'
Expand Down
6 changes: 5 additions & 1 deletion mon-entreprise/source/components/conversation/RuleInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -38,6 +39,7 @@ export default function RuleInput<Name extends string = DottedName>({
onChange,
value,
useSwitch = false,
id,
isTarget = false,
autoFocus = false,
className,
Expand All @@ -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,
Expand All @@ -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')
Expand All @@ -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}
Expand Down
3 changes: 2 additions & 1 deletion mon-entreprise/source/components/conversation/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default function TextInput({
onChange,
dottedName,
value,
id,
defaultValue,
autoFocus
}) {
Expand All @@ -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}'`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}'`)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function FormulairePublicodes({ engine }) {
</>
) : (
<>
<label htmlFor={`step-${field.dottedName}`}>
<label htmlFor={field.dottedName}>
{field.question ? (
<span
css={`
Expand All @@ -157,6 +157,7 @@ function FormulairePublicodes({ engine }) {
</Explicable>
)}
<RuleInput
id={field.dottedName}
dottedName={field.dottedName}
rules={engine.getParsedRules()}
value={situation[field.dottedName]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
5 changes: 4 additions & 1 deletion mon-entreprise/test/regressions/simulations.jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ const runSimulations = (situations, targets, baseSituation = {}) =>
const evaluatedNotifications = Object.values(engine.getParsedRules())
.filter(rule => rule['type'] === 'notification')
.filter(
notification => engine.evaluate(notification.dottedName).isApplicable
notification =>
![null, false].includes(
engine.evaluate(notification.dottedName).isApplicable
)
)
.map(notification => notification.dottedName)

Expand Down
25 changes: 25 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -3881,6 +3889,11 @@ [email protected]:
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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -9189,6 +9209,11 @@ pkg-dir@^4.1.0:
dependencies:
find-up "^4.0.0"

[email protected]:
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"
Expand Down

0 comments on commit 08034fa

Please sign in to comment.