From 9a40c6e356931aa5d5f34c3b58e3b94500e83a8f Mon Sep 17 00:00:00 2001 From: gloas <gloas@afi-sa.fr> Date: Wed, 15 Jun 2022 15:25:03 +0200 Subject: [PATCH] dev #156526 upgrade responsive behavior of rendering horizontal --- VERSIONS_WIP/156526 | 1 + .../templates/Herisson/Library/Settings.php | 3 - .../templates/Intonation/Library/Settings.php | 8 +- .../Templates/ChiliAccordionTest.php | 6 +- tests/scenarios/Templates/ChiliSearchTest.php | 6 +- .../TemplatesAbonneSelectionsTest.php | 2 +- .../Templates/TemplatesAbonneTest.php | 6 +- .../TemplatesRenderingHorizontalTest.php | 107 ++++++++++++++++++ .../Templates/TemplatesSearchSettingsTest.php | 2 +- .../Templates/TemplatesSearchTest.php | 6 +- 10 files changed, 126 insertions(+), 21 deletions(-) create mode 100644 VERSIONS_WIP/156526 create mode 100644 tests/scenarios/Templates/TemplatesRenderingHorizontalTest.php diff --git a/VERSIONS_WIP/156526 b/VERSIONS_WIP/156526 new file mode 100644 index 00000000000..f54c92d98b4 --- /dev/null +++ b/VERSIONS_WIP/156526 @@ -0,0 +1 @@ + - fonctionnalité #156526 : Magasin de thèmes : amélioration de l'adaptabilité de l'affichage média et description à droite. \ No newline at end of file diff --git a/library/templates/Herisson/Library/Settings.php b/library/templates/Herisson/Library/Settings.php index 769d56401c3..9eb49102fa9 100644 --- a/library/templates/Herisson/Library/Settings.php +++ b/library/templates/Herisson/Library/Settings.php @@ -116,9 +116,6 @@ class Herisson_Library_Settings extends Intonation_Library_Settings { $hydrating_mapping['div class card_article'] = 'col-12 mb-0 px-0'; $hydrating_mapping['div class card_action'] = 'col-12 col-md-5 col-lg-12 p-0 mx-1 my-1'; - $hydrating_mapping['div class cardify_horizontal_img'] = 'col-12 col-md-4 col-lg-3 px-0 pl-md-0 pr-md-3'; - $hydrating_mapping['div class cardify_horizontal_content'] = 'col-12 col-md-8 col-lg-6 px-0 py-3 py-md-0'; - $hydrating_mapping['div class cardify_horizontal_actions'] = 'col-12 col-md-12 col-lg-3 px-0 pl-lg-3 pr-lg-0'; $hydrating_mapping['div class card-header'] = 'px-0 py-0 no_background'; $hydrating_mapping['div class widget-header'] = 'card-header no_background'; diff --git a/library/templates/Intonation/Library/Settings.php b/library/templates/Intonation/Library/Settings.php index 8148cd73f2d..161225ec10c 100644 --- a/library/templates/Intonation/Library/Settings.php +++ b/library/templates/Intonation/Library/Settings.php @@ -141,7 +141,7 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'a class badge' => '', 'a class active' => '', 'a class card-link' => '', - 'div class card_action' => 'col col-sm-12 p-1 m-1', + 'div class card_action' => 'col col-lg-12 p-0 mx-1 my-1', 'div class collection_action' => 'col mr-3', 'div class alone_in_the_list' => 'col-3', 'a class list-group-item' => '', @@ -244,9 +244,9 @@ class Intonation_Library_Settings extends Intonation_System_Abstract { 'div class rich_content_actions' => 'col-12 px-0 mt-3 record_summary', 'div class rich_content_row_actions' => 'col col-lg-12 pt-1 mt-1 mr-1 pr-1 w-s_nowrap', - 'div class cardify_horizontal_img' => 'col-12 col-sm-3 px-3 px-sm-0', - 'div class cardify_horizontal_content' => 'col-12 col-sm-6 px-3', - 'div class cardify_horizontal_actions' => 'col-12 col-sm-3 px-3 px-sm-0', + 'div class cardify_horizontal_img' => 'col-12 col-md-4 col-lg-3 px-0 pl-md-0 pr-md-3', + 'div class cardify_horizontal_content' => 'col-12 col-md-8 col-lg-6 px-0 py-3 py-md-0', + 'div class cardify_horizontal_actions' => 'col-12 col-md-12 col-lg-3 px-0 pl-lg-3 pr-lg-0', 'div class loading_icon' => 'spinner-border', 'div class review_author' => 'col-12 col-lg-6 text-md-left', diff --git a/tests/scenarios/Templates/ChiliAccordionTest.php b/tests/scenarios/Templates/ChiliAccordionTest.php index 7e793c1342e..e6f417856ee 100644 --- a/tests/scenarios/Templates/ChiliAccordionTest.php +++ b/tests/scenarios/Templates/ChiliAccordionTest.php @@ -112,18 +112,18 @@ class ChiliAccordionWidgetTest extends AbstractControllerTestCase { /** @test */ public function cardifyHorizontalImgShouldBeHydratedWithCol12ColSm3Px3() { - $this->assertXPath('//div[@class = "cardify_horizontal_img col-12 col-sm-3 px-3 px-sm-0"]'); + $this->assertXPath('//div[@class = "cardify_horizontal_img col-12 col-md-4 col-lg-3 px-0 pl-md-0 pr-md-3"]'); } /** @test */ public function cardifyHorizontalContentShouldBeHydratedWithCol12ColSm6Px3() { - $this->assertXPath('//div[@class = "cardify_horizontal_content col-12 col-sm-6 px-3"]'); + $this->assertXPath('//div[@class = "cardify_horizontal_content col-12 col-md-8 col-lg-6 px-0 py-3 py-md-0"]'); } /** @test */ public function cardifyHorizontalActionsShouldBeHydratedWithCol12ColSm3Px3() { - $this->assertXPath('//div[@class = "cardify_horizontal_actions col-12 col-sm-3 px-3 px-sm-0"]'); + $this->assertXPath('//div[@class = "cardify_horizontal_actions col-12 col-md-12 col-lg-3 px-0 pl-lg-3 pr-lg-0"]'); } } diff --git a/tests/scenarios/Templates/ChiliSearchTest.php b/tests/scenarios/Templates/ChiliSearchTest.php index 1690a112eac..e4699e39080 100644 --- a/tests/scenarios/Templates/ChiliSearchTest.php +++ b/tests/scenarios/Templates/ChiliSearchTest.php @@ -76,21 +76,21 @@ class ChiliSearchHoldLinkTest extends AbstractControllerTestCase { /** @test */ public function linkToReserverRecord2ShouldBePickupLocationItem1() { - $this->assertXPathContentContains('//div[@class="card_action record_hold_link col col-sm-12 p-1 m-1"]//a[@href = "/recherche/reservation-pickup-ajax/id_notice/2/id_int_bib/1/id_bib/1/copy_id/1"][contains(@class, "record_hold_link")]', + $this->assertXPathContentContains('//div[@class="card_action record_hold_link col col-lg-12 p-0 mx-1 my-1"]//a[@href = "/recherche/reservation-pickup-ajax/id_notice/2/id_int_bib/1/id_bib/1/copy_id/1"][contains(@class, "record_hold_link")]', 'Réserver'); } /** @test */ public function viewMoreRecordActionsShouldBeInDivViewMoreRecordActions() { - $this->assertXPathContentContains('//div[@class="card_action view_more_record_actions btn col col-sm-12 p-1 m-1"]//button[@data-toggle="dropdown"]', + $this->assertXPathContentContains('//div[@class="card_action view_more_record_actions btn col col-lg-12 p-0 mx-1 my-1"]//button[@data-toggle="dropdown"]', 'Plus'); } /** @test */ public function readRecordShouldBeInADivReadDocument() { - $this->assertXPathContentContains('//div[@class="card_action read_document col col-sm-12 p-1 m-1"]//a[contains(@href,"recherche/viewnotice")]', + $this->assertXPathContentContains('//div[@class="card_action read_document col col-lg-12 p-0 mx-1 my-1"]//a[contains(@href,"recherche/viewnotice")]', 'Voir'); } diff --git a/tests/scenarios/Templates/TemplatesAbonneSelectionsTest.php b/tests/scenarios/Templates/TemplatesAbonneSelectionsTest.php index d991a9e316f..86c7172ee1e 100644 --- a/tests/scenarios/Templates/TemplatesAbonneSelectionsTest.php +++ b/tests/scenarios/Templates/TemplatesAbonneSelectionsTest.php @@ -488,7 +488,7 @@ class TemplatesAbonneSelectionsAsAdminTest extends Admin_AbstractControllerTestC /** @test */ public function listeDesDocumentsShouldNotBeDisplayed() { - $this->assertNotXPathContentContains('//main//div[contains(@class, "cardify_horizontal_content")]//div', 'Liste des documents'); + $this->assertNotXPathContentContains('//body', 'Liste des documents'); } } diff --git a/tests/scenarios/Templates/TemplatesAbonneTest.php b/tests/scenarios/Templates/TemplatesAbonneTest.php index ed7b7f84f1e..fcb66e4168d 100644 --- a/tests/scenarios/Templates/TemplatesAbonneTest.php +++ b/tests/scenarios/Templates/TemplatesAbonneTest.php @@ -458,7 +458,7 @@ class TemplatesAbonnePaginatedReviewsPage2Test extends TemplatesAbonnePaginatedC /** @test */ public function defaultLayoutShouldBeCardHorizontal() { - $this->assertXPath('//div[@class="list-group bg-transparent no_border"]//div[@class="cardify_horizontal_img col-12 col-sm-3 px-3 px-sm-0"]'); + $this->assertXPath('//div[@class="list-group bg-transparent no_border"]//div[@class="cardify_horizontal_img col-12 col-md-4 col-lg-3 px-0 pl-md-0 pr-md-3"]'); } } @@ -494,14 +494,14 @@ class TemplatesAbonnePaginatedLoansPage1AndSearchTest extends TemplatesAbonnePag /** @test */ public function linkToReturnPnbLoanShouldBePresent() { - $this->assertXPathContentContains('//div[@class="card_action col col-sm-12 p-1 m-1"]/a[@href= "/bib-numerique/return-pnb-loan/page/1/search/house/size/10/id/ec2c17cefacacad7f25f875ae87956c1/loan_id/666_3"]', + $this->assertXPathContentContains('//div[@class="card_action col col-lg-12 p-0 mx-1 my-1"]/a[@href= "/bib-numerique/return-pnb-loan/page/1/search/house/size/10/id/ec2c17cefacacad7f25f875ae87956c1/loan_id/666_3"]', utf8_encode('Retour anticipé')); } /** @test */ public function linkToExtendPnbLoanShouldBePresent() { - $this->assertXPathContentContains('//div[@class="card_action col col-sm-12 p-1 m-1"]/a[contains(@href, "/bib-numerique/extends-pnb-loan/page/1/search/house/size/10/id/ec2c17cefacacad7f25f875ae87956c1/loan_id/666_3")]', + $this->assertXPathContentContains('//div[@class="card_action col col-lg-12 p-0 mx-1 my-1"]/a[contains(@href, "/bib-numerique/extends-pnb-loan/page/1/search/house/size/10/id/ec2c17cefacacad7f25f875ae87956c1/loan_id/666_3")]', 'Prolonger'); } } diff --git a/tests/scenarios/Templates/TemplatesRenderingHorizontalTest.php b/tests/scenarios/Templates/TemplatesRenderingHorizontalTest.php new file mode 100644 index 00000000000..e72402b5678 --- /dev/null +++ b/tests/scenarios/Templates/TemplatesRenderingHorizontalTest.php @@ -0,0 +1,107 @@ +<?php +/** + * Copyright (c) 2012-2022, Agence Française Informatique (AFI). All rights reserved. + * + * BOKEH is free software; you can redistribute it and/or modify + * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by + * the Free Software Foundation. + * + * There are special exceptions to the terms and conditions of the AGPL as it + * is applied to this software (see README file). + * + * BOKEH is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE + * along with BOKEH; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +abstract class TemplatesRenderingHorizontalTestCase extends AbstractControllerTestCase { + + protected $_template_name = ''; + + + public function setUp() { + parent::setUp(); + + $profile = $this->_buildTemplateProfil(['id' => '878979', + 'template' => $this->_template_name]); + + $profile_patcher = (new Class_Template_ProfilePatcher(null)) + ->setProfile($profile); + + $profile_patcher + ->addWidget(Intonation_Library_Widget_Carousel_Newsletter_Definition::CODE, + Class_Profil::DIV_MAIN, + ['rendering' => 'card-horizontal', + 'layout' => 'list', + 'size' => 1, + 'id_items' => '789']); + + $this->fixture(Class_Newsletter::class, + ['id' => 789, + 'titre' => 'Comment améliorer le magasin de thèmes en quelques commits ?', + 'mail_subject' => 'Comment améliorer le magasin de thèmes en quelques commits ?', + 'contenu' => 'Un bon pairing à Annecy']); + + $this->dispatch('/index'); + } + + + /** @test */ + public function divClassCardifyHorizontalImgShouldHaveClassCol12ColMd4ColLg3() { + $this->assertXPath('//div[@class="cardify_horizontal_img col-12 col-md-4 col-lg-3 px-0 pl-md-0 pr-md-3"]'); + } + + + /** @test */ + public function divClassCardifyHorizontalContentShouldHaveClassCol12ColMd8ColLg6() { + $this->assertXPath('//div[@class="cardify_horizontal_content col-12 col-md-8 col-lg-6 px-0 py-3 py-md-0"]'); + } + + + /** @test */ + public function divClassCardifyHorizontalActionsShouldHaveClassCol12ColMd12ColLg3() { + $this->assertXPath('//div[@class="cardify_horizontal_actions col-12 col-md-12 col-lg-3 px-0 pl-lg-3 pr-lg-0"]'); + } + + + /** @test */ + public function divClassCardActionShouldHaveClassColColLg12() { + $this->assertXPath('//div[@class="card_action col col-lg-12 p-0 mx-1 my-1"]'); + } +} + + + + +class TemplatesRenderingHorizontalInIntonationTest extends TemplatesRenderingHorizontalTestCase { + + protected $_template_name = 'INTONATION'; +} + + + + +class TemplatesRenderingHorizontalInHerissonTest extends TemplatesRenderingHorizontalTestCase { + + protected $_template_name = 'HERISSON'; + + + /** @test */ + public function divClassCardActionShouldHaveClassColColLg12() { + $this->assertXPath('//div[@class="card_action col-12 col-md-5 col-lg-12 p-0 mx-1 my-1"]'); + } +} + + + + +class TemplatesRenderingHorizontalInChiliTest extends TemplatesRenderingHorizontalTestCase { + + protected $_template_name = 'CHILI'; +} diff --git a/tests/scenarios/Templates/TemplatesSearchSettingsTest.php b/tests/scenarios/Templates/TemplatesSearchSettingsTest.php index d3f28d1f461..cadeff70c1d 100644 --- a/tests/scenarios/Templates/TemplatesSearchSettingsTest.php +++ b/tests/scenarios/Templates/TemplatesSearchSettingsTest.php @@ -78,7 +78,7 @@ class TemplatesSearchSettingsResultWithSearchTermHighLightedTest /** @test */ public function cardLinkReadDocumentTitleShouldNotContainsHTML() { - $this->assertXPath('//div[@class="card_action read_document col col-sm-12 p-1 m-1"]//a[@href="/recherche/viewnotice/id/1/expressionRecherche/ero+Odiar"][@title="Voir le document Un héros très discret"]'); + $this->assertXPath('//div[@class="card_action read_document col col-lg-12 p-0 mx-1 my-1"]//a[@href="/recherche/viewnotice/id/1/expressionRecherche/ero+Odiar"][@title="Voir le document Un héros très discret"]'); } } diff --git a/tests/scenarios/Templates/TemplatesSearchTest.php b/tests/scenarios/Templates/TemplatesSearchTest.php index 9108e566b76..44703a03020 100644 --- a/tests/scenarios/Templates/TemplatesSearchTest.php +++ b/tests/scenarios/Templates/TemplatesSearchTest.php @@ -21,8 +21,8 @@ require_once 'TemplatesTest.php'; -abstract class TemplatesSearchWithSortParameterInWidgetTestCase extends Admin_AbstractControllerTestCase { - protected $_storm_default_to_volatile = true; +abstract class TemplatesSearchWithSortParameterInWidgetTestCase + extends AbstractControllerTestCase { public function setUp() { parent::setUp(); @@ -1177,7 +1177,7 @@ class TemplatesSearchResultWithSearchTermHighLightedTest extends AbstractControl /** @test */ public function cardLinkReadDocumentTitleShouldNotContainsHTML() { - $this->assertXPathContentContains('//div[@class="card_action read_document col col-sm-12 p-1 m-1"]//a[@href="/recherche/viewnotice/id/1/expressionRecherche/ero+Odiar"][@title="Voir le document Un héros très discret"]//span[@class="sr-only"]', + $this->assertXPathContentContains('//div[@class="card_action read_document col col-lg-12 p-0 mx-1 my-1"]//a[@href="/recherche/viewnotice/id/1/expressionRecherche/ero+Odiar"][@title="Voir le document Un héros très discret"]//span[@class="sr-only"]', ' le document Un héros très discret de Heros Audiard de type '); } -- GitLab