<NME> edit.feature
<BEF> @mink:selenium2 @alice(Page) @reset-schema
Feature: Edit a widget

    Background:
        Given the following Jedis:
            | name   | side   | midiChlorians | slug   |
            | Anakin | dark   | 20000         | anakin |
            | Yoda   | bright | 17500         | yoda   |
        Given the following BusinessTemplate:
            | currentLocale | name                         | backendName  | slug                       | businessEntityId | parent | template |
            | en            | Jedi profile - {{item.name}} | Jedi profile | jedi-profile-{{item.slug}} | jedi             | home   | base     |
        And I maximize the window

    Scenario: I can create a new Business entity page pattern, create a widget and edit this widget
        Given the following WidgetMap:
            | view                       | action | slot         |
            | jedi-profile-{{item.slug}} | create | main_content |
        Given the following WidgetForce:
            | widgetMap                  | fields                       | mode           | businessEntityId |
            | jedi-profile-{{item.slug}} | a:1:{s:4:"side";s:4:"side";} | businessEntity | jedi             |
        Given I am on "/en/victoire-dcms/business-template/show/4"
        And I should see "The dark side of the force"
        When I switch to "edit" mode
        And I edit the "Force" widget
        Then I should see "UPDATE"
        When I select "slug" from "jedi_a_businessEntity_widget_force[fields][side]"
    Scenario: I can create a new Business entity page pattern, create a widget and edit this widget
        When I select "Force" from the "1" select of "content" slot
        Then I should see "Créer"
        When I follow "Jedi"
        And I follow "Objet courant"
        And I select "side" from "jedi_businessEntity_victoire_widget_form_force[fields][side]"
        When I submit the widget
        And the following WidgetForce:
            | widgetMap                  | side |
            | jedi-profile-{{item.slug}} | dark |
        And I am on "/en/victoire-dcms/business-template/show/4"
        Then I should see "The dark side of the force"
        When I switch to "edit" mode
        And I edit the "Force" widget
        Then I should see "UPDATE"
        When I follow the tab "Entities"
        Then I should see "Jedi"
        When I follow the drop anchor "Jedi"
        And I open the widget mode drop for entity "Jedi"
        Then I should see "Query"
        When I follow the drop anchor "Query"
        And I select "side" from "jedi_a_query_widget_force[fields][side]"
        And I submit the widget
        Then I should see "The dark side of the force"
        When I switch to "edit" mode
        And I edit the "Force" widget
        Then I should see "Widget #1 - Force"
        When I follow "Jedi"
        And I follow "Requête"
        When I select "side" from "jedi_query_victoire_widget_form_force[fields][side]"
        And I submit the widget
        When I follow the tab "Entities"
        And I should see disable drop anchor "Spaceship"

    Scenario: I can edit the original widget from a child page
        Given the following Jedis:
            | name   | side | midiChlorians | slug   |
        When I follow "Vaisseaux"
        And I follow "Choix"
        Then I should not see "Côté de la force"
        When I follow "Jedi"
        And I follow "Choix"
        Then I should see "Côté de la force"
            | jedi-profile-{{item.slug}} | dark |
        Given I am on "/en/victoire-dcms/business-template/show/4"
        And I should see "The dark side of the force"
        Given I am on "/en/jedi-profile-anakin"
        And I should see "The dark side of the force"
        When I switch to "edit" mode
        And I edit the "Force" widget
        And I wait 3 seconds
        Then I should see "Warning!"
        And I should see "This content is owned by a parent template"
        And I should see "EDIT THE ORIGINAL CONTENT"
        When I follow "EDIT THE ORIGINAL CONTENT"
        And I wait 5 seconds
        Then I should not see "Warning!"
        And I should not see "This content is owned by a parent template"
        When I fill in "Force side" with "dark"
        And I submit the widget
        Given I am on "/en/victoire-dcms/business-template/show/4"
        Then I should see "The dark side of the force"

    Scenario: I can't edit the original widget from a child page as non Victoire developper
        Given the following Jedis:
            | name   | side | midiChlorians | slug   |
            | Anakin | dark | 20000         | anakin |
        Given the following WidgetMap:
            | view                       | action | slot         |
            | jedi-profile-{{item.slug}} | create | main_content |
        Given the following WidgetForce:
            | widgetMap                  | side |
            | jedi-profile-{{item.slug}} | dark |
        Given I login as Victoire default user
        And I am on "/en/jedi-profile-anakin"
        Then I should see "The dark side of the force"
        When I switch to "edit" mode
        And I can't edit the "Force" widget

    Scenario: I can edit the widget from current page as Victoire default user
        Given I login as Victoire default user
        Given the following WidgetMap:
            | view | action | slot         |
            | home | create | main_content |
        Given the following WidgetForce:
            | widgetMap | side |
            | home      | dark |
        Then I am on the homepage
        And I should see "The dark side of the force"
        When I switch to "edit" mode
        And I edit the "Force" widget
        And I wait 3 seconds
        When I fill in "Force side" with "light"
        And I submit the widget
        Given I am on the homepage
        Then I should see "light side"

<MSG> fix some behat tests

<DFF> @@ -27,7 +27,7 @@ Feature: Edit a widget
     Scenario: I can create a new Business entity page pattern, create a widget and edit this widget
         When I select "Force" from the "1" select of "content" slot
         Then I should see "Créer"
-        When I follow "Jedi"
+        When I follow the tab "Jedi"
         And I follow "Objet courant"
         And I select "side" from "jedi_businessEntity_victoire_widget_form_force[fields][side]"
         When I submit the widget
@@ -51,7 +51,7 @@ Feature: Edit a widget
         When I switch to "edit" mode
         And I edit the "Force" widget
         Then I should see "Widget #1 - Force"
-        When I follow "Jedi"
+        When I follow the tab "Jedi"
         And I follow "Requête"
         When I select "side" from "jedi_query_victoire_widget_form_force[fields][side]"
         And I submit the widget
@@ -64,6 +64,6 @@ Feature: Edit a widget
         When I follow "Vaisseaux"
         And I follow "Choix"
         Then I should not see "Côté de la force"
-        When I follow "Jedi"
+        When I follow the tab "Jedi"
         And I follow "Choix"
         Then I should see "Côté de la force"

{'addition_count': 3, 'commit_subject': 'fix some behat tests', 'deletion_count': 3, 'file_extension': '.feature', 'lang': 'feature', 'license': 'mit', 'repo_name': 'Victoire/victoire'}