From 170bcdafd6a4515083bf7fef9cdf57cc9eed0842 Mon Sep 17 00:00:00 2001 From: niehuayang <126219214+niehuayang@users.noreply.github.com> Date: Thu, 6 Jul 2023 18:58:17 +0800 Subject: [PATCH] test: enable asm e2e tests skiped (#17593) --- .../e2e/b2b/regression/asm/asm.core-e2e.cy.ts | 29 +++++----- .../asm/asm.emulation.core-e2e.cy.ts | 58 ++++++++++++++++--- 2 files changed, 64 insertions(+), 23 deletions(-) diff --git a/projects/storefrontapp-e2e-cypress/cypress/e2e/b2b/regression/asm/asm.core-e2e.cy.ts b/projects/storefrontapp-e2e-cypress/cypress/e2e/b2b/regression/asm/asm.core-e2e.cy.ts index 92f50fe5392..65b7ed09d8e 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/e2e/b2b/regression/asm/asm.core-e2e.cy.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/e2e/b2b/regression/asm/asm.core-e2e.cy.ts @@ -4,16 +4,20 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { clearAllStorage } from '../../../../support/utils/clear-all-storage'; import * as asm from '../../../../helpers/asm'; +import { addB2bProductToCartAndCheckout } from '../../../../helpers/b2b/b2b-checkout'; +import * as checkout from '../../../../helpers/checkout-flow'; import { ELECTRONICS_BASESITE } from '../../../../helpers/checkout-flow'; import { POWERTOOLS_BASESITE } from '../../../../sample-data/b2b-checkout'; -import { user } from '../../../../sample-data/checkout-flow'; -import { register } from '../../../../helpers/auth-forms'; -import { addB2bProductToCartAndCheckout } from '../../../../helpers/b2b/b2b-checkout'; +import { clearAllStorage } from '../../../../support/utils/clear-all-storage'; import { interceptGet } from '../../../../support/utils/intercept'; context('B2B - Assisted Service Module', () => { + const customer = { + fullName: 'William Hunter', + email: 'william.hunter@pronto-hw.com', + }; + before(() => { clearAllStorage(); }); @@ -27,8 +31,7 @@ context('B2B - Assisted Service Module', () => { Cypress.env('BASE_SITE', ELECTRONICS_BASESITE); }); - // This test only works if "sap-commerce-cloud-user-id" is added to the allowed headers of "corsfilter.commercewebservices.allowedHeaders" on the Commerce Cloud side (CXSPA-1355) - it.skip("should fetch cost centers based on the emulated user's role", () => { + it("should fetch cost centers based on the emulated user's role", () => { cy.cxConfig({ context: { baseSite: ['powertools-spa'], @@ -36,15 +39,13 @@ context('B2B - Assisted Service Module', () => { }, }); - cy.visit('/', { qs: { asm: true } }); - - cy.visit('/login/register'); - - register(user, true); - + cy.log('--> Agent logging in'); + checkout.visitHomePage('asm=true'); + cy.get('cx-asm-main-ui').should('exist'); + cy.get('cx-asm-main-ui').should('be.visible'); asm.agentLogin('brandon.leclair@acme.com', 'pw4all'); - - asm.startCustomerEmulation(user, true); + cy.log('--> Agent emulate customer'); + asm.startCustomerEmulation(customer, true); addB2bProductToCartAndCheckout(); diff --git a/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/asm/asm.emulation.core-e2e.cy.ts b/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/asm/asm.emulation.core-e2e.cy.ts index 14667b2547a..f84b7f252e3 100644 --- a/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/asm/asm.emulation.core-e2e.cy.ts +++ b/projects/storefrontapp-e2e-cypress/cypress/e2e/regression/asm/asm.emulation.core-e2e.cy.ts @@ -11,13 +11,13 @@ import { ELECTRONICS_BASESITE } from '../../../helpers/checkout-flow'; import { getErrorAlert } from '../../../helpers/global-message'; import { navigateToCategory, waitForPage } from '../../../helpers/navigation'; import { APPAREL_BASESITE } from '../../../helpers/variants/apparel-checkout-flow'; -import { clearAllStorage } from '../../../support/utils/clear-all-storage'; - import { getSampleUser } from '../../../sample-data/checkout-flow'; +import { clearAllStorage } from '../../../support/utils/clear-all-storage'; context('Assisted Service Module', () => { describe('Customer Support Agent - Emulation', () => { asm.testCustomerEmulation(); + it('should checkout as customer', () => { const customer = getSampleUser(); @@ -78,11 +78,43 @@ context('Assisted Service Module', () => { ); }); - // TODO(#9445): Add e2e test for this scenario - it.skip('agent login when user is logged in should start this user emulation', () => {}); + // TODO(#3974): fix the bug to enable e2e test for this scenario + it.skip('agent login when user is logged in should start this user emulation', () => { + cy.visit('/login'); + login(customer.email, customer.password); + + checkout.visitHomePage('asm=true'); + + cy.get('cx-asm-main-ui').should('exist'); + cy.get('cx-asm-main-ui').should('be.visible'); + + cy.log('--> Agent logging in'); + asm.agentLogin('asagent', 'pw4all'); + + cy.get('cx-csagent-login-form').should('not.exist'); + cy.get('cx-customer-selection').should('not.exist'); + cy.get('cx-customer-emulation').should('be.visible'); + }); + + // TODO(#7221): enable this case + it.skip('agent logout when user was logged and emulated should restore the session', () => { + checkout.visitHomePage('asm=true'); + + cy.get('cx-asm-main-ui').should('exist'); + cy.get('cx-asm-main-ui').should('be.visible'); + + cy.log('--> Agent logging in'); + asm.agentLogin('asagent', 'pw4all'); + + cy.log('--> Starting customer emulation'); + asm.startCustomerEmulation(customer); - // TODO(#9445): Add e2e test for this scenario - it.skip('agent logout when user was logged and emulated should restore the session', () => {}); + cy.log('--> Agent sign out'); + asm.agentSignOut(); + + cy.get('cx-csagent-login-form').should('exist'); + cy.get('cx-customer-emulation').should('not.exist'); + }); }); describe('Apparel Site', () => { @@ -94,8 +126,7 @@ context('Assisted Service Module', () => { Cypress.env('BASE_SITE', ELECTRONICS_BASESITE); }); - // This test only works if "sap-commerce-cloud-user-id" is added to the allowed headers of "corsfilter.commercewebservices.allowedHeaders" on the Commerce Cloud side. (CXSPA-1355) - it.skip("should fetch products in a category based on the emulated user's authentication", () => { + it("should fetch products in a category based on the emulated user's authentication", () => { cy.cxConfig({ context: { baseSite: ['apparel-uk-spa'], @@ -113,11 +144,20 @@ context('Assisted Service Module', () => { asm.startCustomerEmulation(customer); navigateToCategory('Brands', 'brands', true); + cy.get('cx-product-list').should('exist'); + cy.get('cx-product-list cx-product-grid-item').should( + 'have.length.at.least', + 1 + ); + navigateToCategory('Streetwear', 'streetwear', true); cy.get('cx-product-list').should('exist'); + cy.get('cx-product-list cx-product-grid-item').should( + 'have.length.at.least', + 1 + ); navigateToCategory('Snow', 'snow', true); - cy.get('cx-product-list').should('exist'); }); });