Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
shardIndex: [1,2]
shardIndex: [1,2,3]
shardTotal: [2]

steps:
Expand All @@ -31,6 +31,14 @@ jobs:
run: |
echo "USERNAME=${{ secrets.USERNAME }}" >> .env
echo "PASSWORD=${{ secrets.PASSWORD }}" >> .env
echo "PASSWORD=${{ secrets.PASSWORD }}" >> .env
echo "NEW_PASSWORD=${{ secrets.NEW_PASSWORD }}" >> .env
echo "FIRST_NAME=${{ secrets.FIRST_NAME }}" >> .env
echo "STREET_NAME=${{ secrets.STREET_NAME }}" >> .env
echo "CITY=${{ secrets.CITY }}" >> .env
echo "STATE=${{ secrets.STATE }}" >> .env
echo "COUNTRY=${{ secrets.COUNTRY }}" >> .env
echo "ZIP_CODE=${{ secrets.ZIP_CODE }}" >> .env

- name: Cache npm dependencies
uses: actions/cache@v3
Expand Down
20 changes: 18 additions & 2 deletions pages/AllPages.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
import LoginPage from "./LoginPage";
import UserPage from "./UserPage";
import InventoryPage from "./InventoryPage";
import SignupPage from "./SignupPage";
import HomePage from "./HomePage";
import AllProductsPage from "./AllProductsPage";
import ProductDetailsPage from "./ProductDetailsPage";
import CartPage from "./CartPage";
import CheckoutPage from "./CheckoutPage";
import OrderPage from "./OrderPage"; // Import OrderPage
import UserPage from "./UserPage"; // Import UserPage
import OrderDetailsPage from "./OrderDetailsPage";

class AllPages {
constructor(page) {
this.page = page;
this.loginPage = new LoginPage(page);
this.inventoryPage = new InventoryPage(page);
this.userPage = new UserPage(page);
this.signupPage = new SignupPage(page);
this.homePage = new HomePage(page);
this.allProductsPage = new AllProductsPage(page);
this.productDetailsPage = new ProductDetailsPage(page);
this.cartPage = new CartPage(page);
this.checkoutPage = new CheckoutPage(page);
this.orderPage = new OrderPage(page); // Instantiate OrderPage
this.userPage = new UserPage(page); // Instantiate UserPage
this.orderDetailsPage = new OrderDetailsPage(page);
}
}

Expand Down
64 changes: 64 additions & 0 deletions pages/AllProductsPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import BasePage from './BasePage.js';
import { expect } from '@playwright/test';

class AllProductsPage extends BasePage{

/**
* @param {import('@playwright/test').Page} page
*/
constructor(page) {
super(page);
this.page = page;
}

locators = {
allProductsTitle: `//h1[text()="All Products"]`,
nthProduct: `[href*="/product-detail/product"]`,
nthProductName: `[href*="/product-detail/product"] h2`,
nthProductPrice: `[href*="/product-detail/product"] p`,
nthProductReviewCount: `[href*="/product-detail/product"] h2 + div span.text-sm`,
nthProductWishlistIcon: '[aria-label="heart"]',
nthProductWishlistIconCount: '.bg-orange-100'
}

async assertAllProductsTitle() {
await expect(this.page.locator(this.locators.allProductsTitle)).toBeVisible();
}

getNthProduct(n) {
return this.page.locator(this.locators.nthProduct).nth(n - 1)
}

async clickNthProduct(n) {
await this.getNthProduct(n).click();
}

getNthProductName(n) {
return this.page.locator(this.locators.nthProductName).nth(n - 1).textContent();
}

getNthProductPrice(n) {
return this.page.locator(this.locators.nthProductPrice).nth(n - 1).textContent();
}

getNthProductReviewCount(n) {
return this.page.locator(this.locators.nthProductReviewCount).nth(n - 1).textContent();
}

getNthProductWishlistIcon(n) {
return this.page.locator(this.locators.nthProductWishlistIcon).nth(n - 1)
}

async clickNthProductWishlistIcon(n) {
await this.getNthProduct(n).hover()
await this.getNthProductWishlistIcon(n).click();
await expect(this.page.getByText('Added to the wishlist')).toBeVisible();
}

getNthProductWishlistIconCount(n) {
return this.page.locator(this.locators.nthProductWishlistIconCount).nth(n - 1);
}

}

