Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@releng - fix pipeline issues and tests #326

Merged
merged 5 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ version: 2.1

orbs:
codecov: codecov/codecov@1.1.1
browser-tools: circleci/browser-tools@1.2.4
browser-tools: circleci/browser-tools@1.4.4

common:
integration_test_steps: &integration_test_steps
steps:
- checkout
- browser-tools/install-browser-tools:
chrome-version: 114.0.5735.90 # TODO: remove -> https://github.com/CircleCI-Public/browser-tools-orb/issues/75
chrome-version: 116.0.5845.96 # TODO: remove -> https://github.com/CircleCI-Public/browser-tools-orb/issues/75
- restore_cache:
keys:
- maven-repo-{{ .Environment.CACHE_VERSION }}-its-{{ arch }}-{{ .Branch }}-{{ checksum "pom.xml" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,10 @@ public String getId() {
@Override
public ComponentData getData() {
final ComponentData data = ((Component) searchResults).getData();
if (data == null) {
return null;
}

final AtomicReference<ComponentData> dataRef = new AtomicReference<>();
ComponentData componentData = (ComponentData) Proxy.newProxyInstance(this.getClass().getClassLoader(),
new Class[]{ComponentData.class}, (proxy, method, args) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,4 +282,10 @@ public void testDataLayerFeature() throws Exception {

Assertions.assertEquals(dataLayerJson, underTest.getData().getJson());
}

@Test
void testGetProductRetriever() throws Exception {
setup(PRODUCTTEASER_NO_BADGE);
Assertions.assertNotNull(underTest.getProductRetriever());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@
******************************************************************************/
package com.venia.core.models.commerce;

import com.adobe.cq.commerce.core.components.models.searchresults.SearchResults;
import com.adobe.cq.commerce.core.components.services.urls.UrlProvider;
import com.adobe.cq.commerce.core.search.models.SearchResultsSet;
import com.adobe.cq.commerce.core.search.models.Sorter;
import com.adobe.cq.commerce.core.search.models.SorterKey;
import com.adobe.cq.commerce.core.search.services.SearchResultsService;
import com.adobe.cq.commerce.magento.graphql.FilterMatchTypeInput;
import com.adobe.cq.commerce.magento.graphql.ProductAttributeFilterInput;
import com.adobe.cq.wcm.core.components.models.datalayer.ComponentData;
import com.day.cq.wcm.api.Page;
import io.wcm.testing.mock.aem.junit5.AemContext;
import io.wcm.testing.mock.aem.junit5.AemContextExtension;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.wrappers.ValueMapDecorator;
import org.apache.sling.caconfig.ConfigurationBuilder;
import org.apache.sling.testing.mock.sling.ResourceResolverType;
import org.apache.sling.testing.mock.sling.servlet.MockSlingHttpServletRequest;
import org.junit.jupiter.api.Assertions;
Expand All @@ -38,8 +42,7 @@
import java.util.Map;
import java.util.function.Function;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand All @@ -49,7 +52,8 @@ public class MySearchResultsImplTest {
private static final String PAGE = "/content/page";
private final AemContext context = new AemContext(ResourceResolverType.JCR_MOCK);

private SearchResults underTest;
private MySearchResultsImpl underTest;
private HashMap<String, Object> dataLayerConfigMap;

@BeforeEach
void beforeEach() {
Expand Down Expand Up @@ -79,13 +83,49 @@ void beforeEach() {
context.registerService(UrlProvider.class, mock(UrlProvider.class));
context.addModelsForClasses(MySearchResultsImpl.class);

ConfigurationBuilder configurationBuilder = mock(ConfigurationBuilder.class);
when(configurationBuilder.name("com.adobe.cq.wcm.core.components.internal.DataLayerConfig")).thenReturn(configurationBuilder);
dataLayerConfigMap = new HashMap<>();
when(configurationBuilder.asValueMap()).thenReturn(new ValueMapDecorator(dataLayerConfigMap));
context.registerAdapter(Resource.class, ConfigurationBuilder.class, configurationBuilder);

MockSlingHttpServletRequest request = context.request();
request.addRequestParameter("search_query", "test");

underTest = request.adaptTo(MySearchResultsImpl.class);
Assertions.assertNotNull(underTest);
}

@Test
void testInstance() {
assertEquals("paginationbar", underTest.getPaginationType());
assertFalse(underTest.isAddToCartEnabled());
assertFalse(underTest.isAddToWishListEnabled());
assertTrue(underTest.loadClientPrice());
assertNotNull(underTest.getSearchResultsStorefrontContext());
assertNotNull(underTest.getSearchStorefrontContext());
underTest.getAppliedCssClasses();
assertEquals("venia/components/commerce/searchresults", underTest.getExportedType());
ComponentData componentData = underTest.getData();
assertNull(componentData);
assertEquals("searchresults-50df7e8869", underTest.getId());

underTest.extendProductQueryWith(p-> p.color());
underTest.extendProductFilterWith(f -> f.setName(new FilterMatchTypeInput().setMatch("winter")));
assertNotNull(underTest.getProducts());
}

@Test
void testComponentData() {
dataLayerConfigMap.put("enabled", true);

ComponentData componentData = underTest.getData();
assertNotNull(componentData);
assertEquals("venia/components/commerce/searchresults", componentData.getType());
assertEquals("searchresults-50df7e8869", componentData.getId());
}


@Test
void testSorterKeys() {
List<SorterKey> keys = underTest.getSearchResultsSet().getSorter().getKeys();
Expand Down
63 changes: 31 additions & 32 deletions it.tests/src/main/resources/datalayer/grouped-product-65.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
{
"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"
}
"product-3c02043652": {
"xdm:listPrice": 78.0,
"xdm:SKU": "VA23",
"xdm:assets": [
{
"repo:path": "https://mcprod.catalogservice4commerce.fun/media/catalog/product/cache/dbba4389ce8da2ab9399ca5f8b677aac/v/a/va23_main.jpg",
"repo:id": "image-daa709cd50",
"@type": "image"
}
],
"xdm:categories": [
{
"repo:id": "category-4c0609820d",
"xdm:name": "Accessories",
"xdm:asset": {
"repo:path": "https://mcprod.catalogservice4commerce.fun/media/catalog/category/carefree.jpg",
"repo:id": "image-11a31da9a5",
"@type": "image"
}
},
{
"repo:id": "category-6e6f7c1718",
"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"
}
}
63 changes: 31 additions & 32 deletions it.tests/src/main/resources/datalayer/grouped-product.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,33 @@
{
"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&#39;re in the mood to be.",
"dc:title": "Augusta Trio",
"@type": "venia/components/commerce/product"
}
"product-3c02043652": {
"xdm:listPrice": 78.0,
"xdm:SKU": "VA23",
"xdm:assets": [
{
"repo:path": "https://mcprod.catalogservice4commerce.fun/media/catalog/product/cache/dbba4389ce8da2ab9399ca5f8b677aac/v/a/va23_main.jpg",
"repo:id": "image-daa709cd50",
"@type": "image"
}
],
"xdm:categories": [
{
"repo:id": "category-4c0609820d",
"xdm:name": "Accessories",
"xdm:asset": {
"repo:path": "https://mcprod.catalogservice4commerce.fun/media/catalog/category/carefree.jpg",
"repo:id": "image-11a31da9a5",
"@type": "image"
}
},
{
"repo:id": "category-6e6f7c1718",
"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&#39;re in the mood to be.",
"dc:title": "Augusta Trio",
"@type": "venia/components/commerce/product"
}
}
116 changes: 56 additions & 60 deletions it.tests/src/main/resources/datalayer/simple-product-65.json
Original file line number Diff line number Diff line change
@@ -1,62 +1,58 @@
{
"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"
}
"product-dc59ad50df": {
"xdm:listPrice": 78.0,
"xdm:SKU": "VP05",
"xdm:assets": [
{
"repo:path": "https://mcprod.catalogservice4commerce.fun/media/catalog/product/cache/dbba4389ce8da2ab9399ca5f8b677aac/v/p/vp05-rn_main.jpg",
"repo:id": "image-2ea11abe0a",
"@type": "image"
},
{
"repo:path": "https://mcprod.catalogservice4commerce.fun/media/catalog/product/cache/dbba4389ce8da2ab9399ca5f8b677aac/v/p/vp05-rn_alt.jpg",
"repo:id": "image-35c39a6a6b",
"@type": "image"
},
{
"repo:path": "https://mcprod.catalogservice4commerce.fun/media/catalog/product/cache/dbba4389ce8da2ab9399ca5f8b677aac/v/p/vp05-rn_back.jpg",
"repo:id": "image-7ed6d7593b",
"@type": "image"
},
{
"repo:path": "https://mcprod.catalogservice4commerce.fun/media/catalog/product/cache/dbba4389ce8da2ab9399ca5f8b677aac/v/p/vp05_look.jpg",
"repo:id": "image-3b4d560585",
"@type": "image"
}
],
"xdm:categories": [
{
"repo:id": "category-2212426126",
"xdm:name": "Bottoms",
"xdm:asset": {
"repo:path": "https://mcprod.catalogservice4commerce.fun/media/catalog/category/minimalist.jpg",
"repo:id": "image-9d427bd572",
"@type": "image"
}
},
{
"repo:id": "category-3c1d5daf00",
"xdm:name": "Pants & Shorts",
"xdm:asset": null
},
{
"repo:id": "category-77640b4209",
"xdm:name": "Shop The Look",
"xdm:asset": null
},
{
"repo:id": "category-077469fda4",
"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"
}
}
Loading