From ec875b348b7a2195642f7ebf7ee5bf63d67452f2 Mon Sep 17 00:00:00 2001 From: levente Date: Wed, 8 Nov 2023 20:34:14 +0200 Subject: [PATCH] @releng - fixing test after AEM docker image update --- .circleci/ci/it-tests.js | 3 +- .../com/venia/it/category/IgnoreOn65.java | 16 +++++ .../com/venia/it/category/IgnoreOnCloud.java | 16 +++++ .../com/venia/it/tests/ProductPageIT.java | 27 +++++++- .../datalayer/grouped-product-65.json | 34 ++++++++++ .../datalayer/simple-product-65.json | 62 +++++++++++++++++++ 6 files changed, 155 insertions(+), 3 deletions(-) create mode 100644 it.tests/src/main/java/com/venia/it/category/IgnoreOn65.java create mode 100644 it.tests/src/main/java/com/venia/it/category/IgnoreOnCloud.java create mode 100644 it.tests/src/main/resources/datalayer/grouped-product-65.json create mode 100644 it.tests/src/main/resources/datalayer/simple-product-65.json diff --git a/.circleci/ci/it-tests.js b/.circleci/ci/it-tests.js index e0ae5e2e..5d0a0c3d 100644 --- a/.circleci/ci/it-tests.js +++ b/.circleci/ci/it-tests.js @@ -106,8 +106,9 @@ try { // Run integration tests if (TYPE === 'integration') { + let excludedCategory = classifier === 'classic' ? 'com.venia.it.category.IgnoreOn65' : 'com.venia.it.category.IgnoreOnCloud'; ci.dir('it.tests', () => { - ci.sh(`mvn clean verify -U -B -Plocal`); // The -Plocal profile comes from the AEM archetype + ci.sh(`mvn clean verify -U -B -Plocal -Dexclude.category=${excludedCategory}`); // The -Plocal profile comes from the AEM archetype }); } if (TYPE === 'selenium') { diff --git a/it.tests/src/main/java/com/venia/it/category/IgnoreOn65.java b/it.tests/src/main/java/com/venia/it/category/IgnoreOn65.java new file mode 100644 index 00000000..d9b652f8 --- /dev/null +++ b/it.tests/src/main/java/com/venia/it/category/IgnoreOn65.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * + * Copyright 2023 Adobe. All rights reserved. + * This file is licensed to you 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 REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + * + ******************************************************************************/ +package com.venia.it.category; + +public interface IgnoreOn65 {} diff --git a/it.tests/src/main/java/com/venia/it/category/IgnoreOnCloud.java b/it.tests/src/main/java/com/venia/it/category/IgnoreOnCloud.java new file mode 100644 index 00000000..edf88990 --- /dev/null +++ b/it.tests/src/main/java/com/venia/it/category/IgnoreOnCloud.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * + * Copyright 2023 Adobe. All rights reserved. + * This file is licensed to you 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 REPRESENTATIONS + * OF ANY KIND, either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + * + ******************************************************************************/ +package com.venia.it.category; + +public interface IgnoreOnCloud {} diff --git a/it.tests/src/main/java/com/venia/it/tests/ProductPageIT.java b/it.tests/src/main/java/com/venia/it/tests/ProductPageIT.java index 86f535ad..c684de88 100644 --- a/it.tests/src/main/java/com/venia/it/tests/ProductPageIT.java +++ b/it.tests/src/main/java/com/venia/it/tests/ProductPageIT.java @@ -18,6 +18,8 @@ import java.util.Collections; import java.util.List; +import com.venia.it.category.IgnoreOn65; +import com.venia.it.category.IgnoreOnCloud; import org.apache.commons.lang3.StringUtils; import org.apache.http.NameValuePair; import org.apache.http.message.BasicNameValuePair; @@ -30,6 +32,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.venia.it.utils.Utils; +import org.junit.experimental.categories.Category; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -43,6 +46,15 @@ public class ProductPageIT extends CommerceTestBase { @Test public void testProductPageWithSampleData() throws ClientException, IOException { + testProductPageWithSampleData("datalayer/simple-product.json"); + } + + @Test + public void testProductPageWithSampleData65() throws ClientException, IOException { + testProductPageWithSampleData("datalayer/simple-product-65.json"); + } + + public void testProductPageWithSampleData(String jsonFile) throws ClientException, IOException { String pagePath = VENIA_CONTENT_US_EN_PRODUCTS_PRODUCT_PAGE + ".html/honora-wide-leg-pants.html"; SlingHttpResponse response = adminAuthor.doGet(pagePath, 200); Document doc = Jsoup.parse(response.getContent()); @@ -71,12 +83,23 @@ public void testProductPageWithSampleData() throws ClientException, IOException // Verify dataLayer attributes elements = doc.select(PRODUCT_DETAILS_SELECTOR); JsonNode result = Utils.OBJECT_MAPPER.readTree(elements.first().attr("data-cmp-data-layer")); - JsonNode expected = Utils.OBJECT_MAPPER.readTree(Utils.getResource("datalayer/simple-product.json")); + JsonNode expected = Utils.OBJECT_MAPPER.readTree(Utils.getResource(jsonFile)); assertEquals(expected, result); } @Test + @Category({ IgnoreOn65.class }) public void testProductPageWithSampleDataForGroupedProduct() throws ClientException, IOException { + testProductPageWithSampleDataForGroupedProduct("datalayer/grouped-product.json"); + } + + @Test + @Category({ IgnoreOnCloud.class }) + public void testProductPageWithSampleDataForGroupedProduct65() throws ClientException, IOException { + testProductPageWithSampleDataForGroupedProduct("datalayer/grouped-product-65.json"); + } + + public void testProductPageWithSampleDataForGroupedProduct(String jsonFile) throws ClientException, IOException { SlingHttpResponse response = adminAuthor.doGet(VENIA_CONTENT_US_EN_PRODUCTS_PRODUCT_PAGE + ".html/augusta-trio.html", 200); Document doc = Jsoup.parse(response.getContent()); @@ -90,7 +113,7 @@ public void testProductPageWithSampleDataForGroupedProduct() throws ClientExcept // Verify dataLayer attributes elements = doc.select(PRODUCT_DETAILS_SELECTOR); JsonNode result = Utils.OBJECT_MAPPER.readTree(elements.first().attr("data-cmp-data-layer")); - JsonNode expected = Utils.OBJECT_MAPPER.readTree(Utils.getResource("datalayer/grouped-product.json")); + JsonNode expected = Utils.OBJECT_MAPPER.readTree(Utils.getResource(jsonFile)); assertEquals(expected, result); } diff --git a/it.tests/src/main/resources/datalayer/grouped-product-65.json b/it.tests/src/main/resources/datalayer/grouped-product-65.json new file mode 100644 index 00000000..2ecaa222 --- /dev/null +++ b/it.tests/src/main/resources/datalayer/grouped-product-65.json @@ -0,0 +1,34 @@ +{ + "product-3c02043652": { + "xdm:listPrice": 78.0, + "xdm:SKU": "VA23", + "xdm:assets": [ + { + + "repo:path": "https://mystage1-amspro120.amscommerce.cloud/media/catalog/product/cache/8735dd21982cf027014173d1affcf80c/v/a/va23_main.jpg", + "repo:id": "image-3d3553c5dc", + "@type": "image" + } + ], + "xdm:categories": [ + { + "repo:id": "category-8c01c593b9", + "xdm:name": "Accessories", + "xdm:asset": { + "repo:path": "https://mystage1-amspro120.amscommerce.cloud/media/catalog/category/carefree.jpg", + "repo:id": "image-6310f9e8a5", + "@type": "image" + } + }, + { + "repo:id": "category-f5a5c5aea0", + "xdm:name": "Jewelry", + "xdm:asset": null + } + ], + "xdm:currencyCode": "USD", + "dc:description": "This trio is designed for versatility. Brighten up a simple look or add another layer of “wow” to an already vibrant ensemble. Go as big and bold, or understated as you're in the mood to be.", + "dc:title": "Augusta Trio", + "@type": "venia/components/commerce/product" + } +} \ No newline at end of file diff --git a/it.tests/src/main/resources/datalayer/simple-product-65.json b/it.tests/src/main/resources/datalayer/simple-product-65.json new file mode 100644 index 00000000..f776e951 --- /dev/null +++ b/it.tests/src/main/resources/datalayer/simple-product-65.json @@ -0,0 +1,62 @@ +{ + "product-dc59ad50df": { + "xdm:listPrice": 78.0, + "xdm:SKU": "VP05", + "xdm:assets": [ + { + "repo:path": "https://mystage1-amspro120.amscommerce.cloud/media/catalog/product/cache/8735dd21982cf027014173d1affcf80c/v/p/vp05-rn_main_4.jpg", + "repo:id": "image-73439b9cf3", + "@type": "image" + }, + { + "repo:path": "https://mystage1-amspro120.amscommerce.cloud/media/catalog/product/cache/8735dd21982cf027014173d1affcf80c/v/p/vp05-rn_alt_2.jpg", + "repo:id": "image-2e75bb2439", + "@type": "image" + }, + { + "repo:path": "https://mystage1-amspro120.amscommerce.cloud/media/catalog/product/cache/8735dd21982cf027014173d1affcf80c/v/p/vp05-rn_back_2.jpg", + "repo:id": "image-40bcf141f9", + "@type": "image" + }, + { + "repo:path": "https://mystage1-amspro120.amscommerce.cloud/media/catalog/product/cache/8735dd21982cf027014173d1affcf80c/v/p/vp05_look_2.jpg", + "repo:id": "image-e049cce860", + "@type": "image" + } + ], + "xdm:categories": [ + { + "repo:id": "category-cf9d757f29", + "xdm:name": "Bottoms", + "xdm:asset": { + "repo:path": "https://mystage1-amspro120.amscommerce.cloud/media/catalog/category/minimalist.jpg", + "repo:id": "image-74c855fbf3", + "@type": "image" + } + }, + { + "repo:id": "category-6e60cf4797", + "xdm:name": "Pants & Shorts", + "xdm:asset": null + }, + { + "repo:id": "category-b8a3caa888", + "xdm:name": "Shop The Look", + "xdm:asset": { + "repo:path": "https://mystage1-amspro120.amscommerce.cloud/media/catalog/category/beachy.jpg", + "repo:id": "image-8a0806aaab", + "@type": "image" + } + }, + { + "repo:id": "category-df146c27a3", + "xdm:name": "Minimalist Sensibility", + "xdm:asset": null + } + ], + "xdm:currencyCode": "USD", + "dc:description": "

The Honora Wide Leg Pants definitely hold their own when it comes to standing out from the crowd. These pants feature a unique design and a varying color palette to make pairing a snap.

Features:

", + "dc:title": "Honora Wide Leg Pants", + "@type": "venia/components/commerce/product" + } +} \ No newline at end of file