This project includes automated test scripts to clear test data and run Postman collection tests.
Python script that clears test users and related data from MongoDB.
Usage:
python clear_test_data.pyWhat it does:
- Removes test users (
testuser1,testuser2) - Removes users with test email addresses
- Removes users matching test patterns (e.g.,
testuser1_*,testuser2_*) - Optionally removes test messages and private messages (commented out by default)
Batch script that automates the entire test process.
Usage:
run_tests.batWhat it does:
- Clears test data from database using
clear_test_data.py - Checks and installs Newman (Postman CLI) if needed
- Checks and installs HTML reporter if needed
- Runs Postman collection tests
- Generates HTML test report
- Opens the report in browser
Shell script with the same functionality as the batch script.
Usage:
chmod +x run_tests.sh
./run_tests.shThe test script will:
- ✅ Clear old test data automatically
- ✅ Install required dependencies
- ✅ Run all Postman collection tests
- ✅ Generate an HTML report in
Tests/reports/report.html
Some tests will fail because they require:
- TOTP Setup: After registration, users must complete TOTP setup using an authenticator app
- Authentication: Users must login to get session cookies
- Test Data: Some tests need topics/messages to exist
These are expected failures and indicate that:
- ✅ The test infrastructure is working
- ✅ The API endpoints are responding
⚠️ Manual steps are needed for full test coverage
For complete test coverage, follow these steps:
- Run the test script to register users
- Complete TOTP setup:
- Get QR code from registration response
- Scan with authenticator app (Google Authenticator, Authy, etc.)
- Use the 6-digit code in "1.3 Complete TOTP Setup" request
- Login using "1.3 Login Passwordless" request
- Re-run tests or continue manually
- Ensure MongoDB is running:
mongodor check your MongoDB service - Check connection string in
.envfile or environment variables - Default:
mongodb://localhost:27017/TopicsFlow
- The script will automatically install Newman
- If it fails, manually run:
npm install -g newman
- The script will automatically install the HTML reporter
- If it fails, manually run:
npm install -g newman-reporter-html
- Check
Tests/TEST_TROUBLESHOOTING.mdfor detailed solutions - Review backend logs for error messages
- Verify environment variables are set correctly
Tests/reports/report.html- HTML test report (opens automatically on Windows)
- Review test report to see which tests passed/failed
- Complete TOTP setup for registered users
- Login to get authentication cookies
- Re-run specific test folders or individual requests
- Check
Tests/TEST_TROUBLESHOOTING.mdfor detailed guidance