Skip to content

Commit

Permalink
Update Behat scenarios for user-system-refacto
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentchalamon committed May 13, 2020
1 parent 272011e commit 9fad177
Show file tree
Hide file tree
Showing 17 changed files with 601 additions and 221 deletions.
140 changes: 83 additions & 57 deletions features/organization/assets.feature
Original file line number Diff line number Diff line change
@@ -1,145 +1,171 @@
Feature:
In order to manage the assets in my organization,
As an organization,
As an admin of an organization,
I must be able to list, edit and delete assets in my organization.

Scenario: As anonymous, I cannot list the assets from an organization
When I go to "/organizations/201/assets"
Then I should be on "/organizations/login"
Then I should be on "/login"
And the response status code should be 200

Scenario: As an organization, I can list the assets from my organization
Given I am authenticated as "DT75"
And I am on "/organizations"
Scenario: As an admin of an organization, I can list the assets from my organization
Given I am authenticated as "[email protected]"
And I am on "/organizations/203"
When I follow "Afficher la liste de mes véhicules"
Then I should be on "/organizations/201/assets/"
Then I should be on "/organizations/203/assets"
And the response status code should be 200
And I should see "75992"
And I should see "75996"
And I should not see "7799"
And I should not see "7501"
And I should not see "7710"

Scenario: As a parent organization, I can list the assets from my children organizations
Given I am authenticated as "DT75"
And I am on "/organizations"
Scenario: As an admin of a parent organization, I can list the assets from my children organizations
Given I am authenticated as "[email protected]"
And I am on "/organizations/201"
When I follow "Modifier mes structures"
Then I should be on "/organizations/children"
Then I should be on "/organizations/201/children"
And the response status code should be 200
When I follow "Liste des véhicules"
Then I should be on "/organizations/203/assets/"
Then I should be on "/organizations/201/assets?organization=203"
And the response status code should be 200
And I should see "75012"
And I should see "75016"
And I should not see "7599"
And I should not see "7799"
And I should not see "7710"

Scenario: As an organization, I cannot list the assets from an organization I don't have access to
Given I am authenticated as "DT75"
Scenario: As an admin of an organization, I cannot list the assets from an organization I don't have access to
Given I am authenticated as "[email protected]"
When I go to "/organizations/202/assets"
Then the response status code should be 403

Scenario Outline: As an authenticated parent organization, I can add an asset on my organization or children organizations
Scenario: As an admin of a child organization, I cannot list the assets from the parent organization
Given I am authenticated as "[email protected]"
When I go to "/organizations/201/assets"
Then the response status code should be 403

Scenario Outline: As an admin of an organization, I can add an asset on my organization or children organizations
Given I am authenticated as "<login>"
When I go to "/organizations/203/assets"
When I go to "<list_url>"
And I follow "Ajouter un nouveau véhicule"
Then the response status code should be 200
And I should be on "/organizations/203/assets/preAdd"
And I should be on "<preAdd_url>"
When I select "VL" from "type"
And I press "Continuer"
Then the response status code should be 200
And I should be on "/organizations/203/assets/add"
And I should be on "<add_url>"
When I fill in the following:
| commissionable_asset[name] | new vehicule |
| commissionable_asset[type] | VL |
| commissionable_asset[name] | new vehicule |
| commissionable_asset[hasMobileRadio] | 1 |
| commissionable_asset[hasFirstAidKit] | 1 |
| commissionable_asset[parkingLocation] | some parking location |
| commissionable_asset[contact] | some contact |
| commissionable_asset[seatingCapacity] | 5 |
| commissionable_asset[licensePlate] | some license plate |
| commissionable_asset[comments] | some comments |
And I press "Enregistrer"
Then I should be on "<list_url>"
And the response status code should be 200
And I should see "Véhicule créé"
And I should see "new vehicule"
And I should see "VL - new vehicule"
When I follow the last "Modifier"
Then I should be on "/organizations/3/assets/1/edit"
And the response status code should be 200
And the "commissionable_asset_type" field should contain "VL"
And the "commissionable_asset_name" field should contain "new vehicule"
And the "commissionable_asset_hasMobileRadio_0" checkbox is checked
And the "commissionable_asset_hasFirstAidKit_0" checkbox is checked
And the "commissionable_asset_parkingLocation" field should contain "some parking location"
And the "commissionable_asset_contact" field should contain "some contact"
And the "commissionable_asset_seatingCapacity" field should contain "5"
And the "commissionable_asset_licensePlate" field should contain "some license plate"
And the "commissionable_asset_comments" field should contain "some comments"
Examples:
| login |
| login | list_url | preAdd_url | add_url |
# todo: there is a bug when using parent organization: https://github.com/crf-devs/resop/issues/360
# | DT75 |
| UL 01-02 |
# todo: how to create a new asset on a children organization (but not on current one)?
# | [email protected] | /organizations/201/assets?organization=203 | /organizations/201/assets/preAdd | /organizations/201/assets/add |
| jane.doe@resop.com | /organizations/203/assets | /organizations/203/assets/preAdd | /organizations/203/assets/add |

