Files
rxminder/tests/manual/auth-db-debug.js
William Valentin b4a9318324 test: enhance E2E and integration testing infrastructure
- Add comprehensive TypeScript types to E2E test helpers
- Improve medication, auth, modal, and wait helper classes with proper typing
- Enhance test data with readonly type assertions for better immutability
- Update integration tests with better error handling and assertions
- Improve Playwright type definitions for better IDE support
- Add environment variable support to manual test scripts
2025-09-07 15:22:33 -07:00

85 lines
2.5 KiB
JavaScript
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');
}