"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
describe('Migrations', () => {
    test('getMigrationStatus returns current state', () => {
        const { getMigrationStatus } = require('../walls/06-memory/database/migrations');
        const status = getMigrationStatus();
        expect(status).toHaveProperty('currentVersion');
        expect(status).toHaveProperty('applied');
        expect(status).toHaveProperty('pending');
        expect(Array.isArray(status.applied)).toBe(true);
        expect(typeof status.pending).toBe('number');
    });
    test('runMigrations does not throw', () => {
        const { runMigrations } = require('../walls/06-memory/database/migrations');
        const result = runMigrations();
        expect(result).toHaveProperty('applied');
        expect(result).toHaveProperty('errors');
        expect(Array.isArray(result.errors)).toBe(true);
    });
});
describe('Validation', () => {
    test('validateEventType rejects empty', () => {
        const { validateEventType } = require('../walls/06-memory/database/validation');
        expect(validateEventType('')).toBe('Event type is required');
        expect(validateEventType(null)).toBe('Event type is required');
    });
    test('validateEventType rejects invalid types', () => {
        const { validateEventType } = require('../walls/06-memory/database/validation');
        expect(validateEventType('invalid_type')).toContain('Invalid event type');
    });
    test('validateEventType accepts valid types', () => {
        const { validateEventType } = require('../walls/06-memory/database/validation');
        expect(validateEventType('edit')).toBeNull();
        expect(validateEventType('decision')).toBeNull();
        expect(validateEventType('error')).toBeNull();
    });
    test('validateImportance rejects out of range', () => {
        const { validateImportance } = require('../walls/06-memory/database/validation');
        expect(validateImportance(0)).toBe('Importance must be between 1 and 10');
        expect(validateImportance(11)).toBe('Importance must be between 1 and 10');
        expect(validateImportance(3.5)).toBe('Importance must be an integer');
    });
    test('validateImportance accepts valid range', () => {
        const { validateImportance } = require('../walls/06-memory/database/validation');
        expect(validateImportance(5)).toBeNull();
        expect(validateImportance(null)).toBeNull();
    });
    test('validateProjectName rejects empty', () => {
        const { validateProjectName } = require('../walls/06-memory/database/validation');
        expect(validateProjectName('')).toBe('Project name is required');
        expect(validateProjectName(null)).toBe('Project name is required');
    });
    test('validateProjectName rejects long names', () => {
        const { validateProjectName } = require('../walls/06-memory/database/validation');
        expect(validateProjectName('x'.repeat(201))).toContain('200 characters');
    });
    test('validateMemoryEvent returns errors for invalid events', () => {
        const { validateMemoryEvent } = require('../walls/06-memory/database/validation');
        const errors = validateMemoryEvent({ type: '', project: '', summary: '' });
        expect(errors.length).toBeGreaterThanOrEqual(2);
    });
    test('validateMemoryEvent returns no errors for valid events', () => {
        const { validateMemoryEvent } = require('../walls/06-memory/database/validation');
        const errors = validateMemoryEvent({ type: 'edit', project: 'myproject', summary: 'fixed a bug' });
        expect(errors.length).toBe(0);
    });
    test('sanitizeString removes control characters', () => {
        const { sanitizeString } = require('../walls/06-memory/database/validation');
        expect(sanitizeString('hello\x00world')).toBe('helloworld');
        expect(sanitizeString('  hello  ')).toBe('hello');
        expect(sanitizeString('x'.repeat(3000)).length).toBe(2000);
    });
});
describe('Auto Restart', () => {
    test('getRestartStatus returns expected shape', () => {
        const { getRestartStatus } = require('../walls/07-runtime/daemon/restart');
        const status = getRestartStatus();
        expect(status).toHaveProperty('recentRestarts');
        expect(status).toHaveProperty('maxRestarts');
        expect(status).toHaveProperty('canRestart');
        expect(typeof status.canRestart).toBe('boolean');
    });
    test('resetRestartState resets counters', () => {
        const { resetRestartState, getRestartStatus, recordRestart } = require('../walls/07-runtime/daemon/restart');
        recordRestart();
        resetRestartState();
        const status = getRestartStatus();
        expect(status.recentRestarts).toBe(0);
    });
    test('shouldAutoRestart returns boolean', () => {
        const { shouldAutoRestart } = require('../walls/07-runtime/daemon/restart');
        expect(typeof shouldAutoRestart()).toBe('boolean');
    });
});
//# sourceMappingURL=polish.test.js.map