/**
 * RED-GREEN tests for the onboarding tier router (W5.1-support).
 *
 * @connexum/ai-governance  F-NEW-PRODUCT-NON-TECH-ONBOARDING-LADDER
 */
import { describe, it } from 'node:test';
import * as assert from 'node:assert/strict';
import { recommendOnboardingTier } from './onboarding-tier-router.js';
const profile = (over = {}) => ({
    techTeamSize: 3,
    cloudLlmOnly: false,
    vertical: 'devtools',
    agentCount: 5,
    regulated: false,
    hasMspPartner: false,
    wantsFullyManaged: false,
    ...over,
});
describe('onboarding tier router (W5.1)', () => {
    it('Tier E: wantsFullyManaged trumps everything else', () => {
        const r = recommendOnboardingTier(profile({ wantsFullyManaged: true, regulated: true }));
        assert.equal(r.tier, 'E');
        assert.match(r.label, /Compliance-as-a-Service/);
        assert.ok(r.alternatives.some((a) => a.tier === 'D'));
        assert.match(r.cta, /managed dashboard/);
    });
    it('Tier D: regulated + existing MSP partner', () => {
        const r = recommendOnboardingTier(profile({ regulated: true, hasMspPartner: true, techTeamSize: 4 }));
        assert.equal(r.tier, 'D');
        assert.match(r.cta, /MSP/);
        assert.ok(r.alternatives.some((a) => a.tier === 'C'));
    });
    it('Tier A: cloud-LLM-only + at least one engineer', () => {
        const r = recommendOnboardingTier(profile({ cloudLlmOnly: true, techTeamSize: 2, regulated: false }));
        assert.equal(r.tier, 'A');
        assert.match(r.cta, /one URL change/);
        assert.ok(r.alternatives.some((a) => a.tier === 'C'));
    });
    it('Tier A includes MSP alternative for fleets of 50+ agents', () => {
        const r = recommendOnboardingTier(profile({ cloudLlmOnly: true, techTeamSize: 2, agentCount: 75 }));
        assert.equal(r.tier, 'A');
        assert.ok(r.alternatives.some((a) => a.tier === 'D'));
    });
    it('Tier B: zero tech team + small agent footprint', () => {
        const r = recommendOnboardingTier(profile({ techTeamSize: 0, agentCount: 2 }));
        assert.equal(r.tier, 'B');
        assert.match(r.cta, /Chrome extension/);
    });
    it('Tier C: mid-market tech team with tool-using agents', () => {
        const r = recommendOnboardingTier(profile({ techTeamSize: 5, cloudLlmOnly: false, agentCount: 12 }));
        assert.equal(r.tier, 'C');
        assert.match(r.cta, /customer success/);
        assert.ok(r.alternatives.some((a) => a.tier === 'A'));
    });
    it('Tier D fallback: large team (>10)', () => {
        const r = recommendOnboardingTier(profile({ techTeamSize: 15, cloudLlmOnly: false, regulated: false }));
        assert.equal(r.tier, 'D');
        assert.ok(r.alternatives.some((a) => a.tier === 'E'));
    });
    it('Tier D fallback: regulated org without MSP partner', () => {
        const r = recommendOnboardingTier(profile({ techTeamSize: 0, cloudLlmOnly: false, regulated: true }));
        assert.equal(r.tier, 'D');
        assert.match(r.reasoning.join(' '), /Regulated/);
    });
    it('reasoning is non-empty for every recommendation', () => {
        const profiles = [
            profile({ wantsFullyManaged: true }),
            profile({ regulated: true, hasMspPartner: true }),
            profile({ cloudLlmOnly: true }),
            profile({ techTeamSize: 0, agentCount: 1 }),
            profile({ techTeamSize: 5 }),
            profile({ techTeamSize: 20 }),
        ];
        for (const p of profiles) {
            const r = recommendOnboardingTier(p);
            assert.ok(r.reasoning.length > 0, `${r.tier} should explain itself`);
            assert.ok(r.cta.length > 0);
        }
    });
    it('cta and label match the recommended tier', () => {
        const tiers = [
            { profile: profile({ wantsFullyManaged: true }), expected: 'as-a-Service' },
            { profile: profile({ regulated: true, hasMspPartner: true }), expected: 'MSP' },
            { profile: profile({ cloudLlmOnly: true, techTeamSize: 2 }), expected: 'Proxy' },
            { profile: profile({ techTeamSize: 0, agentCount: 1 }), expected: 'Browser' },
            { profile: profile({ techTeamSize: 5 }), expected: 'CSM' },
        ];
        for (const t of tiers) {
            const r = recommendOnboardingTier(t.profile);
            assert.match(r.label + ' ' + r.cta, new RegExp(t.expected, 'i'));
        }
    });
    it('alternatives are never empty', () => {
        const profiles = [
            profile(),
            profile({ wantsFullyManaged: true }),
            profile({ cloudLlmOnly: true }),
            profile({ regulated: true, hasMspPartner: true }),
        ];
        for (const p of profiles) {
            const r = recommendOnboardingTier(p);
            assert.ok(r.alternatives.length > 0, `${r.tier} should have at least one alternative`);
        }
    });
});
//# sourceMappingURL=onboarding-tier-router.test.js.map