forked from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
cypress/src/tests/e2eTests/events/shopping-cart-view.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/shopping-cart-view.md | ||
* | ||
* Required Contexts: page, storefront, shoppingCart | ||
*/ | ||
|
||
it("is sent on view cart button click", () => { | ||
cy.visit(products.configurable.urlPathWithOptions); | ||
// add to cart | ||
cy.get(".product-details__buttons__add-to-cart button") | ||
.should("be.visible") | ||
.click(); | ||
// click the minicart toggle | ||
cy.get('button[data-count="1"]').should("be.visible").click(); | ||
// click the view cart button | ||
cy.get('#nav div.cart-mini-cart a[href="/cart"]') | ||
.should("be.visible") | ||
.click(); | ||
|
||
cy.waitForResource("commerce-events-collector.js").then(() => { | ||
cy.window() | ||
.its("adobeDataLayer") | ||
.then((adobeDataLayer) => { | ||
expectsEventWithContext( | ||
"shopping-cart-view", | ||
["pageContext", "storefrontInstanceContext", "shoppingCartContext"], | ||
adobeDataLayer | ||
); | ||
}); | ||
}); | ||
}); |