Skip to content

Commit

Permalink
ajout de tests fonctionnels sur l'import de fichier
Browse files Browse the repository at this point in the history
dans le cadre de l'issue afup#1428 on ajoute un cas de test sur l'import
de fichier.
  • Loading branch information
agallou committed Feb 25, 2024
1 parent 55e3db0 commit 301c015
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 0 deletions.
5 changes: 5 additions & 0 deletions db/seeds/ComptaCategorie.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,11 @@ public function run()
'idevenement'=>0,
'categorie'=>'Seminaire',
],
[
'id'=>48,
'idevenement'=>0,
'categorie'=>'Outils',
],
];

$table = $this->table('compta_categorie');
Expand Down
36 changes: 36 additions & 0 deletions tests/behat/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,29 @@ public function selectHasForCurrentSelectedValue($field, $expectedValue)
}
}

/**
* @Then The :field field should has the following selected text :expectedValue
*/
public function selectHasForCurrentSelectedText($field, $expectedValue)
{
$node = $this->minkContext->assertSession()->fieldExists($field);
$options = $node->findAll('css', 'option');

$selectedValue = null;
foreach ($options as $option) {
if ($option->isSelected()) {
$selectedValue = $option->getText();
break;
}
}

if ($selectedValue != $expectedValue) {
throw new \Exception(
sprintf('The select has the following text "%s" (expected "%s")', $selectedValue, $expectedValue)
);
}
}


/**
* @Then the response header :arg1 should equal :arg2
Expand All @@ -205,6 +228,19 @@ public function assertResponseHeaderMatch($headerName, $regExpExpectedValue)
$this->minkContext->assertSession()->responseHeaderMatches($headerName, $regExpExpectedValue);
}

/**
* @Then the current URL should match :arg1
*/
public function assertCurrentUrlContains($regex)
{
$currentUrl = $this->minkContext->getSession()->getCurrentUrl();

if (!preg_match($regex, $currentUrl)) {
throw new \Exception(sprintf('The current URL "%s" does not matches "%s"', $currentUrl, $regex));
}

}

/**
* @When I follow the button of tooltip :arg1
*/
Expand Down
43 changes: 43 additions & 0 deletions tests/behat/features/Admin/Tresorerie/JournalImport.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
Feature: Administration - Trésorerie - Journal import

@reloadDbWithTestData
Scenario: Test d'import du fichier
Given I am logged in as admin and on the Administration
When I follow "Journal"
Then the ".content h2" element should contain "Journal"
# On vérifie qu'on a aucune entrée pour la période
When I select "2019-01-01 - 2019-12-31" from "id_periode"
And I submit the form with name "forum"
Then the current URL should match "/id_periode=13/"
When I check "also_display_classifed_entries"
And I press "Filtrer"
Then the current URL should match "/id_periode=13/"
And the current URL should match "/also_display_classifed_entries=on/"
And I should see " Aucune ecriture"
# On importe le fichier sur le crédit mutuel
When I follow "Importer un fichier CSV"
Then I should see "Import CSV"
When I select "CMUT" from "banque"
And I attach the file "test_credit_mutuel.csv" to "fichiercsv"
And I press "Soumettre"
Then I should see "Le fichier a été importé"
# On vérifie que l'import s'est bien passé
When I select "2019-01-01 - 2019-12-31" from "id_periode"
And I submit the form with name "forum"
Then the current URL should match "/id_periode=13/"
When I check "also_display_classifed_entries"
And I press "Filtrer"
Then the current URL should match "/id_periode=13/"
And the current URL should match "/also_display_classifed_entries=on/"
And I should not see " Aucune ecriture"
# Test meetup
When I follow the button of tooltip "Modifier la ligne CB MEETUP ORG SUB FACT 190323 DONT FRAIS DE COMM. 1,89 EUR"
Then I should see "Modifier une écriture"
Then The "idevenement" field should has the following selected text "Association AFUP"
Then The "idcategorie" field should has the following selected text "Meetup"
# Test Twilio
When I move backward one page
When I follow the button of tooltip "Modifier la ligne CB Twilio SZ5KZ54M FACT 090223 DONT FRAIS DE COMM. 0,26 EUR"
Then I should see "Modifier une écriture"
Then The "idevenement" field should has the following selected text "Association AFUP"
Then The "idcategorie" field should has the following selected text "Outils"
3 changes: 3 additions & 0 deletions tests/behat/files/test_credit_mutuel.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Date;Date de valeur;Débit;Crédit;Libellé;Solde
31/01/2019;02/02/2019;-69,73;;CB MEETUP ORG SUB FACT 190323 DONT FRAIS DE COMM. 1,89 EUR ;23147,48
31/01/2019;02/02/2019;-9,88;;CB Twilio SZ5KZ54M FACT 090223 DONT FRAIS DE COMM. 0,26 EUR ;23136,32

0 comments on commit 301c015

Please sign in to comment.