diff --git a/projects/storefrontapp-e2e-cypress/cypress/e2e/b2b/regression/asm/customer-list.e2e-flaky.cy.ts b/projects/storefrontapp-e2e-cypress/cypress/e2e/b2b/regression/asm/customer-list.e2e-flaky.cy.ts index eaae974e83f..dfd44574642 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/e2e/b2b/regression/asm/customer-list.e2e-flaky.cy.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/e2e/b2b/regression/asm/customer-list.e2e-flaky.cy.ts @@ -45,7 +45,6 @@ context('Assisted Service Module', () => { asm.agentLogin('brandon.leclair@acme.com', 'pw4all'); asm.asmB2bCustomerLists(); - asm.agentSignOut(); }); it('checking pagination (CXSPA-2109)', () => { @@ -61,7 +60,6 @@ context('Assisted Service Module', () => { asm.agentLogin('jules.hasson@acme.com', 'pw4all'); asm.asmB2bCustomerListPagination(); - asm.agentSignOut(); }); }); }); diff --git a/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/asm/bind-cart.e2e-flaky.cy.ts b/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/asm/bind-cart.e2e-flaky.cy.ts index d8f4f31e926..cfb79f8ef34 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/asm/bind-cart.e2e-flaky.cy.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/asm/bind-cart.e2e-flaky.cy.ts @@ -13,14 +13,14 @@ import { getSampleUser } from '../../../sample-data/checkout-flow'; context('Assisted Service Module', () => { describe('Bind cart', () => { - it('should be able to bind anonymous cart to customer (CXSAP-153)', () => { - const customer = getSampleUser(); + const customerForBindCart = getSampleUser(); + let anonymousCartCodeForBindCart: string; - let anonymousCartCode: string; + it('should be able to bind anonymous cart to customer (CXSAP-153)', () => { checkout.visitHomePage(); cy.get('cx-asm-main-ui').should('not.exist'); - checkout.registerUser(false, customer); + checkout.registerUser(false, customerForBindCart); cy.log('--> Add to cart as an anonymous user'); cart.addProductAsAnonymous(); @@ -32,7 +32,7 @@ context('Assisted Service Module', () => { .then(($cartId) => { // localStorage contains anonymous cart uid, read code from UI const text = $cartId.text(); - anonymousCartCode = text.replace('Cart #', '').trim(); + anonymousCartCodeForBindCart = text.replace('Cart #', '').trim(); cy.log('--> Agent logging in'); checkout.visitHomePage('asm=true'); @@ -41,12 +41,12 @@ context('Assisted Service Module', () => { asm.agentLogin('asagent', 'pw4all'); cy.log('--> Starting customer emulation'); - asm.startCustomerEmulation(customer); + asm.startCustomerEmulation(customerForBindCart); cy.log('--> Enter users cart number'); cy.get( 'cx-customer-emulation input[formcontrolname="cartNumber"]' - ).type(anonymousCartCode); + ).type(anonymousCartCodeForBindCart); }); cy.log('--> Agent binding cart'); @@ -58,22 +58,17 @@ context('Assisted Service Module', () => { const customerCartCode = JSON.parse( window.localStorage.getItem('spartacus⚿electronics-spa⚿cart') ).active; - expect(customerCartCode).to.equal(anonymousCartCode); + expect(customerCartCode).to.equal(anonymousCartCodeForBindCart); }); + }); - cy.log( - '--> Stop customer emulation using the end emulation button in the ASM UI' - ); - asm.agentSignOut(); - - cy.get('cx-asm-main-ui').should('exist'); - + it(`Verify anonymous cart is now the user's active cart for bind cart (CXSAP-153)`, () => { cy.log('--> Log in as customer'); const loginPage = waitForPage('/login', 'getLoginPage'); cy.visit('/login'); cy.wait(`@${loginPage}`); - login(customer.email, customer.password); - cy.wait('@csAgentAuthentication'); + login(customerForBindCart.email, customerForBindCart.password); + cy.get('cx-login .cx-login-greet').should('be.visible'); cy.log("--> Verify anonymous cart is now the user's active cart"); cart.goToCart(); @@ -81,17 +76,17 @@ context('Assisted Service Module', () => { const customerCartCode = JSON.parse( window.localStorage.getItem('spartacus⚿electronics-spa⚿cart') ).active; - expect(customerCartCode).to.equal(anonymousCartCode); + expect(customerCartCode).to.equal(anonymousCartCodeForBindCart); }); }); + const customerForReplaceBindCart = getSampleUser(); + let anonymousCartCodeForReplaceBindCart: string; it('should be able to replace current customer cart with anonymous cart (CXSAP-153)', () => { - const customer = getSampleUser(); - checkout.visitHomePage(); cy.get('cx-asm-main-ui').should('not.exist'); - checkout.registerUser(false, customer); + checkout.registerUser(false, customerForReplaceBindCart); cy.log('--> Add to cart as an anonymous user'); cart.addProductAsAnonymous(); @@ -103,8 +98,10 @@ context('Assisted Service Module', () => { .then(($cartId) => { // localStorage contains anonymous cart uid, but need cart code. read cart code from UI const text = $cartId.text(); - const anonymousCartCode = text.replace('Cart #', '').trim(); - cy.wrap(anonymousCartCode).as('anonymousCartCode'); + anonymousCartCodeForReplaceBindCart = text + .replace('Cart #', '') + .trim(); + cy.wrap(anonymousCartCodeForReplaceBindCart).as('anonymousCartCode'); }); cy.get('@anonymousCartCode').then((anonymousCartCode) => { cy.log(`--> Anonymous cart id: ${anonymousCartCode}`); @@ -117,7 +114,7 @@ context('Assisted Service Module', () => { asm.agentLogin('asagent', 'pw4all'); cy.log('--> Starting customer emulation'); - asm.startCustomerEmulation(customer); + asm.startCustomerEmulation(customerForReplaceBindCart); cy.log('--> Create current active cart'); cart.addProductFromPdp(cart.products[1].code).then(() => { @@ -155,20 +152,18 @@ context('Assisted Service Module', () => { expect(customerCartCode).to.equal(anonymousCartCode); }); }); + }); - cy.log( - '--> Stop customer emulation using the end emulation button in the ASM UI' - ); - asm.agentSignOut(); - - cy.get('cx-asm-main-ui').should('exist'); - + it(`Verify anonymous cart is now the user's active cart for replace bind cart (CXSAP-153)`, () => { cy.log('--> Log in as customer'); const loginPage = waitForPage('/login', 'getLoginPage'); cy.visit('/login'); cy.wait(`@${loginPage}`); - login(customer.email, customer.password); - cy.wait('@csAgentAuthentication'); + login( + customerForReplaceBindCart.email, + customerForReplaceBindCart.password + ); + cy.get('cx-login .cx-login-greet').should('be.visible'); cy.log("--> Verify anonymous cart is now the user's active cart"); cart.goToCart(); @@ -176,9 +171,7 @@ context('Assisted Service Module', () => { const customerCartCode = JSON.parse( window.localStorage.getItem('spartacus⚿electronics-spa⚿cart') ).active; - cy.get('@anonymousCartCode').then((anonymousCartCode) => { - expect(customerCartCode).to.equal(anonymousCartCode); - }); + expect(customerCartCode).to.equal(anonymousCartCodeForReplaceBindCart); }); }); }); diff --git a/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/asm/create-customer.e2e-flaky.cy.ts b/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/asm/create-customer.e2e-flaky.cy.ts index cce0303f15c..f5dc14a04aa 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/asm/create-customer.e2e-flaky.cy.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/asm/create-customer.e2e-flaky.cy.ts @@ -16,6 +16,7 @@ context('Assisted Service Module', () => { }); describe('Create Customer', () => { + const user = getSampleUser(); it('should be able to create a new customer by agent click button (CXSPA-1594)', () => { cy.log('--> Agent logging in'); checkout.visitHomePage('asm=true'); @@ -35,7 +36,6 @@ context('Assisted Service Module', () => { asm.asmOpenCreateCustomerDialogOnCustomerListDialog(); cy.log('--> fill form'); - let user = getSampleUser(); asm.fillCreateCustomerForm(user); cy.log('--> submit form'); @@ -46,8 +46,6 @@ context('Assisted Service Module', () => { cy.get('cx-customer-emulation').should('be.visible'); - asm.agentSignOut(); - const backOfficeUrl = Cypress.env('BACK_OFFICE_URL') + Cypress.env('BACK_OFFICE_PREFIX'); cy.log('--> Go to ' + backOfficeUrl + ' to update the customer password'); @@ -120,7 +118,9 @@ context('Assisted Service Module', () => { 'Saved items' ); }); + }); + it('vertify login to Spartacus (CXSPA-1594)', () => { cy.log('--> Return to Spartacus to verify login'); checkout.visitHomePage(); cy.log('--> Log in to Spartacus'); @@ -150,8 +150,6 @@ context('Assisted Service Module', () => { cy.log('--> close create customer dialog'); asm.asmCloseCreateCustomerDialog(); - - asm.agentSignOut(); }); it('should be not able to create a new customer with invalid user data by agent (CXSPA-1594)', () => { cy.log('--> Agent logging in'); @@ -206,8 +204,6 @@ context('Assisted Service Module', () => { cy.log('--> close create customer dialog'); asm.asmCloseCreateCustomerDialog(); - - asm.agentSignOut(); }); }); }); diff --git a/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/asm/customer-list.e2e-flaky.cy.ts b/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/asm/customer-list.e2e-flaky.cy.ts index af310c31a62..270555a3f37 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/asm/customer-list.e2e-flaky.cy.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/asm/customer-list.e2e-flaky.cy.ts @@ -27,7 +27,6 @@ context('Assisted Service Module', () => { asm.agentLogin('asagent', 'pw4all'); asm.asmCustomerLists(); - asm.agentSignOut(); }); it('checking pagination (CXSPA-2109)', () => { @@ -37,7 +36,6 @@ context('Assisted Service Module', () => { asm.agentLogin('asagent', 'pw4all'); asm.asmCustomerListPagination(); - asm.agentSignOut(); }); }); }); diff --git a/projects/storefrontapp-e2e-cypress/cypress/helpers/accessibility/tabbing-order/asm.ts b/projects/storefrontapp-e2e-cypress/cypress/helpers/accessibility/tabbing-order/asm.ts index c7ab5ab9ccd..d1845bf8e53 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/helpers/accessibility/tabbing-order/asm.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/helpers/accessibility/tabbing-order/asm.ts @@ -109,7 +109,6 @@ export function asmTabbingOrderWithSaveInactiveCartDialog( cy.get('button[id=asm-save-inactive-cart-btn]').click(); verifyTabbingOrder(containerSelectorForInactiveCartDialog, config); cy.findByText(/Cancel/i).click(); - asm.agentSignOut(); }); }); } diff --git a/projects/storefrontapp-e2e-cypress/cypress/helpers/asm.ts b/projects/storefrontapp-e2e-cypress/cypress/helpers/asm.ts index 0bf9029dc1e..9c400e2b540 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/helpers/asm.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/helpers/asm.ts @@ -479,6 +479,7 @@ export function loginCustomerInStorefront(customer) { cy.wait(authRequest).its('response.statusCode').should('eq', 200); } +// It is not recommended to use agentSignOut as it can cause failure in E2E tests related to ASM in the pipeline export function agentSignOut() { const tokenRevocationAlias = loginHelper.listenForTokenRevocationRequest(); cy.get('button[title="Sign Out"]').click();