Skip to content

Commit

Permalink
Sites 19919 1 (#2694)
Browse files Browse the repository at this point in the history
* [SITES-19919] Fixed List (v4) missing teaser image for page with external redirect

Jira: https://jira.corp.adobe.com/browse/SITES-19919
There are 3 distinct cases:
* internal page list item
* internal page list item with external redirect
* external page list item

First and third cases were handled correctly
But in the second case the page was treated as external (3rd case) leading to the missing teaser image
The current fix makes sure that in the 2nd case the page is considered internal just like in the 1st case

* SITES-19919: add tests

* Change Test name

* SITES-19919: fix tests

* SITES-19919: improve test mocking

---------

Co-authored-by: Igor Myronenko <igor@adobe.com>
  • Loading branch information
hrayrpapikyan and Igor Myronenko committed Mar 19, 2024
1 parent 8fbb567 commit d6699e5
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public Collection<ListItem> getListItems() {
private Collection<ListItem> getStaticListItems() {
Stream<AbstractListItemImpl> itemStream = getStaticItemResourceStream().map(linkResource -> {
Link link = linkManager.get(linkResource).build();
if (LinkManagerImpl.isExternalLink(link.getURL())) {
if (LinkManagerImpl.isExternalLink(link.getURL()) && (link.getReference() == null)) {
return new ExternalLinkListItemImpl(link, linkResource, getId(), component);
} else {
Object reference = link.getReference();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ public void testList() throws ClientException, IOException {
.select(".list.list-v4", 2).expect("list-v4-static-pages-and-links.html")
.select(".list.list-v4", 3).expect("list-v4-static-pages-linked-description-modified.html")
.select(".list.list-v4", 4).expect("list-v4-static-pages-linked-description-modifieddate-teaser.html")
.select(".list.list-v4", 5).expect("list-v4-static-pages-empty.html");
.select(".list.list-v4", 5).expect("list-v4-static-internal-pages-containing-external-redirect.html")
.select(".list.list-v4", 6).expect("list-v4-static-pages-empty.html");

}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<div class="list-v4 list">
<ul class="cmp-list" data-cmp-data-layer="{&quot;list-v4-c9b2ee1865&quot;:{&quot;@type&quot;:&quot;core-component/components/list-v4&quot;}}" id="list-v4-c9b2ee1865">
<li class="cmp-list__item" data-cmp-data-layer="{&quot;list-v4-c9b2ee1865-item-5a69939138&quot;:{&quot;@type&quot;:&quot;core-component/components/list-v4/item&quot;,&quot;dc:title&quot;:&quot;List&quot;,&quot;repo:modifyDate&quot;:&quot;0000-00-00T00:00:00Z&quot;,&quot;xdm:linkURL&quot;:&quot;/content/core-components/list.html&quot;}}">
<div class="cmp-teaser" data-cmp-data-layer="{&quot;teaser-v2-c9b2ee1865&quot;:{&quot;@type&quot;:&quot;core-component/components/teaser-v2&quot;,&quot;dc:title&quot;:&quot;List&quot;,&quot;xdm:linkURL&quot;:&quot;/content/core-components/list.html&quot;}}" id="teaser-v2-c9b2ee1865">
<a class="cmp-teaser__link" data-cmp-clickable="" href="/content/core-components/list.html">
<div class="cmp-teaser__content">
<h2 class="cmp-teaser__title"> List </h2>
</div></a>
</div></li>
<li class="cmp-list__item" data-cmp-data-layer="{&quot;list-v4-c9b2ee1865-item-e7fc6d9060&quot;:{&quot;@type&quot;:&quot;core-component/components/list-v4/item&quot;,&quot;dc:title&quot;:&quot;lorem ipsum1&quot;,&quot;repo:modifyDate&quot;:&quot;0000-00-00T00:00:00Z&quot;,&quot;xdm:linkURL&quot;:&quot;https://www.adobe.com&quot;}}">
<div class="cmp-teaser" data-cmp-data-layer="{&quot;teaser-v2-c9b2ee1865&quot;:{&quot;@type&quot;:&quot;core-component/components/teaser-v2&quot;,&quot;dc:title&quot;:&quot;Page redirecting to external link&quot;,&quot;xdm:linkURL&quot;:&quot;https://www.adobe.com&quot;}}" id="teaser-v2-c9b2ee1865">
<a class="cmp-teaser__link" data-cmp-clickable="" href="https://www.adobe.com" target="_blank">
<div class="cmp-teaser__content">
<h2 class="cmp-teaser__title"> Page redirecting to external link </h2>
</div>
<div class="cmp-teaser__image">
<div class="cmp-image" data-asset-id="7f2a2314-7701-4c27-8945-bd5388ac94da" data-cmp-data-layer="{&quot;teaser-v2-c9b2ee1865-image&quot;:{&quot;@type&quot;:&quot;core-component/components/image-v3&quot;,&quot;dc:title&quot;:&quot;Rock Climbing and Bouldering above the lake and mountains&quot;,&quot;image&quot;:{&quot;@type&quot;:&quot;image/jpeg&quot;,&quot;repo:id&quot;:&quot;7f2a2314-7701-4c27-8945-bd5388ac94da&quot;,&quot;repo:modifyDate&quot;:&quot;0000-00-00T00:00:00Z&quot;,&quot;repo:path&quot;:&quot;/content/dam/core-components/AdobeStock_140634652_climbing.jpeg&quot;,&quot;xdm:smartTags&quot;:{&quot;bay&quot;:0.5985470414161682,&quot;beach&quot;:0.5976041555404663,&quot;beautiful&quot;:0.6171958446502686,&quot;blue&quot;:0.7352101802825928,&quot;clouds&quot;:0.571403980255127,&quot;coast&quot;:0.6973159313201904,&quot;coastline&quot;:0.595418393611908,&quot;day&quot;:0.571010410785675,&quot;green&quot;:0.6390171051025391,&quot;hiking&quot;:0.5750616788864136,&quot;hill&quot;:0.6186604499816895,&quot;island&quot;:0.6160755157470703,&quot;italy&quot;:0.5701255798339844,&quot;lake&quot;:0.7277572751045227,&quot;landscape&quot;:0.757290244102478,&quot;mountain&quot;:0.7924668192863464,&quot;mountains&quot;:0.6863020062446594,&quot;nature&quot;:0.7408576607704163,&quot;rock&quot;:0.6624879240989685,&quot;sea&quot;:0.7226889729499817,&quot;sky&quot;:0.6803537011146545,&quot;summer&quot;:0.642336905002594,&quot;travel&quot;:0.6782629489898682,&quot;view&quot;:0.5776767134666443,&quot;water&quot;:0.7416633367538452}},&quot;xdm:linkURL&quot;:&quot;https://www.adobe.com&quot;}}" data-cmp-filereference="/content/dam/core-components/AdobeStock_140634652_climbing.jpeg" data-cmp-hook-image="imageV3" data-cmp-is="image" data-cmp-src="/content/core-components/list/_jcr_content/root/container/list_v4_static_internal_pages_containing_external_redirect.coreimg{.width}.jpeg/content/core-components/simple-page/simple-redirect/jcr:content/cq:featuredimage/0/adobestock-140634652-climbing.jpeg" id="teaser-v2-c9b2ee1865-image" itemscope itemtype="http://schema.org/ImageObject">
<img alt="Rock Climbing and Bouldering above the lake and mountains" class="cmp-image__image" height="862" itemprop="contentUrl" loading="lazy" src="/content/core-components/list/_jcr_content/root/container/list_v4_static_internal_pages_containing_external_redirect.coreimg.jpeg/content/core-components/simple-page/simple-redirect/_jcr_content/_cq_featuredimage/0/adobestock-140634652-climbing.jpeg" title="Rock Climbing and Bouldering above the lake and mountains" width="1293">
<meta content="Rock Climbing and Bouldering above the lake and mountains" itemprop="caption">
</div>
</div></a>
</div></li>
</ul>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,26 @@
linkTarget="_blank"/>
</static>
</list_v4_static_pages_linked_description_modifieddate_teaser>
<list_v4_static_internal_pages_containing_external_redirect
jcr:primaryType="nt:unstructured"
sling:resourceType="core-component/components/list-v4"
listFrom="static"
linkItems="true"
showDescription="true"
showModificationDate="true"
displayItemAsTeaser="true">
<static
jcr:primaryType="nt:unstructured">
<item0
jcr:primaryType="nt:unstructured"
linkURL="/content/core-components/list"/>
<item1
jcr:primaryType="nt:unstructured"
linkURL="/content/core-components/simple-page/simple-redirect"
linkText="lorem ipsum1"
linkTarget="_blank"/>
</static>
</list_v4_static_internal_pages_containing_external_redirect>
<list_v4_static_pages_empty
jcr:primaryType="nt:unstructured"
sling:resourceType="core-component/components/list-v4"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Copyright 2021 Adobe
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Page">
<jcr:content
cq:lastModified="{Date}2021-01-15T16:44:49.861+02:00"
cq:lastModifiedBy="admin"
cq:template="/conf/core-components/settings/wcm/templates/simple-template"
jcr:primaryType="cq:PageContent"
jcr:title="Page redirecting to external link"
cq:redirectTarget="https://www.adobe.com"
cq:redirectPermanent="true"
sling:resourceType="core/wcm/components/page/v2/page">
<cq:featuredimage
jcr:primaryType="nt:unstructured"
sling:resourceType="core/wcm/components/image/v3/image"
altValueFromDAM="true"
fileReference="/content/dam/core-components/AdobeStock_140634652_climbing.jpeg" />
<image
jcr:primaryType="nt:unstructured"
fileReference="/content/dam/core-components/AdobeStock_140634652_climbing.jpeg" />
</jcr:content>
</jcr:root>

0 comments on commit d6699e5

Please sign in to comment.