From fe374e4e5a2a04f1bae156d0cc518144fe1a43fb Mon Sep 17 00:00:00 2001 From: Nicolas PHILIPPE Date: Thu, 7 May 2020 19:53:30 +0200 Subject: [PATCH] behat: activate js tests (#391) --- behat.yml.dist | 1 + composer.json | 2 +- composer.lock | 16 ++-- features/organization/assets.feature | 29 +++--- features/organization/forecast.feature | 4 +- features/organization/mission_type.feature | 103 ++++++++++----------- features/organization/users.feature | 32 +++---- 7 files changed, 94 insertions(+), 93 deletions(-) diff --git a/behat.yml.dist b/behat.yml.dist index 327e0f9a..faa7439c 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -11,6 +11,7 @@ default: - App\Tests\Behat\UserPlanningContext - Behat\MinkExtension\Context\MinkContext - PantherExtension\Context\PantherContext + - PantherExtension\Context\WaitContext: extensions: PantherExtension\Extension\PantherExtension: ~ Behat\MinkExtension: diff --git a/composer.json b/composer.json index 2f33af5f..8cb53be7 100644 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ "friends-of-behat/mink-extension": "^2.4", "friends-of-behat/symfony-extension": "^2.1", "friendsofphp/php-cs-fixer": "^2.16", - "guikingone/panther-extension": "^0.3.1", + "guikingone/panther-extension": "^0.4.0", "hautelook/alice-bundle": "^2.7", "mheap/phpunit-github-actions-printer": "^1.2", "phpstan/phpstan-doctrine": "^0.12.8", diff --git a/composer.lock b/composer.lock index ef1e5ddb..1e66f743 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2fbc248970a6d0fbc48057b4dbdbda27", + "content-hash": "8b3bcfa39b72b3daa37852dba4dc26eb", "packages": [ { "name": "beberlei/assert", @@ -7870,16 +7870,16 @@ }, { "name": "guikingone/panther-extension", - "version": "0.3.1", + "version": "0.4.1", "source": { "type": "git", "url": "https://github.com/Guikingone/panther-extension.git", - "reference": "4551f965fa80e04333e1be4d08a9b62c4f322889" + "reference": "849fd2c87ed7ecd760c99784cf83984f376058dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Guikingone/panther-extension/zipball/4551f965fa80e04333e1be4d08a9b62c4f322889", - "reference": "4551f965fa80e04333e1be4d08a9b62c4f322889", + "url": "https://api.github.com/repos/Guikingone/panther-extension/zipball/849fd2c87ed7ecd760c99784cf83984f376058dc", + "reference": "849fd2c87ed7ecd760c99784cf83984f376058dc", "shasum": "" }, "require": { @@ -7888,12 +7888,13 @@ "behat/mink-extension": "^2.0", "ext-zip": "*", "php": ">=7.1", - "symfony/config": "^2.7|^3.0|^4.0|^5.0", + "symfony/config": "^3.0|^4.0|^5.0", "symfony/panther": "^0.7.1" }, "require-dev": { "friendsofphp/php-cs-fixer": "^2.16", "infection/infection": "^0.13.6", + "phpstan/phpstan": "^0.12.23", "phpunit/phpunit": "^7.5" }, "type": "library", @@ -7904,6 +7905,7 @@ "PantherExtension\\Driver\\": "src/Driver/", "PantherExtension\\Driver\\Element\\": "src/Driver/Element/", "PantherExtension\\Driver\\Exception\\": "src/Driver/Exception/", + "PantherExtension\\Driver\\Helper\\": "src/Driver/Helper/", "PantherExtension\\Extension\\": "src/Extension/" } }, @@ -7926,7 +7928,7 @@ "extension", "web" ], - "time": "2020-05-01T18:49:53+00:00" + "time": "2020-05-06T19:31:23+00:00" }, { "name": "hautelook/alice-bundle", diff --git a/features/organization/assets.feature b/features/organization/assets.feature index b93bf85b..6f9c7783 100644 --- a/features/organization/assets.feature +++ b/features/organization/assets.feature @@ -40,7 +40,6 @@ Feature: When I go to "/organizations/202/assets" Then the response status code should be 403 - # todo: add some properties in asset_type fixtures Scenario Outline: As an authenticated parent organization, I can add an asset on my organization or children organizations Given I am authenticated as "" When I go to "/organizations/203/assets" @@ -84,7 +83,7 @@ Feature: And the "commissionable_asset_name" field should contain "new name" Examples: | login | -# todo: there is a bug when using parent organization +# todo: there is a bug when using parent organization: https://github.com/crf-devs/resop/issues/360 # | DT75 | | UL 01-02 | @@ -110,19 +109,19 @@ Feature: And I press "Je me connecte" Then I should be on "/organizations/" -# @javascript -# Scenario: As a parent organization, I can delete an asset from my organization or children organizations -# Given I am authenticated as "DT75" -# And I go to "/organizations/203/assets" -# Then I should be on "/organizations/203/assets/" -# And I should see "75012" -# When I follow "Supprimer" -# And I wait for the element "#modal-delete-asset" to load -# Then I should see "Vous êtes sur le point de supprimer le véhicule VPSP - 75012" -# When I press "Supprimer" -# Then I should be on "/organizations/203/assets/" -# And I should see "Le véhicule a été supprimé avec succès." -# And I should not see "75012" + @javascript + Scenario: As a parent organization, I can delete an asset from my organization or children organizations + Given I am authenticated as "DT75" + And I go to "/organizations/203/assets" + Then I should be on "/organizations/203/assets/" + And I should see "75012" + When I follow "Supprimer" + And I wait for "#delete-item-modal" to be visible + Then I should see "Vous êtes sur le point de supprimer le véhicule suivant et toutes ses disponibilités : VPSP - 75012" + When I press "Supprimer" + Then I should be on "/organizations/203/assets/" + And I should see "Le véhicule a été supprimé avec succès." + And I should not see "75012" #https://github.com/crf-devs/resop/issues/348 # Scenario: As a parent organization, I cannot directly delete an asset from my organization diff --git a/features/organization/forecast.feature b/features/organization/forecast.feature index 17e9a5dc..3eedf521 100644 --- a/features/organization/forecast.feature +++ b/features/organization/forecast.feature @@ -27,11 +27,11 @@ Feature: Given I am authenticated as "DT75" And I am on "/organizations/forecast" When I click on "#availableRange" - Then the ".daterangepicker" should be visible + Then I wait for ".daterangepicker" to be visible When I click on ".daterangepicker .left table tbody td[data-title=r1c0]" And I click on ".daterangepicker .left table tbody td[data-title=r1c6]" And I press "Valider" - Then the ".daterangepicker" should not be visible + Then I wait for ".daterangepicker" to be invisible When I press "Calculer" Then I should be on "/organizations/forecast" And I should not see "Choisissez une plage horaire pour calculer les équipages possibles." diff --git a/features/organization/mission_type.feature b/features/organization/mission_type.feature index 88425d23..646e4b95 100644 --- a/features/organization/mission_type.feature +++ b/features/organization/mission_type.feature @@ -19,31 +19,31 @@ Feature: And I should not see "Mission type DT77 1" And I should not see "Mission type DT77 2" -# @javascript -# Scenario: As an organization, I can create a mission type -# Given I am authenticated as "DT75" -# And I am on "/organizations/mission_type/" -# When I follow "Ajouter un nouveau type de mission" -# Then I should be on "/organizations/mission_type/new" -# When I press "Ajouter un type de bénévole" -# And I press "Ajouter un type de véhicule" -# And I fill in the following: -# | mission_type[name] | mission type name | -# | mission_type[minimumAvailableHours] | 2 | -# | mission_type[userSkillsRequirement][0][skill] | ci_bspp | -# | mission_type[userSkillsRequirement][0][number] | 3 | -# | mission_type[assetTypesRequirement][0][type] | VPSP | -# | mission_type[assetTypesRequirement][0][number] | 4 | -# And I press "Enregistrer" -# Then I should be on "/organizations/mission_type/" -# And I should see "mission type name" -# When I follow the last "Modifier" -# Then the "mission_type_name" field should contain "mission type name" -# And the "mission_type_minimumAvailableHours" field should contain "2" -# And the "mission_type_userSkillsRequirement_0_skill" field should contain "ci_bspp" -# And the "mission_type_userSkillsRequirement_0_number" field should contain "3" -# And the "mission_type_assetTypesRequirement_0_type" field should contain "302" -# And the "mission_type_assetTypesRequirement_0_number" field should contain "4" + @javascript + Scenario: As an organization, I can create a mission type + Given I am authenticated as "DT75" + And I am on "/organizations/mission_type/" + When I follow "Ajouter un nouveau type de mission" + Then I should be on "/organizations/mission_type/new" + When I press "Ajouter un type de bénévole" + And I press "Ajouter un type de véhicule" + And I fill in the following: + | mission_type[name] | mission type name | + | mission_type[minimumAvailableHours] | 2 | + | mission_type[userSkillsRequirement][0][skill] | ci_bspp | + | mission_type[userSkillsRequirement][0][number] | 3 | + | mission_type[assetTypesRequirement][0][type] | VPSP | + | mission_type[assetTypesRequirement][0][number] | 4 | + And I press "Enregistrer" + Then I should be on "/organizations/mission_type/" + And I should see "mission type name" + When I follow the last "Modifier" + Then the "mission_type_name" field should contain "mission type name" + And the "mission_type_minimumAvailableHours" field should contain "2" + And the "mission_type_userSkillsRequirement_0_skill" field should contain "ci_bspp" + And the "mission_type_userSkillsRequirement_0_number" field should contain "3" + And the "mission_type_assetTypesRequirement_0_type" field should contain "302" + And the "mission_type_assetTypesRequirement_0_number" field should contain "4" @javascript Scenario: As an organization, I cannot create a mission type with duplicate requirements @@ -71,39 +71,38 @@ Feature: And I should see "Au moins une compétence de bénévole est dupliquée" And I should see "Au moins un type de véhicule est dupliqué" -# # todo: this form has a buggy behavior: https://github.com/crf-devs/resop/issues/361 -# @javascript -# Scenario: As an organization, I can edit a mission type -# Given I am authenticated as "DT75" -# And I am on "/organizations/mission_type/" -# When I follow "Modifier" -# Then I should be on "/organizations/mission_type/751/edit" -# When I fill in the following: -# | mission_type[name] | mission type name | -# | mission_type[userSkillsRequirement][0][skill] | ci_bspp | -# And I press "delete_mission_type_userSkillsRequirement_1" -# And I press "Enregistrer" -# Then I should be on "/organizations/mission_type/" -# And I should see "mission type name" -# When I follow "Modifier" -# And I should see "CI Réseau BSPP" + @javascript + Scenario: As an organization, I can edit a mission type + Given I am authenticated as "DT75" + And I am on "/organizations/mission_type/" + When I follow "Modifier" + Then I should be on "/organizations/mission_type/751/edit" + When I fill in the following: + | mission_type[name] | mission type name | + | mission_type[userSkillsRequirement][0][skill] | ci_bspp | + And I press "delete_mission_type_userSkillsRequirement_1" + And I press "Enregistrer" + Then I should be on "/organizations/mission_type/" + And I should see "mission type name" + When I follow "Modifier" + And I should see "CI Réseau BSPP" Scenario: As an organization, I cannot edit a mission type of another organization Given I am authenticated as "DT75" And I am on "/organizations/mission_type/771/edit" Then the response status code should be 403 -# @javascript -# Scenario: As an organization, I can delete a mission type -# Given I am authenticated as "DT75" -# And I am on "/organizations/mission_type/" -# When I press "Supprimer" -# Then I should see "Vous êtes sur le point de supprimer le type de mission : Mission type DT75 1" -# When I press "Supprimer" -# Then the response status code should be 200 -# And I should be on "/organizations/mission_type/" -# And I should not see "Le type de mission a été supprimé avec succès " -# And I should not see "Mission type DT75 1" + @javascript + Scenario: As an organization, I can delete a mission type + Given I am authenticated as "DT75" + And I am on "/organizations/mission_type/" + When I follow "Supprimer" + And I wait for "#delete-item-modal" to be visible + Then I should see "Vous êtes sur le point de supprimer l'élément : Mission type DT75 1." + When I press "Supprimer" + Then I should be on "/organizations/mission_type/" + And I should see "Le type de mission a été supprimé avec succès " + And I should not see "Mission type DT75 1" Scenario: As an organization, I cannot delete a mission type of another organization Given I am authenticated as "DT75" diff --git a/features/organization/users.feature b/features/organization/users.feature index 051a0ba4..84c0a590 100644 --- a/features/organization/users.feature +++ b/features/organization/users.feature @@ -73,22 +73,22 @@ Feature: Given I am authenticated as "DT75" When I go to "/organizations/204/users/103/edit" Then the response status code should be 403 -# -# @javascript -# Scenario Outline: As an admin of an organization, I can delete a user from my organization or children organizations -# Given I am authenticated as "" -# When I go to "/organizations/3/users" -# And I press "Supprimer" -# Then I should see "Vous êtes sur le point de supprimer le bénévole : Jill DOE ( 990003A ) et toutes ses disponibilités." -# When I press "Supprimer" -# Then I should be on "/organizations/3/users" -# And the response status code should be 200 -# And I should see "Le bénévole a été supprimé avec succès." -# And I should not see "jill.doe@resop.com" -# Examples: -# | login | -# | john.doe@resop.com | -# | jane.doe@resop.com | + + @javascript + Scenario Outline: As an organization, I can delete a user from my organization or children organizations + Given I am authenticated as "" + When I go to "/organizations/203/users" + And I follow "Supprimer" + And I wait for "#delete-item-modal" to be visible + Then I should see "Vous êtes sur le point de supprimer le bénévole suivant et toutes ses disponibilités : Jane DOE ( 990002A )." + When I press "Supprimer" + Then I should be on "/organizations/203/users/" + And I should see "Le bénévole a été supprimé avec succès." + And I should not see "jill.doe@resop.com" + Examples: + | login | + | DT75 | + | UL 01-02 | # # Scenario: As an admin of an organization, I cannot directly delete a user from my organization # Given I am authenticated as "john.doe@resop.com"