From 4c33bfdda672c54dc4a4eee9d5f47ea6f4e9a600 Mon Sep 17 00:00:00 2001 From: Danilo Hoffmann Date: Sun, 12 Apr 2020 15:29:48 +0200 Subject: [PATCH] test: cypress test stabilization --- .../pages/account/wishlists-overview.page.ts | 4 ---- e2e/cypress/integration/pages/header.module.ts | 13 +++++++++++++ .../integration/pages/shopping/category.page.ts | 3 +++ .../pages/shopping/product-list.module.ts | 1 + .../extras/wishlists-management.b2c.e2e-spec.ts | 6 +++--- .../specs/extras/wishlists-shopping.b2c.e2e-spec.ts | 5 ++--- ...uthentication-timeouts-anonymous.b2c.e2e-spec.ts | 8 ++++---- ...authentication-timeouts-loggedin.b2c.e2e-spec.ts | 4 ++-- 8 files changed, 28 insertions(+), 16 deletions(-) diff --git a/e2e/cypress/integration/pages/account/wishlists-overview.page.ts b/e2e/cypress/integration/pages/account/wishlists-overview.page.ts index 8867ebf552..748d118ff3 100644 --- a/e2e/cypress/integration/pages/account/wishlists-overview.page.ts +++ b/e2e/cypress/integration/pages/account/wishlists-overview.page.ts @@ -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"]') diff --git a/e2e/cypress/integration/pages/header.module.ts b/e2e/cypress/integration/pages/header.module.ts index ea82561707..ce042d3eca 100644 --- a/e2e/cypress/integration/pages/header.module.ts +++ b/e2e/cypress/integration/pages/header.module.ts @@ -1,3 +1,5 @@ +import { waitLoadingEnd } from '../framework'; + import { MiniCartModule } from './checkout/mini-cart.module'; import { SearchBoxModule } from './shopping/search-box.module'; @@ -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() { diff --git a/e2e/cypress/integration/pages/shopping/category.page.ts b/e2e/cypress/integration/pages/shopping/category.page.ts index 65cc3fa9ce..d62d2bbb3d 100644 --- a/e2e/cypress/integration/pages/shopping/category.page.ts +++ b/e2e/cypress/integration/pages/shopping/category.page.ts @@ -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() { diff --git a/e2e/cypress/integration/pages/shopping/product-list.module.ts b/e2e/cypress/integration/pages/shopping/product-list.module.ts index c571b7ffcd..281eed52b2 100644 --- a/e2e/cypress/integration/pages/shopping/product-list.module.ts +++ b/e2e/cypress/integration/pages/shopping/product-list.module.ts @@ -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) { diff --git a/e2e/cypress/integration/specs/extras/wishlists-management.b2c.e2e-spec.ts b/e2e/cypress/integration/specs/extras/wishlists-management.b2c.e2e-spec.ts index c701b37b1b..8ec3fdd3bf 100644 --- a/e2e/cypress/integration/specs/extras/wishlists-management.b2c.e2e-spec.ts +++ b/e2e/cypress/integration/specs/extras/wishlists-management.b2c.e2e-spec.ts @@ -28,7 +28,7 @@ describe('Wishlist MyAccount Functionality', () => { before(() => { createUserViaREST(_.user); - LoginPage.navigateTo(); + LoginPage.navigateTo('/account/wishlists'); at(LoginPage, page => { page.fillForm(_.user.login, _.user.password); page @@ -36,7 +36,7 @@ describe('Wishlist MyAccount Functionality', () => { .its('status') .should('equal', 200); }); - WishlistsOverviewPage.navigateTo(); + at(WishlistsOverviewPage); }); it('user creates an unpreferred wishlist', () => { @@ -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); }); diff --git a/e2e/cypress/integration/specs/extras/wishlists-shopping.b2c.e2e-spec.ts b/e2e/cypress/integration/specs/extras/wishlists-shopping.b2c.e2e-spec.ts index c9ddf0d5bf..4430d4ab20 100644 --- a/e2e/cypress/integration/specs/extras/wishlists-shopping.b2c.e2e-spec.ts +++ b/e2e/cypress/integration/specs/extras/wishlists-shopping.b2c.e2e-spec.ts @@ -26,7 +26,7 @@ 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 @@ -34,7 +34,6 @@ describe('Wishlist Shopping Experience Functionality', () => { .its('status') .should('equal', 200); }); - WishlistsOverviewPage.navigateTo(); at(WishlistsOverviewPage, page => { page.addWishlist(unpreferredWishlist, false); page.addWishlist(shoppingUnpreferred, false); @@ -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(); diff --git a/e2e/cypress/integration/specs/system/authentication-timeouts-anonymous.b2c.e2e-spec.ts b/e2e/cypress/integration/specs/system/authentication-timeouts-anonymous.b2c.e2e-spec.ts index b366aa7b72..82db0f430e 100644 --- a/e2e/cypress/integration/specs/system/authentication-timeouts-anonymous.b2c.e2e-spec.ts +++ b/e2e/cypress/integration/specs/system/authentication-timeouts-anonymous.b2c.e2e-spec.ts @@ -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(); }); @@ -64,8 +64,8 @@ describe('Anonymous Sleeping User', () => { cy.route({ method: 'GET', url: `**/cms/**`, - }).as('valid'); - cy.wait('@valid'); + }); + waitLoadingEnd(5000); cy.window().screenshot(); }); diff --git a/e2e/cypress/integration/specs/system/authentication-timeouts-loggedin.b2c.e2e-spec.ts b/e2e/cypress/integration/specs/system/authentication-timeouts-loggedin.b2c.e2e-spec.ts index 1cd443a50d..3bf8aec864 100644 --- a/e2e/cypress/integration/specs/system/authentication-timeouts-loggedin.b2c.e2e-spec.ts +++ b/e2e/cypress/integration/specs/system/authentication-timeouts-loggedin.b2c.e2e-spec.ts @@ -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(); });