Test User Injection Guide for Digital Ocean
This guide explains how to inject test users into your Digital Ocean deployment for testing purposes.
Prerequisites
- Digital Ocean App Platform deployment running
- Backend application deployed and accessible
- Database connection configured
Method 1: Using Digital Ocean Console (Recommended)
This method runs the seed script directly in your deployed backend environment.
Step 1: Access the Console
- Navigate to Digital Ocean App Platform
- Select your
stemblockai-backendapp - Click on the Console tab in the left sidebar
- Select the backend component from the dropdown
Step 2: Run Database Migration
First, ensure the database schema is up to date:
cd /workspace
npx prisma migrate deploy
This will add any missing columns (like Google Classroom OAuth tokens) to the database.
Step 3: Run the Seed Script
In the console terminal, run:
cd /workspace
npm run seed:users
Step 4: Verify Success
You should see output like:
🌱 Starting user seed...
Creating admin user...
✅ Admin created: admin@stemblockai.com
Creating coach user...
✅ Coach created: coach@stemblockai.com
Creating parent user...
✅ Parent created: parent@stemblockai.com
Creating student users...
✅ Student 1 created: alex.student@stemblockai.com
✅ Student 2 created: emma.student@stemblockai.com
Linking parent to students...
✅ Parent-child relationships created
Creating test class...
✅ Test class created: Robotics 101 - Period 3
Enrolling students in class...
✅ Students enrolled in class
Creating sample assignments...
✅ Sample assignments created
Creating sample submissions...
✅ Sample submissions with evaluations created
🎉 Seed completed successfully!
📧 Test User Credentials:
Admin: admin@stemblockai.com / Admin123!
Coach: coach@stemblockai.com / Coach123!
Parent: parent@stemblockai.com / Parent123!
Student: alex.student@stemblockai.com / Student123!
Student: emma.student@stemblockai.com / Student123!
Step 5: Test Login
Navigate to your frontend URL and login with any of the test accounts:
- Admin:
admin@stemblockai.com/Admin123! - Coach:
coach@stemblockai.com/Coach123! - Parent:
parent@stemblockai.com/Parent123! - Student:
alex.student@stemblockai.com/Student123! - Student:
emma.student@stemblockai.com/Student123!
Method 2: Using Database Console
If you need to inject users without using the backend console, you can use the database console directly.
Step 1: Access Database Console
- Navigate to Digital Ocean Databases
- Select your
stemblock-db-devdatabase - Click on Users & Databases tab
- Click on Console button
Step 2: Connect to Database
The console will automatically connect to your database.
Step 3: Run SQL Commands
⚠️ Note: You'll need to hash passwords first. Use this Node.js command in the backend console:
node -e "const bcrypt = require('bcrypt'); bcrypt.hash('Admin123!', 10).then(h => console.log(h));"
Then in the database console:
-- Insert Admin User
INSERT INTO users (id, email, password_hash, first_name, last_name, role, created_at, updated_at)
VALUES (
gen_random_uuid(),
'admin@stemblockai.com',
'YOUR_HASHED_PASSWORD_HERE',
'Admin',
'User',
'ADMIN',
NOW(),
NOW()
)
ON CONFLICT (email) DO NOTHING;
Note: This method is more complex. We recommend using Method 1.
Method 3: Using Admin Dashboard (After Initial Setup)
Once you have an admin user created, you can create additional users through the UI.
Step 1: Login as Admin
Login to the admin dashboard at:
https://your-frontend-url.ondigitalocean.app/admin/users
Use credentials: admin@stemblockai.com / Admin123!
Step 2: Create Users
- Click "Create New User" button
- Fill in the form:
- Password
- First Name
- Last Name
- Role (STUDENT, PARENT, COACH, ADMIN)
- Grade Level (for students)
- Click "Create User"
Step 3: Link Parent to Students
If creating parent-student relationships:
- Note the student IDs from the students list
- Create the parent user
- Use the "Link to Student" option to establish relationships
Method 4: Local Testing First (Recommended for Development)
Before deploying to Digital Ocean, test the seed script locally.
Step 1: Run Locally
cd ~/Documents/Github/stemblockai-backend
npm run seed:users
Step 2: Verify Locally
# Check the database
npm run prisma:studio
Step 3: Test with Local Frontend
Start the frontend and test all user flows:
cd ~/Documents/Github/stemblockai-frontend
npm run dev
Navigate to http://localhost:3000 and test login with each user type.
What the Seed Script Creates
The seed script creates the following test data:
Users
| Role | Password | Name | |
|---|---|---|---|
| Admin | admin@stemblockai.com | Admin123! | Admin User |
| Coach | coach@stemblockai.com | Coach123! | Sarah Johnson |
| Parent | parent@stemblockai.com | Parent123! | Michael Smith |
| Student | alex.student@stemblockai.com | Student123! | Alex Thompson (Grade 8) |
| Student | emma.student@stemblockai.com | Student123! | Emma Smith (Grade 6) |
Relationships
- Michael Smith (Parent) → Alex Thompson (Student)
- Michael Smith (Parent) → Emma Smith (Student)
Class
- Name: Robotics 101 - Period 3
- Coach: Sarah Johnson
- Students: Alex Thompson, Emma Smith
- Note: Includes dummy Google Classroom OAuth tokens for database compatibility
Assignments
-
Robot Design Challenge (Due in 7 days)
- Type: DESIGN
- Max Score: 100
-
Code Optimization Exercise (Due in 14 days)
- Type: CODE
- Max Score: 100
Sample Submissions & Evaluations
Alex Thompson's submissions:
-
Robot Design Challenge - Submitted 2 days ago
- Overall Score: 85/100
- Status: PUBLISHED
- Has detailed AI feedback and coach feedback
- Visible to student and parent
-
Code Optimization Exercise - Submitted 5 days ago
- Overall Score: 72/100
- Status: PUBLISHED
- Has detailed AI feedback and coach feedback
- Visible to student and parent
Troubleshooting
Issue: "npm: command not found"
Solution: The backend console may not have Node.js in PATH. Try:
export PATH=$PATH:/workspace/node_modules/.bin
npm run seed:users
Issue: "Cannot find module"
Solution: The script may need to be compiled first:
cd /workspace
npm run build
node dist/scripts/seed-users.js
Issue: "Database connection error"
Solution: Verify your DATABASE_URL environment variable:
echo $DATABASE_URL
If it's not set, check your app settings in Digital Ocean.
Issue: "User already exists"
Solution: The seed script uses upsert, so it won't fail if users exist. If you want to start fresh:
# WARNING: This will delete all data!
# Only use in development environments
npm run prisma:migrate reset
npm run seed:users
Issue: "Permission denied"
Solution: Make sure you're running the command in the correct component (backend, not frontend).
Re-running the Seed Script
The seed script is idempotent - it can be run multiple times safely. It uses upsert operations, which means:
- ✅ Existing users will be skipped (not overwritten)
- ✅ New users will be created
- ✅ Relationships will be created if they don't exist
- ✅ Safe to run after every deployment
Security Notes
⚠️ IMPORTANT: These test credentials are for development and testing only!
Before Production
-
Delete all test users before going to production:
DELETE FROM users WHERE email LIKE '%@stemblockai.com'; -
Change all default passwords
-
Remove the seed script from production builds
-
Use environment-specific credentials
Next Steps
After seeding users:
- ✅ Test login for each user type
- ✅ Verify dashboards display correctly
- ✅ Test assignment creation (as coach)
- ✅ Test submission upload (as student)
- ✅ Test evaluation viewing (as student/parent)
- ✅ Test admin functionality (as admin)
Quick Reference Commands
# Seed users (in backend console)
npm run seed:users
# View database (in backend console)
npm run prisma:studio
# Check database connection
node -e "const { PrismaClient } = require('@prisma/client'); const p = new PrismaClient(); p.$connect().then(() => console.log('✅ Connected')).catch(e => console.log('❌ Error:', e));"
# Hash a new password
node -e "const bcrypt = require('bcrypt'); bcrypt.hash('YourPassword123!', 10).then(h => console.log(h));"
Support
If you encounter issues not covered in this guide:
-
Check the Digital Ocean logs:
- Navigate to your app
- Click "Runtime Logs" tab
- Look for errors related to database or seeding
-
Verify environment variables:
- Navigate to your app
- Click "Settings" tab
- Check that DATABASE_URL and other vars are set
-
Test database connectivity:
node -e "const \{ PrismaClient \} = require('@prisma/client'); new PrismaClient().\$connect().then(() => console.log('OK')).catch(console.error);"
Last Updated: November 2025 Version: 1.0