Skip to content

Commit

Permalink
Fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
OscarMerino committed Dec 10, 2024
2 parents d45706d + 4f646dd commit e9ce17e
Show file tree
Hide file tree
Showing 281 changed files with 2,260 additions and 1,638 deletions.
10 changes: 7 additions & 3 deletions 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"@dropins/storefront-auth/": "/scripts/__dropins__/storefront-auth/"
}
}
</script>
</script>
<script type="text/javascript">
window.isErrorPage = true;
window.errorCode = '404';
Expand Down Expand Up @@ -42,9 +42,13 @@
<link rel="stylesheet" href="/styles/styles.css">
<style>
main.error {
min-height: calc(100vh - var(--nav-height));
display: flex;
align-items: center;
display: flex;
margin: 0 auto;
max-width: 1264px;
min-height: calc(100vh - var(--nav-height));
padding: 0 32px;
width: 100%;
}

main.error .error-number {
Expand Down
13 changes: 11 additions & 2 deletions blocks/commerce-cart/commerce-cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import EstimateShipping from '@dropins/storefront-cart/containers/EstimateShippi
import EmptyCart from '@dropins/storefront-cart/containers/EmptyCart.js';
import Coupons from '@dropins/storefront-cart/containers/Coupons.js';

// API
import { publishShoppingCartViewEvent } from '@dropins/storefront-cart/api.js';

// Initializers
import '../../scripts/initializers/cart.js';

Expand Down Expand Up @@ -71,7 +74,7 @@ export default async function decorate(block) {
// Cart List
provider.render(CartSummaryList, {
hideHeading: hideHeading === 'true',
routeProduct: (product) => `/products/${product.url.urlKey}/${product.sku}`,
routeProduct: (product) => `/products/${product.url.urlKey}/${product.topLevelSku}`,
routeEmptyCartCTA: startShoppingURL ? () => startShoppingURL : undefined,
maxItems: parseInt(maxItems, 10) || undefined,
attributesToHide: hideAttributes.split(',').map((attr) => attr.trim().toLowerCase()),
Expand All @@ -81,7 +84,7 @@ export default async function decorate(block) {

// Order Summary
provider.render(OrderSummary, {
routeProduct: (product) => `/products/${product.url.urlKey}/${product.sku}`,
routeProduct: (product) => `/products/${product.url.urlKey}/${product.topLevelSku}`,
routeCheckout: checkoutURL ? () => checkoutURL : undefined,
slots: {
EstimateShipping: async (ctx) => {
Expand All @@ -107,9 +110,15 @@ export default async function decorate(block) {
})($emptyCart),
]);

let cartViewEventPublished = false;
// Events
events.on('cart/data', (payload) => {
toggleEmptyCart(isCartEmpty(payload));

if (!cartViewEventPublished) {
cartViewEventPublished = true;
publishShoppingCartViewEvent();
}
}, { eager: true });

return Promise.resolve();
Expand Down
8 changes: 7 additions & 1 deletion blocks/commerce-create-return/commerce-create-return.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ import '../../scripts/initializers/order.js';

export default async function decorate(block) {
await orderRenderer.render(CreateReturn, {
routeReturnSuccess: (orderData) => (checkIsAuthenticated() ? `${CUSTOMER_ORDER_DETAILS_PATH}?orderRef=${orderData.number}` : `${ORDER_DETAILS_PATH}?orderRef=${orderData.token}`),
routeReturnSuccess: (orderData) => {
const orderRef = checkIsAuthenticated() ? orderData.number : orderData.token;
const encodedOrderRef = encodeURIComponent(orderRef);
const path = checkIsAuthenticated() ? CUSTOMER_ORDER_DETAILS_PATH : ORDER_DETAILS_PATH;

return `${path}?orderRef=${encodedOrderRef}`;
},
})(block);
}
2 changes: 1 addition & 1 deletion blocks/commerce-mini-cart/commerce-mini-cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ export default async function decorate(block) {
routeEmptyCartCTA: startShoppingURL ? () => startShoppingURL : undefined,
routeCart: cartURL ? () => cartURL : undefined,
routeCheckout: checkoutURL ? () => checkoutURL : undefined,
routeProduct: (product) => `/products/${product.url.urlKey}/${product.sku}`,
routeProduct: (product) => `/products/${product.url.urlKey}/${product.topLevelSku}`,
})(block);
}
8 changes: 8 additions & 0 deletions blocks/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
// Drop-in Tools
import { events } from '@dropins/tools/event-bus.js';

// Cart dropin
import { publishShoppingCartViewEvent } from '@dropins/storefront-cart/api.js';

import { getMetadata } from '../../scripts/aem.js';
import { loadFragment } from '../fragment/fragment.js';

Expand Down Expand Up @@ -190,7 +193,12 @@ export default async function decorate(block) {

async function toggleMiniCart(state) {
const show = state ?? !minicartPanel.classList.contains('nav-tools-panel--show');
const stateChanged = show !== minicartPanel.classList.contains('nav-tools-panel--show');
minicartPanel.classList.toggle('nav-tools-panel--show', show);

if (stateChanged && show) {
publishShoppingCartViewEvent();
}
}

cartButton.addEventListener('click', () => toggleMiniCart());
Expand Down
7 changes: 1 addition & 6 deletions blocks/product-details/product-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import ProductAttributes from '@dropins/storefront-pdp/containers/ProductAttribu
import ProductGallery from '@dropins/storefront-pdp/containers/ProductGallery.js';

// Libs
import { setJsonLd, loadErrorPage } from '../../scripts/commerce.js';
import { setJsonLd } from '../../scripts/commerce.js';
import { fetchPlaceholders } from '../../scripts/aem.js';

// Initializers
Expand All @@ -33,11 +33,6 @@ export default async function decorate(block) {
const product = events._lastEvent?.['pdp/data']?.payload ?? null;
const labels = await fetchPlaceholders();

if (!product) {
await loadErrorPage();
return Promise.reject();
}

// Layout
const fragment = document.createRange().createContextualFragment(`
<div class="product-details__wrapper">
Expand Down
33 changes: 33 additions & 0 deletions cypress/src/tests/e2eTests/events/add-to-cart.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { products } from "../../../fixtures";
import { expectsEventWithContext } from "../../../assertions";
/**
* https://github.com/adobe/commerce-events/blob/main/examples/events/add-to-cart.md
*
* Required Contexts: page, storefront, product, shoppingCart, changedProducts
*/

it("is sent on add to cart button click", () => {
cy.visit(products.configurable.urlPathWithOptions);
// add to cart
cy.get(".product-details__buttons__add-to-cart button")
.should("be.visible")
.click();

cy.waitForResource("commerce-events-collector.js").then(() => {
cy.window()
.its("adobeDataLayer")
.then((adobeDataLayer) => {
expectsEventWithContext(
"add-to-cart",
[
"pageContext",
"storefrontInstanceContext",
"productContext",
"shoppingCartContext",
"changedProductsContext",
],
adobeDataLayer
);
});
});
});
10 changes: 5 additions & 5 deletions cypress/src/tests/e2eTests/events/recs.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { expectsEventWithContext } from "../../../assertions";
*/

it('api-request-sent, api-response-received, unit-impression-render', () => {
cy.visit('/products/crown-summit-backpack/24-MB03');
cy.visit('/gear');
cy.waitForResource('commerce-events-collector.js').then(() => {
cy.window().its('adobeDataLayer').then((adobeDataLayer) => {
expectsEventWithContext(
Expand All @@ -36,7 +36,7 @@ it('api-request-sent, api-response-received, unit-impression-render', () => {
});

it('recs-unit-view', () => {
cy.visit('/products/crown-summit-backpack/24-MB03');
cy.visit('/gear');
cy.waitForResource('commerce-events-collector.js').then(() => {
cy.get('.product-recommendations-wrapper').scrollIntoView({ duration: 1000 });
cy.window().its('adobeDataLayer').then((adobeDataLayer) => {
Expand All @@ -49,7 +49,7 @@ it('recs-unit-view', () => {
return adobeDataLayer;
}).then(adobeDataLayer => {
// triggers a second view when scrolled again
cy.get('.pdp-header__title').scrollIntoView({ duration: 50 }).then(() => {
cy.get('#gear').scrollIntoView({ duration: 50 }).then(() => {
cy.get('.product-recommendations-wrapper').scrollIntoView({ duration: 50 }).then(() => {
const eventCount = adobeDataLayer.filter(data => data?.event === 'recs-unit-view');
expect(eventCount).to.have.lengthOf(2);
Expand All @@ -60,7 +60,7 @@ it('recs-unit-view', () => {
});

it('recs-item-click', () => {
cy.visit('/products/crown-summit-backpack/24-MB03');
cy.visit('/gear');
cy.waitForResource("commerce-events-collector.js").then(() => {
cy.window().then((win) => {
cy.spy(win.adobeDataLayer, "push").as("adl");
Expand Down Expand Up @@ -92,7 +92,7 @@ it('recs-item-click', () => {
});

it('reqs-item-add-to-cart', () => {
cy.visit('/products/crown-summit-backpack/24-MB03');
cy.visit('/gear');
cy.waitForResource("commerce-events-collector.js").then(() => {
cy.window().then((win) => {
cy.spy(win.adobeDataLayer, "push").as("adl");
Expand Down
2 changes: 1 addition & 1 deletion cypress/src/tests/e2eTests/verifyGuestUserCheckout.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe('Verify guest user can place order', () => {
cy.get('.dropin-header-container__title', {timeout: 3000})
.should('exist')
.and('be.visible')
.and('contain.text', 'cancellation requested');
.and('contain.text', 'Cancellation requested');

cy.get(fields.cancellationReasonsModal).should('not.exist');

Expand Down
31 changes: 31 additions & 0 deletions helix-query.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
version: 1
indices:
sitemap:
target: /sitemap.json
exclude:
- 'drafts/**'
- 'enrichment/**'
- 'fragments/**'
- 'products/**'
properties:
title:
select: head > meta[property="og:title"]
value: |
attribute(el, 'content')
image:
select: head > meta[property="og:image"]
value: |
attribute(el, 'content')
description:
select: head > meta[name="description"]
value: |
attribute(el, 'content')
template:
select: head > meta[name="template"]
value: |
attribute(el, 'content')
robots:
select: head > meta[name="robots"]
value: |
attribute(el, 'content')
lastModified:
select: none
value: parseTimestamp(headers["last-modified"], "ddd, DD MMM YYYY hh:mm:ss GMT")
enrichment:
target: /enrichment/enrichment.json
include:
Expand Down
5 changes: 5 additions & 0 deletions helix-sitemap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sitemaps:
default:
source: /sitemap.json
destination: /sitemap-content.xml
lastmod: YYYY-MM-DD
40 changes: 24 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
"dependencies": {
"@adobe/magento-storefront-event-collector": "^1.8.0",
"@adobe/magento-storefront-events-sdk": "^1.8.0",
"@dropins/storefront-account": "0.1.0-alpha20",
"@dropins/storefront-auth": "0.0.1-alpha25",
"@dropins/storefront-cart": "0.10.0",
"@dropins/storefront-account": "1.0.0-beta3",
"@dropins/storefront-auth": "1.0.0-beta2",
"@dropins/storefront-cart": "1.0.0-beta2",
"@dropins/storefront-checkout": "1.0.0-beta1",
"@dropins/storefront-order": "0.1.0-alpha26",
"@dropins/storefront-order": "1.0.0-beta2",
"@dropins/storefront-pdp": "1.0.0-beta3",
"@dropins/tools": "^0.36.0"
"@dropins/tools": "^0.37.0"
}
}
2 changes: 1 addition & 1 deletion draft.robots.txt → robots.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ Disallow: /enrichment/
Disallow: /tools/
Disallow: /plugins/experimentation/

Sitemap: https://www.aemshop.net/sitemap.xml
Sitemap: https://www.aemshop.net/sitemap-index.xml
4 changes: 3 additions & 1 deletion scripts/__dropins__/storefront-account/api.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export declare const CREATE_CUSTOMER_ADDRESS = "\n mutation CREATE_CUSTOMER_ADDRESS($input: CustomerAddressInput!) {\n createCustomerAddress(input:$input) {\n firstname\n }\n }\n";
export declare const CREATE_CUSTOMER_ADDRESS = "\n mutation CREATE_CUSTOMER_ADDRESS($input: CustomerAddressInput!) {\n createCustomerAddress(input: $input) {\n firstname\n }\n }\n";
//# sourceMappingURL=createCustomerAddress.graphql.d.ts.map
4 changes: 4 additions & 0 deletions scripts/__dropins__/storefront-account/api/fragments.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { BASIC_CUSTOMER_INFO_FRAGMENT } from './graphql/CustomerFragment.graphql';
export { ADDRESS_FRAGMENT } from './graphql/CustomerAddressFragment.graphql';
export { ORDER_SUMMARY_FRAGMENT } from './graphql/OrderSummaryFragment.graphql';
//# sourceMappingURL=fragments.d.ts.map

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export declare const GET_ATTRIBUTES_FORM = "\n query GET_ATTRIBUTES_FORM($formCode: String!) {\n attributesForm(formCode: $formCode) {\n items {\n code\n default_value\n entity_type\n frontend_class\n frontend_input\n is_required\n is_unique\n label\n options {\n is_default\n label\n value\n }\n ... on CustomerAttributeMetadata {\n multiline_count\n sort_order\n validate_rules {\n name\n value\n }\n }\n }\n errors {\n type\n message\n }\n }\n }\n";
export declare const GET_ATTRIBUTES_FORM_SHORT = "\n query GET_ATTRIBUTES_FORM_SHORT {\n attributesForm(formCode: \"customer_register_address\") {\n items {\n frontend_input\n label\n code\n ... on CustomerAttributeMetadata {\n multiline_count\n sort_order\n }\n }\n }\n }\n";
export declare const GET_ATTRIBUTES_FORM_SHORT = "\n query GET_ATTRIBUTES_FORM_SHORT {\n attributesForm(formCode: \"customer_register_address\") {\n items {\n frontend_input\n label\n code\n ... on CustomerAttributeMetadata {\n multiline_count\n sort_order\n }\n }\n }\n }\n";
//# sourceMappingURL=getAttributesForm.graphql.d.ts.map
Loading

0 comments on commit e9ce17e

Please sign in to comment.