Skip to content

Commit

Permalink
add test #2124
Browse files Browse the repository at this point in the history
  • Loading branch information
numew committed Mar 8, 2024
1 parent fd5bed2 commit afa115c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ function attachSubmitFormDemandeLienSignalementEvent() {
containerFormDemandeLienSignalement.innerHTML = json.html;
attachSubmitFormDemandeLienSignalementEvent();
})
return false;
});
return false
})
const inputAdresse = document?.querySelector('#demande_lien_signalement_adresseHelper')
const apiAdresse = 'https://api-adresse.data.gouv.fr/search/?q='
const addressGroup = fomDemandeLienSignalement.querySelector('.fr-address-group')
Expand All @@ -42,7 +42,6 @@ function attachSubmitFormDemandeLienSignalementEvent() {
data-postcode="${feature.properties.postcode}"
>${feature.properties.label}</div>`
})
//pour chaque suggestion d'adresse on attache l'evenement click
let suggestions = addressGroup.querySelectorAll('.fr-address-suggestion')
suggestions.forEach((suggestion) => {
attachAddressSuggestionEvent(suggestion)
Expand Down
1 change: 1 addition & 0 deletions src/DataFixtures/Files/Signalement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ signalements:
adresse_occupant: "3 rue Mars"
cp_occupant: "13015"
ville_occupant: "Marseille"
mail_occupant: "francis.cabrel@astaffort.com"
statut: 2
reference: "2022-1"
geoloc: "{\"lat\":\"43.3426152\",\"lng\":\"5.3711848\"}"
Expand Down
2 changes: 1 addition & 1 deletion src/DataFixtures/Loader/LoadSignalementData.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private function loadSignalements(ObjectManager $manager, array $row)
->setNbAdultes($row['nb_adultes'])
->setNbEnfantsM6($row['nb_enfants_m6'])
->setNbEnfantsP6($row['nb_enfants_p6'])
->setMailOccupant($faker->email())
->setMailOccupant($row['mail_occupant'] ?? $faker->email())
->setNumAppartOccupant($faker->randomNumber(3))
->setNatureLogement($row['nature_logement'])
->setTypeLogement($row['type_logement'] ?? null)
Expand Down
20 changes: 20 additions & 0 deletions tests/Functional/Controller/HomepageControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,24 @@ public function testSubmitContactWithEmptyMessage(): void
$client->getResponse()->getContent()
);
}

public function testSubmitDemandeLienSignalement(): void
{
$client = static::createClient();
/** @var UrlGeneratorInterface $generatorUrl */
$generatorUrl = static::getContainer()->get(UrlGeneratorInterface::class);
$client->request('GET', $generatorUrl->generate('home'));

$client->submitForm('demande_lien_signalement_save', [
'demande_lien_signalement[email]' => 'francis.cabrel@astaffort.com',
'demande_lien_signalement[adresseHelper]' => '3 rue Mars 13015 Marseille',
'demande_lien_signalement[adresse]' => '3 rue Mars',
'demande_lien_signalement[codePostal]' => '13015',
'demande_lien_signalement[ville]' => 'Marseille',
]);

$this->assertEmailCount(1);
$responseContent = json_decode($client->getResponse()->getContent(), true);
$this->assertStringContainsString('Si un signalement correspond aux informations saisies', $responseContent['html']);
}
}

0 comments on commit afa115c

Please sign in to comment.