"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const vitest_1 = require("vitest");
const utils_1 = require("./utils");
const createCluster = (overrides = {}) => (Object.assign({ id: 'test-cluster', name: 'test-cluster', kind: 'Cluster', href: '/api/assisted-install/v2/clusters/test-cluster', openshiftVersion: '4.11', status: 'ready', statusInfo: 'Cluster is ready', machineNetworks: [], clusterNetworks: [], serviceNetworks: [] }, overrides));
const createMachineNetwork = (cidr) => ({ cidr, clusterId: 'test' });
const createClusterNetwork = (cidr, hostPrefix) => ({
    cidr,
    hostPrefix,
    clusterId: 'test',
});
const createServiceNetwork = (cidr) => ({ cidr, clusterId: 'test' });
(0, vitest_1.describe)('getStackTypeLabel', () => {
    (0, vitest_1.describe)('OCP < 4.12 (legacy behavior)', () => {
        (0, vitest_1.test)('returns "Dual-stack" for valid dual stack with IPv4 primary', () => {
            const cluster = createCluster({
                openshiftVersion: '4.11',
                machineNetworks: [
                    createMachineNetwork('192.168.1.0/24'),
                    createMachineNetwork('2001:db8::/64'),
                ],
                clusterNetworks: [
                    createClusterNetwork('10.128.0.0/14', 23),
                    createClusterNetwork('fd01::/48', 64),
                ],
                serviceNetworks: [
                    createServiceNetwork('172.30.0.0/16'),
                    createServiceNetwork('fd02::/112'),
                ],
            });
            (0, vitest_1.expect)((0, utils_1.getStackTypeLabel)(cluster)).toBe('Dual-stack');
        });
        (0, vitest_1.test)('returns "IPv4" for single stack', () => {
            const cluster = createCluster({
                openshiftVersion: '4.11',
                machineNetworks: [createMachineNetwork('192.168.1.0/24')],
                clusterNetworks: [createClusterNetwork('10.128.0.0/14', 23)],
                serviceNetworks: [createServiceNetwork('172.30.0.0/16')],
            });
            (0, vitest_1.expect)((0, utils_1.getStackTypeLabel)(cluster)).toBe('IPv4');
        });
        (0, vitest_1.test)('returns "IPv4" for IPv6 primary (invalid for OCP < 4.12)', () => {
            const cluster = createCluster({
                openshiftVersion: '4.11',
                machineNetworks: [
                    createMachineNetwork('2001:db8::/64'),
                    createMachineNetwork('192.168.1.0/24'),
                ],
                clusterNetworks: [
                    createClusterNetwork('fd01::/48', 64),
                    createClusterNetwork('10.128.0.0/14', 23),
                ],
                serviceNetworks: [
                    createServiceNetwork('fd02::/112'),
                    createServiceNetwork('172.30.0.0/16'),
                ],
            });
            (0, vitest_1.expect)((0, utils_1.getStackTypeLabel)(cluster)).toBe('IPv4');
        });
    });
    (0, vitest_1.describe)('OCP >= 4.12 (new behavior)', () => {
        (0, vitest_1.test)('returns "Dual-stack" for IPv4 primary and IPv6 secondary', () => {
            const cluster = createCluster({
                openshiftVersion: '4.12',
                machineNetworks: [
                    createMachineNetwork('192.168.1.0/24'),
                    createMachineNetwork('2001:db8::/64'),
                ],
                clusterNetworks: [
                    createClusterNetwork('10.128.0.0/14', 23),
                    createClusterNetwork('fd01::/48', 64),
                ],
                serviceNetworks: [
                    createServiceNetwork('172.30.0.0/16'),
                    createServiceNetwork('fd02::/112'),
                ],
            });
            (0, vitest_1.expect)((0, utils_1.getStackTypeLabel)(cluster)).toBe('Dual-stack');
        });
        (0, vitest_1.test)('returns "Dual-stack" for IPv6 primary and IPv4 secondary', () => {
            const cluster = createCluster({
                openshiftVersion: '4.12',
                machineNetworks: [
                    createMachineNetwork('2001:db8::/64'),
                    createMachineNetwork('192.168.1.0/24'),
                ],
                clusterNetworks: [
                    createClusterNetwork('fd01::/48', 64),
                    createClusterNetwork('10.128.0.0/14', 23),
                ],
                serviceNetworks: [
                    createServiceNetwork('fd02::/112'),
                    createServiceNetwork('172.30.0.0/16'),
                ],
            });
            (0, vitest_1.expect)((0, utils_1.getStackTypeLabel)(cluster)).toBe('Dual-stack');
        });
        (0, vitest_1.test)('returns "IPv4" for IPv6 primary and IPv6 secondary (not dual-stack)', () => {
            const cluster = createCluster({
                openshiftVersion: '4.12',
                machineNetworks: [
                    createMachineNetwork('2001:db8::/64'),
                    createMachineNetwork('2001:db9::/64'),
                ],
                clusterNetworks: [
                    createClusterNetwork('fd01::/48', 64),
                    createClusterNetwork('fd02::/48', 64),
                ],
                serviceNetworks: [createServiceNetwork('fd03::/112'), createServiceNetwork('fd04::/112')],
            });
            (0, vitest_1.expect)((0, utils_1.getStackTypeLabel)(cluster)).toBe('IPv4');
        });
        (0, vitest_1.test)('returns "IPv4" for IPv4 primary and IPv4 secondary (not dual-stack)', () => {
            const cluster = createCluster({
                openshiftVersion: '4.12',
                machineNetworks: [
                    createMachineNetwork('192.168.1.0/24'),
                    createMachineNetwork('10.0.0.0/24'),
                ],
                clusterNetworks: [
                    createClusterNetwork('10.128.0.0/14', 23),
                    createClusterNetwork('172.16.0.0/14', 23),
                ],
                serviceNetworks: [
                    createServiceNetwork('172.30.0.0/16'),
                    createServiceNetwork('172.31.0.0/16'),
                ],
            });
            (0, vitest_1.expect)((0, utils_1.getStackTypeLabel)(cluster)).toBe('IPv4');
        });
        (0, vitest_1.test)('returns "IPv4" for single stack', () => {
            const cluster = createCluster({
                openshiftVersion: '4.12',
                machineNetworks: [createMachineNetwork('192.168.1.0/24')],
                clusterNetworks: [createClusterNetwork('10.128.0.0/14', 23)],
                serviceNetworks: [createServiceNetwork('172.30.0.0/16')],
            });
            (0, vitest_1.expect)((0, utils_1.getStackTypeLabel)(cluster)).toBe('IPv4');
        });
    });
    (0, vitest_1.describe)('edge cases', () => {
        (0, vitest_1.test)('handles undefined openshiftVersion', () => {
            const cluster = createCluster({
                openshiftVersion: undefined,
                machineNetworks: [
                    createMachineNetwork('192.168.1.0/24'),
                    createMachineNetwork('2001:db8::/64'),
                ],
                clusterNetworks: [
                    createClusterNetwork('10.128.0.0/14', 23),
                    createClusterNetwork('fd01::/48', 64),
                ],
                serviceNetworks: [
                    createServiceNetwork('172.30.0.0/16'),
                    createServiceNetwork('fd02::/112'),
                ],
            });
            (0, vitest_1.expect)((0, utils_1.getStackTypeLabel)(cluster)).toBe('Dual-stack');
        });
        (0, vitest_1.test)('handles empty networks', () => {
            const cluster = createCluster({
                openshiftVersion: '4.12',
                machineNetworks: [],
                clusterNetworks: [],
                serviceNetworks: [],
            });
            (0, vitest_1.expect)((0, utils_1.getStackTypeLabel)(cluster)).toBe('IPv4');
        });
        (0, vitest_1.test)('handles undefined networks', () => {
            const cluster = createCluster({
                openshiftVersion: '4.12',
                machineNetworks: undefined,
                clusterNetworks: undefined,
                serviceNetworks: undefined,
            });
            (0, vitest_1.expect)((0, utils_1.getStackTypeLabel)(cluster)).toBe('IPv4');
        });
    });
});
//# sourceMappingURL=utils.test.js.map