diff --git a/web/modules/custom/server_general/src/Plugin/EntityViewBuilder/NodeNews.php b/web/modules/custom/server_general/src/Plugin/EntityViewBuilder/NodeNews.php index 0253e387d..c5dcb6dba 100644 --- a/web/modules/custom/server_general/src/Plugin/EntityViewBuilder/NodeNews.php +++ b/web/modules/custom/server_general/src/Plugin/EntityViewBuilder/NodeNews.php @@ -128,7 +128,7 @@ public function buildTeaser(array $build, NodeInterface $entity) { */ public function buildFeatured(array $build, NodeInterface $entity) { $media = $this->getReferencedEntityFromField($entity, 'field_featured_image'); - $image = $media instanceof MediaInterface ? $this->buildImageStyle($media, 'card', 'field_media_image') : NULL; + $image = $media instanceof MediaInterface ? $this->buildImageStyle($media, 'card', 'field_media_image') : []; $title = $entity->label(); $url = $entity->toUrl(); $summary = $this->buildProcessedText($entity, 'field_body'); diff --git a/web/modules/custom/server_general/tests/src/ExistingSite/ServerGeneralHomepageTest.php b/web/modules/custom/server_general/tests/src/ExistingSite/ServerGeneralHomepageTest.php deleted file mode 100644 index 2401f616b..000000000 --- a/web/modules/custom/server_general/tests/src/ExistingSite/ServerGeneralHomepageTest.php +++ /dev/null @@ -1,37 +0,0 @@ -drupalGet(''); - /** @var \Drupal\FunctionalJavascriptTests\JSWebAssert $web_assert */ - $web_assert = $this->assertSession(); - - $featured_content = $web_assert->waitForElement('css', '.paragraph--type--related-content'); - $this->assertNotNull($featured_content); - $web_assert->elementTextContains('css', '.paragraph--type--related-content h2', 'Featured Content'); - // Slick is initialized. - $carousel = $web_assert->waitForElement('css', '.paragraph--type--related-content .carousel-wrapper.slick-initialized'); - $this->assertNotNull($carousel); - - // Assert the current slide has the expected title. - $web_assert->elementTextContains('css', '.paragraph--type--related-content .carousel-slide.slick-current', 'Current Digital Marketing Is Sports-Watching, Rather Than Marketing'); - // Click on the 2nd dot navigation. - $dots_2 = $carousel->find('css', '.slick-dots li:nth-child(2)'); - $this->assertNotNull($dots_2); - $dots_2->click(); - // Wait half sec for the JS and animation. - $this->getSession()->wait(500); - // Assert that the active slide is now different. - $web_assert->elementTextContains('css', '.paragraph--type--related-content .carousel-slide.slick-current', 'Pandemic Moves Education Online'); - } - -} diff --git a/web/modules/custom/server_general/tests/src/ExistingSite/ServerGeneralRelatedContentFeaturedTest.php b/web/modules/custom/server_general/tests/src/ExistingSite/ServerGeneralRelatedContentFeaturedTest.php new file mode 100644 index 000000000..86796b406 --- /dev/null +++ b/web/modules/custom/server_general/tests/src/ExistingSite/ServerGeneralRelatedContentFeaturedTest.php @@ -0,0 +1,81 @@ +createNode([ + 'type' => 'news', + 'title' => $first_news_title, + 'status' => NodeInterface::PUBLISHED, + 'moderation_state' => 'published', + ]); + + $second_news = $this->createNode([ + 'type' => 'news', + 'title' => $second_news_title, + 'status' => NodeInterface::PUBLISHED, + 'moderation_state' => 'published', + ]); + + $featured_content_paragraph = $this->createParagraph([ + 'type' => 'related_content', + 'field_title' => 'Featured Content', + 'field_is_featured' => 1, + 'field_related_content' => [ + ['target_id' => $first_news->id()], + ['target_id' => $second_news->id()], + ], + ]); + + $landing_page = $this->createNode([ + 'type' => 'landing_page', + 'title' => $this->randomString(), + 'status' => NodeInterface::PUBLISHED, + 'moderation_state' => 'published', + 'field_paragraphs' => [ + [ + 'target_id' => $featured_content_paragraph->id(), + 'target_revision_id' => $featured_content_paragraph->getRevisionId(), + ], + ], + ]); + + $this->drupalGet($landing_page->toUrl()); + /** @var \Drupal\FunctionalJavascriptTests\JSWebAssert $web_assert */ + $web_assert = $this->assertSession(); + + $featured_content = $web_assert->waitForElement('css', '.paragraph--type--related-content'); + $this->assertNotNull($featured_content); + $web_assert->elementTextContains('css', '.paragraph--type--related-content h2', 'Featured Content'); + // Slick is initialized. + $carousel = $web_assert->waitForElement('css', '.paragraph--type--related-content .carousel-wrapper.slick-initialized'); + $this->assertNotNull($carousel); + + // Assert the current slide has the expected title. + $web_assert->elementTextContains('css', '.paragraph--type--related-content .carousel-slide.slick-current', $first_news_title); + // Click on the 2nd dot navigation. + $dots_2 = $carousel->find('css', '.slick-dots li:nth-child(2)'); + $this->assertNotNull($dots_2); + $dots_2->click(); + // Wait half sec for the JS and animation. + $this->getSession()->wait(500); + // Assert that the active slide is now different. + $web_assert->elementTextContains('css', '.paragraph--type--related-content .carousel-slide.slick-current', $second_news_title); + } +}