This repository contains integration test cases for a Course Selling backend application, written using Bun’s test runner.
The focus of this project is testing, not backend implementation.
✅ Authentication
- Signup
- Login
- JWT validation
- Protected routes (
/me)
✅ Authorization (Role-based)
- Students cannot create courses or lessons
- Instructors cannot purchase courses
- Ownership enforcement for updates & deletes
✅ Courses
- Create course (Instructor only)
- Get all courses (Public)
- Get course by ID
- Update & delete course (Owner only)
✅ Lessons
- Add lessons (Course instructor only)
- Get lessons for a course (Public)
✅ Purchases
- Student purchases a course
- Duplicate purchase prevention
- User can view only their own purchases
✅ Negative & Edge Cases
- Forbidden access (
403) - Unauthorized access (
401) - Ownership violations
Install dependencies:
bun installUpdate backend URL if required:
const BASE_URL = "http://localhost:3000";
⚠️ Backend implementation must be running locally before executing tests.
Run all test suites:
bun testRun a specific test file:
bun test courses.test.tsThis video demonstrates the test cases being executed for the Course Selling application:
Kapture.2026-01-27.at.20.35.03.mp4
- Tests are integration tests (real API, real auth, real database)
- No mocking is used
- Tests are self-contained and safe to re-run
✅ JWT-based authentication ✅ Role-based authorization (Student vs Instructor) ✅ Ownership checks for courses & lessons ✅ Purchase flow integrity ✅ Correct HTTP status codes
This project was created using bun init with Bun v1.2.x.
Bun is a fast all-in-one JavaScript runtime.