Skip to content

Commit

Permalink
Merge branch 'develop-6.3.x' into epic/b2b-commerce-quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
Larisa-Staroverova committed Jul 18, 2023
2 parents 534580c + d1328a3 commit 6bd5b2b
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ context('Assisted Service Module', () => {

asm.agentLogin('[email protected]', 'pw4all');
asm.asmB2bCustomerLists();
asm.agentSignOut();
});

it('checking pagination (CXSPA-2109)', () => {
Expand All @@ -61,7 +60,6 @@ context('Assisted Service Module', () => {

asm.agentLogin('[email protected]', 'pw4all');
asm.asmB2bCustomerListPagination();
asm.agentSignOut();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -58,40 +58,35 @@ 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();
cy.get('cx-cart-details').then(() => {
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();
Expand All @@ -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<string>('@anonymousCartCode').then((anonymousCartCode) => {
cy.log(`--> Anonymous cart id: ${anonymousCartCode}`);
Expand All @@ -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(() => {
Expand Down Expand Up @@ -155,30 +152,26 @@ 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();
cy.get('cx-cart-details').then(() => {
const customerCartCode = JSON.parse(
window.localStorage.getItem('spartacus⚿electronics-spa⚿cart')
).active;
cy.get<string>('@anonymousCartCode').then((anonymousCartCode) => {
expect(customerCartCode).to.equal(anonymousCartCode);
});
expect(customerCartCode).to.equal(anonymousCartCodeForReplaceBindCart);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -35,7 +36,6 @@ context('Assisted Service Module', () => {
asm.asmOpenCreateCustomerDialogOnCustomerListDialog();

cy.log('--> fill form');
let user = getSampleUser();
asm.fillCreateCustomerForm(user);

cy.log('--> submit form');
Expand All @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -206,8 +204,6 @@ context('Assisted Service Module', () => {

cy.log('--> close create customer dialog');
asm.asmCloseCreateCustomerDialog();

asm.agentSignOut();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ context('Assisted Service Module', () => {

asm.agentLogin('asagent', 'pw4all');
asm.asmCustomerLists();
asm.agentSignOut();
});

it('checking pagination (CXSPA-2109)', () => {
Expand All @@ -37,7 +36,6 @@ context('Assisted Service Module', () => {

asm.agentLogin('asagent', 'pw4all');
asm.asmCustomerListPagination();
asm.agentSignOut();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
}
1 change: 1 addition & 0 deletions projects/storefrontapp-e2e-cypress/cypress/helpers/asm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 6bd5b2b

Please sign in to comment.