Skip to content

Commit

Permalink
feat(e2e): add tags for playwright tests (#1436)
Browse files Browse the repository at this point in the history
  • Loading branch information
kstala authored Nov 8, 2024
1 parent c762fd5 commit 8551a70
Show file tree
Hide file tree
Showing 15 changed files with 133 additions and 117 deletions.
2 changes: 1 addition & 1 deletion apps/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"description": "",
"scripts": {
"test:e2e": "playwright test e2e",
"test:e2e": "playwright test --grep @vue-demo-store",
"test:examples": "playwright test -c examples.config.ts checkCodeExamples.spec.ts",
"lint": "biome lint .",
"start": "npx http-server"
Expand Down
2 changes: 1 addition & 1 deletion apps/e2e-tests/tests/addProductReview.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require("dotenv").config({ path: findEnv() });
const userEmail = process.env.USER_EMAIL || "[email protected]";
const password = process.env.PASSWORD || "shopware123";

test.describe("Add review", () => {
test.describe("Add review", { tag: "@vue-demo-store" }, () => {
let homePage: HomePage;
let productPage: ProductPage;
let loginform: LoginForm;
Expand Down
64 changes: 34 additions & 30 deletions apps/e2e-tests/tests/addToCart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,41 @@ import { CartPage } from "../page-objects/CartPage";
import { WishlistPage } from "../page-objects/WishlistPage";

test.setTimeout(50000);
test.describe.parallel("Add product to cart / Remove from cart", () => {
let homePage: HomePage;
let productPage: ProductPage;
let cartPage: CartPage;
let wishlistPage: WishlistPage;
test.describe.parallel(
"Add product to cart / Remove from cart",
{ tag: "@vue-demo-store" },
() => {
let homePage: HomePage;
let productPage: ProductPage;
let cartPage: CartPage;
let wishlistPage: WishlistPage;

// Before Hook
test.beforeEach(async ({ page }) => {
homePage = new HomePage(page);
productPage = new ProductPage(page);
cartPage = new CartPage(page);
wishlistPage = new WishlistPage(page);
// Before Hook
test.beforeEach(async ({ page }) => {
homePage = new HomePage(page);
productPage = new ProductPage(page);
cartPage = new CartPage(page);
wishlistPage = new WishlistPage(page);

await homePage.visitMainPage();
});
await homePage.visitMainPage();
});

test("Add product to cart", async ({ page }) => {
await homePage.openCartPage();
await productPage.addToCart();
await cartPage.openMiniCart();
await page.getByTestId("cart-product-image").waitFor();
await expect(page.getByTestId("cart-product-image")).toBeVisible();
});
test("Add product to cart", async ({ page }) => {
await homePage.openCartPage();
await productPage.addToCart();
await cartPage.openMiniCart();
await page.getByTestId("cart-product-image").waitFor();
await expect(page.getByTestId("cart-product-image")).toBeVisible();
});

test("Add product to cart from wishlist", async ({ page }) => {
await page.waitForEvent("requestfinished");
await homePage.addProductToWishlist();
await wishlistPage.openWishlist();
await expect(page.getByTestId("product-box")).toHaveCount(1);
await productPage.addToCart();
await cartPage.openMiniCart();
await expect(page.getByTestId("cart-product-image")).toBeVisible();
});
});
test("Add product to cart from wishlist", async ({ page }) => {
await page.waitForEvent("requestfinished");
await homePage.addProductToWishlist();
await wishlistPage.openWishlist();
await expect(page.getByTestId("product-box")).toHaveCount(1);
await productPage.addToCart();
await cartPage.openMiniCart();
await expect(page.getByTestId("cart-product-image")).toBeVisible();
});
},
);
62 changes: 33 additions & 29 deletions apps/e2e-tests/tests/addToWishlist.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,41 @@ import { HomePage } from "../page-objects/HomePage";
import { ProductPage } from "../page-objects/ProductPage";
import { WishlistPage } from "../page-objects/WishlistPage";

test.describe.parallel("Add product to wishlist / Remove from wishlist", () => {
let homePage: HomePage;
let productPage: ProductPage;
let wishlistPage: WishlistPage;
test.describe.parallel(
"Add product to wishlist / Remove from wishlist",
{ tag: "@vue-demo-store" },
() => {
let homePage: HomePage;
let productPage: ProductPage;
let wishlistPage: WishlistPage;

// Before Hook
test.beforeEach(async ({ page }) => {
homePage = new HomePage(page);
productPage = new ProductPage(page);
wishlistPage = new WishlistPage(page);
// Before Hook
test.beforeEach(async ({ page }) => {
homePage = new HomePage(page);
productPage = new ProductPage(page);
wishlistPage = new WishlistPage(page);

await homePage.visitMainPage();
});
await homePage.visitMainPage();
});

test("Add product to wishlist", async ({ page }) => {
await homePage.addProductToWishlist();
await wishlistPage.openWishlist();
await expect(page.getByTestId("product-box")).toHaveCount(1);
});
test("Add product to wishlist", async ({ page }) => {
await homePage.addProductToWishlist();
await wishlistPage.openWishlist();
await expect(page.getByTestId("product-box")).toHaveCount(1);
});

test("Remove product from wishlist", async ({ page }) => {
await homePage.addProductToWishlist();
await wishlistPage.openWishlist();
await wishlistPage.removeProductFromWishlist();
await expect(page.getByTestId("wishlist-empty")).toHaveCount(1);
});
test("Remove product from wishlist", async ({ page }) => {
await homePage.addProductToWishlist();
await wishlistPage.openWishlist();
await wishlistPage.removeProductFromWishlist();
await expect(page.getByTestId("wishlist-empty")).toHaveCount(1);
});

test("Clear whole wishlist", async ({ page }) => {
await homePage.addProductToWishlist();
await wishlistPage.openWishlist();
await wishlistPage.clearWishlist();
await expect(page.getByTestId("wishlist-empty")).toHaveCount(1);
});
});
test("Clear whole wishlist", async ({ page }) => {
await homePage.addProductToWishlist();
await wishlistPage.openWishlist();
await wishlistPage.clearWishlist();
await expect(page.getByTestId("wishlist-empty")).toHaveCount(1);
});
},
);
2 changes: 1 addition & 1 deletion apps/e2e-tests/tests/checkCategory.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { test, expect } from "@playwright/test";
import { HomePage } from "../page-objects/HomePage";
import { CategoryPage } from "../page-objects/CategoryPage";

test.describe("Check category page", () => {
test.describe("Check category page", { tag: "@vue-demo-store" }, () => {
let homePage: HomePage;
let categoryPage: CategoryPage;

Expand Down
2 changes: 1 addition & 1 deletion apps/e2e-tests/tests/checkCodeExamples.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const directoryPath = path.join(__dirname, "../../../examples/");
fs.readdirSync(directoryPath)
.filter((file) => !IGNORE_CHECK_EXAMPLES.includes(file))
.forEach((file) => {
test(`Verify ${file}`, async ({ page }) => {
test(`Verify, { tag: "stackblitz" }, ${file}`, async ({ page }) => {
const exampleName = `shopware/frontends/tree/main/examples/${file}`;
await page.goto(`file://${__dirname}/pages/blank.html`, {
waitUntil: "domcontentloaded",
Expand Down
2 changes: 1 addition & 1 deletion apps/e2e-tests/tests/checkForSeoUrl.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect, request } from "@playwright/test";
import { HomePage } from "../page-objects/HomePage";

test.describe("Check for seo-url requests", () => {
test.describe("Check for seo-url requests", { tag: "@vue-demo-store" }, () => {
let homePage: HomePage;

// Before Hook
Expand Down
36 changes: 20 additions & 16 deletions apps/e2e-tests/tests/checkProductVariants.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,26 @@ import { HomePage } from "../page-objects/HomePage";
import { ProductPage } from "../page-objects/ProductPage";
import { CartPage } from "../page-objects/CartPage";

test.describe.parallel("Check product variants", () => {
let homePage: HomePage;
let productPage: ProductPage;
let cartPage: CartPage;
test.describe.parallel(
"Check product variants",
{ tag: "@vue-demo-store" },
() => {
let homePage: HomePage;
let productPage: ProductPage;
let cartPage: CartPage;

// Before Hook
test.beforeEach(async ({ page }) => {
homePage = new HomePage(page);
productPage = new ProductPage(page);
cartPage = new CartPage(page);
// Before Hook
test.beforeEach(async ({ page }) => {
homePage = new HomePage(page);
productPage = new ProductPage(page);
cartPage = new CartPage(page);

await homePage.visitMainPage();
});
await homePage.visitMainPage();
});

test("Add product variants to cart", async ({ page }) => {
await homePage.openVariantsCartPage();
await productPage.addVariantToCart();
});
});
test("Add product variants to cart", async ({ page }) => {
await homePage.openVariantsCartPage();
await productPage.addVariantToCart();
});
},
);
2 changes: 1 addition & 1 deletion apps/e2e-tests/tests/checkSearch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { test, expect } from "@playwright/test";
import { HomePage } from "../page-objects/HomePage";
import { SearchResultPage } from "../page-objects/SearchResultPage";

test.describe("Check search page", () => {
test.describe("Check search page", { tag: "@vue-demo-store" }, () => {
let homePage: HomePage;
let resultPage: SearchResultPage;

Expand Down
2 changes: 1 addition & 1 deletion apps/e2e-tests/tests/checkStackblitzTemplates.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ declare global {
const directoryPath = path.join(__dirname, "../../../templates/");

fs.readdirSync(directoryPath).forEach((template) => {
test(`Open ${template}`, async ({ page }) => {
test(`Open, { tag: "@stackblitz" }, ${template}`, async ({ page }) => {
test.setTimeout(200000);
const templateName = `shopware/frontends/tree/main/templates/${template}`;
await page.goto(`file://${__dirname}/pages/blank.html`, {
Expand Down
2 changes: 1 addition & 1 deletion apps/e2e-tests/tests/createOrder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const userEmail = process.env.USER_EMAIL || "[email protected]";
const password = process.env.PASSWORD || "shopware123";
test.setTimeout(50000);

test.describe("Create Order", () => {
test.describe("Create Order", { tag: "@vue-demo-store" }, () => {
let homePage: HomePage;
let registrationPage: RegisterForm;
let checkoutPage: CheckoutPage;
Expand Down
2 changes: 1 addition & 1 deletion apps/e2e-tests/tests/login.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require("dotenv").config({ path: findEnv() });
const userEmail = process.env.USER_EMAIL || "[email protected]";
const password = process.env.PASSWORD || "shopware123";

test.describe("Login user", () => {
test.describe("Login user", { tag: "@vue-demo-store" }, () => {
let homePage: HomePage;
let loginForm: LoginForm;

Expand Down
66 changes: 35 additions & 31 deletions apps/e2e-tests/tests/myAccountTests.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,41 @@ import { HomePage } from "../page-objects/HomePage";
import { MyAccountPage } from "../page-objects/MyAccountPage";
import { RegisterForm } from "../page-objects/RegisterPage";

test.describe.parallel("My account functionalities tests", () => {
let homePage: HomePage;
let myAccountPage: MyAccountPage;
let registrationPage: RegisterForm;
test.describe.parallel(
"My account functionalities tests",
{ tag: "@vue-demo-store" },
() => {
let homePage: HomePage;
let myAccountPage: MyAccountPage;
let registrationPage: RegisterForm;

// Before Hook
test.beforeEach(async ({ page }) => {
homePage = new HomePage(page);
myAccountPage = new MyAccountPage(page);
registrationPage = new RegisterForm(page);
// Before Hook
test.beforeEach(async ({ page }) => {
homePage = new HomePage(page);
myAccountPage = new MyAccountPage(page);
registrationPage = new RegisterForm(page);

await homePage.visitMainPage();
});
await homePage.visitMainPage();
});

test("Change personal data", async ({ page }) => {
await homePage.clickOnSignIn();
await homePage.openRegistrationPage();
await registrationPage.createUser();
await homePage.openMyAccount();
await myAccountPage.changePersonalData();
await myAccountPage.changePersonalFirstName("test first name");
await myAccountPage.changePersonalLastName("test last name");
expect(
await page
.getByTestId("account-personal-data-firstname-input")
.inputValue(),
).toEqual("test first name");
expect(
await page
.getByTestId("account-personal-data-lastname-input")
.inputValue(),
).toEqual("test last name");
});
});
test("Change personal data", async ({ page }) => {
await homePage.clickOnSignIn();
await homePage.openRegistrationPage();
await registrationPage.createUser();
await homePage.openMyAccount();
await myAccountPage.changePersonalData();
await myAccountPage.changePersonalFirstName("test first name");
await myAccountPage.changePersonalLastName("test last name");
expect(
await page
.getByTestId("account-personal-data-firstname-input")
.inputValue(),
).toEqual("test first name");
expect(
await page
.getByTestId("account-personal-data-lastname-input")
.inputValue(),
).toEqual("test last name");
});
},
);
2 changes: 1 addition & 1 deletion apps/e2e-tests/tests/registrationUser.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { HomePage } from "../page-objects/HomePage";
import { RegisterForm } from "../page-objects/RegisterPage";
import { faker } from "@faker-js/faker";

test.describe("Registration new user", () => {
test.describe("Registration new user", { tag: "@vue-demo-store" }, () => {
let homePage: HomePage;
let registrationPage: RegisterForm;

Expand Down
2 changes: 1 addition & 1 deletion apps/e2e-tests/tests/search.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { test, expect } from "@playwright/test";
import { HomePage } from "../page-objects/HomePage";
import { SearchResultPage } from "../page-objects/SearchResultPage";

test.describe("Search phrase", () => {
test.describe("Search phrase", { tag: "@vue-demo-store" }, () => {
let homePage: HomePage;
let resultPage: SearchResultPage;

Expand Down

0 comments on commit 8551a70

Please sign in to comment.