Skip to content

Commit d6699e5

Browse files
hrayrpapikyanIgor Myronenko
andauthored
Sites 19919 1 (#2694)
* [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 <[email protected]>
1 parent 8fbb567 commit d6699e5

File tree

5 files changed

+85
-2
lines changed

5 files changed

+85
-2
lines changed

bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v4/ListImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public Collection<ListItem> getListItems() {
7373
private Collection<ListItem> getStaticListItems() {
7474
Stream<AbstractListItemImpl> itemStream = getStaticItemResourceStream().map(linkResource -> {
7575
Link link = linkManager.get(linkResource).build();
76-
if (LinkManagerImpl.isExternalLink(link.getURL())) {
76+
if (LinkManagerImpl.isExternalLink(link.getURL()) && (link.getReference() == null)) {
7777
return new ExternalLinkListItemImpl(link, linkResource, getId(), component);
7878
} else {
7979
Object reference = link.getReference();

testing/it/http/src/test/java/com/adobe/cq/wcm/core/components/it/http/ComponentsIT.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,9 @@ public void testList() throws ClientException, IOException {
147147
.select(".list.list-v4", 2).expect("list-v4-static-pages-and-links.html")
148148
.select(".list.list-v4", 3).expect("list-v4-static-pages-linked-description-modified.html")
149149
.select(".list.list-v4", 4).expect("list-v4-static-pages-linked-description-modifieddate-teaser.html")
150-
.select(".list.list-v4", 5).expect("list-v4-static-pages-empty.html");
150+
.select(".list.list-v4", 5).expect("list-v4-static-internal-pages-containing-external-redirect.html")
151+
.select(".list.list-v4", 6).expect("list-v4-static-pages-empty.html");
152+
151153
}
152154

153155
@Test
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<div class="list-v4 list">
2+
<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">
3+
<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;}}">
4+
<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">
5+
<a class="cmp-teaser__link" data-cmp-clickable="" href="/content/core-components/list.html">
6+
<div class="cmp-teaser__content">
7+
<h2 class="cmp-teaser__title"> List </h2>
8+
</div></a>
9+
</div></li>
10+
<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;}}">
11+
<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">
12+
<a class="cmp-teaser__link" data-cmp-clickable="" href="https://www.adobe.com" target="_blank">
13+
<div class="cmp-teaser__content">
14+
<h2 class="cmp-teaser__title"> Page redirecting to external link </h2>
15+
</div>
16+
<div class="cmp-teaser__image">
17+
<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">
18+
<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">
19+
<meta content="Rock Climbing and Bouldering above the lake and mountains" itemprop="caption">
20+
</div>
21+
</div></a>
22+
</div></li>
23+
</ul>
24+
</div>

testing/it/it.ui.content/src/content/jcr_root/content/core-components/list/.content.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,26 @@
118118
linkTarget="_blank"/>
119119
</static>
120120
</list_v4_static_pages_linked_description_modifieddate_teaser>
121+
<list_v4_static_internal_pages_containing_external_redirect
122+
jcr:primaryType="nt:unstructured"
123+
sling:resourceType="core-component/components/list-v4"
124+
listFrom="static"
125+
linkItems="true"
126+
showDescription="true"
127+
showModificationDate="true"
128+
displayItemAsTeaser="true">
129+
<static
130+
jcr:primaryType="nt:unstructured">
131+
<item0
132+
jcr:primaryType="nt:unstructured"
133+
linkURL="/content/core-components/list"/>
134+
<item1
135+
jcr:primaryType="nt:unstructured"
136+
linkURL="/content/core-components/simple-page/simple-redirect"
137+
linkText="lorem ipsum1"
138+
linkTarget="_blank"/>
139+
</static>
140+
</list_v4_static_internal_pages_containing_external_redirect>
121141
<list_v4_static_pages_empty
122142
jcr:primaryType="nt:unstructured"
123143
sling:resourceType="core-component/components/list-v4"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
~ Copyright 2021 Adobe
4+
~
5+
~ Licensed under the Apache License, Version 2.0 (the "License");
6+
~ you may not use this file except in compliance with the License.
7+
~ You may obtain a copy of the License at
8+
~
9+
~ http://www.apache.org/licenses/LICENSE-2.0
10+
~
11+
~ Unless required by applicable law or agreed to in writing, software
12+
~ distributed under the License is distributed on an "AS IS" BASIS,
13+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
~ See the License for the specific language governing permissions and
15+
~ limitations under the License.
16+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
17+
<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"
18+
jcr:primaryType="cq:Page">
19+
<jcr:content
20+
cq:lastModified="{Date}2021-01-15T16:44:49.861+02:00"
21+
cq:lastModifiedBy="admin"
22+
cq:template="/conf/core-components/settings/wcm/templates/simple-template"
23+
jcr:primaryType="cq:PageContent"
24+
jcr:title="Page redirecting to external link"
25+
cq:redirectTarget="https://www.adobe.com"
26+
cq:redirectPermanent="true"
27+
sling:resourceType="core/wcm/components/page/v2/page">
28+
<cq:featuredimage
29+
jcr:primaryType="nt:unstructured"
30+
sling:resourceType="core/wcm/components/image/v3/image"
31+
altValueFromDAM="true"
32+
fileReference="/content/dam/core-components/AdobeStock_140634652_climbing.jpeg" />
33+
<image
34+
jcr:primaryType="nt:unstructured"
35+
fileReference="/content/dam/core-components/AdobeStock_140634652_climbing.jpeg" />
36+
</jcr:content>
37+
</jcr:root>

0 commit comments

Comments
 (0)