feat: Add comprehensive test data generator and enhance user management with initials

This commit is contained in:
2026-01-26 23:18:49 +01:00
parent cb815177a1
commit c13a991778
3 changed files with 879 additions and 3 deletions

View File

@@ -11,11 +11,15 @@ export async function createUser({ name, username, password, role = 'user', is_a
const passwordHash = await bcrypt.hash(password, 12)
const userId = randomBytes(16).toString('hex')
// Generate initials from name (e.g., "John Doe" -> "JD")
const nameParts = name.trim().split(/\s+/)
const initial = nameParts.map(part => part.charAt(0).toUpperCase()).join('')
const result = db.prepare(`
INSERT INTO users (id, name, username, password_hash, role, is_active, can_be_assigned)
VALUES (?, ?, ?, ?, ?, ?, ?)
`).run(userId, name, username, passwordHash, role, is_active ? 1 : 0, can_be_assigned ? 1 : 0)
INSERT INTO users (id, name, username, password_hash, role, initial, is_active, can_be_assigned)
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
`).run(userId, name, username, passwordHash, role, initial, is_active ? 1 : 0, can_be_assigned ? 1 : 0)
return db.prepare(`
SELECT id, name, username, role, created_at, updated_at, last_login,