Skip to content

Commit

Permalink
fix: flaky tests improvements (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
kstala committed Apr 27, 2023
1 parent a1edcd1 commit 4369d4a
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 28 deletions.
2 changes: 1 addition & 1 deletion apps/e2e-tests/page-objects/CartPage.ts
Expand Up @@ -14,7 +14,7 @@ export class CartPage {
}

async openMiniCart() {
await this.page.waitForLoadState();
await this.miniCartLink.waitFor();
await this.miniCartLink.click();
}

Expand Down
6 changes: 4 additions & 2 deletions apps/e2e-tests/page-objects/CheckoutPage.ts
Expand Up @@ -40,8 +40,10 @@ export class CheckoutPage {
}

async goToCheckout() {
await this.page.waitForSelector("[data-testid='cart-product-image']");
await this.goToCheckoutButton.click();
await Promise.all([
await this.page.waitForSelector("[data-testid='cart-product-image']"),
await this.goToCheckoutButton.click(),
]);
}

async markTerms() {
Expand Down
24 changes: 13 additions & 11 deletions apps/e2e-tests/page-objects/HomePage.ts
Expand Up @@ -32,13 +32,13 @@ export class HomePage extends AbstractPage {
}

async clickOnSignIn() {
await this.page.waitForLoadState("load");
await this.signInButton.isEnabled();
await this.signInButton.click();
await expect(this.page.getByTestId("header-sign-in-link")).toBeVisible();
await this.signInButton.waitFor();
await this.signInButton.dispatchEvent("click");
}

async openCartPage() {
await this.page.waitForLoadState("load");
await this.linkToCartPage.waitFor();
await this.linkToCartPage.click();
await this.page.waitForSelector("[data-testid='product-quantity']");
await this.page.waitForLoadState("load");
Expand All @@ -51,9 +51,10 @@ export class HomePage extends AbstractPage {
}

async openRegistrationPage() {
await this.page.waitForLoadState("load");
await this.linkToRegistrationPage.isVisible();
await this.linkToRegistrationPage.click();
await Promise.all([
await this.page.waitForLoadState("load"),
await this.linkToRegistrationPage.click(),
]);
}

async typeSearchPhrase(phrase: string) {
Expand All @@ -65,13 +66,14 @@ export class HomePage extends AbstractPage {
async addProductToWishlist() {
await Promise.all([
this.page.waitForLoadState("load"),
await this.addToWishlist.nth(13).click(),
await this.addToWishlist.nth(13).dispatchEvent("click"),
]);
}

async openMyAccount() {
this.page.waitForLoadState("load");
await this.accountMenuHelloButton.click();
await this.myAccountLink.click();
await this.accountMenuHelloButton.waitFor();
await this.accountMenuHelloButton.dispatchEvent("click");
await this.myAccountLink.waitFor();
await this.myAccountLink.dispatchEvent("click");
}
}
3 changes: 1 addition & 2 deletions apps/e2e-tests/page-objects/LoginPage.ts
Expand Up @@ -20,8 +20,7 @@ export class LoginForm {
await this.usernameInput.isVisible();
await this.usernameInput.type(username);
await this.passwordInput.type(password);
await this.page.waitForLoadState("load");
await this.page.waitForLoadState();
await this.submitButton.click();
await this.page.waitForLoadState("load");
}
}
5 changes: 2 additions & 3 deletions apps/e2e-tests/page-objects/MyAccountPage.ts
Expand Up @@ -44,9 +44,8 @@ export class MyAccountPage {
}

async changePersonalData() {
await this.page.waitForLoadState();
await this.accountChangeProfileButton.click();
await this.page.waitForLoadState("load");
await this.accountChangeProfileButton.waitFor();
await this.accountChangeProfileButton.dispatchEvent("click");
}

async changePersonalFirstName(firstname: string) {
Expand Down
11 changes: 7 additions & 4 deletions apps/e2e-tests/page-objects/ProductPage.ts
Expand Up @@ -20,7 +20,8 @@ export class ProductPage {
}

async addToCart() {
await this.page.waitForLoadState("load");
await expect(this.page.getByTestId("add-to-cart-button")).toBeVisible();
await this.addToCartButton.waitFor();
await this.addToCartButton.click();
}

Expand All @@ -29,14 +30,16 @@ export class ProductPage {
.getByTestId("product-variant-text")
.all())
await variant.click(), await this.page.waitForLoadState("load");
await this.addToCartButton.isEnabled();
await this.addToCartButton.waitFor();
await this.addToCartButton.click();
await this.miniCartLink.click();
expect(this.variantText.textContent).toEqual(
this.productOption.textContent
);
await this.page.waitForLoadState("load");
await this.productRemove.click();
await Promise.all([
await this.page.waitForLoadState("load"),
await this.productRemove.click(),
]);
await this.page.getByTestId("cart-close-button").click();
}
}
15 changes: 10 additions & 5 deletions apps/e2e-tests/page-objects/RegisterPage.ts
Expand Up @@ -50,16 +50,19 @@ export class RegisterForm {
await this.zipcode.type(zipcode);
await this.city.type(city);
await this.country.selectOption({ label: "Germany" });
await this.page.waitForLoadState("load");
}

async submitRegistraionForm() {
await this.page.waitForLoadState("load");
await this.submitButton.click();
await Promise.all([
this.page.waitForLoadState(),
await this.submitButton.dispatchEvent("click"),
]);
await this.page.waitForSelector(
"[data-testid='product-box-wishlist-icon-not-in']"
);
}

async createUser() {
await this.page.waitForLoadState();
await this.salutation.selectOption({ label: "Mr." });
await this.firstName.type("e2e " + faker.name.firstName());
await this.lastName.type("e2e " + faker.name.lastName());
Expand All @@ -69,7 +72,9 @@ export class RegisterForm {
await this.zipcode.type(faker.address.zipCode());
await this.city.type(faker.address.city());
await this.country.selectOption({ label: "Germany" });
await this.page.waitForLoadState("load");
await this.submitButton.click();
await this.page.waitForSelector(
"[data-testid='product-box-wishlist-icon-not-in']"
);
}
}

2 comments on commit 4369d4a

@vercel
Copy link

@vercel vercel bot commented on 4369d4a Apr 27, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

frontends-demo – ./templates/vue-demo-store

frontends-demo-shopware-frontends.vercel.app
frontends-demo.vercel.app
frontends-demo-git-main-shopware-frontends.vercel.app

@vercel
Copy link

@vercel vercel bot commented on 4369d4a Apr 27, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.