Sweet Shop Project - Test Report
Started: 2025-12-23 17:08:53
Suites (6)
6 passed
0 failed
0 pending
Tests (44)
44 passed
0 failed
0 pending
C:\Users\pksci\OneDrive\Desktop\sweet-shop-management\backend\tests\smoke.test.js2.314s
Jest ES6 smoke test
should add numbers correctly
passed
0.031s
C:\Users\pksci\OneDrive\Desktop\sweet-shop-management\backend\tests\sweets_read.test.js18.123s
Sweets Public Endpoints (GET)
should retrieve all sweets (default pagination)
passed
2.155s
Sweets Public Endpoints (GET)
should search sweets by name (case insensitive)
passed
0.178s
Sweets Public Endpoints (GET)
should filter sweets by category
passed
0.157s
Sweets Public Endpoints (GET)
should filter sweets by price range
passed
0.081s
Sweets Public Endpoints (GET)
should paginate results correctly
passed
0.102s
C:\Users\pksci\OneDrive\Desktop\sweet-shop-management\backend\tests\purchase.test.js20.876s
Purchase Endpoint (Protected)
should successfully purchase a sweet and decrease stock
passed
2.618s
Purchase Endpoint (Protected)
should return 400 if requested quantity exceeds stock
passed
0.497s
Purchase Endpoint (Protected)
should return 400 if sweet is out of stock
passed
0.834s
Purchase Endpoint (Protected)
should return 404 if sweet does not exist
passed
0.629s
Purchase Endpoint (Protected)
should return 400 if quantity is invalid (negative or zero)
passed
0.473s
Purchase Endpoint (Protected)
should calculate total price applying the discount percentage
passed
0.702s
C:\Users\pksci\OneDrive\Desktop\sweet-shop-management\backend\tests\restock.test.js22.292s
Restock Endpoint (Admin Protected)
should allow Admin to increase stock
passed
3.352s
Restock Endpoint (Admin Protected)
should return 403 Forbidden if user is NOT admin
passed
1.043s
Restock Endpoint (Admin Protected)
should return 401 Unauthorized if no token is provided
passed
1.183s
Restock Endpoint (Admin Protected)
should return 400 if quantity is negative or zero
passed
1.003s
Restock Endpoint (Admin Protected)
should return 404 if sweet does not exist
passed
0.911s
C:\Users\pksci\OneDrive\Desktop\sweet-shop-management\backend\tests\auth.test.js24.13s
Auth Endpoints > POST /api/auth/register
should register a new user successfully
passed
2.404s
Auth Endpoints > POST /api/auth/register
should reject registration if fullname is missing
passed
0.063s
Auth Endpoints > POST /api/auth/register
should reject registration if username is missing
passed
0.052s
Auth Endpoints > POST /api/auth/register
should reject registration if email is missing
passed
0.047s
Auth Endpoints > POST /api/auth/register
should reject registration if password is missing
passed
0.085s
Auth Endpoints > POST /api/auth/register
should reject registration if all fields missing
passed
0.048s
Auth Endpoints > POST /api/auth/register
should reject registration if password is too short
passed
0.048s
Auth Endpoints > POST /api/auth/register
should reject duplicate usernames
passed
0.622s
Auth Endpoints > POST /api/auth/register
should reject duplicate email
passed
0.536s
Auth Endpoints > POST /api/v1/users/login
should login successfully with valid EMAIL and password
passed
1.221s
Auth Endpoints > POST /api/v1/users/login
should login successfully with valid USERNAME and password
passed
1.266s
Auth Endpoints > POST /api/v1/users/login
should reject login with incorrect password
passed
0.91s
Auth Endpoints > POST /api/v1/users/login
should reject login with non-existent user
passed
0.444s
Auth Endpoints > POST /api/v1/users/login
should reject login if identifier is missing
passed
0.522s
Auth Endpoints > POST /api/v1/users/login
should reject login if password is missing
passed
0.473s
Auth Endpoints > POST /api/v1/users/logout
should logout successfully and blacklist the token
passed
0.522s
Auth Endpoints > POST /api/v1/users/logout
should return 200 even if no token is provided (Idempotent)
passed
0.544s
C:\Users\pksci\OneDrive\Desktop\sweet-shop-management\backend\tests\sweets.test.js25.953s
Sweets Endpoints (Protected) > POST /api/v1/sweets
should create a new sweet with image URL when Admin uploads file
passed
2.749s
Sweets Endpoints (Protected) > POST /api/v1/sweets
should return 401 Unauthorized if no token is provided
passed
1.145s
Sweets Endpoints (Protected) > POST /api/v1/sweets
should return 403 Forbidden if user is NOT admin
passed
1.293s
Sweets Endpoints (Protected) > POST /api/v1/sweets
should return 400 if required fields are missing
passed
1.105s
Sweets Endpoints (Protected) > POST /api/v1/sweets
should return 400/500 if price is invalid (string text)
passed
1.207s
Sweets Endpoints (Protected) > POST /api/v1/sweets
should return 400/500 if quantity is negative
passed
0.962s
Sweets Endpoints (Protected) > POST /api/v1/sweets
should return 400/500 if uploaded file is NOT an image (e.g., .txt)
passed
1.074s
Sweets Endpoints (Protected) > POST /api/v1/sweets
should return 500 if Cloudinary upload fails
passed
0.84s
Sweets Endpoints (Protected) > POST /api/v1/sweets
should allow admin to create a sweet with a discount percentage
passed
0.814s
Sweets Endpoints (Protected) > POST /api/v1/sweets
should default discount to 0 if not provided
passed
0.693s