From d6699e5326222b3b8c0ecfbc03986d29717cb033 Mon Sep 17 00:00:00 2001 From: Hrayr Papikyan Date: Tue, 19 Mar 2024 09:57:14 +0200 Subject: [PATCH] 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 --- .../internal/models/v4/ListImpl.java | 2 +- .../core/components/it/http/ComponentsIT.java | 4 +- ...al-pages-containing-external-redirect.html | 24 ++++++++++++ .../content/core-components/list/.content.xml | 20 ++++++++++ .../simple-page/simple-redirect/.content.xml | 37 +++++++++++++++++++ 5 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 testing/it/http/src/test/resources/components/list-v4-static-internal-pages-containing-external-redirect.html create mode 100644 testing/it/it.ui.content/src/content/jcr_root/content/core-components/simple-page/simple-redirect/.content.xml diff --git a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v4/ListImpl.java b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v4/ListImpl.java index b77297a361..d73a4ace67 100644 --- a/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v4/ListImpl.java +++ b/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v4/ListImpl.java @@ -73,7 +73,7 @@ public Collection getListItems() { private Collection getStaticListItems() { Stream 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(); diff --git a/testing/it/http/src/test/java/com/adobe/cq/wcm/core/components/it/http/ComponentsIT.java b/testing/it/http/src/test/java/com/adobe/cq/wcm/core/components/it/http/ComponentsIT.java index 6a5f9e72c9..e45c481ec4 100644 --- a/testing/it/http/src/test/java/com/adobe/cq/wcm/core/components/it/http/ComponentsIT.java +++ b/testing/it/http/src/test/java/com/adobe/cq/wcm/core/components/it/http/ComponentsIT.java @@ -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 diff --git a/testing/it/http/src/test/resources/components/list-v4-static-internal-pages-containing-external-redirect.html b/testing/it/http/src/test/resources/components/list-v4-static-internal-pages-containing-external-redirect.html new file mode 100644 index 0000000000..2693a53778 --- /dev/null +++ b/testing/it/http/src/test/resources/components/list-v4-static-internal-pages-containing-external-redirect.html @@ -0,0 +1,24 @@ + \ No newline at end of file diff --git a/testing/it/it.ui.content/src/content/jcr_root/content/core-components/list/.content.xml b/testing/it/it.ui.content/src/content/jcr_root/content/core-components/list/.content.xml index b1f4fcbe59..14e80b4975 100644 --- a/testing/it/it.ui.content/src/content/jcr_root/content/core-components/list/.content.xml +++ b/testing/it/it.ui.content/src/content/jcr_root/content/core-components/list/.content.xml @@ -118,6 +118,26 @@ linkTarget="_blank"/> + + + + + + + + + + + + +