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
This commit is contained in:
35
tests/.backup/admin-login-debug.js.20250908-012049
Normal file
35
tests/.backup/admin-login-debug.js.20250908-012049
Normal file
@@ -0,0 +1,35 @@
|
||||
/* 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()');
|
||||
84
tests/.backup/auth-db-debug.js.20250908-012049
Normal file
84
tests/.backup/auth-db-debug.js.20250908-012049
Normal file
@@ -0,0 +1,84 @@
|
||||
/* 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');
|
||||
}
|
||||
23
tests/.backup/debug-email-validation.js.20250908-012049
Normal file
23
tests/.backup/debug-email-validation.js.20250908-012049
Normal file
@@ -0,0 +1,23 @@
|
||||
/* 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
|
||||
30
tests/cleanup-report.json
Normal file
30
tests/cleanup-report.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"cleanup_date": "2025-09-08T08:20:49Z",
|
||||
"removed_files": ["manual/admin-login-debug.js", "manual/auth-db-debug.js", "manual/debug-email-validation.js"],
|
||||
"added_files": [
|
||||
"__mocks__/index.js",
|
||||
"e2e/auth-debug.spec.ts",
|
||||
"e2e/test-utils.ts",
|
||||
"integration/run-integration.sh",
|
||||
"README-CLEANUP.md"
|
||||
],
|
||||
"optimizations": {
|
||||
"removed_manual_tests": 3,
|
||||
"added_automated_tests": 1,
|
||||
"consolidated_mocks": true,
|
||||
"added_test_utilities": true,
|
||||
"improved_documentation": true
|
||||
},
|
||||
"test_count_before": {
|
||||
"manual": 3,
|
||||
"e2e": 5,
|
||||
"integration": 1,
|
||||
"unit": "variable"
|
||||
},
|
||||
"test_count_after": {
|
||||
"manual": 0,
|
||||
"e2e": 6,
|
||||
"integration": 1,
|
||||
"unit": "variable"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user