Skip to content

Commit

Permalink
test: cypress stabilization (#454)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi authored Nov 6, 2020
1 parent 877398c commit f0010e5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion e2e/cypress/integration/pages/account/my-account.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class MyAccountPage {
}

navigateToAddresses() {
cy.get('a[data-testing-id="addresses-link"]').click({ force: true });
cy.get('a[data-testing-id="addresses-link"]').click();
}

navigateToWishlists() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { waitLoadingEnd } from '../../framework';
import { BreadcrumbModule } from '../breadcrumb.module';
import { HeaderModule } from '../header.module';

Expand Down Expand Up @@ -39,27 +40,29 @@ export class WishlistsDetailsPage {
cy.get('[data-testing-id="preferred"]').check();
}
cy.get('[data-testing-id="wishlist-dialog-submit"]').click();
cy.wait(500);
waitLoadingEnd(2000);
}

deleteWishlist(id: string) {
this.getWishlistItemById(id).find('[data-testing-id="delete-wishlist"]').click();
waitLoadingEnd(2000);
}

moveProductToWishlist(productId: string, listName: string) {
this.getWishlistItemById(productId).find('[data-testing-id="move-wishlist"]').click();
cy.get(`[data-testing-id="${listName}"]`).check();
cy.get('ngb-modal-window').find('button[class="btn btn-primary"]').click();
cy.get('[data-testing-id="wishlist-success-link"] a').click();
waitLoadingEnd(2000);
}

addProductToBasket(productId: string, quantity: number) {
this.getWishlistItemById(productId).find('[data-testing-id="quantity"]').clear().type(quantity.toString());

cy.wait(3000);
waitLoadingEnd(2000);
cy.server().route('POST', '**/baskets/*/items').as('basket');
cy.server().route('GET', '**/baskets/current*').as('basketCurrent');
cy.wait(3000);
waitLoadingEnd(2000);

this.getWishlistItemById(productId).find('[data-testing-id="addToCartButton"]').click();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class CheckoutPaymentPage {

submit() {
cy.get(`[data-testing-id=payment-parameter-form-${method}]`).find('[type="submit"]').click();
waitLoadingEnd(3000);
},

delete() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { at, waitLoadingEnd } from '../../framework';
import { at } from '../../framework';
import { createUserViaREST } from '../../framework/users';
import { LoginPage } from '../../pages/account/login.page';
import { sensibleDefaults } from '../../pages/account/registration.page';
Expand Down Expand Up @@ -109,7 +109,6 @@ describe('Wishlist MyAccount Functionality', () => {
it('user deletes a product from wishlist', () => {
at(WishlistsDetailsPage, page => {
page.deleteWishlist(_.product2);
waitLoadingEnd();
page.listItemLinks.invoke('attr', 'href').should('not.contain', _.product2);
page.listItemLinks.should('have.length', 1);
});
Expand All @@ -118,7 +117,6 @@ describe('Wishlist MyAccount Functionality', () => {
it('user moves a product to another wishlist', () => {
at(WishlistsDetailsPage, page => {
page.moveProductToWishlist(_.product1, anotherWishlist);
waitLoadingEnd();
page.wishlistTitle.should('equal', anotherWishlist);
page.getWishlistItemById(_.product1).should('exist');
page.header.gotoWishlists();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,11 @@ describe('Logged in Sleeping User', () => {

describe('being a long time on a myaccount page', () => {
it('should wait a long time on myaccount page after logging in', () => {
LoginPage.navigateTo();
LoginPage.navigateTo('/account/wishlists');
at(LoginPage, page => page.fillForm(_.user.login, _.user.password).submit().its('status').should('equal', 200));
at(MyAccountPage, page => {
page.header.myAccountLink.should('have.text', `${_.user.firstName} ${_.user.lastName}`);
waitLoadingEnd(2000);
});
});

Expand Down

0 comments on commit f0010e5

Please sign in to comment.