Files
Profa 2253d05618 feat: flatten project structure — archive v2, promote v3 to root
Remove the nested v3/ subdirectory by moving all active source code,
tests, configs, and assets directly to the project root. Archive v2/
(dead code, 847MB) to v2-archive.tar.gz.

Key changes:
- Move v3/src/ → src/, v3/tests/ → tests/, v3/packages/ → packages/
- Move v3/tsconfig.json, v3/vitest.config.ts to root
- Merge v3/package.json into root package.json (ESM, scripts, deps, exports)
- Merge v3/scripts/ into scripts/, v3/implementation/ into docs/implementation/
- Update all CI workflows to remove "cd v3 &&" and v3/ path prefixes
- Fix all init installer path resolution (3-level-up → 2-level-up)
- Fix hooks to use "node ./dist/cli/bundle.js" instead of bare "aqe"
- Update settings.json ADR/DDD directories to docs/implementation/
- Fix helper scripts (statusline, adr-compliance, ddd-tracker, guidance-hooks)
- Update 58 agent definitions: aqe/v3/ → aqe/ memory namespaces
- Update 15 guidance shards: v3/src/ → src/ path references
- Fix sync interfaces: remove v3/ and v2/ path references
- Fix test path calculations (process.cwd() + '..' no longer needed)
- Fix flaky perf test threshold (500ms → 1000ms for CI environments)
- Fix complexity-analyzer test to match ADR-051 keyword-based eligibility

Build passes, 17,901 tests pass, CLI and MCP bundles verified.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 11:35:41 +00:00

137 lines
4.3 KiB
TypeScript

/**
* Logger Interface Tests
* Milestone 2.7: Structured Logging Facade
*/
import { describe, it, expect } from 'vitest';
import {
LogLevel,
LOG_LEVEL_NAMES,
parseLogLevel,
isLogger,
} from '../../../src/logging/logger.js';
import { ConsoleLogger, NullLogger } from '../../../src/logging/console-logger.js';
describe('LogLevel', () => {
describe('enum values', () => {
it('should have DEBUG as the lowest value (most verbose)', () => {
expect(LogLevel.DEBUG).toBe(0);
});
it('should have INFO higher than DEBUG', () => {
expect(LogLevel.INFO).toBeGreaterThan(LogLevel.DEBUG);
});
it('should have WARN higher than INFO', () => {
expect(LogLevel.WARN).toBeGreaterThan(LogLevel.INFO);
});
it('should have ERROR higher than WARN', () => {
expect(LogLevel.ERROR).toBeGreaterThan(LogLevel.WARN);
});
it('should have SILENT as the highest value (no output)', () => {
expect(LogLevel.SILENT).toBeGreaterThan(LogLevel.ERROR);
});
it('should maintain ordering for level filtering', () => {
const levels = [LogLevel.DEBUG, LogLevel.INFO, LogLevel.WARN, LogLevel.ERROR, LogLevel.SILENT];
for (let i = 0; i < levels.length - 1; i++) {
expect(levels[i]).toBeLessThan(levels[i + 1]);
}
});
});
describe('LOG_LEVEL_NAMES', () => {
it('should have a name for each level', () => {
expect(LOG_LEVEL_NAMES[LogLevel.DEBUG]).toBe('DEBUG');
expect(LOG_LEVEL_NAMES[LogLevel.INFO]).toBe('INFO');
expect(LOG_LEVEL_NAMES[LogLevel.WARN]).toBe('WARN');
expect(LOG_LEVEL_NAMES[LogLevel.ERROR]).toBe('ERROR');
expect(LOG_LEVEL_NAMES[LogLevel.SILENT]).toBe('SILENT');
});
});
});
describe('parseLogLevel', () => {
it('should parse DEBUG level', () => {
expect(parseLogLevel('debug')).toBe(LogLevel.DEBUG);
expect(parseLogLevel('DEBUG')).toBe(LogLevel.DEBUG);
expect(parseLogLevel('Debug')).toBe(LogLevel.DEBUG);
});
it('should parse INFO level', () => {
expect(parseLogLevel('info')).toBe(LogLevel.INFO);
expect(parseLogLevel('INFO')).toBe(LogLevel.INFO);
});
it('should parse WARN level', () => {
expect(parseLogLevel('warn')).toBe(LogLevel.WARN);
expect(parseLogLevel('WARN')).toBe(LogLevel.WARN);
expect(parseLogLevel('warning')).toBe(LogLevel.WARN);
expect(parseLogLevel('WARNING')).toBe(LogLevel.WARN);
});
it('should parse ERROR level', () => {
expect(parseLogLevel('error')).toBe(LogLevel.ERROR);
expect(parseLogLevel('ERROR')).toBe(LogLevel.ERROR);
});
it('should parse SILENT level and aliases', () => {
expect(parseLogLevel('silent')).toBe(LogLevel.SILENT);
expect(parseLogLevel('SILENT')).toBe(LogLevel.SILENT);
expect(parseLogLevel('none')).toBe(LogLevel.SILENT);
expect(parseLogLevel('off')).toBe(LogLevel.SILENT);
});
it('should default to INFO for unknown values', () => {
expect(parseLogLevel('unknown')).toBe(LogLevel.INFO);
expect(parseLogLevel('')).toBe(LogLevel.INFO);
expect(parseLogLevel('VERBOSE')).toBe(LogLevel.INFO);
});
});
describe('isLogger', () => {
it('should return true for ConsoleLogger', () => {
const logger = new ConsoleLogger('test', LogLevel.INFO);
expect(isLogger(logger)).toBe(true);
});
it('should return true for NullLogger', () => {
const logger = new NullLogger();
expect(isLogger(logger)).toBe(true);
});
it('should return false for null', () => {
expect(isLogger(null)).toBe(false);
});
it('should return false for undefined', () => {
expect(isLogger(undefined)).toBe(false);
});
it('should return false for plain objects', () => {
expect(isLogger({})).toBe(false);
expect(isLogger({ debug: () => {} })).toBe(false);
});
it('should return false for non-objects', () => {
expect(isLogger('logger')).toBe(false);
expect(isLogger(123)).toBe(false);
expect(isLogger(true)).toBe(false);
});
it('should return true for objects with all Logger methods', () => {
const customLogger = {
debug: () => {},
info: () => {},
warn: () => {},
error: () => {},
isEnabled: () => true,
getDomain: () => 'test',
child: () => customLogger,
};
expect(isLogger(customLogger)).toBe(true);
});
});