Loading...
QA Testing Guide/API Documentation
Comprehensive guide/API documentation for testing the e-commerce platform
🔌
API Testing
Login OTP API
Test Login OTP endpoints
API Endpoints:
- POST /api/auth/send-otp - Send OTP and display it in response
Sample Request Body:
// Request:
{
"email": "user@example.com"
}
// Response:
{
"data": {
"success": true,
"message": "OTP sent successfully to your email",
"email": "user@example.com",
"expiresIn": 1,
"otp": "200126"
},
"status": 200,
"message": "OTP sent successfully to your email",
"success": true
}Verify OTP API
Test Verify OTP endpoints
API Endpoints:
- POST /api/auth/verify-otp - Verify OTP and log user in
Sample Request Body:
// Request:
{
"email": "user@example.com",
"otp": "123456"
}
// Response:
{
"data": {
"success": true,
"message": "Login successful",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiJ1c2VyLTE3NTM1NjExNzM5MDkiLCJlbWFpbCI6ImV3ZWxsLm1
ja2VuemllQGdtYWlsLmNvbSIsInJvbGUiOiJjdXN0b21lciIsImlhdCI6MTc1MzU2MTE3MywiZXhwIjoxNzUzNjQ3NTczLCJhdWQi
OiJxYS11c2VycyIsImlzcyI6ImVjb21tZXJjZS1xYS1wbGF0Zm9ybSJ9.uwmE4tnrwa3atecp1mLKyK8qV68h3ITziLKzTpkHtnQ",
"user": {
"id": "user-1753561173909",
"email": "user@example.com",
"role": "customer",
"name": "John Doe",
},
"expiresIn": 24
},
"status": 200,
"message": "Login successful",
"success": true
}
Get Products API
List products with pagination
API Endpoints:
- GET /api/products
Sample Request Body:
// Response:
{
"data": {
"products": [
{
"id": "product-46",
"name": "Cybersecurity Fundamentals",
"price": 50.59,
"stock": 15,
"category": "books",
"description": "Updated content reflecting the latest trends and industry standards...",
"image": "https://raw.githubusercontent.com/heroamogs/QA-TestCraft-Images/main/Books/database-design-principles.jpg",
"createdAt": "2024-09-30T13:37:00.550Z",
"updatedAt": "2025-08-21T19:08:12.953Z",
"views": 287,
"rating": 3.6,
"reviewCount": 91
}
],
"pagination": {
"currentPage": 1,
"totalPages": 5,
"totalItems": 50,
"itemsPerPage": 12,
"hasNextPage": true,
"hasPrevPage": false
},
"filters": {
"search": "",
"category": "",
"sortBy": "name",
"sortOrder": "asc"
}
},
"status": 200,
"message": "Products retrieved successfully",
"success": true
}Get Single Product API
Get product details
API Endpoints:
- GET /api/products/id
Sample Request Body:
// Response:
{
"data": {
"id": "product-46",
"name": "JavaScript: The Complete Guide",
"price": 33.93,
"stock": 200,
"category": "books",
"description": "In-depth coverage of essential topics with hands-on exercises and projects...",
"image": "https://raw.githubusercontent.com/heroamogs/QA-TestCraft-Images/main/Books/database-design-principles.jpg",
"createdAt": "2025-04-03T03:37:11.768Z",
"updatedAt": "2025-08-21T20:07:50.094Z",
"views": 137,
"rating": 4.1,
"reviewCount": 143,
"lastViewed": "2025-08-21T20:08:00.766Z"
},
"status": 200,
"message": "Product retrieved successfully",
"success": true
}📝
Testing Guide
OTP Login Flow
Test email-based OTP authentication
Test Steps:
- Navigate to /login
- Enter email (user@example.com) or (admin@ecommerce-qa.com for admin access)
- Click "Send Login Code" - OTP will be displayed in UI. This is because the API is mocked and is for testing/demonstration purposes only.
- Enter the 6-digit OTP
- Verify successful login and role assignment
Key Test IDs:
login-email-inputlogin-otp-inputlogin-submit-btn
Role-Based Access Control
Test admin vs customer permissions
Test Steps:
- Login as admin (admin@ecommerce-qa.com)
- Verify access to /admin routes
- Logout and login as customer
- Verify admin routes are blocked
Session Management
Test token expiration and logout
Test Steps:
- Login successfully
- Perform actions requiring authentication
- Test logout functionality
- Verify protected routes redirect to login