Refactor database services and add component tests

- Remove deprecated CouchDB service files
- Update database test configurations
- Add test files for components and auth modules
- Update user context and admin interface
- Remove migration script for unified config
- Fix User interface properties in tests (use status instead of isActive)
This commit is contained in:
William Valentin
2025-09-08 18:30:43 -07:00
parent 31e08d730d
commit ac3643f76d
10 changed files with 934 additions and 1614 deletions

View File

@@ -1,7 +1,7 @@
import React, { useState, useEffect } from 'react';
import { User, UserRole } from '../../types';
import { AccountStatus } from '../../services/auth/auth.constants';
import { dbService } from '../../services/couchdb.factory';
import { databaseService } from '../../services/database';
import { useUser } from '../../contexts/UserContext';
interface AdminInterfaceProps {
@@ -22,8 +22,8 @@ const AdminInterface: React.FC<AdminInterfaceProps> = ({ onClose }) => {
const loadUsers = async () => {
try {
const allUsers = await dbService.getAllUsers();
setUsers(allUsers);
const users = await databaseService.getAllUsers();
setUsers(users);
} catch (error) {
setError('Failed to load users');
console.error('Error loading users:', error);
@@ -34,7 +34,7 @@ const AdminInterface: React.FC<AdminInterfaceProps> = ({ onClose }) => {
const handleSuspendUser = async (userId: string) => {
try {
await dbService.suspendUser(userId);
await databaseService.suspendUser(userId);
await loadUsers();
} catch (error) {
setError('Failed to suspend user');
@@ -44,7 +44,7 @@ const AdminInterface: React.FC<AdminInterfaceProps> = ({ onClose }) => {
const handleActivateUser = async (userId: string) => {
try {
await dbService.activateUser(userId);
await databaseService.activateUser(userId);
await loadUsers();
} catch (error) {
setError('Failed to activate user');
@@ -62,7 +62,7 @@ const AdminInterface: React.FC<AdminInterfaceProps> = ({ onClose }) => {
}
try {
await dbService.deleteUser(userId);
await databaseService.deleteUser(userId);
await loadUsers();
} catch (error) {
setError('Failed to delete user');
@@ -77,7 +77,7 @@ const AdminInterface: React.FC<AdminInterfaceProps> = ({ onClose }) => {
}
try {
await dbService.changeUserPassword(userId, newPassword);
await databaseService.changeUserPassword(userId, newPassword);
setNewPassword('');
setSelectedUser(null);
setError('');