From 7779dba7e55f1825eac7f85540b9a235a9bf3942 Mon Sep 17 00:00:00 2001 From: 22Alexandra Date: Sun, 14 Jan 2024 12:54:02 +0200 Subject: [PATCH] EWPP-3875: Update News CT rendering tests. --- tests/src/Functional/ContentNewsRenderTest.php | 9 +++------ tests/src/Functional/ContentRenderTestBase.php | 2 +- tests/src/Kernel/NewsRenderTest.php | 1 - tests/src/PatternAssertions/ListItemAssert.php | 4 ++-- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/tests/src/Functional/ContentNewsRenderTest.php b/tests/src/Functional/ContentNewsRenderTest.php index 369b673a5..7f1a3ae83 100644 --- a/tests/src/Functional/ContentNewsRenderTest.php +++ b/tests/src/Functional/ContentNewsRenderTest.php @@ -45,7 +45,6 @@ protected function setUp(): void { * Tests that the News page renders correctly. */ public function testNewsRendering(): void { - $this->markTestSkipped('Must be re-enabled before considering migration to ECL 4 as complete.'); // Create a News node. /** @var \Drupal\node\Entity\Node $node */ $node = $this->getStorage('node')->create([ @@ -69,7 +68,7 @@ public function testNewsRendering(): void { $this->drupalGet($node->toUrl()); // Assert page header - metadata. - $page_header = $this->assertSession()->elementExists('css', '.ecl-page-header.ecl-page-header--negative'); + $page_header = $this->assertSession()->elementExists('css', '.ecl-page-header'); $assert = new PatternPageHeaderAssert(); $expected_values = [ 'title' => 'Test news node', @@ -249,11 +248,9 @@ public function testNewsRendering(): void { $this->drupalGet($node->toUrl()); $this->assertEquals('Related links', $this->assertSession()->elementExists('css', 'h2.ecl-u-type-heading-2:nth-child(8)')->getText()); $first_related_link = $this->assertSession()->elementExists('css', 'div.ecl-u-border-bottom.ecl-u-border-color-grey-15.ecl-u-pt-m.ecl-u-pb-m:nth-child(9) a'); - $this->assertEquals('/build/node', $first_related_link->getAttribute('href')); - $this->assertEquals('Node listing', $first_related_link->getText()); + $this->assertLinkIcon($first_related_link, 'Node listing', '/build/node', FALSE, 'xs'); $second_related_link = $this->assertSession()->elementExists('css', 'div.ecl-u-border-bottom.ecl-u-border-color-grey-15.ecl-u-pt-m.ecl-u-pb-m:nth-child(10) a'); - $this->assertEquals('https://example.com', $second_related_link->getAttribute('href')); - $this->assertEquals('External link', $second_related_link->getText()); + $this->assertLinkIcon($second_related_link, 'External link', 'https://example.com', TRUE, 'xs'); } } diff --git a/tests/src/Functional/ContentRenderTestBase.php b/tests/src/Functional/ContentRenderTestBase.php index da25b5800..2a31ed7da 100644 --- a/tests/src/Functional/ContentRenderTestBase.php +++ b/tests/src/Functional/ContentRenderTestBase.php @@ -468,7 +468,7 @@ protected function assertContentHeader(NodeElement $element, string $title, stri * Icon size. */ protected function assertLinkIcon(NodeElement $element, string $title, string $href, bool $is_external = TRUE, string $icon_size = 's'): void { - $link = $element->findAll('css', 'a.ecl-link.ecl-link--standalone.ecl-link--icon.ecl-link--icon-after'); + $link = $element->findAll('css', 'a.ecl-link.ecl-link--standalone.ecl-link--icon'); $this->assertCount(1, $link); $this->assertEquals($href, $link[0]->getAttribute('href')); diff --git a/tests/src/Kernel/NewsRenderTest.php b/tests/src/Kernel/NewsRenderTest.php index b9c72ba0a..e53e36c0c 100644 --- a/tests/src/Kernel/NewsRenderTest.php +++ b/tests/src/Kernel/NewsRenderTest.php @@ -32,7 +32,6 @@ protected function setUp(): void { * Tests News node type rendered as teaser. */ public function testNewsTeaser(): void { - $this->markTestSkipped('Must be re-enabled before considering migration to ECL 4 as complete.'); $file = \Drupal::service('file.repository')->writeData(file_get_contents(\Drupal::service('extension.list.theme')->getPath('oe_theme') . '/tests/fixtures/example_1.jpeg'), 'public://example_1.jpeg'); $file->setPermanent(); $file->save(); diff --git a/tests/src/PatternAssertions/ListItemAssert.php b/tests/src/PatternAssertions/ListItemAssert.php index 4c83d3113..c2fa67b68 100644 --- a/tests/src/PatternAssertions/ListItemAssert.php +++ b/tests/src/PatternAssertions/ListItemAssert.php @@ -37,11 +37,11 @@ protected function getAssertions($variant): array { return [ 'title' => [ [$this, 'assertElementText'], - 'article.ecl-content-item div.ecl-content-item__content-block h1.ecl-content-block__title', + 'article.ecl-content-item div.ecl-content-item__content-block div.ecl-content-block__title', ], 'url' => [ [$this, 'assertElementAttribute'], - 'article.ecl-content-item div.ecl-content-item__content-block h1.ecl-content-block__title a.ecl-link.ecl-link--standalone', + 'article.ecl-content-item div.ecl-content-item__content-block div.ecl-content-block__title a.ecl-link.ecl-link--standalone', 'href', ], 'meta' => [