diff --git a/Bundle/WidgetBundle/Entity/Widget.php b/Bundle/WidgetBundle/Entity/Widget.php index 93a5ebd86..cacaf0486 100644 --- a/Bundle/WidgetBundle/Entity/Widget.php +++ b/Bundle/WidgetBundle/Entity/Widget.php @@ -368,10 +368,12 @@ public function setChildrenSlot($childrenSlot) * * @return Widget */ - public function setWidgetMap(WidgetMap $widgetMap) + public function setWidgetMap(WidgetMap $widgetMap = null) { + if ($widgetMap) { + $widgetMap->addWidget($this); + } $this->widgetMap = $widgetMap; - $widgetMap->addWidget($this); return $this; } diff --git a/Bundle/WidgetBundle/Model/WidgetManager.php b/Bundle/WidgetBundle/Model/WidgetManager.php index 9dbc88de4..7452aedf6 100644 --- a/Bundle/WidgetBundle/Model/WidgetManager.php +++ b/Bundle/WidgetBundle/Model/WidgetManager.php @@ -344,33 +344,25 @@ public function deleteWidget(Widget $widget, View $view) public function overwriteWidget(View $view, Widget $widget) { $widgetCopy = $this->cloneEntity($widget); - - //we have to persist the widget to get its id - $this->entityManager->persist($view); - $this->entityManager->flush(); - - $originalWidgetMap = WidgetMapHelper::getWidgetMapByWidgetAndView($widget, $view); - + $originalWidgetMap = $widget->getWidgetMap(); $this->widgetMapManager->overwrite($view, $originalWidgetMap, $widgetCopy); - $this->widgetMapBuilder->build($view); - return $widgetCopy; } /** * @param Widget $entity */ - public function cloneEntity($entity) + public function cloneEntity(Widget $entity) { $entityCopy = clone $entity; - + $entityCopy->setWidgetMap(null); //Look for on_to_many relations, if found, duplicate related entities. //It is necessary for 'list' widgets, this algo duplicates and persists list items. $associations = $this->entityManager->getClassMetadata(get_class($entityCopy))->getAssociationMappings(); $accessor = PropertyAccess::createPropertyAccessor(); foreach ($associations as $name => $values) { - if ($values['type'] === ClassMetadataInfo::ONE_TO_MANY && $values['fieldName'] != 'widgetMaps') { + if ($values['type'] === ClassMetadataInfo::ONE_TO_MANY) { $relatedEntities = $accessor->getValue($entityCopy, $values['fieldName']); $relatedEntitiesCopies = []; foreach ($relatedEntities as $relatedEntity) { diff --git a/Bundle/WidgetBundle/Resolver/WidgetResolver.php b/Bundle/WidgetBundle/Resolver/WidgetResolver.php index 0ba8dbae6..d088d9c51 100644 --- a/Bundle/WidgetBundle/Resolver/WidgetResolver.php +++ b/Bundle/WidgetBundle/Resolver/WidgetResolver.php @@ -51,9 +51,15 @@ public function __construct(DataSourceChain $dataSourceChain, AuthorizationCheck public function resolve(WidgetMap $widgetMap) { - //TODO: orderiaze it + //TODO: orderize it + + $widgets = $widgetMap->getWidgets(); + // if the widgetmap is linked to no widgets, it seems that it is an overwrite of the position so keep the replaced widgets for display + if ($widgetMap->getReplaced() && count($widgets) === 0) { + $widgets = $widgetMap->getReplaced()->getWidgets(); + } /* @var Widget $widget */ - foreach ($widgetMap->getWidgets() as $_widget) { + foreach ($widgets as $_widget) { /** @var Criteria $criteria */ foreach ($_widget->getCriterias() as $criteria) { $value = $this->dataSourceChain->getData($criteria->getName()); diff --git a/Bundle/WidgetMapBundle/Manager/WidgetMapManager.php b/Bundle/WidgetMapBundle/Manager/WidgetMapManager.php index b9c8c2f10..c9ab0b8fa 100644 --- a/Bundle/WidgetMapBundle/Manager/WidgetMapManager.php +++ b/Bundle/WidgetMapBundle/Manager/WidgetMapManager.php @@ -86,11 +86,11 @@ public function move(View $view, $sortedWidget) $this->moveChildren($view, $beforeChild, $afterChild, $originalParent, $originalPosition); foreach ($parentWidgetMapChildren['views'] as $_view) { - if ($_view->getId() !== $view->getId()) { - if (isset($parentWidgetMapChildren['before'][$_view->getId()])) { + if ($_view !== $view) { + if (isset($parentWidgetMapChildren['before'][$_view->getId()]) && $parentWidgetMapChildren['before'][$_view->getId()]->getPosition() == $widgetMap->getPosition()) { $parentWidgetMapChildren['before'][$_view->getId()]->setParent($widgetMap); } - if (isset($parentWidgetMapChildren['after'][$_view->getId()])) { + if (isset($parentWidgetMapChildren['after'][$_view->getId()]) && $parentWidgetMapChildren['after'][$_view->getId()]->getPosition() == $widgetMap->getPosition()) { $parentWidgetMapChildren['after'][$_view->getId()]->setParent($widgetMap); } } @@ -121,6 +121,17 @@ public function delete(View $view, Widget $widget) //we remove the widget from the current view if ($widgetMap->getView() === $view) { + // If the widgetMap has substitutes, delete them or transform them in create mode + if (count($widgetMap->getSubstitutes()) > 0) { + foreach ($widgetMap->getSubstitutes() as $substitute) { + if ($substitute->getAction() === WidgetMap::ACTION_OVERWRITE) { + $substitute->setAction(WidgetMap::ACTION_CREATE); + $substitute->setReplaced(null); + } else { + $view->removeWidgetMap($widgetMap); + } + } + } //remove the widget map from the slot $view->removeWidgetMap($widgetMap); } else { @@ -154,10 +165,8 @@ public function overwrite(View $view, WidgetMap $originalWidgetMap, Widget $widg $widgetMap->setAction(WidgetMap::ACTION_OVERWRITE); $widgetMap->setReplaced($originalWidgetMap); $widgetCopy->setWidgetMap($widgetMap); - $widgetMap->setView($view); $widgetMap->setSlot($originalWidgetMap->getSlot()); $widgetMap->setPosition($originalWidgetMap->getPosition()); - $widgetMap->setAsynchronous($widgetCopy->isAsynchronous()); $widgetMap->setParent($originalWidgetMap->getParent()); $view->addWidgetMap($widgetMap); @@ -209,7 +218,6 @@ protected function cloneWidgetMap(WidgetMap $widgetMap, View $view) $widgetMap->setId(null); $widgetMap->setAction(WidgetMap::ACTION_OVERWRITE); $widgetMap->setReplaced($originalWidgetMap); - $originalWidgetMap->addSubstitute($widgetMap); $widgetMap->setView($view); $view->addWidgetMap($widgetMap); $this->em->persist($widgetMap); diff --git a/Tests/Features/Context/VictoireContext.php b/Tests/Features/Context/VictoireContext.php index 67be4e100..c5d787f24 100644 --- a/Tests/Features/Context/VictoireContext.php +++ b/Tests/Features/Context/VictoireContext.php @@ -160,9 +160,11 @@ public function shouldPrecedeForTheQuery($textBefore, $textAfter) { $element = $this->getSession()->getPage()->find( 'xpath', - sprintf('//descendant-or-self::*[normalize-space(text()) = "%s"]/ancestor::div/descendant-or-self::*[normalize-space(text()) = "%s"]', $textBefore, $textAfter) + sprintf('//*[normalize-space(text()) = "%s"][preceding::*[normalize-space(text()) = "%s"]]', + $textAfter, + $textBefore + ) ); - if (null === $element) { $message = sprintf('"%s" does not preceed "%s"', $textBefore, $textAfter); throw new \Behat\Mink\Exception\ResponseTextException($message, $this->getSession()); diff --git a/Tests/Features/WidgetMap/widgetMap.feature b/Tests/Features/WidgetMap/widgetMap.feature index 105dfc9f0..c6ef500c0 100644 --- a/Tests/Features/WidgetMap/widgetMap.feature +++ b/Tests/Features/WidgetMap/widgetMap.feature @@ -1,11 +1,16 @@ -@mink:selenium2 @alice(Page) @reset-schema +@mink:selenium2 @alice(Page) @alice(Template) @reset-schema Feature: Test widgetMap +# Ececuted tests: +# On a simple page: +# - add +# - delete +# - move Background: Given I maximize the window And I am on homepage @reset-schema -Scenario: I move up a widget +Scenario: I move first a widget from simple page Given the following WidgetMaps: | id | action | position | parent | slot | view | | 1 | create | | | main_content | home | @@ -16,15 +21,15 @@ Scenario: I move up a widget | Widget 1 | static | 1 | | Widget 2 | static | 2 | | Widget 3 | static | 3 | - And I am on the homepage - Then I should see "Widget 1" - When I move the widgetMap "1" "before" the widgetMap "3" - And I wait 2 seconds - And I reload the page - And "Widget 1" should precede "Widget 3" + And I am on the homepage + Then I should see "Widget 1" + When I move the widgetMap "3" "before" the widgetMap "1" + And I wait 2 seconds + And I reload the page + And "Widget 3" should precede "Widget 1" @reset-schema -Scenario: I move first a widget +Scenario: I move up a widget from simple page Given the following WidgetMaps: | id | action | position | parent | slot | view | | 1 | create | | | main_content | home | @@ -35,15 +40,15 @@ Scenario: I move first a widget | Widget 1 | static | 1 | | Widget 2 | static | 2 | | Widget 3 | static | 3 | - And I am on the homepage - Then I should see "Widget 1" - When I move the widgetMap "3" "after" the widgetMap "" - And I wait 2 seconds - And I reload the page - And "Widget 3" should precede "Widget 1" + And I am on the homepage + Then I should see "Widget 1" + When I move the widgetMap "1" "before" the widgetMap "3" + And I wait 2 seconds + And I reload the page + And "Widget 1" should precede "Widget 3" @reset-schema -Scenario: I move down a widget +Scenario: I move down a widget from simple page Given the following WidgetMaps: | id | action | position | parent | slot | view | | 1 | create | | | main_content | home | @@ -54,16 +59,50 @@ Scenario: I move down a widget | Widget 1 | static | 1 | | Widget 2 | static | 2 | | Widget 3 | static | 3 | - And I am on the homepage - Then I should see "Widget 1" - When I move the widgetMap "1" "after" the widgetMap "2" - And I wait 2 seconds - And I reload the page - Then "Widget 2" should precede "Widget 1" + And I am on the homepage + Then I should see "Widget 1" + When I move the widgetMap "1" "after" the widgetMap "2" + And I wait 2 seconds + And I reload the page + Then "Widget 2" should precede "Widget 1" @reset-schema -Scenario: I move a widget under a templates one +Scenario: I add widget in a position from simple page + Then I switch to "layout" mode + Then I should see "Nouveau Contenu" + When I select "Force" from the "1" select of "main_content" slot + Then I should see "Créer" + When I fill in "Côté de la force" with "obscur" + And I submit the widget + And I wait 2 seconds + And I should see "Le côté obscur de la force" + Then I should see "Nouveau Contenu" + When I select "Force" from the "2" select of "main_content" slot + Then I should see "Créer" + When I fill in "Côté de la force" with "Lumineux" + And I submit the widget + Then I should see "Le côté Lumineux de la force" + And "Le côté obscur de la force" should precede "Le côté Lumineux de la force" + + Given I reload the page + Then "Le côté obscur de la force" should precede "Le côté Lumineux de la force" + + Then I should see "Nouveau Contenu" + Given I select "Force" from the "2" select of "main_content" slot + Then I should see "Créer" + When I fill in "Côté de la force" with "Double" + And I submit the widget + Then I should see "Le côté Double de la force" + And "Le côté Double de la force" should precede "Le côté Lumineux de la force" + And "Le côté obscur de la force" should precede "Le côté Double de la force" + + Given I reload the page + And "Le côté Double de la force" should precede "Le côté Lumineux de la force" + And "Le côté obscur de la force" should precede "Le côté Double de la force" + +@reset-schema +Scenario: I delete widget from simple page Given the following WidgetMaps: | id | action | position | parent | slot | view | | 1 | create | | | main_content | home | @@ -74,54 +113,13 @@ Scenario: I move a widget under a templates one | Widget 1 | static | 1 | | Widget 2 | static | 2 | | Widget 3 | static | 3 | - And I am on the homepage - Then I should see "Widget 1" - When I switch to "layout" mode - Then I should see "Nouveau Contenu" - When I select "Texte brut" from the "3" select of "main_content" slot - Then I should see "Créer" - When I fill in "Texte *" with "Widget 4" - And I submit the widget - And I reload the page - And "Widget 2" should precede "Widget 4" - And "Widget 4" should precede "Widget 3" - Then I move the widgetMap "1" "after" the widgetMap "4" - And I wait 2 seconds - And I reload the page - Then "Widget 4" should precede "Widget 1" - Then "Widget 1" should precede "Widget 3" - -@reset-schema -Scenario: I create widget in a position - Then I switch to "layout" mode - Then I should see "Nouveau Contenu" - When I select "Force" from the "1" select of "main_content" slot - Then I should see "Créer" - When I fill in "Côté de la force" with "obscur" - And I submit the widget - And I wait 2 seconds - And I should see "Le côté obscur de la force" - - Then I should see "Nouveau Contenu" - When I select "Force" from the "2" select of "main_content" slot - Then I should see "Créer" - When I fill in "Côté de la force" with "Lumineux" - And I submit the widget - Then I should see "Le côté Lumineux de la force" - And "Le côté obscur de la force" should precede "Le côté Lumineux de la force" - - Given I reload the page - Then "Le côté obscur de la force" should precede "Le côté Lumineux de la force" - - Then I should see "Nouveau Contenu" - Given I select "Force" from the "2" select of "main_content" slot - Then I should see "Créer" - When I fill in "Côté de la force" with "Double" - And I submit the widget - Then I should see "Le côté Double de la force" - And "Le côté Double de la force" should precede "Le côté Lumineux de la force" - And "Le côté obscur de la force" should precede "Le côté Double de la force" - - Given I reload the page - And "Le côté Double de la force" should precede "Le côté Lumineux de la force" - And "Le côté obscur de la force" should precede "Le côté Double de la force" + And I am on the homepage + Then I should see "Widget 1" + When I switch to "edit" mode + And I edit the "Text" widget + Then I should see "Supprimer" + Given I follow "Supprimer" + Then I should see "Cette action va définitivement supprimer ce contenu. Cette action est irréversible. Êtes-vous sûr ?" + Given I press "J'ai bien compris, je confirme la suppression" + And I reload the page + And "Widget 3" should precede "Widget 2" diff --git a/Tests/Features/WidgetMap/widgetMapTemplate.feature b/Tests/Features/WidgetMap/widgetMapTemplate.feature new file mode 100644 index 000000000..46bbc73a8 --- /dev/null +++ b/Tests/Features/WidgetMap/widgetMapTemplate.feature @@ -0,0 +1,341 @@ +@mink:selenium2 @alice(Page) @alice(Template) @reset-schema +Feature: Test widgetMap +# Ececuted tests: +# On a simple page with a template +# - add +# - delete +# - move +# - overwrite +# - overwrite + add on child +# - overwrite + delete on child +# - overwrite + move on child +# - overwrite + add on template +# - overwrite + delete on template +# - overwrite + move on template + + Background: + Given I maximize the window + And I am on homepage + +@reset-schema +Scenario: I move first a widget from template + Given the following WidgetMaps: + | id | action | position | parent | slot | view | + | 1 | create | | | main_content | base | + | 2 | create | after | 1 | main_content | base | + | 3 | create | before | 2 | main_content | base | + Given the following WidgetTexts: + | content | mode | widgetMap | + | Widget 1 | static | 1 | + | Widget 2 | static | 2 | + | Widget 3 | static | 3 | + And I am on the homepage + Then I should see "Widget 1" + When I move the widgetMap "3" "before" the widgetMap "1" + And I wait 2 seconds + And I reload the page + And "Widget 3" should precede "Widget 1" + And "Widget 1" should precede "Widget 2" + Then I am on "/fr/victoire-dcms/template/show/1" + And "Widget 1" should precede "Widget 3" + And "Widget 3" should precede "Widget 2" + +@reset-schema +Scenario: I move up a widget from template + Given the following WidgetMaps: + | id | action | position | parent | slot | view | + | 1 | create | | | main_content | base | + | 2 | create | after | 1 | main_content | base | + | 3 | create | before | 2 | main_content | base | + Given the following WidgetTexts: + | content | mode | widgetMap | + | Widget 1 | static | 1 | + | Widget 2 | static | 2 | + | Widget 3 | static | 3 | + And I am on the homepage + Then I should see "Widget 1" + When I move the widgetMap "2" "before" the widgetMap "3" + And I wait 2 seconds + And I reload the page + And "Widget 1" should precede "Widget 2" + And "Widget 2" should precede "Widget 3" + Then I am on "/fr/victoire-dcms/template/show/1" + And "Widget 1" should precede "Widget 3" + And "Widget 3" should precede "Widget 2" + +@reset-schema +Scenario: I move down a widget from template + Given the following WidgetMaps: + | id | action | position | parent | slot | view | + | 1 | create | | | main_content | base | + | 2 | create | after | 1 | main_content | base | + | 3 | create | before | 2 | main_content | base | + Given the following WidgetTexts: + | content | mode | widgetMap | + | Widget 1 | static | 1 | + | Widget 2 | static | 2 | + | Widget 3 | static | 3 | + And I am on the homepage + Then I should see "Widget 1" + When I move the widgetMap "1" "after" the widgetMap "2" + And I wait 2 seconds + And I reload the page + Then "Widget 3" should precede "Widget 2" + Then "Widget 2" should precede "Widget 1" + Then I am on "/fr/victoire-dcms/template/show/1" + And "Widget 1" should precede "Widget 3" + And "Widget 3" should precede "Widget 2" + +@reset-schema +Scenario: I add widget in a position from template + Given the following WidgetMaps: + | id | action | position | parent | slot | view | + | 1 | create | | | main_content | base | + | 2 | create | after | 1 | main_content | base | + | 3 | create | before | 2 | main_content | base | + Given the following WidgetTexts: + | content | mode | widgetMap | + | Widget 1 | static | 1 | + | Widget 2 | static | 2 | + | Widget 3 | static | 3 | + And I am on the homepage + Then I should see "Widget 1" + When I switch to "layout" mode + Then I should see "Nouveau Contenu" + When I select "Texte brut" from the "3" select of "main_content" slot + Then I should see "Créer" + When I fill in "Texte *" with "Widget 4" + And I submit the widget + And I reload the page + And "Widget 1" should precede "Widget 3" + And "Widget 3" should precede "Widget 4" + And "Widget 4" should precede "Widget 2" + Then I move the widgetMap "1" "after" the widgetMap "4" + And I wait 2 seconds + And I reload the page + Then "Widget 3" should precede "Widget 4" + Then "Widget 4" should precede "Widget 1" + Then "Widget 1" should precede "Widget 2" + Then I am on "/fr/victoire-dcms/template/show/1" + And "Widget 1" should precede "Widget 3" + And "Widget 3" should precede "Widget 2" + +@reset-schema +Scenario: I delete widget from template + Given the following WidgetMaps: + | id | action | position | parent | slot | view | + | 1 | create | | | main_content | base | + | 2 | create | after | 1 | main_content | base | + | 3 | create | before | 2 | main_content | base | + Given the following WidgetTexts: + | content | mode | widgetMap | + | Widget 1 | static | 1 | + | Widget 2 | static | 2 | + | Widget 3 | static | 3 | + And I am on the homepage + Then I should see "Widget 1" + When I switch to "edit" mode + And I edit the "Text" widget + Then I should see "Supprimer" + Given I follow "Supprimer" + Then I should see "Cette action va définitivement supprimer ce contenu. Cette action est irréversible. Êtes-vous sûr ?" + Given I press "J'ai bien compris, je confirme la suppression" + And I reload the page + And "Widget 3" should precede "Widget 2" + Then I am on "/fr/victoire-dcms/template/show/1" + And "Widget 1" should precede "Widget 3" + And "Widget 3" should precede "Widget 2" + +@reset-schema + Scenario: I overwrite a widget from template + Given the following WidgetMaps: + | id | action | position | parent | slot | view | + | 1 | create | | | main_content | base | + | 2 | create | after | 1 | main_content | base | + | 3 | create | before | 2 | main_content | base | + Given the following WidgetTexts: + | content | mode | widgetMap | + | Widget 1 | static | 1 | + | Widget 2 | static | 2 | + | Widget 3 | static | 3 | + And I am on the homepage + Then I should see "Widget 1" + When I switch to "edit" mode + And I edit the "Text" widget + Then I should see "Mettre à jour" + When I fill in "Texte *" with "Widget 1 overwrite" + And I submit the widget + And I should see "Widget 1 overwrite" + And "Widget 1 overwrite" should precede "Widget 3" + And "Widget 3" should precede "Widget 2" + Then I am on "/fr/victoire-dcms/template/show/1" + And "Widget 1" should precede "Widget 3" + And "Widget 3" should precede "Widget 2" + +@reset-schema +Scenario: I move an overwrite widget from template + Given the following WidgetMaps: + | id | action | position | parent | slot | view | + | 1 | create | | | main_content | base | + | 2 | create | after | 1 | main_content | base | + | 3 | create | before | 2 | main_content | base | + Given the following WidgetTexts: + | content | mode | widgetMap | + | Widget 1 | static | 1 | + | Widget 2 | static | 2 | + | Widget 3 | static | 3 | + | Widget 3 overwrite | static | 4 | + And I am on the homepage + Then I should see "Widget 1" + When I move the widgetMap "1" "after" the widgetMap "2" + And I wait 2 seconds + And I reload the page + Then "Widget 2" should precede "Widget 1" + Then I am on "/fr/victoire-dcms/template/show/1" + And "Widget 1" should precede "Widget 3" + And "Widget 3" should precede "Widget 2" + +@reset-schema +Scenario: I add a widget after an overwrite widget from template + Given the following WidgetMaps: + | id | action | position | parent | slot | view | replaced | + | 1 | create | | | main_content | base | | + | 2 | create | after | 1 | main_content | base | | + | 3 | create | before | 2 | main_content | base | | + | 4 | overwrite | before | 2 | main_content | home | 3 | + Given the following WidgetTexts: + | content | mode | widgetMap | + | Widget 1 | static | 1 | + | Widget 2 | static | 2 | + | Widget 3 | static | 3 | + | Widget 3 overwrite | static | 4 | + And I am on the homepage + Then "Widget 1" should precede "Widget 3 overwrite" + Then "Widget 3 overwrite" should precede "Widget 2" + When I switch to "layout" mode + Then I should see "Nouveau Contenu" + When I select "Texte brut" from the "3" select of "main_content" slot + Then I should see "Créer" + When I fill in "Texte *" with "Widget 4" + And I submit the widget + Then "Widget 1" should precede "Widget 3 overwrite" + Then "Widget 3 overwrite" should precede "Widget 4" + Then "Widget 4" should precede "Widget 2" + Then I am on "/fr/victoire-dcms/template/show/1" + And "Widget 1" should precede "Widget 3" + And "Widget 3" should precede "Widget 2" + +@reset-schema +Scenario: I delete an overwrite widget from template + Given the following WidgetMaps: + | id | action | position | parent | slot | view | replaced | + | 1 | create | | | main_content | base | | + | 2 | create | after | 1 | main_content | base | | + | 3 | create | before | 2 | main_content | base | | + | 4 | overwrite | before | 2 | main_content | home | 3 | + Given the following WidgetTexts: + | content | mode | widgetMap | + | Widget 1 | static | 1 | + | Widget 2 | static | 2 | + | Widget 3 | static | 3 | + | Widget 3 overwrite | static | 4 | + And I am on the homepage + When I switch to "edit" mode + And I press the "Widget 3 overwrite" content + Then I should see "Supprimer" + Given I follow "Supprimer" + Then I should see "Cette action va définitivement supprimer ce contenu. Cette action est irréversible. Êtes-vous sûr ?" + Given I press "J'ai bien compris, je confirme la suppression" + And I reload the page + Then I should see "Widget 1" + Then I should see "Widget 2" + Then I should see "Widget 3" + Then I should not see "Widget 3 overwrite" + Then I am on "/fr/victoire-dcms/template/show/1" + And "Widget 1" should precede "Widget 3" + And "Widget 3" should precede "Widget 2" + +@reset-schema +Scenario: I move an overwrite widget on template + Given the following WidgetMaps: + | id | action | position | parent | slot | view | replaced | + | 1 | create | | | main_content | base | | + | 2 | create | after | 1 | main_content | base | | + | 3 | create | before | 2 | main_content | base | | + | 4 | overwrite | before | 2 | main_content | home | 3 | + Given the following WidgetTexts: + | content | mode | widgetMap | + | Widget 1 | static | 1 | + | Widget 2 | static | 2 | + | Widget 3 | static | 3 | + | Widget 3 overwrite | static | 4 | + Then I am on "/fr/victoire-dcms/template/show/1" + When I switch to "edit" mode + When I move the widgetMap "3" "after" the widgetMap "2" + And I wait 2 seconds + And I reload the page + And "Widget 1" should precede "Widget 2" + And "Widget 2" should precede "Widget 3" + And I am on the homepage + Then "Widget 1" should precede "Widget 3 overwrite" + Then "Widget 3 overwrite" should precede "Widget 2" + +@reset-schema +Scenario: I add a widget after an overwrite widget on template + Given the following WidgetMaps: + | id | action | position | parent | slot | view | replaced | + | 1 | create | | | main_content | base | | + | 2 | create | after | 1 | main_content | base | | + | 3 | create | before | 2 | main_content | base | | + | 4 | overwrite | before | 2 | main_content | home | 3 | + Given the following WidgetTexts: + | content | mode | widgetMap | + | Widget 1 | static | 1 | + | Widget 2 | static | 2 | + | Widget 3 | static | 3 | + | Widget 3 overwrite | static | 4 | + Then I am on "/fr/victoire-dcms/template/show/1" + When I switch to "layout" mode + Then I should see "Nouveau Contenu" + When I select "Texte brut" from the "3" select of "main_content" slot + Then I should see "Créer" + When I fill in "Texte *" with "Widget 4" + And I submit the widget + And I reload the page + And "Widget 1" should precede "Widget 3" + And "Widget 3" should precede "Widget 4" + And "Widget 4" should precede "Widget 2" + When I am on the homepage + And "Widget 1" should precede "Widget 3 overwrite" + And "Widget 3 overwrite" should precede "Widget 4" + And "Widget 4" should precede "Widget 2" + +@reset-schema +Scenario: I delete an overwrite widget on template + Given the following WidgetMaps: + | id | action | position | parent | slot | view | replaced | + | 1 | create | | | main_content | base | | + | 2 | create | after | 1 | main_content | base | | + | 3 | create | before | 2 | main_content | base | | + | 4 | overwrite | before | 2 | main_content | home | 3 | + Given the following WidgetTexts: + | content | mode | widgetMap | + | Widget 1 | static | 1 | + | Widget 2 | static | 2 | + | Widget 3 | static | 3 | + | Widget 3 overwrite | static | 4 | + Then I am on "/fr/victoire-dcms/template/show/1" + When I switch to "edit" mode + And I press the "Widget 3" content + Then I should see "Supprimer" + Given I follow "Supprimer" + Then I should see "Cette action va définitivement supprimer ce contenu. Cette action est irréversible. Êtes-vous sûr ?" + Given I press "J'ai bien compris, je confirme la suppression" + And I reload the page + Then I should see "Widget 1" + Then I should see "Widget 2" + Then I should not see "Widget 3" + When I am on the homepage + Then I should see "Widget 1" + Then I should see "Widget 2" + Then I should see "Widget 3 overwrite"