const os = require('os');
const path = require('path');

// Use temp directory for all file-based operations during tests
const tmpDir = path.join(os.tmpdir(), 'dashcaddy-tests');

// Prevent modules from touching production files
process.env.ENCRYPTION_KEY_FILE = path.join(tmpDir, '.encryption-key');
process.env.DASHCADDY_ENCRYPTION_KEY = 'a'.repeat(64); // 32 bytes in hex for test determinism

// Suppress console output during tests (set DEBUG_TESTS=1 to enable)
if (!process.env.DEBUG_TESTS) {
  global.console = {
    ...console,
    log: jest.fn(),
    warn: jest.fn(),
    error: jest.fn(),
    info: jest.fn(),
    debug: jest.fn(),
  };
}
