"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const quota_paywall_1 = require("./quota-paywall");
(0, vitest_1.describe)('getAiQuotaPaywallReasonFromMessage', () => {
    (0, vitest_1.it)('returns no_seat_assigned for various seat-missing phrasings', () => {
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('no_seat_assigned')).toBe('no_seat_assigned');
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)("You don't have an AI Builder license assigned. Ask your admin to assign a license.")).toBe('no_seat_assigned');
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)("user doesn't have an AI Builder license assigned")).toBe('no_seat_assigned');
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('user does not have an AI Builder seat assigned')).toBe('no_seat_assigned');
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('No builder seat assigned to user')).toBe('no_seat_assigned');
    });
    (0, vitest_1.it)('returns payment_past_due for the dedicated phrasings, including the dashboard-chat router copy', () => {
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('payment_past_due')).toBe('payment_past_due');
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('Your subscription payment failed. Update your payment method to continue.')).toBe('payment_past_due');
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('Your payment is past due')).toBe('payment_past_due');
    });
    (0, vitest_1.it)('returns trial_expired for the dashboard-chat router copy and other variants', () => {
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('trial_expired')).toBe('trial_expired');
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('Your AI trial period has ended')).toBe('trial_expired');
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('Your free trial has ended')).toBe('trial_expired');
    });
    (0, vitest_1.it)('returns token_limit_exceeded for the generic fallback message', () => {
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('token_limit_exceeded')).toBe('token_limit_exceeded');
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('AI usage limit reached')).toBe('token_limit_exceeded');
    });
    (0, vitest_1.it)('returns deploy_quota_exceeded for the deploy variant', () => {
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('deploy_quota_exceeded')).toBe('deploy_quota_exceeded');
    });
    (0, vitest_1.it)('returns credit_limit_exceeded when the org credit copy fires', () => {
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('credit_limit_exceeded')).toBe('credit_limit_exceeded');
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('Your organization has reached its AI usage limit')).toBe('credit_limit_exceeded');
    });
    (0, vitest_1.it)('is case insensitive', () => {
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('PAYMENT_PAST_DUE')).toBe('payment_past_due');
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('YOUR FREE TRIAL HAS ENDED')).toBe('trial_expired');
    });
    (0, vitest_1.it)('returns provisioning_error for the provisioning phrasings, including the server 402/429 copy', () => {
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('provisioning_error')).toBe('provisioning_error');
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)("Your organization's plan hasn't finished provisioning. Try again in a few minutes.")).toBe('provisioning_error');
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('The plan has not finished provisioning')).toBe('provisioning_error');
    });
    (0, vitest_1.it)('returns undefined when the message does not match any known phrasing', () => {
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('Connection refused')).toBeUndefined();
        (0, vitest_1.expect)((0, quota_paywall_1.getAiQuotaPaywallReasonFromMessage)('')).toBeUndefined();
    });
});
(0, vitest_1.describe)('AI_QUOTA_PAYWALL_REASON_CONFIG', () => {
    (0, vitest_1.it)('has a config entry for every AiQuotaPaywallReason', () => {
        // If a new reason is added without a config entry, the modal will fall back to
        // undefined `title`/`subtitle` strings — better to fail at compile time AND at
        // runtime here.
        const expectedReasons = [
            'credit_limit_exceeded',
            'deploy_quota_exceeded',
            'no_seat_assigned',
            'payment_past_due',
            'provisioning_error',
            'token_limit_exceeded',
            'trial_expired'
        ];
        for (const r of expectedReasons) {
            (0, vitest_1.expect)(quota_paywall_1.AI_QUOTA_PAYWALL_REASON_CONFIG[r]).toBeDefined();
            (0, vitest_1.expect)(quota_paywall_1.AI_QUOTA_PAYWALL_REASON_CONFIG[r].title.length).toBeGreaterThan(0);
            (0, vitest_1.expect)(quota_paywall_1.AI_QUOTA_PAYWALL_REASON_CONFIG[r].subtitle.length).toBeGreaterThan(0);
        }
    });
    (0, vitest_1.it)('payment_past_due copy mentions payment / subscription', () => {
        const cfg = quota_paywall_1.AI_QUOTA_PAYWALL_REASON_CONFIG.payment_past_due;
        const text = `${cfg.title} ${cfg.subtitle}`.toLowerCase();
        (0, vitest_1.expect)(text).toContain('payment');
        (0, vitest_1.expect)(text).toMatch(/subscription|paid features/);
    });
});
//# sourceMappingURL=quota-paywall.test.js.map