From 30ddf86d732cb60643db1372224158146eb0afa2 Mon Sep 17 00:00:00 2001 From: dimitriyTsemma Date: Fri, 29 Nov 2024 15:26:20 +0200 Subject: [PATCH 1/2] FRW-7936 Adjusted tests --- .../pages/yves/cart/repositories/b2b-cart-repository.ts | 8 ++++++++ .../yves/cart/repositories/b2b-mp-cart-repository.ts | 8 ++++++++ .../pages/yves/cart/repositories/b2c-cart-repository.ts | 8 ++++++++ .../yves/cart/repositories/b2c-mp-cart-repository.ts | 8 ++++++++ 4 files changed, 32 insertions(+) diff --git a/cypress/support/pages/yves/cart/repositories/b2b-cart-repository.ts b/cypress/support/pages/yves/cart/repositories/b2b-cart-repository.ts index 703c7ad3..9217bd29 100644 --- a/cypress/support/pages/yves/cart/repositories/b2b-cart-repository.ts +++ b/cypress/support/pages/yves/cart/repositories/b2b-cart-repository.ts @@ -35,6 +35,10 @@ export class B2bCartRepository implements CartRepository { cy.get('.product-quick-add-form__button'); findCartItemRemovalForm = (sku: string): Cypress.Chainable => { return cy.get('[action]').filter((index, element) => { + if (Cypress.env('isDynamicStoreEnabled')) { + const regex = new RegExp(`^/\\w+/\\w+/cart/async/remove/${sku}/\\w+`); + return regex.test(element.getAttribute('action') ?? ''); + } const regex = new RegExp(`^/\\w+/cart/async/remove/${sku}/\\w+`); return regex.test(element.getAttribute('action') ?? ''); }); @@ -42,6 +46,10 @@ export class B2bCartRepository implements CartRepository { findCartItemRemovalSubmit = (sku: string): Cypress.Chainable => this.findCartItemRemovalForm(sku).find('button'); findCartItemChangeQuantityForm = (sku: string): Cypress.Chainable => { return cy.get('[action]').filter((index, element) => { + if (Cypress.env('isDynamicStoreEnabled')) { + const regex = new RegExp(`^/\\w+/\\w+/cart/async/change-quantity/${sku}$`); + return regex.test(element.getAttribute('action') ?? ''); + } const regex = new RegExp(`^/\\w+/cart/async/change-quantity/${sku}$`); return regex.test(element.getAttribute('action') ?? ''); }); diff --git a/cypress/support/pages/yves/cart/repositories/b2b-mp-cart-repository.ts b/cypress/support/pages/yves/cart/repositories/b2b-mp-cart-repository.ts index f1b899b9..35a33f7f 100644 --- a/cypress/support/pages/yves/cart/repositories/b2b-mp-cart-repository.ts +++ b/cypress/support/pages/yves/cart/repositories/b2b-mp-cart-repository.ts @@ -35,6 +35,10 @@ export class B2bMpCartRepository implements CartRepository { cy.get('.product-quick-add-form__button'); findCartItemRemovalForm = (sku: string): Cypress.Chainable => { return cy.get('[action]').filter((index, element) => { + if (Cypress.env('isDynamicStoreEnabled')) { + const regex = new RegExp(`^/\\w+/\\w+/cart/async/remove/${sku}/\\w+`); + return regex.test(element.getAttribute('action') ?? ''); + } const regex = new RegExp(`^/\\w+/cart/async/remove/${sku}/\\w+`); return regex.test(element.getAttribute('action') ?? ''); }); @@ -42,6 +46,10 @@ export class B2bMpCartRepository implements CartRepository { findCartItemRemovalSubmit = (sku: string): Cypress.Chainable => this.findCartItemRemovalForm(sku).find('button'); findCartItemChangeQuantityForm = (sku: string): Cypress.Chainable => { return cy.get('[action]').filter((index, element) => { + if (Cypress.env('isDynamicStoreEnabled')) { + const regex = new RegExp(`^/\\w+/\\w+/cart/async/change-quantity/${sku}$`); + return regex.test(element.getAttribute('action') ?? ''); + } const regex = new RegExp(`^/\\w+/cart/async/change-quantity/${sku}$`); return regex.test(element.getAttribute('action') ?? ''); }); diff --git a/cypress/support/pages/yves/cart/repositories/b2c-cart-repository.ts b/cypress/support/pages/yves/cart/repositories/b2c-cart-repository.ts index bd43eace..d51b1d09 100644 --- a/cypress/support/pages/yves/cart/repositories/b2c-cart-repository.ts +++ b/cypress/support/pages/yves/cart/repositories/b2c-cart-repository.ts @@ -12,12 +12,20 @@ export class B2cCartRepository implements CartRepository { cy.get('[data-qa="product-quick-add-form-submit-button"]'); findCartItemRemovalForm = (sku: string): Cypress.Chainable => { return cy.get('[action]').filter((index, element) => { + if (Cypress.env('isDynamicStoreEnabled')) { + const regex = new RegExp(`^/\\w+/\\w+/cart/async/remove/${sku}/\\w+`); + return regex.test(element.getAttribute('action') ?? ''); + } const regex = new RegExp(`^/\\w+/cart/async/remove/${sku}/\\w+`); return regex.test(element.getAttribute('action') ?? ''); }); }; findCartItemChangeQuantityForm = (sku: string): Cypress.Chainable => { return cy.get('[action]').filter((index, element) => { + if (Cypress.env('isDynamicStoreEnabled')) { + const regex = new RegExp(`^/\\w+/\\w+/cart/async/change-quantity/${sku}$`); + return regex.test(element.getAttribute('action') ?? ''); + } const regex = new RegExp(`^/\\w+/cart/async/change-quantity/${sku}$`); return regex.test(element.getAttribute('action') ?? ''); }); diff --git a/cypress/support/pages/yves/cart/repositories/b2c-mp-cart-repository.ts b/cypress/support/pages/yves/cart/repositories/b2c-mp-cart-repository.ts index ea6173c1..0d303b39 100644 --- a/cypress/support/pages/yves/cart/repositories/b2c-mp-cart-repository.ts +++ b/cypress/support/pages/yves/cart/repositories/b2c-mp-cart-repository.ts @@ -16,6 +16,10 @@ export class B2cMpCartRepository implements CartRepository { cy.get('[data-qa="product-quick-add-form-submit-button"]'); findCartItemRemovalForm = (sku: string): Cypress.Chainable => { return cy.get('[action]').filter((index, element) => { + if (Cypress.env('isDynamicStoreEnabled')) { + const regex = new RegExp(`^/\\w+/\\w+/cart/async/remove/${sku}/\\w+`); + return regex.test(element.getAttribute('action') ?? ''); + } const regex = new RegExp(`^/\\w+/cart/async/remove/${sku}/\\w+`); return regex.test(element.getAttribute('action') ?? ''); }); @@ -23,6 +27,10 @@ export class B2cMpCartRepository implements CartRepository { findCartItemRemovalSubmit = (sku: string): Cypress.Chainable => this.findCartItemRemovalForm(sku).find('button'); findCartItemChangeQuantityForm = (sku: string): Cypress.Chainable => { return cy.get('[action]').filter((index, element) => { + if (Cypress.env('isDynamicStoreEnabled')) { + const regex = new RegExp(`^/\\w+/\\w+/cart/async/change-quantity/${sku}$`); + return regex.test(element.getAttribute('action') ?? ''); + } const regex = new RegExp(`^/\\w+/cart/async/change-quantity/${sku}$`); return regex.test(element.getAttribute('action') ?? ''); }); From 7acbaa038c0d9425d0cfab8114b891f2d8dfbd77 Mon Sep 17 00:00:00 2001 From: dimitriyTsemma Date: Mon, 9 Dec 2024 10:36:32 +0200 Subject: [PATCH 2/2] FRW-7936 Fixed tests --- .../cart/repositories/b2b-comment-cart-repository.ts | 8 +++++++- .../cart/repositories/b2b-mp-comment-cart-repository.ts | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/cypress/support/pages/yves/comment/cart/repositories/b2b-comment-cart-repository.ts b/cypress/support/pages/yves/comment/cart/repositories/b2b-comment-cart-repository.ts index b18a7c2a..816f8be3 100644 --- a/cypress/support/pages/yves/comment/cart/repositories/b2b-comment-cart-repository.ts +++ b/cypress/support/pages/yves/comment/cart/repositories/b2b-comment-cart-repository.ts @@ -7,7 +7,13 @@ export class B2bCommentCartRepository implements CommentCartRepository { getCommentThreadListSection = (): Cypress.Chainable => cy.get('[data-qa="component cart-sidebar-item"]').find('[data-qa="component add-comment-form"]').parent(); getAddCommentButtonSelector = (): string => '[data-qa="component icon"]'; - getRemoveCommentButtonSelector = (): string => '[formaction="/en/comment/async/remove"]'; + getRemoveCommentButtonSelector = (): string => { + if (Cypress.env('isDynamicStoreEnabled')) { + return '[formaction="/DE/en/comment/async/remove"]'; + } + + return '[formaction="/en/comment/async/remove"]'; + }; getFirstCommentTextarea = (): Cypress.Chainable => { this.getCommentThreadListSection().first().find('button:contains("Edit")').click(); diff --git a/cypress/support/pages/yves/comment/cart/repositories/b2b-mp-comment-cart-repository.ts b/cypress/support/pages/yves/comment/cart/repositories/b2b-mp-comment-cart-repository.ts index 5cff9679..3ef8fe88 100644 --- a/cypress/support/pages/yves/comment/cart/repositories/b2b-mp-comment-cart-repository.ts +++ b/cypress/support/pages/yves/comment/cart/repositories/b2b-mp-comment-cart-repository.ts @@ -7,7 +7,13 @@ export class B2bMpCommentCartRepository implements CommentCartRepository { getCommentThreadListSection = (): Cypress.Chainable => cy.get('[data-qa="component cart-sidebar-item"]').find('[data-qa="component add-comment-form"]').parent(); getAddCommentButtonSelector = (): string => '[data-qa="component icon"]'; - getRemoveCommentButtonSelector = (): string => '[formaction="/en/comment/async/remove"]'; + getRemoveCommentButtonSelector = (): string => { + if (Cypress.env('isDynamicStoreEnabled')) { + return '[formaction="/DE/en/comment/async/remove"]'; + } + + return '[formaction="/en/comment/async/remove"]'; + }; getFirstCommentTextarea = (): Cypress.Chainable => { this.getCommentThreadListSection().first().find('button:contains("Edit")').click();