refactor: remove manual browser console test scripts
- Remove tests/manual/admin-login-debug.js (replaced by E2E) - Remove tests/manual/auth-db-debug.js (replaced by E2E) - Remove tests/manual/debug-email-validation.js (replaced by E2E) All manual testing functionality now automated with Playwright E2E tests. Manual scripts backed up in tests/.backup/ for reference.
This commit is contained in:
@@ -1,35 +0,0 @@
|
|||||||
/* eslint-disable no-console */
|
|
||||||
// Simple test script to verify admin login functionality
|
|
||||||
// Run this in the browser console to test admin credentials
|
|
||||||
|
|
||||||
async function testAdminLogin() {
|
|
||||||
console.log('🧪 Testing admin login...');
|
|
||||||
|
|
||||||
// Import the services (this won't work directly, but helps us understand the flow)
|
|
||||||
console.log('Admin credentials:');
|
|
||||||
console.log('Email: admin@localhost');
|
|
||||||
console.log('Password: admin123!');
|
|
||||||
|
|
||||||
// Check if admin user exists in localStorage
|
|
||||||
const users = JSON.parse(localStorage.getItem('users') || '[]');
|
|
||||||
console.log('All users in localStorage:', users);
|
|
||||||
|
|
||||||
const adminUser = users.find(u => u.email === 'admin@localhost');
|
|
||||||
console.log('Admin user found:', adminUser);
|
|
||||||
|
|
||||||
if (adminUser) {
|
|
||||||
console.log('Admin user details:');
|
|
||||||
console.log('- Email:', adminUser.email);
|
|
||||||
console.log('- Password:', adminUser.password);
|
|
||||||
console.log('- Role:', adminUser.role);
|
|
||||||
console.log('- Status:', adminUser.status);
|
|
||||||
console.log('- Email Verified:', adminUser.emailVerified);
|
|
||||||
} else {
|
|
||||||
console.log('❌ Admin user not found in localStorage');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Instructions
|
|
||||||
console.log('Copy and paste this function in browser console:');
|
|
||||||
console.log(testAdminLogin.toString());
|
|
||||||
console.log('Then run: testAdminLogin()');
|
|
||||||
@@ -1,84 +0,0 @@
|
|||||||
/* 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');
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
/* eslint-disable no-console */
|
|
||||||
// Test the email validation in browser console
|
|
||||||
console.log('Testing email validation for admin@localhost');
|
|
||||||
|
|
||||||
const emailRegex = /^[^\s@]+@[^\s@]+(\.[^\s@]+|localhost)$/;
|
|
||||||
const testEmail = 'admin@localhost';
|
|
||||||
|
|
||||||
console.log('Email:', testEmail);
|
|
||||||
console.log('Regex:', emailRegex.toString());
|
|
||||||
console.log('Test result:', emailRegex.test(testEmail));
|
|
||||||
|
|
||||||
// Let's also test step by step
|
|
||||||
console.log('Parts breakdown:');
|
|
||||||
console.log('- Has @ symbol:', testEmail.includes('@'));
|
|
||||||
console.log('- Before @:', testEmail.split('@')[0]);
|
|
||||||
console.log('- After @:', testEmail.split('@')[1]);
|
|
||||||
console.log('- No spaces:', !/\s/.test(testEmail));
|
|
||||||
|
|
||||||
// Let's test a simpler regex that should definitely work
|
|
||||||
const simpleRegex = /^[^@\s]+@[^@\s]+$/;
|
|
||||||
console.log('Simple regex test:', simpleRegex.test(testEmail));
|
|
||||||
|
|
||||||
// Copy this code and paste it in the browser console when you get the validation error
|
|
||||||
Reference in New Issue
Block a user