import { describe, expect, it } from 'vitest';
import { serializeBrandVoiceDocument } from '../../ai/brand-voice-document.js';
import { applyStructuredProfileToDocument, defaultStructuredProfile, parseStructuredProfile, scoreBrandAlignment, } from '../../ai/brand-voice-structured.js';
describe('parseStructuredProfile', () => {
    it('reads vocabulary, channels, and worked examples from a profile document', () => {
        const structured = defaultStructuredProfile();
        structured.bannedTerms = [{ term: 'cheap', useInstead: 'affordable' }];
        structured.preferredTerms = ['ecommerce'];
        structured.workedExamples = [
            {
                offBrand: 'Our cheap tool!',
                onBrand: 'Our affordable tool.',
                why: 'Removed banned term and exclamation.',
            },
        ];
        const document = applyStructuredProfileToDocument(serializeBrandVoiceDocument({
            fields: {
                name: 'Acme',
                tone: 'plain-spoken',
                audience: 'teams',
                guidelines: 'Do:\n- Be clear',
                sampleText: 'Sample',
            },
        }), structured);
        const parsed = parseStructuredProfile(document);
        expect(parsed.bannedTerms[0]?.term).toBe('cheap');
        expect(parsed.preferredTerms).toContain('ecommerce');
        expect(parsed.workedExamples[0]?.onBrand).toContain('affordable');
        expect(parsed.channels.some((c) => c.id === 'meta_description')).toBe(true);
    });
});
describe('scoreBrandAlignment', () => {
    it('flags banned terms and exclamation points', () => {
        const structured = defaultStructuredProfile();
        structured.bannedTerms = [{ term: 'cheap', useInstead: 'affordable' }];
        structured.mechanics.exclamationPoints = 'forbid';
        const result = scoreBrandAlignment('Our cheap tool is the best!', structured);
        expect(result.score).toBeLessThan(80);
        expect(result.issues.some((issue) => issue.id.startsWith('banned-'))).toBe(true);
        expect(result.issues.some((issue) => issue.id === 'exclamation-forbid')).toBe(true);
    });
    it('enforces channel character limits', () => {
        const structured = defaultStructuredProfile();
        const long = 'x'.repeat(180);
        const result = scoreBrandAlignment(long, structured, 'meta_description');
        expect(result.issues.some((issue) => issue.id === 'channel-length-meta_description')).toBe(true);
    });
});
//# sourceMappingURL=brand-voice-structured.test.js.map