Skip to content

Commit

Permalink
EWPP-3875: Update News CT rendering tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
22Alexandra committed Jan 16, 2024
1 parent cf5035f commit 7779dba
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 10 deletions.
9 changes: 3 additions & 6 deletions tests/src/Functional/ContentNewsRenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand All @@ -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',
Expand Down Expand Up @@ -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');
}

}
2 changes: 1 addition & 1 deletion tests/src/Functional/ContentRenderTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));

Expand Down
1 change: 0 additions & 1 deletion tests/src/Kernel/NewsRenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions tests/src/PatternAssertions/ListItemAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [
Expand Down

0 comments on commit 7779dba

Please sign in to comment.