Skip to content

Commit

Permalink
TRACKING-1140 v 1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
stiegi committed Jul 5, 2023
1 parent ccd4d47 commit 048412a
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 119 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@
- Add pixel statistics call
# 1.1.0
- Add support for Shopware 6.5, drop support for 6.3 and lower
# 1.1.1
- Raised time between virtual PI and add-to-cart request at product lists from 50ms to 500ms

6 changes: 3 additions & 3 deletions E2E/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ module.exports = defineConfig({
defaultCommandTimeout: 40000,
pageLoadTimeout: 50000,
video: false,
screenshotsFolder: '/results/screenshots',
videosFolder: '/results/videos',
screenshotsFolder: '/cypress/results/screenshots',
videosFolder: '/cypress/results/videos',
reporter: 'junit',
reporterOptions: {
mochaFile: '/results/output-[hash].xml',
mochaFile: '/cypress/results/output-[hash].xml',
jenkinsMode: true,
},
e2e: {
Expand Down
247 changes: 135 additions & 112 deletions E2E/cypress/e2e/07_product.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,31 @@

beforeEach(() => {
cy.consentMapp();
cy.interceptTracking();
});

describe("Product detail datalayer", () => {
it("normal product: view", () => {
cy.visit("/MappIntelligence-product-aeoeue/MAPP10001");
let data;
cy.testTrackRequest().then((track) => {
expect(track.pageName).to.equal(
"shopware.test/MappIntelligence-product-aeoeue/MAPP10001"
);
expect(track.cr).to.equal("EUR");
expect(track.ba).to.equal("MAPP10001");
expect(track.co).to.equal("495.95");
expect(track.qn).to.equal("1");
expect(track.ca1).to.equal("MappTestProducts");
expect(track.ca2).to.equal("MappSubCategory");
expect(track.ca3).to.equal("MappIntelligence-product-äöü");
expect(track.st).to.equal("view");
expect(track.cg1).to.equal("Catalogue");
expect(track.cg2).to.equal("Product Detail");
expect(track.pu).to.equal(
"http://shopware.test/MappIntelligence-product-aeoeue/MAPP10001"
);
});
cy.window()
.then((win) => {
data = win._ti;
Expand Down Expand Up @@ -44,50 +63,47 @@ describe("Product detail datalayer", () => {
it("normal product: multiple add to cart", () => {
let wts;
let data;
cy.intercept({
url: "/checkout/line-item/add",
method: "post",
}).as("addToCart");

cy.visit("/MappIntelligence-product-aeoeue/MAPP10001");
cy.window().its("wts.push").should("exist");
cy.window().then((win) => {
wts = cy
.stub(win.wts, "push", () => {
data = JSON.parse(JSON.stringify(win._ti));
})
.as("wts");
cy.testTrackRequest().then((track) => {
expect(track.pageName).to.equal(
"shopware.test/MappIntelligence-product-aeoeue/MAPP10001"
);
expect(track.cr).to.equal("EUR");
expect(track.ba).to.equal("MAPP10001");
expect(track.co).to.equal("495.95");
expect(track.qn).to.equal("1");
expect(track.ca1).to.equal("MappTestProducts");
expect(track.ca2).to.equal("MappSubCategory");
expect(track.ca3).to.equal("MappIntelligence-product-äöü");
expect(track.st).to.equal("view");
expect(track.cg1).to.equal("Catalogue");
expect(track.cg2).to.equal("Product Detail");
expect(track.pu).to.equal(
"http://shopware.test/MappIntelligence-product-aeoeue/MAPP10001"
);
});

cy.get(".product-detail-quantity-input").clear().type("5");
cy.contains("Add to shopping cart").click();
cy.wait("@addToCart").then(() => {
expect(wts).to.be.calledOnce;
expect(data.pageRequestType).to.equal("virtual");
expect(data.contentCategory).to.equal("Catalogue");
expect(data.contentSubcategory).to.equal("Product Detail");
expect(data.currency).to.equal("EUR");
expect(data.pageName).to.equal(
cy.get(".btn-buy").click();

cy.testTrackRequest().then((track) => {
expect(track.pageName).to.equal(
"shopware.test/MappIntelligence-product-aeoeue/MAPP10001"
);
expect(data.pageTitle).to.equal(
"MappIntelligence-product-äöü | MAPP10001"
);
expect(data.productCategories).to.deep.equal([
"MappTestProducts",
"MappSubCategory",
]);
expect(data.productCategory).to.equal("MappTestProducts");
expect(data.productCost).to.equal("2479.75");
expect(data.productId).to.equal("MAPP10001");
expect(data.productName).to.equal("MappIntelligence-product-äöü");
expect(data.productQuantity).to.equal("5");
expect(data.productShopwareId).to.equal(
"222aee2d4ef6484f99e541a03976d867"
expect(track.cr).to.equal("EUR");
expect(track.ba).to.equal("MAPP10001");
expect(track.co).to.equal("2479.75");
expect(track.qn).to.equal("5");
expect(track.ca1).to.equal("MappTestProducts");
expect(track.ca2).to.equal("MappSubCategory");
expect(track.ca3).to.equal("MappIntelligence-product-äöü");
expect(track.st).to.equal("add");
expect(track.cg1).to.equal("Catalogue");
expect(track.cg2).to.equal("Product Detail");
expect(track.pu).to.equal(
"http://shopware.test/MappIntelligence-product-aeoeue/MAPP10001"
);
expect(data.productSoldOut).to.equal("");
expect(data.productSubCategory).to.equal("MappSubCategory");
expect(data.shoppingCartStatus).to.equal("add");
});
});

Expand Down Expand Up @@ -128,53 +144,47 @@ describe("Product detail datalayer", () => {
});

it("soldout product: multiple add to cart", () => {
let wts;
let data;
cy.intercept({
url: "/checkout/line-item/add",
method: "post",
}).as("addToCart");

cy.visit("/MappIntelligence-product-soldout/MAPP100013");
cy.window().its("wts.push").should("exist");
cy.window().then((win) => {
wts = cy
.stub(win.wts, "push", () => {
data = JSON.parse(JSON.stringify(win._ti));
})
.as("wts");

cy.testTrackRequest().then((track) => {
expect(track.pageName).to.equal(
"shopware.test/MappIntelligence-product-soldout/MAPP100013"
);
expect(track.cr).to.equal("EUR");
expect(track.ba).to.equal("MAPP100013");
expect(track.co).to.equal("1.99");
expect(track.qn).to.equal("1");
expect(track.ca1).to.equal("MappTestProducts");
expect(track.ca2).to.equal("MappSubCategory");
expect(track.ca3).to.equal("MappIntelligence-product-soldout");
expect(track.st).to.equal("view");
expect(track.cg1).to.equal("Catalogue");
expect(track.cg2).to.equal("Product Detail");
expect(track.pu).to.equal(
"http://shopware.test/MappIntelligence-product-soldout/MAPP100013"
);
});

cy.get(".product-detail-quantity-input").clear().type("5");
cy.contains("Add to shopping cart").click();
cy.wait("@addToCart").then(() => {
expect(wts).to.be.calledOnce;
expect(data.pageRequestType).to.equal("virtual");
expect(data.contentCategory).to.equal("Catalogue");
expect(data.contentSubcategory).to.equal("Product Detail");
expect(data.currency).to.equal("EUR");

expect(data.pageName).to.equal(
cy.testTrackRequest().then((track) => {
expect(track.pageName).to.equal(
"shopware.test/MappIntelligence-product-soldout/MAPP100013"
);
expect(data.pageTitle).to.equal(
"MappIntelligence-product-soldout | MAPP100013"
);
expect(data.productCategories).to.deep.equal([
"MappTestProducts",
"MappSubCategory",
]);
expect(data.productCategory).to.equal("MappTestProducts");
expect(data.productCost).to.equal("9.95");
expect(data.productId).to.equal("MAPP100013");
expect(data.productName).to.equal("MappIntelligence-product-soldout");
expect(data.productQuantity).to.equal("5");
expect(data.productShopwareId).to.equal(
"333aee2d4ef6484f99e541a03976d867"
expect(track.cr).to.equal("EUR");
expect(track.ba).to.equal("MAPP100013");
expect(track.co).to.equal("9.95");
expect(track.qn).to.equal("5");
expect(track.ca1).to.equal("MappTestProducts");
expect(track.ca2).to.equal("MappSubCategory");
expect(track.ca3).to.equal("MappIntelligence-product-soldout");
expect(track.st).to.equal("add");
expect(track.cg1).to.equal("Catalogue");
expect(track.cg2).to.equal("Product Detail");
expect(track.pu).to.equal(
"http://shopware.test/MappIntelligence-product-soldout/MAPP100013"
);
expect(data.productSoldOut).to.equal("1");
expect(data.productSubCategory).to.equal("MappSubCategory");
expect(data.shoppingCartStatus).to.equal("add");
});
});

Expand Down Expand Up @@ -253,58 +263,71 @@ describe("Product detail datalayer", () => {
});

it("variable product: switch, then multiple add to cart", () => {
let wts;
let data;
cy.intercept({
url: "/checkout/line-item/add",
method: "post",
}).as("addToCart");

cy.visit(
"/MappIntelligence-Variant-product/MappIntelligence-Variant-product-Red"
);
cy.testTrackRequest().then((track) => {
expect(track.pageName).to.equal(
"shopware.test/MappIntelligence-Variant-product/MappIntelligence-Variant-product-Red"
);
expect(track.cr).to.equal("EUR");
expect(track.ba).to.equal("MappIntelligence-Variant-product-Red");
expect(track.co).to.equal("295.95");
expect(track.qn).to.equal("1");
expect(track.ca1).to.equal("MappTestProducts");
expect(track.ca2).to.equal("MappSubCategory");
expect(track.ca3).to.equal("MappIntelligence-Variant-product");
expect(track.st).to.equal("view");
expect(track.cg1).to.equal("Catalogue");
expect(track.cg2).to.equal("Product Detail");
expect(track.pu).to.equal(
"http://shopware.test/MappIntelligence-Variant-product/MappIntelligence-Variant-product-Red"
);
});
cy.window().its("wts.push").should("exist");
cy.get(".product-detail-configurator-option input")
.eq(0)
.click({ force: true });
cy.contains("MappIntelligence-Variant-product-Blue").should("be.visible");
cy.window().its("wts.push").should("exist");

cy.window().then((win) => {
wts = cy
.stub(win.wts, "push", () => {
data = JSON.parse(JSON.stringify(win._ti));
})
.as("wts");
cy.testTrackRequest().then((track) => {
expect(track.pageName).to.equal(
"shopware.test/MappIntelligence-Variant-product/MappIntelligence-Variant-product-Blue"
);
expect(track.cr).to.equal("EUR");
expect(track.ba).to.equal("MappIntelligence-Variant-product-Blue");
expect(track.co).to.equal("295.95");
expect(track.qn).to.equal("1");
expect(track.ca1).to.equal("MappTestProducts");
expect(track.ca2).to.equal("MappSubCategory");
expect(track.ca3).to.equal("MappIntelligence-Variant-product");
expect(track.st).to.equal("view");
expect(track.cg1).to.equal("Catalogue");
expect(track.cg2).to.equal("Product Detail");
expect(track.pu).to.equal(
"http://shopware.test/MappIntelligence-Variant-product/MappIntelligence-Variant-product-Blue"
);
});
cy.contains("MappIntelligence-Variant-product-Blue").should("be.visible");

cy.get(".product-detail-quantity-input").clear().type("5");
cy.contains("Add to shopping cart").click();
cy.wait("@addToCart").then(() => {
expect(wts).to.be.calledOnce;
expect(data.pageRequestType).to.equal("virtual");
expect(data.contentCategory).to.equal("Catalogue");
expect(data.contentSubcategory).to.equal("Product Detail");
expect(data.currency).to.equal("EUR");
expect(data.pageName).to.equal(

cy.testTrackRequest().then((track) => {
expect(track.pageName).to.equal(
"shopware.test/MappIntelligence-Variant-product/MappIntelligence-Variant-product-Blue"
);
expect(data.pageTitle).to.equal(
"MappIntelligence-Variant-product | Blue | MappIntelligence-Variant-product-Blue"
expect(track.cr).to.equal("EUR");
expect(track.ba).to.equal("MappIntelligence-Variant-product-Blue");
expect(track.co).to.equal("1479.75");
expect(track.qn).to.equal("5");
expect(track.ca1).to.equal("MappTestProducts");
expect(track.ca2).to.equal("MappSubCategory");
expect(track.ca3).to.equal("MappIntelligence-Variant-product");
expect(track.st).to.equal("add");
expect(track.cg1).to.equal("Catalogue");
expect(track.cg2).to.equal("Product Detail");
expect(track.pu).to.equal(
"http://shopware.test/MappIntelligence-Variant-product/MappIntelligence-Variant-product-Blue"
);
expect(data.productCategories).to.deep.equal([
"MappTestProducts",
"MappSubCategory",
]);
expect(data.productCategory).to.equal("MappTestProducts");
expect(data.productCost).to.equal("1479.75");
expect(data.productId).to.equal("MappIntelligence-Variant-product-Blue");
expect(data.productName).to.equal("MappIntelligence-Variant-product");
expect(data.productQuantity).to.equal("5");
expect(data.productShopwareId).to.match(/^[0-9a-f]{32}$/);
expect(data.productSoldOut).to.equal("");
expect(data.productSubCategory).to.equal("MappSubCategory");
expect(data.shoppingCartStatus).to.equal("add");
});
});
});
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mapp/intelligence",
"description": "Add your Mapp Intelligence account ID and start tracking. The plugin adds the tracking script and data layer for your customer insights dashboard automatically.",
"version": "1.1.0",
"version": "1.1.1",
"type": "shopware-platform-plugin",
"license": "MIT",
"authors": [
Expand Down
Loading

0 comments on commit 048412a

Please sign in to comment.