From cee86ce0bbbc8bfb475f12e133cc46e31414bcd0 Mon Sep 17 00:00:00 2001 From: William Valentin Date: Mon, 8 Sep 2025 01:40:10 -0700 Subject: [PATCH] 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. --- tests/manual/admin-login-debug.js | 35 ----------- tests/manual/auth-db-debug.js | 84 -------------------------- tests/manual/debug-email-validation.js | 23 ------- 3 files changed, 142 deletions(-) delete mode 100644 tests/manual/admin-login-debug.js delete mode 100644 tests/manual/auth-db-debug.js delete mode 100644 tests/manual/debug-email-validation.js diff --git a/tests/manual/admin-login-debug.js b/tests/manual/admin-login-debug.js deleted file mode 100644 index 043e329..0000000 --- a/tests/manual/admin-login-debug.js +++ /dev/null @@ -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()'); diff --git a/tests/manual/auth-db-debug.js b/tests/manual/auth-db-debug.js deleted file mode 100644 index 4dc89f0..0000000 --- a/tests/manual/auth-db-debug.js +++ /dev/null @@ -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'); -} diff --git a/tests/manual/debug-email-validation.js b/tests/manual/debug-email-validation.js deleted file mode 100644 index 9cb5a6b..0000000 --- a/tests/manual/debug-email-validation.js +++ /dev/null @@ -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