You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This repository contains automated UI tests for the ShopDemo e-commerce application using Playwright and TypeScript.
What I Implemented
End-to-End test automation using Playwright
Functional testing for key user flows
Independent test cases with no shared state
Reliable selectors using data-testid
Test Coverage
Product Listing
Search functionality
Category filtering
Sorting by price
Empty state validation
Product Detail
Product info validation
Add to Cart button state (enabled/disabled)
Cart
Add item to cart
Update quantity
Remove item
Total price validation
Empty cart state
Checkout
Form validation (required fields)
Email validation
Zip code validation
End-to-End Flow
Complete purchase journey
Order confirmation validation
Run Tests
npx playwright test
Test Files
tests/product-listing.spec.ts
tests/product-detail.spec.ts
tests/cart.spec.ts
tests/checkout.spec.ts
tests/e2e-purchase.spec.ts
---
## After adding
Run:
```bashgit add README.mdgit commit -m "Updated README with test details"git push# ShopDemo - Ecommerce Test ApplicationA fully functional dummy ecommerce frontend built for QA testing with Playwright. All backend data is mocked using [MSW (Mock Service Worker)](https://mswjs.io/) — no real server required.## Prerequisites- Node.js 18+- npm## Getting Started```bash
# Install dependencies
npm install
# Start development server
npm run dev
# Or build and start production server
npm run build
npm start
The app runs on http://localhost:3000 by default.
Custom Port
PORT=4000 npm run dev
PORT=4000 npm start
Pages & Routes
Route
Description
/
Product listing with search, filter by category, and sort by price
/products/:id
Product detail page with add-to-cart
/cart
Shopping cart with quantity controls
/checkout
Checkout form with shipping and payment validation
/order-confirmation?orderId=...
Order confirmation page
Features Available for Testing
Product Listing (/)
Grid display of 14 products across 4 categories
Search: Type in the search bar to filter products by name (debounced 300ms)
Category filter: Filter by Electronics, Clothing, Home, or Books
Sort: Sort by price (low-to-high or high-to-low)
Product count updates dynamically
Empty state when no products match
Loading skeleton while fetching
Product Detail (/products/:id)
Product image, name, description, price, category, stock status
Quantity selector
"Add to Cart" button (disabled for out-of-stock items)
Success notification after adding to cart
404 state for invalid product IDs
Shopping Cart (/cart)
List of cart items with images, names, prices
Increase/decrease quantity buttons
Remove item button
Running total
"Proceed to Checkout" button
Empty cart message with link back to products
Checkout (/checkout)
Shipping fields: First Name, Last Name, Email, Address, City, State, Zip Code
Payment fields: Name on Card, Card Number, Expiry Date (MM/YY), CVV
Client-side validation with inline error messages
Server-side validation on submit
Redirects to order confirmation on success
Empty cart redirect
Validation Rules
Field
Rule
First Name, Last Name, Address, City, State, Name on Card
Required
Email
Required, valid email format
Zip Code
Required, exactly 5 digits
Card Number
Required, exactly 16 digits (spaces allowed)
Expiry Date
Required, MM/YY format
CVV
Required, 3 or 4 digits
API Endpoints (Mocked via MSW)
All endpoints are intercepted by MSW in the browser — no real HTTP requests leave the app.
Validation error for a field (e.g., field-error-shipping-email)
Order Confirmation
Selector
Element
order-confirmation
Confirmation container
order-id
Order ID display
continue-shopping-link
Continue Shopping button
Mock Data
The app uses 14 deterministic products with stable IDs (prod-001 through prod-014). Product prod-008 (Wool Beanie) is marked as out-of-stock for testing disabled states.
Notes
No real backend: All data is served by MSW's service worker in the browser
Cart resets on page reload: Cart state lives in MSW's in-memory handler, not persistent storage
Deterministic data: Product IDs, names, and prices are fixed — safe for assertions in tests
Images: Placeholder images from placehold.co (no external API dependency)
About
End-to-end and functional UI testing using Playwright for a Next.js e-commerce application with MSW mock backend.