Skip to content

Commit

Permalink
CXSPA-700: fix promotion tabs issue and make tests as flaky
Browse files Browse the repository at this point in the history
  • Loading branch information
i53577 committed Sep 14, 2023
1 parent 2097401 commit 67cf486
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import * as checkout from '../../../../helpers/checkout-flow';
import { POWERTOOLS_BASESITE } from '../../../../sample-data/b2b-checkout';
import { ELECTRONICS_BASESITE } from '../../../../helpers/checkout-flow';
import * as asm from '../../../../helpers/asm';
import { addProductToCart } from '../../../../helpers/checkout-flow';
import {
interceptDelete,
interceptPost,
} from '../../../../support/utils/intercept';

context('Assisted Service Module', () => {
const customer = {
Expand Down Expand Up @@ -93,12 +98,17 @@ context('Assisted Service Module', () => {
});
});
it('should be able to sent customer coupon for customer coupon (CXSPA-3945)', () => {
interceptPost(
'claim_customer_coupon',
'/users/*/customercoupons/*/claim?*'
);
cy.get('.cx-asm-customer-promotion-listing-row')
.contains('Buy over $1000 get 20% off on cart')
.parent()
.parent()
.within(() => {
cy.get('button').contains('Assign to Customer').click();
cy.wait(`@claim_customer_coupon`);
});
cy.get('.cx-asm-customer-promotion-listing-row').should(
'not.contain',
Expand All @@ -107,12 +117,17 @@ context('Assisted Service Module', () => {
});
it('should be able to remove customer coupon for customer coupon (CXSPA-3945)', () => {
cy.get('.cx-tab-header').contains('Sent').click();
interceptDelete(
'disclaim_customer_coupon',
'/users/*/customercoupons/*/claim?*'
);
cy.get('.cx-asm-customer-promotion-listing-row')
.contains('Buy over $1000 get 20% off on cart')
.parent()
.parent()
.within(() => {
cy.get('button').contains('Remove').click();
cy.wait(`@disclaim_customer_coupon`);
});
cy.get('.cx-asm-customer-promotion-listing-row').should(
'not.contain',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import { clearAllStorage } from '../../../support/utils/clear-all-storage';
import * as checkout from '../../../helpers/checkout-flow';
import { waitForPage } from '../../../helpers/navigation';
import { waitForProductPage } from '../../../helpers/checkout-flow';
import { addProductToCart } from '../../../helpers/checkout-flow';
import {
interceptDelete,
interceptPost,
} from '../../../support/utils/intercept';

context('Assisted Service Module', () => {
before(() => {
Expand Down Expand Up @@ -255,9 +260,7 @@ context('Assisted Service Module', () => {
it('promotion rule should be auto applied when the total price of the cart reaches the promotion threshold(CXSPA-3932)', () => {
checkout.goToProductDetailsPage();
cy.get('input[type="number"]').clear().type('100');
cy.get('cx-add-to-cart')
.findByText(/Add To Cart/i)
.click({ force: true });
addProductToCart();
checkout.visitHomePage('asm=true');
cy.get('button.cx-360-button').click();
cy.get('button.cx-tab-header').contains('Promotion').click();
Expand Down Expand Up @@ -301,12 +304,17 @@ context('Assisted Service Module', () => {
});
});
it('should be able to sent customer coupon for customer coupon (CXSPA-3945)', () => {
interceptPost(
'claim_customer_coupon',
'/users/*/customercoupons/*/claim?*'
);
cy.get('.cx-asm-customer-promotion-listing-row')
.contains('Buy over $1000 get 20% off on cart')
.parent()
.parent()
.within(() => {
cy.get('button').contains('Assign to Customer').click();
cy.wait(`@claim_customer_coupon`);
});
cy.get('.cx-asm-customer-promotion-listing-row').should(
'not.contain',
Expand All @@ -315,12 +323,17 @@ context('Assisted Service Module', () => {
});
it('should be able to remove customer coupon for customer coupon (CXSPA-3945)', () => {
cy.get('.cx-tab-header').contains('Sent').click();
interceptDelete(
'disclaim_customer_coupon',
'/users/*/customercoupons/*/claim?*'
);
cy.get('.cx-asm-customer-promotion-listing-row')
.contains('Buy over $1000 get 20% off on cart')
.parent()
.parent()
.within(() => {
cy.get('button').contains('Remove').click();
cy.wait(`@disclaim_customer_coupon`);
});
cy.get('.cx-asm-customer-promotion-listing-row').should(
'not.contain',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2453,5 +2453,7 @@ export const tabbingOrderConfig: TabbingOrderConfig = {
{ type: TabbingOrderTypes.BUTTON, value: ' Assign to Customer ' },
{ type: TabbingOrderTypes.BUTTON, value: ' Assign to Customer ' },
{ type: TabbingOrderTypes.BUTTON, value: ' Assign to Customer ' },
// uncomment the following line to test againt S4,S7
{ type: TabbingOrderTypes.BUTTON, value: ' Assign to Customer ' },
],
};

0 comments on commit 67cf486

Please sign in to comment.