# TODO Fix this test
# @javascript
# Scenario: As an organization, I can display an asset modal
# Given I am authenticated as "DT75"
# When I go to "/organizations/203/assets"
# And I follow "Afficher"
# Scenario: As an admin of an organization, I can display an asset modal
# Given I am authenticated as "[email protected]"
# When I go to "/organizations/201/assets"
# And I press "Afficher"
# And I wait for ".ajax-modal-content" to be visible
# Then I should see "Modifier"
# And I follow "Modifier"
# Then I should be on "/organizations/203/assets/75012/edit"
# Then I should be on "/organizations/201/assets/75012/edit"

Scenario Outline: As an organization, I can update an asset from my organization or children organizations
Scenario Outline: As an admin of an organization, I can update an asset from my organization or children organizations
Given I am authenticated as "<login>"
When I go to "/organizations/203/assets/75012/edit"
Then I should be on "/organizations/203/assets/75012/edit"
When I go to "<edit_url>"
Then I should be on "<edit_url>"
And the response status code should be 200
And the "commissionable_asset_name" field should contain "75012"
When I fill in the following:
| commissionable_asset[name] | new name |
And I press "Enregistrer"
Then I should be on "/organizations/203/assets/"
Then I should be on "<list_url>"
And the response status code should be 200
And I should see "Véhicule \"VPSP - new name\" mis à jour avec succès"
When I go to "/organizations/203/assets/75012/edit"
When I go to "<edit_url>"
And the "commissionable_asset_name" field should contain "new name"
Examples:
| login |
| login | edit_url | list_url |
# todo: there is a bug when using parent organization: https://github.com/crf-devs/resop/issues/360
# | DT75 |
| UL 01-02 |
# | [email protected] | /organizations/201/assets/75012/edit | /organizations/201/assets?organization=203 |
| jane.doe@resop.com | /organizations/203/assets/75012/edit | /organizations/203/assets |

Scenario: As a parent organization, I cannot update an asset from an organization I don't have access to
Given I am authenticated as "DT75"
Scenario: As an admin of a parent organization, I cannot update an asset from an organization I don't have access to
Given I am authenticated as "[email protected]"
When I go to "/organizations/202/assets/77992/edit"
Then the response status code should be 403

Scenario: As an admin of a child organization, I cannot update an asset on the parent organization
Given I am authenticated as "UL 01-02"
Given I am authenticated as "[email protected]"
When I go to "/organizations/201/assets/75992/edit"
Then the response status code should be 403

Scenario: As a parent organization, I cannot update an invalid asset
Given I am authenticated as "DT75"
Scenario: As an admin of a parent organization, I cannot update an invalid asset
Given I am authenticated as "[email protected]"
When I go to "/organizations/201/assets/75012/edit"
Then the response status code should be 404

Scenario: As a parent organization, I can delete an asset from my organization or children organizations
Given I am on "/organizations/login"
When I select "DT75" from "identifier"
And I fill in "password" with "covid19"
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/75012/edit"
Scenario: As an admin of a parent organization, I can delete an asset from my organization or children organizations
Given I am authenticated as "[email protected]"
And I go to "/organizations/201/assets/75012/edit"
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/"
Then I should be on "/organizations/201/assets?organization=203"
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
# https://github.com/crf-devs/resop/issues/348
# Scenario: As an admin of a parent organization, I cannot directly delete an asset from my organization
# Given I am authenticated as "[email protected]"
# When I go to "/organizations/201/assets/75992/delete"
# Then the response status code should be 405

Scenario: As a parent organization, I cannot delete an asset from another organization
Given I am authenticated as "DT75"
Scenario: As an admin of a parent organization, I cannot delete an asset from another organization
Given I am authenticated as "[email protected]"
When I go to "/organizations/202/assets"
Then the response status code should be 403
When I go to "/organizations/202/assets/77992/delete"
Then the response status code should be 403

Scenario: As a parent organization, I cannot access availability of an invalid asset
Given I am authenticated as "DT75"
Scenario: As an admin of a parent organization, I cannot access availability of an invalid asset
Given I am authenticated as "[email protected]"
When I go to "/organizations/201/availability/75012/2020-W10"
Then the response status code should be 404

Scenario: As an admin of an organization, I cannot access availability of an asset with a mismatched url
Given I am authenticated as "[email protected]"
When I go to "/organizations/201/availability/75012/2020-W10"
Then the response status code should be 404
89 changes: 57 additions & 32 deletions features/organization/children.feature
Original file line number Diff line number Diff line change
@@ -1,76 +1,101 @@
Feature:
In order to manage my children organizations,
As a parent organization,
As an admin of a parent organization,
I must be able to list, edit and create them.

