Skip to content

Commit

Permalink
Merge pull request #877 from openeuropa/EWPP-1317
Browse files Browse the repository at this point in the history
[EWPP-1142] EWPP-1317: Update FeaturedItemAssert classes and patch twig card component.
  • Loading branch information
ademarco authored Jul 20, 2021
2 parents 5980e59 + 65d2a49 commit 5ceada6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
12 changes: 12 additions & 0 deletions patches/@ecl/twig-component-card+3.0.0-beta.1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
patch-package
--- a/node_modules/@ecl/twig-component-card/card.html.twig
+++ b/node_modules/@ecl/twig-component-card/card.html.twig
@@ -99,7 +99,7 @@

<div class="ecl-card__body">
{% if _card.meta is not empty %}
- <div class="ecl-card__meta">{{ _card.meta|join(" | ") }}</div>
+ <div class="ecl-card__meta">{{ _card.meta|safe_join(" | ") }}</div>
{% endif %}
{% if _card.title is not empty %}
<h1 class="ecl-card__title">
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
{% endif %}
{% endif %}


{% include '@ecl-twig/language-list' with {
eu_category: eu_category,
non_eu_category: non_eu_category,
Expand All @@ -27,6 +26,6 @@
icon_path: ecl_icon_path,
logo: {
alt: 'European Commission logo'|t,
path: ecl_logo_path ~ '/logo--mute.svg'
path: ecl_logo_path ~ '/logo-' ~ ecl_component_library ~ '--mute.svg'
}
} only %}
10 changes: 5 additions & 5 deletions tests/PatternAssertions/FeaturedItemAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ protected function getAssertions($variant): array {
return [
'title' => [
[$this, 'assertElementText'],
'article.ecl-card header.ecl-card__header h1.ecl-card__title a.ecl-link',
'article.ecl-card .ecl-card__body h1.ecl-card__title a.ecl-link',
],
'link' => [
[$this, 'assertLink'],
Expand All @@ -34,7 +34,7 @@ protected function getAssertions($variant): array {
],
'meta' => [
[$this, 'assertElementText'],
'article.ecl-card header.ecl-card__header div.ecl-card__meta',
'article.ecl-card .ecl-card__body div.ecl-card__meta',
],
'footer_items' => [
[$this, 'assertFooterItems'],
Expand Down Expand Up @@ -63,7 +63,7 @@ protected function assertBaseElements(string $html, string $variant): void {
* The DomCrawler where to check the element.
*/
protected function assertFeaturedItemImage($expected_image, string $variant, Crawler $crawler): void {
$image_div_selector = 'article.ecl-card header.ecl-card__header div.ecl-card__image';
$image_div_selector = 'article.ecl-card div.ecl-card__image';
if (is_null($expected_image)) {
$this->assertElementNotExists($image_div_selector, $crawler);
return;
Expand All @@ -85,7 +85,7 @@ protected function assertFeaturedItemImage($expected_image, string $variant, Cra
*/
protected function assertLink($expected_link, string $variant, Crawler $crawler): void {
// Assert the title url points to the correct direction.
$this->assertElementAttribute($expected_link['href'], 'article.ecl-card header.ecl-card__header h1.ecl-card__title a.ecl-link', 'href', $crawler);;
$this->assertElementAttribute($expected_link['href'], 'article.ecl-card .ecl-card__body h1.ecl-card__title a.ecl-link', 'href', $crawler);;

// If the variant is extended, assert that the button is correct.
if ($variant == 'extended') {
Expand All @@ -103,7 +103,7 @@ protected function assertLink($expected_link, string $variant, Crawler $crawler)
* The DomCrawler where to check the element.
*/
protected function assertFooterItems($expected_info_items, Crawler $crawler): void {
$info_elements = $crawler->filter('article.ecl-card footer.ecl-card__footer ul.ecl-card__info-container li.ecl-card__info-item');
$info_elements = $crawler->filter('article.ecl-card div.ecl-card__body ul.ecl-card__info-container li.ecl-card__info-item');
self::assertCount(count($expected_info_items), $info_elements, 'The expected info items do not match the found info items.');
foreach ($expected_info_items as $index => $expected_info_item) {
$info_element = $info_elements->eq($index);
Expand Down

0 comments on commit 5ceada6

Please sign in to comment.