🪻 distributed transcription service thistle.dunkirk.sh
1#!/usr/bin/env bun 2import db from "../src/db/schema"; 3import { createClass, enrollUserInClass, getMeetingTimesForClass, createMeetingTime } from "../src/lib/classes"; 4 5// Create a test user (admin) 6const email = "admin@thistle.test"; 7const existingUser = db 8 .query<{ id: number }, [string]>("SELECT id FROM users WHERE email = ?") 9 .get(email); 10 11let userId: number; 12 13if (!existingUser) { 14 db.run( 15 "INSERT INTO users (email, password_hash, role) VALUES (?, ?, ?)", 16 [email, "test-hash", "admin"], 17 ); 18 userId = db.query<{ id: number }, []>("SELECT last_insert_rowid() as id").get()!.id; 19 console.log(`✅ Created admin user: ${email} (ID: ${userId})`); 20} else { 21 userId = existingUser.id; 22 console.log(`✅ Using existing admin user: ${email} (ID: ${userId})`); 23} 24 25// Create a test class 26const cls = createClass({ 27 course_code: "CS 101", 28 name: "Introduction to Computer Science", 29 professor: "Dr. Jane Smith", 30 semester: "Fall", 31 year: 2024, 32}); 33 34console.log(`✅ Created class: ${cls.course_code} - ${cls.name} (ID: ${cls.id})`); 35 36// Enroll the admin in the class 37enrollUserInClass(userId, cls.id); 38console.log(`✅ Enrolled admin in class`); 39 40// Create meeting times 41const meeting1 = createMeetingTime(cls.id, "Monday Lecture"); 42const meeting2 = createMeetingTime(cls.id, "Wednesday Lab"); 43console.log(`✅ Created meeting times: ${meeting1.label}, ${meeting2.label}`); 44 45// Verify 46const meetings = getMeetingTimesForClass(cls.id); 47console.log(`✅ Class has ${meetings.length} meeting times`); 48 49console.log("\n📊 Test Summary:"); 50console.log(`- Class ID: ${cls.id}`); 51console.log(`- Course: ${cls.course_code} - ${cls.name}`); 52console.log(`- Professor: ${cls.professor}`); 53console.log(`- Semester: ${cls.semester} ${cls.year}`); 54console.log(`- Meetings: ${meetings.map(m => m.label).join(", ")}`);