- Fix design document initialization with proper null handling - Fix bulk operations in migration script (bulkDocs method signature) - Remove hardcoded credentials from docker-compose.yml - Fix test infrastructure incompatibility (use npm/Jest instead of bun) - Implement comprehensive database indexes for performance - Add health check endpoint for Docker container monitoring - Create 7 design documents: users, streets, tasks, posts, badges, transactions, general - Update jest.setup.js with proper mock exports - Add .env.example with secure defaults 🤖 Generated with [AI Assistant] Co-Authored-By: AI Assistant <noreply@ai-assistant.com>
54 lines
1.5 KiB
JavaScript
54 lines
1.5 KiB
JavaScript
// Mock CouchDB service globally for all tests
|
|
const mockCouchdbService = {
|
|
initialize: jest.fn().mockResolvedValue(true),
|
|
isReady: jest.fn().mockReturnValue(true),
|
|
isConnected: true,
|
|
isConnecting: false,
|
|
create: jest.fn(),
|
|
getById: jest.fn(),
|
|
get: jest.fn(),
|
|
find: jest.fn(),
|
|
destroy: jest.fn(),
|
|
delete: jest.fn(),
|
|
createDocument: jest.fn().mockImplementation((doc) => Promise.resolve({
|
|
_id: `test_${Date.now()}`,
|
|
_rev: '1-test',
|
|
...doc
|
|
})),
|
|
updateDocument: jest.fn().mockImplementation((id, doc) => Promise.resolve({
|
|
_id: id,
|
|
_rev: '2-test',
|
|
...doc
|
|
})),
|
|
deleteDocument: jest.fn().mockResolvedValue(true),
|
|
findByType: jest.fn().mockResolvedValue([]),
|
|
findUserById: jest.fn(),
|
|
findUserByEmail: jest.fn(),
|
|
update: jest.fn(),
|
|
updateUserPoints: jest.fn(),
|
|
getDocument: jest.fn(),
|
|
findDocumentById: jest.fn(),
|
|
bulkDocs: jest.fn(),
|
|
shutdown: jest.fn().mockResolvedValue(true),
|
|
};
|
|
|
|
jest.mock('../services/couchdbService', () => mockCouchdbService);
|
|
|
|
// Make the mock available for tests to reference
|
|
global.mockCouchdbService = mockCouchdbService;
|
|
|
|
// Set test environment variables
|
|
process.env.JWT_SECRET = 'test-jwt-secret';
|
|
process.env.NODE_ENV = 'test';
|
|
process.env.COUCHDB_URL = 'http://localhost:5984';
|
|
process.env.COUCHDB_DB_NAME = 'test-adopt-a-street';
|
|
|
|
// Suppress console logs during tests unless there's an error
|
|
global.console = {
|
|
...console,
|
|
log: jest.fn(),
|
|
debug: jest.fn(),
|
|
info: jest.fn(),
|
|
warn: jest.fn(),
|
|
error: console.error, // Keep error logging
|
|
}; |