Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare Behat scenarios #339

Merged
merged 2 commits into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 79 additions & 51 deletions features/organization/assets.feature
Original file line number Diff line number Diff line change
@@ -1,27 +1,22 @@
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"
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/201"
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"
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/201/children/"
Expand All @@ -35,82 +30,110 @@ Feature:
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/203/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 |
| [email protected] | /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 |
| [email protected] | /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/77102/edit"
Then the response status code should be 404

@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"
Expand All @@ -119,20 +142,25 @@ Feature:
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
# Given I am authenticated as "john.doe@resop.com"
# 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 "admin201@resop.com"
# 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
66 changes: 38 additions & 28 deletions features/organization/children.feature
Original file line number Diff line number Diff line change
@@ -1,36 +1,41 @@
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/201/children/"
Then I should be on "/organizations/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/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/203/children/"
And the response status code should be 403

Scenario: As anonymous, I cannot create an organization
When I go to "/organizations/201/children/new"
Then I should be on "/organizations/login"
And the response status code should be 200
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 a parent organization, I can create an organization
Given I am authenticated as "DT75"
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/201/children/new"
Expand All @@ -43,20 +48,20 @@ Feature:
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/203/children/new"
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 "/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/children/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"
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/201/children/203/edit"
Expand All @@ -70,7 +75,12 @@ Feature:
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/201/children/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 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
4 changes: 0 additions & 4 deletions features/organization/forecast.feature
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ Feature:
As an organization,
I must be able to search for available users and assets.

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

Scenario: As an authenticated children organization, I cannot use the forecast search form
Given I am authenticated as "UL 01-02"
When I go to "/organizations/201/forecast/"
Expand Down
41 changes: 41 additions & 0 deletions features/organization/home.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
Feature:
In order to manage an organization,
As an admin of an organization,
I must be able to log in to my organization.

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

Scenario: As an admin of an organization, I can go to the homepage of my organization
Given I am authenticated as "[email protected]"
And I am on the homepage
When I follow "Gérer ma structure"
Then I should be on "/organizations/201"
And the response status code should be 200
And I should see "DT75"

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 "<url>"
Then the response status code should be 403
Examples:
| url |
| /organizations/203 |
| /organizations/203/new |
| /organizations/203/search |
| /organizations/203/edit |
| /organizations/203/assets |
| /organizations/203/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]"
When I go to "<url>"
Then the response status code should be 403
Examples:
| url |
| /organizations/2 |
| /organizations/203 |
| /organizations/204 |
Loading