import { afterEach, describe, expect, it } from 'vitest';
import { assertPlanFeature, getPlanTier, hasPlanFeature, listPlanFeatures, } from '../../plan/features.js';
import { setActuateConfig } from '../../config/runtime.js';
describe('plan features', () => {
    const originalTier = process.env.CMS_PLAN_TIER;
    afterEach(() => {
        if (originalTier === undefined)
            delete process.env.CMS_PLAN_TIER;
        else
            process.env.CMS_PLAN_TIER = originalTier;
        setActuateConfig({});
    });
    it('defaults to pro when no tier is configured', () => {
        delete process.env.CMS_PLAN_TIER;
        setActuateConfig({});
        expect(getPlanTier()).toBe('pro');
        expect(hasPlanFeature('seo.inlineApply')).toBe(true);
    });
    it('starter tier blocks advanced SEO features', () => {
        process.env.CMS_PLAN_TIER = 'starter';
        expect(listPlanFeatures()).toEqual([]);
        expect(assertPlanFeature('seo.batchContentBriefs')).toEqual({
            feature: 'seo.batchContentBriefs',
            requiredTier: 'pro',
            message: 'This feature requires the pro plan.',
        });
    });
    it('reads tier from config when env is unset', () => {
        delete process.env.CMS_PLAN_TIER;
        setActuateConfig({ plan: { tier: 'starter' } });
        expect(getPlanTier()).toBe('starter');
        expect(hasPlanFeature('seo.contentBrief')).toBe(false);
    });
});
//# sourceMappingURL=features.test.js.map