import { describe, expect, it } from 'vitest';
import { setActuateConfig } from '../../config/runtime.js';
import { resolveEffectiveMeta } from '../../seo/page-meta.js';
describe('resolveEffectiveMeta', () => {
    it('applies site title template when metaTitle is unset', () => {
        setActuateConfig({
            seo: {
                siteName: 'Acme',
                siteUrl: 'https://acme.com',
                titleTemplate: '%page% | %site%',
            },
            collections: {
                pages: { slug: 'pages', type: 'page', fields: [] },
            },
        });
        const effective = resolveEffectiveMeta({
            data: { title: 'About Us', slug: 'about' },
            collectionSlug: 'pages',
            site: {
                siteName: 'Acme',
                siteUrl: 'https://acme.com',
                titleTemplate: '%page% | %site%',
            },
            siteUrl: 'https://acme.com',
        });
        expect(effective.metaTitle).toBe('About Us | Acme');
        setActuateConfig({});
    });
    it('uses keyTakeaway as meta description fallback', () => {
        const effective = resolveEffectiveMeta({
            data: {
                title: 'Pricing',
                keyTakeaway: 'Transparent pricing for teams of every size with no hidden fees.',
            },
            collectionSlug: 'pages',
        });
        expect(effective.metaDescription).toBe('Transparent pricing for teams of every size with no hidden fees.');
    });
    it('prefers explicit metaTitle over title template', () => {
        const effective = resolveEffectiveMeta({
            data: { title: 'Home', metaTitle: 'Custom SEO Title Here For Home Page' },
            collectionSlug: 'pages',
            site: {
                siteName: 'Acme',
                titleTemplate: '%page% | %site%',
            },
        });
        expect(effective.metaTitle).toBe('Custom SEO Title Here For Home Page');
    });
    it('provides dynamic OG image URL when siteUrl is configured', () => {
        const effective = resolveEffectiveMeta({
            data: { title: 'Home', metaTitle: 'Home | Acme' },
            siteUrl: 'https://acme.com',
        });
        expect(effective.ogImage).toContain('https://acme.com/api/cms/og.png');
    });
});
//# sourceMappingURL=effective-meta.test.js.map