Skip to content

Commit

Permalink
@releng - fixing test after AEM docker image update
Browse files Browse the repository at this point in the history
  • Loading branch information
LSantha committed Nov 8, 2023
1 parent 8d35017 commit ec875b3
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .circleci/ci/it-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
16 changes: 16 additions & 0 deletions it.tests/src/main/java/com/venia/it/category/IgnoreOn65.java
Original file line number Diff line number Diff line change
@@ -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 {}
16 changes: 16 additions & 0 deletions it.tests/src/main/java/com/venia/it/category/IgnoreOnCloud.java
Original file line number Diff line number Diff line change
@@ -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 {}
27 changes: 25 additions & 2 deletions it.tests/src/main/java/com/venia/it/tests/ProductPageIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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());
Expand Down Expand Up @@ -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());

Expand All @@ -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);
}

Expand Down
34 changes: 34 additions & 0 deletions it.tests/src/main/resources/datalayer/grouped-product-65.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
62 changes: 62 additions & 0 deletions it.tests/src/main/resources/datalayer/simple-product-65.json
Original file line number Diff line number Diff line change
@@ -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": "<p>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.</p><p>Features:</p><ul><li>Elastic waistband</li><li>Drawstring waist</li><li>Sits just below the waist</li><li>31&quot; inseam</li><li>Machine wash, line dry</li></ul>",
"dc:title": "Honora Wide Leg Pants",
"@type": "venia/components/commerce/product"
}
}

0 comments on commit ec875b3

Please sign in to comment.