Skip to content

Commit

Permalink
test: add e2e tests for merging baskets with promotion code
Browse files Browse the repository at this point in the history
  • Loading branch information
SGrueber committed Jan 12, 2021
1 parent b306b29 commit e2eeb5f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,50 @@ describe('Basket Handling', () => {
at(ProductDetailPage, page => {
page.addProductToCart().its('status').should('equal', 201);
page.header.miniCart.total.should('contain', _.product.price);
page.header.miniCart.goToCart();
});
});

it('user adds a promotion code that can be applied yet', () => {
at(CartPage, page => {
page.lineItem(0).quantity.set(2);
cy.wait(1000);
page.collapsePromotionForm();
page.submitPromotionCode('INTERSHOP');
page.successMessage.message.should('contain', 'applied');
page.promotion.should('exist');
});
});

it('user logs in again and baskets should be merged', () => {
at(ProductDetailPage, page => page.header.gotoLoginPage());
at(CartPage, page => page.header.gotoLoginPage());
at(LoginPage, page => {
page.fillForm(_.user.login, _.user.password);
page.submit().its('status').should('equal', 200);
waitLoadingEnd(5000);
});
at(MyAccountPage, page => {
page.header.miniCart.total.should('contain', _.product.price * 2);
page.header.miniCart.total.should('contain', _.product.price * 3);
page.header.miniCart.goToCart();
});
at(CartPage, page => {
page.header.miniCart.total.should('contain', _.product.price * 3);
page.header.miniCart.goToCart();
page.promotion.should('exist');
});
});

it('user adds one more product to basket when logged in', () => {
at(MyAccountPage, page => page.header.gotoCategoryPage(_.catalog));
at(CartPage, page => page.header.gotoCategoryPage(_.catalog));
at(CategoryPage, page => page.gotoSubCategory(_.category.id));
at(FamilyPage, page => page.productList.gotoProductDetailPageBySku(_.product.sku));
at(ProductDetailPage, page => {
page.addProductToCart().its('status').should('equal', 200);
waitLoadingEnd(1000);
page.header.miniCart.total.should('contain', _.product.price * 3);
page.header.miniCart.total.should('contain', _.product.price * 4);
});
at(CartPage, page => {
page.lineItem(0).quantity.get().should('equal', '3');
page.lineItem(0).quantity.get().should('equal', '4');
});
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import { at } from '../../framework';
import { MyAccountPage } from '../../pages/account/my-account.page';
import { Registration, RegistrationPage, sensibleDefaults } from '../../pages/account/registration.page';
import { CartPage } from '../../pages/checkout/cart.page';
import { ProductDetailPage } from '../../pages/shopping/product-detail.page';

const _ = {
productSku: '201807171',
user: {
login: `testuser${new Date().getTime()}@test.intershop.de`,
...sensibleDefaults,
} as Registration,
};

describe('Promotion Handling in Cart', () => {
Expand Down Expand Up @@ -35,6 +41,23 @@ describe('Promotion Handling in Cart', () => {
});
});

it('user registers and the basket is merged with the promotion code', () => {
at(CartPage, page => {
page.header.gotoRegistrationPage();
});
at(RegistrationPage, page => {
page.fillForm(_.user);
page.acceptTAC();
page.submitAndObserve().its('statusMessage').should('equal', '201 (Created)');
});
at(MyAccountPage, page => {
page.header.miniCart.goToCart();
});
at(CartPage, page => {
page.promotion.should('exist');
});
});

it('user removes a promotion code', () => {
at(CartPage, page => {
page.removePromotionCode();
Expand Down

1 comment on commit e2eeb5f

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Azure Demo Servers are available:

Please sign in to comment.