Skip to content

Commit

Permalink
Merge pull request #163 from openeuropa/OEL-1326
Browse files Browse the repository at this point in the history
OEL-1326: Cleaning patterns & paragraphs from OEL-755
  • Loading branch information
brummbar authored Aug 5, 2022
2 parents 09b13a2 + 0cb544b commit 7c8b67e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"https://www.drupal.org/project/entity_reference_revisions/issues/2937835": "https://www.drupal.org/files/issues/2021-03-26/entity_reference_revisions-field_formatter_label-2937835-36.patch"
},
"openeuropa/oe_bootstrap_theme": {
"latest": "https://github.com/openeuropa/oe_bootstrap_theme/compare/1.0.0-beta4...1.x.diff"
"temporary ticket patch": "https://patch-diff.githubusercontent.com/raw/openeuropa/oe_bootstrap_theme/pull/250.diff"
}
},
"drupal-scaffold": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,10 @@ function oe_whitelabel_preprocess_paragraph__oe_list_item_block(array &$variable
$card_badges[] = $meta_item->value;
}

$card_title = $card_paragraph->get('field_oe_title')->value;
/** @var \Drupal\link\LinkItemInterface|null $card_link_item */
$card_link_item = $card_paragraph->get('field_oe_link')->first();
$variables['items'][] = [
'title' => $card_title,
'title' => $card_paragraph->get('field_oe_title')->value,
'url' => $card_link_item ? $card_link_item->getUrl() : '',
'text' => $card_paragraph->get('field_oe_text_long')->value,
'image' => $card_image,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ protected function setUp(): void {
* Test List Items Block paragraph rendering.
*/
public function testListing(): void {

// Create a sample media entity to be embedded.
$image_file = File::create([
'uri' => $this->getTestFiles('image')[0]->uri,
Expand All @@ -50,7 +49,6 @@ public function testListing(): void {
]);

$node = $this->createNode([
'created' => 1636977600,
'type' => 'article',
]);
$nid = (int) $node->id();
Expand All @@ -75,8 +73,7 @@ public function testListing(): void {
$assert->assertDefaultListingRendering($crawler, $image_file);
$this->assertCount(1, $crawler->filter('div.bcl-listing--default-1-col'));
$this->assertCount(1, $crawler->filter('div.row.row-cols-1'));
$this->assertCount(6, $crawler->filter('div.col-md-3.col-lg-2.rounded'));
$this->assertCount(6, $crawler->filter('div.col-md-9.col-lg-10'));
$this->assertCount(6, $crawler->filter('div.card-body'));

// Testing Default 2 col.
$paragraph->get('field_oe_list_item_block_layout')->setValue('two_columns');
Expand All @@ -88,9 +85,8 @@ public function testListing(): void {
$assert->assertListingRendering($crawler, $nid);
$assert->assertDefaultListingRendering($crawler, $image_file);
$this->assertCount(1, $crawler->filter('div.bcl-listing--default-2-col'));
$this->assertCount(1, $crawler->filter('div.row.row-cols-1.row-cols-md-2'));
$this->assertCount(6, $crawler->filter('div.col-xl-3.col-md-5'));
$this->assertCount(6, $crawler->filter('div.col-xl-9.col-md-7'));
$this->assertCount(1, $crawler->filter('div.row.row-cols-1'));
$this->assertCount(6, $crawler->filter('div.card-body'));

// Testing Default 3 col.
$paragraph->get('field_oe_list_item_block_layout')->setValue('three_columns');
Expand All @@ -102,9 +98,8 @@ public function testListing(): void {
$assert->assertListingRendering($crawler, $nid);
$assert->assertDefaultListingRendering($crawler, $image_file);
$this->assertCount(1, $crawler->filter('div.bcl-listing--default-3-col'));
$this->assertCount(1, $crawler->filter('div.row.row-cols-1.row-cols-md-2.row-cols-xl-3'));
$this->assertCount(6, $crawler->filter('div.col-lg-4.col-md-6'));
$this->assertCount(6, $crawler->filter('div.col-lg-8.col-md-6'));
$this->assertCount(1, $crawler->filter('div.row.row-cols-1'));
$this->assertCount(6, $crawler->filter('div.card-body'));

// Testing Highlight 1 col.
$paragraph->get('oe_paragraphs_variant')->setValue('highlight');
Expand All @@ -118,7 +113,6 @@ public function testListing(): void {
$assert->assertHighlightListingRendering($crawler, $image_file);
$this->assertCount(1, $crawler->filter('div.bcl-listing--highlight-1-col'));
$this->assertCount(1, $crawler->filter('div.row.row-cols-1'));
$this->assertCount(6, $crawler->filter('div.col.mt-4-5'));
$this->assertCount(6, $crawler->filter('div.card-body'));

// Testing Highlight 2 col.
Expand Down Expand Up @@ -174,7 +168,6 @@ protected function createListItems(File $image_file, Node $node): array {
'alt' => 'Alt for image ' . $i,
'target_id' => $image_file->id(),
],
'field_oe_date' => '2011-11-13',
'field_oe_meta' => [
0 => [
'value' => 'Label 1 - ' . $i,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ public function assertListingRendering(Crawler $crawler, int $nid): void {
$this->assertCount(6, $crawler->filter('div.row-cols-1.g-4 > div.col'));
$this->assertStringContainsString('Listing item block title', trim($crawler->filter('h2.bcl-heading')->text()));
$this->assertCount(6, $crawler->filter('h1.card-title'));
$link_element = $crawler->filter('a.text-underline-hover');
$link_element = $crawler->filter('a.standalone');
$this->assertCount(6, $link_element);
$this->assertStringContainsString(
'node/' . $nid,
$link_element->attr('href')
);
$text_element = $crawler->filter('div.card-text');
$this->assertStringContainsString('Item title 1', trim($crawler->filter('h1.card-title > a.text-underline-hover')->text()));
$this->assertStringContainsString('Item title 1', trim($crawler->filter('h1.card-title > a.standalone')->text()));
$this->assertStringContainsString('Label 1 - 1', trim($crawler->filter('span.badge')->eq(0)->text()));
$this->assertStringContainsString('Label 2 - 1', trim($crawler->filter('span.badge')->eq(1)->text()));
$this->assertStringContainsString(
Expand Down

0 comments on commit 7c8b67e

Please sign in to comment.