Files
rxminder/tests/.backup/auth-db-debug.js.20250908-012049
William Valentin 1f62ffb3d8 feat: add automated test cleanup infrastructure
- Add cleanup-tests.sh script for automated test reorganization
- Safely backup manual test files with timestamps in tests/.backup/
- Generate cleanup-report.json with migration metrics
- Validate test structure after cleanup
- Log detailed cleanup progress and results

Enables safe migration from manual to automated testing
2025-09-08 01:38:49 -07:00

85 lines
2.5 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* eslint-disable no-console */
// Simple test to verify auth database functionality
// Run this in browser console at http://localhost:5174
console.log('Testing Authentication Database...');
// Test the mock database service
async function testDatabase() {
try {
// Import the services (this would work in browser context)
const { dbService } = await import('./services/couchdb.ts');
const { authService } = await import('./services/auth/auth.service.ts');
console.log('1. Testing user creation with password...');
// Test creating a user with password
const testEmail = 'test@example.com';
const testPassword = 'password123';
try {
const newUser = await dbService.createUserWithPassword(
testEmail,
testPassword
);
console.log('✅ User created successfully:', newUser);
} catch (error) {
if (error.message.includes('already exists')) {
console.log(' User already exists, testing login...');
} else {
console.error('❌ User creation failed:', error);
return;
}
}
console.log('2. Testing password login...');
// Test login with password
try {
const loginResult = await authService.login({
email: testEmail,
password: testPassword,
});
console.log('✅ Password login successful:', loginResult);
} catch (error) {
console.error('❌ Password login failed:', error);
}
console.log('3. Testing OAuth user creation...');
// Test OAuth user creation
const oauthData = {
email: 'oauth@example.com',
username: 'oauth_user',
avatar: 'https://example.com/avatar.jpg',
};
try {
const oauthUser = await dbService.createUserFromOAuth(oauthData);
console.log('✅ OAuth user created successfully:', oauthUser);
} catch (error) {
if (error.message.includes('already exists')) {
console.log(' OAuth user already exists');
} else {
console.error('❌ OAuth user creation failed:', error);
}
}
console.log('4. Testing user lookup by email...');
// Test finding users
const foundUser = await dbService.findUserByEmail(testEmail);
console.log('✅ User found by email:', foundUser);
console.log('🎉 All database tests completed!');
} catch (error) {
console.error('💥 Test setup failed:', error);
}
}
// Export for manual testing
if (typeof window !== 'undefined') {
window.testAuthDB = testDatabase;
console.log('Run window.testAuthDB() to test the authentication database');
}