Skip to main content

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

This method runs the seed script directly in your deployed backend environment.

Step 1: Access the Console

  1. Navigate to Digital Ocean App Platform
  2. Select your stemblockai-backend app
  3. Click on the Console tab in the left sidebar
  4. 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

  1. Navigate to Digital Ocean Databases
  2. Select your stemblock-db-dev database
  3. Click on Users & Databases tab
  4. 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

  1. Click "Create New User" button
  2. Fill in the form:
    • Email
    • Password
    • First Name
    • Last Name
    • Role (STUDENT, PARENT, COACH, ADMIN)
    • Grade Level (for students)
  3. Click "Create User"

If creating parent-student relationships:

  1. Note the student IDs from the students list
  2. Create the parent user
  3. Use the "Link to Student" option to establish relationships

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

RoleEmailPasswordName
Adminadmin@stemblockai.comAdmin123!Admin User
Coachcoach@stemblockai.comCoach123!Sarah Johnson
Parentparent@stemblockai.comParent123!Michael Smith
Studentalex.student@stemblockai.comStudent123!Alex Thompson (Grade 8)
Studentemma.student@stemblockai.comStudent123!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

  1. Robot Design Challenge (Due in 7 days)

    • Type: DESIGN
    • Max Score: 100
  2. Code Optimization Exercise (Due in 14 days)

    • Type: CODE
    • Max Score: 100

Sample Submissions & Evaluations

Alex Thompson's submissions:

  1. 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
  2. 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

  1. Delete all test users before going to production:

    DELETE FROM users WHERE email LIKE '%@stemblockai.com';
  2. Change all default passwords

  3. Remove the seed script from production builds

  4. Use environment-specific credentials


Next Steps

After seeding users:

  1. ✅ Test login for each user type
  2. ✅ Verify dashboards display correctly
  3. ✅ Test assignment creation (as coach)
  4. ✅ Test submission upload (as student)
  5. ✅ Test evaluation viewing (as student/parent)
  6. ✅ 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:

  1. Check the Digital Ocean logs:

    • Navigate to your app
    • Click "Runtime Logs" tab
    • Look for errors related to database or seeding
  2. Verify environment variables:

    • Navigate to your app
    • Click "Settings" tab
    • Check that DATABASE_URL and other vars are set
  3. 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