Skip to content

Commit

Permalink
EWPP-1573: Update test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
sergepavle authored and upchuk committed Nov 30, 2022
1 parent 2a87229 commit 92431d7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion oe_theme.theme
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,10 @@ function oe_theme_preprocess_paragraph__oe_list_item(array &$variables): void {
$list_item_variant = $paragraph->get('oe_paragraphs_variant')->first()->value;
$variables['variant'] = $list_item_variant ?? 'default';
$url = $paragraph->get('field_oe_link')->first()->getUrl();
if (!in_array($url->getRouteName(), ['<nolink>', '<button>'])) {
if (!$url->isRouted() || !in_array($url->getRouteName(), [
'<nolink>',
'<button>',
])) {
$variables['url'] = $url;
$variables['external_link'] = \Drupal::service('oe_theme_helper.external_links')->isExternalLink($url);
}
Expand Down
11 changes: 11 additions & 0 deletions tests/src/Kernel/Paragraphs/ParagraphsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,19 @@ public function testListItem(): void {

$this->assertEquals('Druplicon', $image_element->attr('aria-label'));

$paragraph->set('field_oe_link', ['uri' => 'route:<nolink>']);
$paragraph->save();
$html = $this->renderParagraph($paragraph);
$crawler = new Crawler($html);

$link_element = $crawler->filter('article.ecl-card div.ecl-card__body h1.ecl-content-block__title a.ecl-link');
$this->assertCount(0, $link_element);
$title = $crawler->filter('article.ecl-card div.ecl-card__body h1.ecl-content-block__title');
$this->assertEquals('Item title', $title->text());

// Change the variant and test that the markup changed.
$paragraph->get('oe_paragraphs_variant')->setValue('block');
$paragraph->set('field_oe_link', ['uri' => 'http://www.example.com/']);
$paragraph->save();

$html = $this->renderParagraph($paragraph);
Expand Down

0 comments on commit 92431d7

Please sign in to comment.