Scenario: As anonymous, I cannot list the children of an organization
When I go to "/organizations/children"
Then I should be on "/organizations/login"
When I go to "/organizations/201/children"
Then I should be on "/login"
And the response status code should be 200

Scenario: As a parent organization, I can list the children of my organization
Given I am authenticated as "DT75"
When I go to "/organizations"
Scenario: As an admin of a parent organization, I can list the children of my organization
Given I am authenticated as "[email protected]"
When I go to "/organizations/201"
Then I should see "Modifier mes structures"
When I follow "Modifier mes structures"
Then I should be on "/organizations/children"
Then I should be on "/organizations/201/children"
And the response status code should be 200
And I should see "UL 01-02"

Scenario: As an organization without children, I cannot list the children of my organization
Given I am authenticated as "UL 01-02"
Scenario: As an admin of an organization without children, I cannot list the children of my organization
Given I am authenticated as "[email protected]"
When I go to "/organizations/203"
Then I should not see "Modifier mes structures"
When I go to "/organizations/children"
When I go to "/organizations/203/children"
And the response status code should be 403

Scenario: As an admin of an organization but without a password, I cannot list the children of my organization
Given I am authenticated as "[email protected]"
When I go to "/organizations/203/children"
Then the response status code should be 403

Scenario Outline: As an admin of an organization, I cannot list the children of another organization
Given I am authenticated as "[email protected]"
When I go to "<url>"
Then the response status code should be 403
Examples:
| url |
| /organizations/202/children |
| /organizations/203/children |
| /organizations/204/children |

Scenario: As anonymous, I cannot create an organization
When I go to "/organizations/new"
Then I should be on "/organizations/login"
When I go to "/organizations/201/new"
Then I should be on "/login"
And the response status code should be 200

Scenario: As a parent organization, I can create an organization
Given I am authenticated as "DT75"
And I am on "/organizations/children"
Scenario: As an admin of a parent organization, I can create an organization
Given I am authenticated as "[email protected]"
And I am on "/organizations/201/children"
When I follow "Ajouter une structure"
Then I should be on "/organizations/new"
Then I should be on "/organizations/201/new"
And the response status code should be 200
When I fill in the following:
| organization[name] | Lorem ipsum |
And I press "Valider"
Then the response status code should be 200
And I should be on "/organizations/children"
And I should be on "/organizations/201/children"
And I should see "La structure a été ajoutée avec succès."
And I should see "Lorem ipsum"

Scenario: As a children organization, I cannot create an organization
Given I am authenticated as "UL 01-02"
Scenario: As an admin of a children organization, I cannot create an organization
Given I am authenticated as "[email protected]"
When I go to "/organizations/203"
Then I should not see "Modifier mes structures"
When I go to "/organizations/new"
When I go to "/organizations/203/new"
Then the response status code should be 403

Scenario: As anonymous, I cannot update an organization
When I go to "/organizations/201/edit"
Then I should be on "/organizations/login"
And the response status code should be 200
Scenario: As an admin of an organization, I cannot create an organization on another one
Given I am authenticated as "[email protected]"
When I go to "/organizations/202/new"
Then the response status code should be 403

Scenario: As a parent organization, I can update my children organizations
Given I am authenticated as "DT75"
And I am on "/organizations/children"
Scenario: As an admin of a parent organization, I can update my children organizations
Given I am authenticated as "[email protected]"
And I am on "/organizations/201/children"
When I follow "Modifier"
Then I should be on "/organizations/203/edit"
Then I should be on "/organizations/201/children/203/edit"
And the response status code should be 200
And I should see "Modifier une structure"
When I fill in the following:
| organization[name] | Lorem ipsum |
And I press "Valider"
Then I should be on "/organizations/children"
Then I should be on "/organizations/201/children"
And the response status code should be 200
And I should see "La structure a été mise à jour avec succès."
And I should see "Lorem ipsum"

Scenario: As an organization, I cannot update an organization I don't have access to
Given I am authenticated as "DT75"
When I go to "/organizations/202/edit"
Scenario: As an admin of an organization, I cannot update an organization I don't have access to
Given I am authenticated as "[email protected]"
When I go to "/organizations/201/children/204/edit"
Then the response status code should be 403

Scenario: As anonymous, I cannot update an organization
When I go to "/organizations/201/children/203/edit"
Then I should be on "/login"
And the response status code should be 200

Scenario: As an admin of an organization, I cannot update my organization
Given I am authenticated as "[email protected]"
When I go to "/organizations/201/children/203/edit"
Then the response status code should be 403
2 changes: 1 addition & 1 deletion features/organization/forecast.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Feature:

Scenario: As anonymous, I cannot access to the forecast page
When I go to "/organizations/forecast"
Then I should be on "/organizations/login"
Then I should be on "/login"

Scenario: As an authenticated children organization, I cannot use the forecast search form
Given I am authenticated as "UL 01-02"
Expand Down
Loading

0 comments on commit 9fad177

Please sign in to comment.