💚 corrige les tests E2E

pull/1284/head
Johan Girod 2020-12-08 16:37:40 +01:00
parent 31d4157d79
commit bad6b9503a
4 changed files with 39 additions and 29 deletions

View File

@ -19,14 +19,24 @@ describe('Formulaire demande mobilité', function () {
.tab()
.type('Française')
cy.contains('sécurité sociale').click()
cy.focused().type('1 91 07 468 054 75').tab().type('1991-07-25')
cy.get(
"input[name='coordonnées assuré . commune de naissance . étranger'][value='non']"
)
.next()
.click()
.wait(500)
cy.focused().tab().type('Pouts').wait(1500).type('{enter}')
cy.get(
"input[name='coordonnées assuré . domicile personnel . commune . étranger'][value='non']"
)
.next()
.click()
cy.focused()
.type('1 91 07 468 054 75')
.tab()
.type('1991-07-25')
.tab()
.type('Pouts')
.wait(1500)
.type('{enter}')
.tab()
.type('3 rue de la Rhumerie')
.tab()
@ -52,7 +62,7 @@ describe('Formulaire demande mobilité', function () {
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 . pays unique'][value='oui']").next().click()
cy.get("input[name='demande . infrastructure sauvegardée'][value='oui']")
.next()
.click()

View File

@ -56,7 +56,7 @@ async function searchCommunes(input: string): Promise<Array<Commune> | null> {
.flatMap(({ codesPostaux, ...commune }) =>
codesPostaux
.sort()
.map(codePostal => ({ ...commune, codePostal }))
.map((codePostal) => ({ ...commune, codePostal }))
.filter(({ codePostal }) => codePostal.startsWith(number))
)
.slice(0, 10)
@ -66,7 +66,7 @@ export default function Select({
onChange,
value,
id,
missing
missing,
}: InputCommonProps) {
const [name, setName] = useState(missing ? '' : formatCommune(value))
const [searchResults, setSearchResults] = useState<null | Array<Commune>>(
@ -76,8 +76,8 @@ export default function Select({
const [isLoading, setLoadingState] = useState(false)
const handleSearch = useCallback(
function(value) {
searchCommunes(value).then(results => {
function (value) {
searchCommunes(value).then((results) => {
setLoadingState(false)
setSearchResults(results)
})
@ -85,7 +85,7 @@ export default function Select({
[setSearchResults, setLoadingState]
)
const debouncedHandleSearch = useMemo(() => debounce(300, handleSearch), [
handleSearch
handleSearch,
])
const handleSubmit = useCallback(
@ -108,10 +108,10 @@ export default function Select({
...commune,
...(taux != null
? {
'taux du versement transport': taux
'taux du versement transport': taux,
}
: {})
}
: {}),
},
})
},
[setSearchResults, setName]
@ -214,7 +214,7 @@ export default function Select({
<Option
onMouseDown={
// Prevent input blur and focus elem selection
e => e.preventDefault()
(e) => e.preventDefault()
}
onClick={() => handleSubmit(result)}
role="option"
@ -252,7 +252,7 @@ const Option = styled.li<{ focused: boolean }>`
margin-bottom: 0.3rem;
font-size: 100%;
padding: 0.6rem;
${props =>
${(props) =>
props.focused &&
css`
background-color: var(--lighterColor) !important;

View File

@ -32,13 +32,13 @@ const STATES = [
'Slovénie',
'Suède',
'Suisse',
'Autre'
'Autre',
] as const
export default function SelectEuropeCountry({
value,
onChange,
id
id,
}: InputCommonProps) {
return (
<div>
@ -47,10 +47,10 @@ export default function SelectEuropeCountry({
id={id}
className="ui__"
defaultValue={value?.slice(1, -1)}
onChange={e => onChange(`'${e.target.value}'`)}
onChange={(e) => onChange(`'${e.target.value}'`)}
>
<option disabled selected hidden></option>
{STATES.map(state => (
{STATES.map((state) => (
<option key={state} value={state}>
{state}
</option>

View File

@ -13,7 +13,7 @@ import {
Suspense,
useCallback,
useState,
useContext
useContext,
} from 'react'
import emoji from 'react-easy-emoji'
import { hash } from '../../../../../utils'
@ -94,9 +94,9 @@ const useFields = (
situation: Record<string, unknown>
): Array<EvaluatedRule> => {
const fields = fieldNames
.map(name => evaluateRule(engine, name))
.map((name) => evaluateRule(engine, name))
.filter(
node =>
(node) =>
// TODO change this when not applicable value can be differenciated from false value
(equals(node.missingVariables, { [node.dottedName]: 1 }) ||
node.dottedName in situation ||
@ -115,9 +115,9 @@ function FormulairePublicodes() {
)
const onChange = useCallback(
(dottedName, value) => {
setSituation(situation => ({
setSituation((situation) => ({
...situation,
[dottedName]: value
[dottedName]: value,
}))
},
[setSituation]
@ -140,7 +140,7 @@ function FormulairePublicodes() {
const isMissingValues = !!missingValues.length
return (
<Animate.fromTop key={clearFieldsKey}>
{fields.map(field => (
{fields.map((field) => (
<Animate.fromTop key={field.dottedName}>
{field.type === 'groupe' ? (
<>
@ -183,7 +183,7 @@ function FormulairePublicodes() {
<RuleInput
id={field.dottedName}
dottedName={field.dottedName}
onChange={value => onChange(field.dottedName, value)}
onChange={(value) => onChange(field.dottedName, value)}
/>
</>
)}