Skip to content

Commit

Permalink
Added behat scenarii for assets
Browse files Browse the repository at this point in the history
  • Loading branch information
nikophil committed Apr 23, 2020
1 parent 6b190c9 commit 825f87a
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 8 deletions.
148 changes: 148 additions & 0 deletions features/organization/assets.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
Feature:
In order to manage the assets in my organization,
As an organization admin,
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/1/assets"
Then I should be on "/login"
And the response status code should be 200

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/1"
When I follow "Afficher la liste de mes véhicules"
Then I should be on "/organizations/1/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 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/1"
When I follow "Modifier mes structures"
Then I should be on "/organizations/1/children"
And the response status code should be 200
When I follow "Liste des véhicules"
Then I should be on "/organizations/3/assets"
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 admin of an organization, I cannot list the assets from another organization
Given I am authenticated as "[email protected]"
When I go to "/organizations/2/assets"
Then the response status code should be 403

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/1/assets"
Then the response status code should be 403

Scenario: As an authenticated parent organization, I can add an asset from my organization or children organizations
Given I am authenticated as "DT75"
When I go to "/organizations/3/assets"
And I follow "Ajouter un nouveau véhicule"
Then I should be on "/organizations/3/assets/add"
And the response status code should be 200
When I fill in the following:
| 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 "/organizations/3/assets/"
And the response status code should be 200
And I should see "Véhicule créé"
And I should see "VL - new vehicule"
#don't know how to grab the new id...
When I go to "/organizations/3/assets/[id]/edit"
Then I should be on "/organizations/3/assets/[id]/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_has_mobile_radio" field should contain "1"
And the "commissionable_has_first_aid_kit" field should contain "1"
And the "commissionable_parking_location" field should contain "1"
And the "commissionable_contact" field should contain "some contact"
And the "commissionable_seating_capacity" field should contain "5"
And the "commissionable_license_plate" field should contain "some license plate"
And the "commissionable_comments" field should contain "some comments"
Examples:
| login |
| john.doe@resop.com |
| jane.doe@resop.com |

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/3/assets"
And I follow "Modifier"
Then I should be on "/organizations/3/assets/75012/edit"
And the response status code should be 200
And the "commissionable_asset_type" field should contain "VPSP"
And the "commissionable_asset_name" field should contain "75012"
When I fill in the following:
| commissionable_asset[type] | VL |
| commissionable_asset[name] | new name |
And I press "Valider"
Then I should be on "/organizations/3/assets"
And the response status code should be 200
And I should see "Véhicule \"VL - new name\" mis à jour avec succès"
When I go to "/organizations/3/assets/75012/edit"
Then I should be on "/organizations/3/assets/75012/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 name"
Examples:
| login |
| john.doe@resop.com |
| jane.doe@resop.com |

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

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

@javascript
Scenario Outline: As an admin of an organization, I can delete an asset from my organization or children organizations
Given I am authenticated as "<login>"
When I go to "/organizations/3/assets"
And I press "Supprimer"
Then I should see "Vous êtes sur le point de supprimer le véhicule : VPSP - 75992 et toutes ses disponibilités."
When I press "Supprimer"
Then I should be on "/organizations/3/assets"
And the response status code should be 200
And I should see "Le véhicule a été supprimé avec succès."
And I should not see "75992"
Examples:
| login |
| john.doe@resop.com |
| jane.doe@resop.com |

Scenario: As an admin of an organization, I cannot directly delete an asset from my organization
Given I am authenticated as "[email protected]"
When I go to "/organizations/1/assets/75992/delete"
Then the response status code should be 405

Scenario: As an admin of an organization, I cannot delete an asset from another organization
Given I am authenticated as "[email protected]"
When I go to "/organizations/2/assets"
Then the response status code should be 403
When I go to "/organizations/2/assets/77992/delete"
Then the response status code should be 405
13 changes: 11 additions & 2 deletions features/organization/home.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,19 @@ Feature:
And the response status code should be 200
And I should see "DT75"

Scenario: As an admin of an organization but without a password, I cannot go to the homepage of my organization
Scenario Outline: As an admin of an organization but without a password, I cannot go to any page of my organization
Given I am authenticated as "[email protected]"
When I go to "/organizations/1"
When I go to "<url>"
Then the response status code should be 403
Examples:
| url |
| /organizations/3 |
| /organizations/3/new |
| /organizations/3/search |
| /organizations/3/edit |
| /organizations/3/assets |
| /organizations/3/users |
| /organizations/planning |

Scenario Outline: As an admin of an organization, I cannot go to the homepage of another organization
Given I am authenticated as "[email protected]"
Expand Down
12 changes: 6 additions & 6 deletions features/organization/users.feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Feature:
Given I am authenticated as "<login>"
When I go to "/organizations/3/users"
And I follow "Modifier"
Then I should be on "/organizations/3/users/3"
Then I should be on "/organizations/3/users/3/edit"
And the response status code should be 200
And the "user_identificationNumber" field should contain "990003A"
And the "user_emailAddress" field should contain "[email protected]"
Expand All @@ -59,8 +59,8 @@ Feature:
Then I should be on "/organizations/3/users"
And the response status code should be 200
And I should see "Les informations ont été mises à jour avec succès."
When I go to "/organizations/3/users/3"
Then I should be on "/organizations/3/users/3"
When I go to "/organizations/3/users/3/edit"
Then I should be on "/organizations/3/users/3/edit"
And the response status code should be 200
And the "user_identificationNumber" field should contain "999999A"
And the "user_emailAddress" field should contain "[email protected]"
Expand Down Expand Up @@ -93,12 +93,12 @@ Feature:
| jane.doe@resop.com |

Scenario: As an admin of an organization, I cannot directly delete a user from my organization
Given I am authenticated as "<login>"
When I go to "/organizations/2/users/4/delete"
Given I am authenticated as "[email protected]"
When I go to "/organizations/3/users/3/delete"
Then the response status code should be 405

Scenario: As an admin of an organization, I cannot delete a user from another organization
Given I am authenticated as "<login>"
Given I am authenticated as "[email protected]"
When I go to "/organizations/2/users"
Then the response status code should be 403
When I go to "/organizations/2/users/4/delete"
Expand Down
1 change: 1 addition & 0 deletions fixtures/assets.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# todo: update fixtures to have predictable ids
App\Entity\CommissionableAsset:
Asset.DT75.VPSP.{2..4,2}:
organization: '@Organization.DT75'
Expand Down

0 comments on commit 825f87a

Please sign in to comment.