export default AllProductsPage;
128 changes: 128 additions & 0 deletions pages/CartPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import BasePage from './BasePage.js';
import { expect } from '@playwright/test';

class CartPage extends BasePage{

/**
* @param {import('@playwright/test').Page} page
*/
constructor(page) {
super(page);
this.page = page;
}

locators = {
yourCartTitle: 'h2:has-text("Your Cart")',
cartItemImage: '[data-testid="cart-item-image"]',
cartItemName: '[data-testid="cart-item-header"]',
cartItemQuantity: '[data-testid="item-quantity"]',
increaseQuantityButton: '[data-testid="increase-quantity"]',
decreaseQuantityButton: '[data-testid="decrease-quantity"]',
cartItemPrice: '[data-testid="item-price"]',
removeCartItem: '[data-testid="remove-item"]',
subtotalLabel: '[data-testid="subtotal-label"]',
subtotalValue: '[data-testid="subtotal-value"]',
shippingLabel: '[data-testid="shipping-label"]',
shippingValue: '[data-testid="shipping-value"]',
totalLabel: '[data-testid="total-label"]',
totalValue: '[data-testid="total-value"]',
checkoutButton: '[data-testid="checkout-button"]',
viewCartButton: '[data-testid="view-cart-button"]',
shoppingCartIcon: "//*[name()='svg'][.//*[name()='path' and contains(@d,'M0 24C0 10')]]",
}

async assertYourCartTitle() {
await expect(this.page.locator(this.locators.yourCartTitle)).toBeVisible({ timeout: 10000 });
}

getCartItemImage() {
return this.page.locator(this.locators.cartItemImage)
}

getCartItemName() {
return this.page.locator(this.locators.cartItemName)
}

getCartItemQuantity() {
return this.page.locator(this.locators.cartItemQuantity)
}

getIncreaseQuantityButton() {
return this.page.locator(this.locators.increaseQuantityButton).first();
}

async clickIncreaseQuantityButton() {
await this.getIncreaseQuantityButton().click();
}

getDecreaseQuantityButton() {
return this.page.locator(this.locators.decreaseQuantityButton)
}

async clickDecreaseQuantityButton() {
await this.getDecreaseQuantityButton().click();
}

getCartItemPrice() {
return this.page.locator(this.locators.cartItemPrice)
}

getRemoveCartItem() {
return this.page.locator(this.locators.removeCartItem)
}

getSubtotalLabel() {
return this.page.locator(this.locators.subtotalLabel)
}

getSubtotalValue() {
return this.page.locator(this.locators.subtotalValue)
}

getShippingLabel() {
return this.page.locator(this.locators.shippingLabel)
}

getShippingValue() {
return this.page.locator(this.locators.shippingValue)
}

getTotalLabel() {
return this.page.locator(this.locators.totalLabel)
}

getTotalValue() {
return this.page.locator(this.locators.totalValue);
}

getCheckoutButton() {
return this.page.locator(this.locators.checkoutButton)
}

async clickCheckoutButton() {
await this.getCheckoutButton().click();
}

getViewCartButton() {
return this.page.locator(this.locators.viewCartButton)
}

async clickViewCartButton() {
await this.getViewCartButton().click();
}

async clickOnCartIcon() {
await this.page.locator(this.locators.shoppingCartIcon).click({ force: true });
}

async verifyCartItemVisible(productName) {
await expect(this.page.locator(this.locators.cartItemName)).toBeVisible();
await expect(this.page.locator(this.locators.cartItemName)).toHaveText(productName);
}

async clickOnCheckoutButton() {
await this.page.locator(this.locators.checkoutButton).click({ force: true });
}
}

export default CartPage;
Loading
Loading