Skip to content

Commit

Permalink
test: cypress test stabilization
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi committed Apr 15, 2020
1 parent 1fd4b1f commit 4c33bfd
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ export class WishlistsOverviewPage {

readonly header = new HeaderModule();

static navigateTo() {
cy.visit('/account/wishlists');
}

addWishlist(name: string, preferred: boolean) {
cy.get('a[data-testing-id="add-wishlist"').click();
cy.get('[data-testing-id="wishlist-dialog-name"]')
Expand Down
13 changes: 13 additions & 0 deletions e2e/cypress/integration/pages/header.module.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { waitLoadingEnd } from '../framework';

import { MiniCartModule } from './checkout/mini-cart.module';
import { SearchBoxModule } from './shopping/search-box.module';

Expand All @@ -19,18 +21,29 @@ export class HeaderModule {

gotoHomePage() {
cy.get('[data-testing-id="header-home-link-desktop"]').click();
waitLoadingEnd();
}

gotoLoginPage() {
cy.get('[data-testing-id="user-status-desktop"] .my-account-login').click();
waitLoadingEnd();
}

gotoRegistrationPage() {
cy.get('[data-testing-id="user-status-desktop"] .my-account-register').click();
waitLoadingEnd();
}

gotoCategoryPage(categoryUniqueId: string) {
cy.get(`[data-testing-id="${categoryUniqueId}-link"]`).click();
waitLoadingEnd();
}

gotoWishlists() {
cy.get('ish-wishlists-link a')
.eq(0)
.click({ force: true });
waitLoadingEnd();
}

logout() {
Expand Down
3 changes: 3 additions & 0 deletions e2e/cypress/integration/pages/shopping/category.page.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { waitLoadingEnd } from '../../framework';

export class CategoryPage {
readonly tag = 'ish-category-categories';

gotoSubCategory(categoryUniqueId: string) {
cy.get(`div[data-testing-id="category-${categoryUniqueId}"] a`).click({ force: true });
waitLoadingEnd();
}

get subCategories() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export class ProductListModule {
cy.get(this.contextSelector)
.find(`ish-product-item div[data-testing-sku="${sku}"]`)
.click();
waitLoadingEnd();
}

addProductToCompareBySku(sku: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ describe('Wishlist MyAccount Functionality', () => {

before(() => {
createUserViaREST(_.user);
LoginPage.navigateTo();
LoginPage.navigateTo('/account/wishlists');
at(LoginPage, page => {
page.fillForm(_.user.login, _.user.password);
page
.submit()
.its('status')
.should('equal', 200);
});
WishlistsOverviewPage.navigateTo();
at(WishlistsOverviewPage);
});

it('user creates an unpreferred wishlist', () => {
Expand Down Expand Up @@ -122,8 +122,8 @@ describe('Wishlist MyAccount Functionality', () => {
cy.wait(500);
page.wishlistTitle.should('equal', anotherWishlist);
page.getWishlistItemById(_.product1).should('exist');
page.header.gotoWishlists();
});
WishlistsOverviewPage.navigateTo();
at(WishlistsOverviewPage, page => {
page.goToWishlistDetailLink(editedWishlist);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ describe('Wishlist Shopping Experience Functionality', () => {
const shoppingPreferred = 'shopping wishlist preferred';
before(() => {
createUserViaREST(_.user);
LoginPage.navigateTo();
LoginPage.navigateTo('/account/wishlists');
at(LoginPage, page => {
page.fillForm(_.user.login, _.user.password);
page
.submit()
.its('status')
.should('equal', 200);
});
WishlistsOverviewPage.navigateTo();
at(WishlistsOverviewPage, page => {
page.addWishlist(unpreferredWishlist, false);
page.addWishlist(shoppingUnpreferred, false);
Expand Down Expand Up @@ -79,7 +78,7 @@ describe('Wishlist Shopping Experience Functionality', () => {
});

it('user adds a product to wishlist from shopping cart (to a preferred wishlist without selection)', () => {
WishlistsOverviewPage.navigateTo();
at(WishlistsDetailsPage, page => page.header.gotoWishlists());
at(WishlistsOverviewPage, page => {
page.addWishlist(shoppingPreferred, true);
page.header.miniCart.goToCart();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ describe('Anonymous Sleeping User', () => {
cy.route({
method: 'GET',
url: `**/products/${_.product}*`,
}).as('valid');
cy.wait('@valid');
});

waitLoadingEnd(5000);
cy.window().screenshot();
});
Expand Down Expand Up @@ -64,8 +64,8 @@ describe('Anonymous Sleeping User', () => {
cy.route({
method: 'GET',
url: `**/cms/**`,
}).as('valid');
cy.wait('@valid');
});

waitLoadingEnd(5000);
cy.window().screenshot();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ describe('Logged in Sleeping User', () => {
cy.route({
method: 'GET',
url: `**/products/${_.product}*`,
}).as('valid');
cy.wait('@valid');
});

cy.wait(5000);
cy.window().screenshot();
});
Expand Down

0 comments on commit 4c33bfd

Please sign in to comment.