import { afterEach, describe, expect, it } from 'vitest';
import { resolveRobotsDirectives, resolveSeoEnvironment } from '../../seo/robots.js';
describe('resolveRobotsDirectives', () => {
    it('uses index/follow when no defaults or page overrides are set', () => {
        expect(resolveRobotsDirectives({ environment: 'production' })).toEqual({
            noIndex: false,
            noFollow: false,
        });
    });
    it('uses site-wide defaults when a page does not override robots directives', () => {
        expect(resolveRobotsDirectives({
            settings: { defaultNoIndex: true, defaultNoFollow: true },
            pageData: {},
            environment: 'production',
        })).toEqual({
            noIndex: true,
            noFollow: true,
        });
    });
    it('lets explicit page robots settings override site defaults', () => {
        expect(resolveRobotsDirectives({
            settings: { defaultNoIndex: true, defaultNoFollow: true },
            pageData: { noIndex: false, noFollow: false },
            environment: 'production',
        })).toEqual({
            noIndex: false,
            noFollow: false,
        });
    });
    it('supports explicit per-page robots policies', () => {
        expect(resolveRobotsDirectives({
            settings: { defaultNoIndex: false, defaultNoFollow: false },
            pageData: { robotsPolicy: 'noindex-nofollow' },
            environment: 'production',
        })).toEqual({
            noIndex: true,
            noFollow: true,
        });
    });
    it('can force non-production environments to noindex', () => {
        expect(resolveRobotsDirectives({
            settings: { noIndexNonProduction: true },
            pageData: { noIndex: false },
            environment: 'preview',
        })).toEqual({
            noIndex: true,
            noFollow: false,
        });
    });
});
describe('resolveSeoEnvironment', () => {
    const origVercel = process.env.VERCEL_ENV;
    const origNode = process.env.NODE_ENV;
    afterEach(() => {
        process.env.VERCEL_ENV = origVercel;
        process.env.NODE_ENV = origNode;
    });
    it('returns the explicit value when provided', () => {
        expect(resolveSeoEnvironment('staging')).toBe('staging');
    });
    it('prefers VERCEL_ENV over NODE_ENV (preview deploys report NODE_ENV=production)', () => {
        process.env.VERCEL_ENV = 'preview';
        process.env.NODE_ENV = 'production';
        expect(resolveSeoEnvironment()).toBe('preview');
    });
    it('falls back to NODE_ENV when VERCEL_ENV is unset', () => {
        delete process.env.VERCEL_ENV;
        process.env.NODE_ENV = 'test';
        expect(resolveSeoEnvironment()).toBe('test');
    });
});
//# sourceMappingURL=robots.test.js.map