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