import { describe, it, expect, vi, beforeEach } from 'vitest';
import { renderHook, waitFor } from '@testing-library/react';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import React from 'react';

// Mock dependencies
vi.mock('../../api/client', () => ({
  default: {
    get: vi.fn(),
  },
}));

vi.mock('../../utils/cookies', () => ({
  getCookie: vi.fn(),
}));

import { usePlanFeatures, FEATURE_NAMES, FEATURE_DESCRIPTIONS } from '../usePlanFeatures';
import apiClient from '../../api/client';
import { getCookie } from '../../utils/cookies';
import type { PlanPermissions } from '../../types';

// Create wrapper
const createWrapper = () => {
  const queryClient = new QueryClient({
    defaultOptions: {
      queries: { retry: false },
      mutations: { retry: false },
    },
  });

  return function Wrapper({ children }: { children: React.ReactNode }) {
    return React.createElement(QueryClientProvider, { client: queryClient }, children);
  };
};

describe('usePlanFeatures', () => {
  beforeEach(() => {
    vi.clearAllMocks();
  });

  describe('when business data is loading', () => {
    it('returns isLoading: true and safe defaults', async () => {
      vi.mocked(getCookie).mockReturnValue('valid-token');
      // Don't resolve the promise yet to simulate loading state
      vi.mocked(apiClient.get).mockImplementation(() => new Promise(() => {}));

      const { result } = renderHook(() => usePlanFeatures(), {
        wrapper: createWrapper(),
      });

      expect(result.current.isLoading).toBe(true);
      expect(result.current.plan).toBeUndefined();
      expect(result.current.permissions).toBeUndefined();
      expect(result.current.canUse('sms_reminders')).toBe(false);
    });
  });

  describe('when no business data exists (no token)', () => {
    it('returns false for all feature checks', async () => {
      vi.mocked(getCookie).mockReturnValue(null);

      const { result } = renderHook(() => usePlanFeatures(), {
        wrapper: createWrapper(),
      });

      await waitFor(() => {
        expect(result.current.isLoading).toBe(false);
      });

      expect(result.current.data).toBeUndefined();
      expect(result.current.plan).toBeUndefined();
      expect(result.current.permissions).toBeUndefined();
      expect(result.current.canUse('sms_reminders')).toBe(false);
      expect(result.current.canUse('webhooks')).toBe(false);
      expect(result.current.canUse('api_access')).toBe(false);
    });
  });

  describe('when business has no planPermissions', () => {
    it('returns false for all feature checks', async () => {
      vi.mocked(getCookie).mockReturnValue('valid-token');

      const mockBusiness = {
        id: 1,
        name: 'Test Business',
        subdomain: 'test',
        tier: 'Free',
        // No plan_permissions field
      };
      vi.mocked(apiClient.get).mockResolvedValue({ data: mockBusiness });

      const { result } = renderHook(() => usePlanFeatures(), {
        wrapper: createWrapper(),
      });

      await waitFor(() => {
        expect(result.current.isLoading).toBe(false);
      });

      expect(result.current.plan).toBe('Free');
      expect(result.current.permissions).toBeDefined();
      expect(result.current.canUse('sms_reminders')).toBe(false);
      expect(result.current.canUse('webhooks')).toBe(false);
      expect(result.current.canUse('contracts')).toBe(false);
    });
  });

  describe('canUse', () => {
    it('returns true when feature is enabled in plan permissions', async () => {
      vi.mocked(getCookie).mockReturnValue('valid-token');

      const mockBusiness = {
        id: 1,
        name: 'Test Business',
        subdomain: 'test',
        tier: 'Professional',
        plan_permissions: {
          sms_reminders: true,
          webhooks: true,
          api_access: false,
          custom_domain: false,
          white_label: false,
          custom_oauth: false,
          plugins: false,
          tasks: false,
          export_data: true,
          video_conferencing: false,
          two_factor_auth: false,
          masked_calling: false,
          pos_system: false,
          mobile_app: false,
          contracts: false,
        },
      };
      vi.mocked(apiClient.get).mockResolvedValue({ data: mockBusiness });

      const { result } = renderHook(() => usePlanFeatures(), {
        wrapper: createWrapper(),
      });

      await waitFor(() => {
        expect(result.current.isLoading).toBe(false);
      });

      expect(result.current.canUse('sms_reminders')).toBe(true);
      expect(result.current.canUse('webhooks')).toBe(true);
      expect(result.current.canUse('export_data')).toBe(true);
    });

    it('returns false when feature is disabled in plan permissions', async () => {
      vi.mocked(getCookie).mockReturnValue('valid-token');

      const mockBusiness = {
        id: 1,
        name: 'Test Business',
        subdomain: 'test',
        tier: 'Free',
        plan_permissions: {
          sms_reminders: false,
          webhooks: false,
          api_access: false,
          custom_domain: false,
          white_label: false,
          custom_oauth: false,
          plugins: false,
          tasks: false,
          export_data: false,
          video_conferencing: false,
          two_factor_auth: false,
          masked_calling: false,
          pos_system: false,
          mobile_app: false,
          contracts: false,
        },
      };
      vi.mocked(apiClient.get).mockResolvedValue({ data: mockBusiness });

      const { result } = renderHook(() => usePlanFeatures(), {
        wrapper: createWrapper(),
      });

      await waitFor(() => {
        expect(result.current.isLoading).toBe(false);
      });

      expect(result.current.canUse('sms_reminders')).toBe(false);
      expect(result.current.canUse('webhooks')).toBe(false);
      expect(result.current.canUse('custom_domain')).toBe(false);
    });

    it('returns false for undefined features (null coalescing)', async () => {
      vi.mocked(getCookie).mockReturnValue('valid-token');

      const mockBusiness = {
        id: 1,
        name: 'Test Business',
        subdomain: 'test',
        tier: 'Professional',
        plan_permissions: {
          sms_reminders: true,
          // Missing other features
        } as Partial<PlanPermissions>,
      };
      vi.mocked(apiClient.get).mockResolvedValue({ data: mockBusiness });

      const { result } = renderHook(() => usePlanFeatures(), {
        wrapper: createWrapper(),
      });

      await waitFor(() => {
        expect(result.current.isLoading).toBe(false);
      });

      expect(result.current.canUse('sms_reminders')).toBe(true);
      expect(result.current.canUse('webhooks')).toBe(false);
      expect(result.current.canUse('api_access')).toBe(false);
    });

    it('handles all feature types', async () => {
      vi.mocked(getCookie).mockReturnValue('valid-token');

      const mockBusiness = {
        id: 1,
        name: 'Enterprise Business',
        subdomain: 'enterprise',
        tier: 'Enterprise',
        plan_permissions: {
          sms_reminders: true,
          webhooks: true,
          api_access: true,
          custom_domain: true,
          white_label: true,
          custom_oauth: true,
          automations: true,
          can_create_automations: true,
          tasks: true,
          export_data: true,
          video_conferencing: true,
          two_factor_auth: true,
          masked_calling: true,
          pos_system: true,
          mobile_app: true,
          contracts: true,
        },
      };
      vi.mocked(apiClient.get).mockResolvedValue({ data: mockBusiness });

      const { result } = renderHook(() => usePlanFeatures(), {
        wrapper: createWrapper(),
      });

      await waitFor(() => {
        expect(result.current.isLoading).toBe(false);
      });

      // Test all features are accessible
      expect(result.current.canUse('sms_reminders')).toBe(true);
      expect(result.current.canUse('webhooks')).toBe(true);
      expect(result.current.canUse('api_access')).toBe(true);
      expect(result.current.canUse('custom_domain')).toBe(true);
      expect(result.current.canUse('white_label')).toBe(true);
      expect(result.current.canUse('custom_oauth')).toBe(true);
      expect(result.current.canUse('automations')).toBe(true);
      expect(result.current.canUse('tasks')).toBe(true);
      expect(result.current.canUse('export_data')).toBe(true);
      expect(result.current.canUse('video_conferencing')).toBe(true);
      expect(result.current.canUse('two_factor_auth')).toBe(true);
      expect(result.current.canUse('masked_calling')).toBe(true);
      expect(result.current.canUse('pos_system')).toBe(true);
      expect(result.current.canUse('mobile_app')).toBe(true);
      expect(result.current.canUse('contracts')).toBe(true);
    });
  });

  describe('canUseAny', () => {
    it('returns true when at least one feature is available', async () => {
      vi.mocked(getCookie).mockReturnValue('valid-token');

      const mockBusiness = {
        id: 1,
        name: 'Test Business',
        subdomain: 'test',
        tier: 'Professional',
        plan_permissions: {
          sms_reminders: true,
          webhooks: false,
          api_access: false,
          custom_domain: false,
          white_label: false,
          custom_oauth: false,
          plugins: false,
          tasks: false,
          export_data: false,
          video_conferencing: false,
          two_factor_auth: false,
          masked_calling: false,
          pos_system: false,
          mobile_app: false,
          contracts: false,
        },
      };
      vi.mocked(apiClient.get).mockResolvedValue({ data: mockBusiness });

      const { result } = renderHook(() => usePlanFeatures(), {
        wrapper: createWrapper(),
      });

      await waitFor(() => {
        expect(result.current.isLoading).toBe(false);
      });

      expect(result.current.canUseAny(['sms_reminders', 'webhooks', 'api_access'])).toBe(true);
      expect(result.current.canUseAny(['sms_reminders'])).toBe(true);
    });

    it('returns false when no features are available', async () => {
      vi.mocked(getCookie).mockReturnValue('valid-token');

      const mockBusiness = {
        id: 1,
        name: 'Test Business',
        subdomain: 'test',
        tier: 'Free',
        plan_permissions: {
          sms_reminders: false,
          webhooks: false,
          api_access: false,
          custom_domain: false,
          white_label: false,
          custom_oauth: false,
          plugins: false,
          tasks: false,
          export_data: false,
          video_conferencing: false,
          two_factor_auth: false,
          masked_calling: false,
          pos_system: false,
          mobile_app: false,
          contracts: false,
        },
      };
      vi.mocked(apiClient.get).mockResolvedValue({ data: mockBusiness });

      const { result } = renderHook(() => usePlanFeatures(), {
        wrapper: createWrapper(),
      });

      await waitFor(() => {
        expect(result.current.isLoading).toBe(false);
      });

      expect(result.current.canUseAny(['webhooks', 'api_access', 'custom_domain'])).toBe(false);
    });

    it('handles empty array', async () => {
      vi.mocked(getCookie).mockReturnValue('valid-token');

      const mockBusiness = {
        id: 1,
        name: 'Test Business',
        subdomain: 'test',
        tier: 'Professional',
        plan_permissions: {
          sms_reminders: true,
          webhooks: true,
          api_access: true,
          custom_domain: false,
          white_label: false,
          custom_oauth: false,
          plugins: false,
          tasks: false,
          export_data: false,
          video_conferencing: false,
          two_factor_auth: false,
          masked_calling: false,
          pos_system: false,
          mobile_app: false,
          contracts: false,
        },
      };
      vi.mocked(apiClient.get).mockResolvedValue({ data: mockBusiness });

      const { result } = renderHook(() => usePlanFeatures(), {
        wrapper: createWrapper(),
      });

      await waitFor(() => {
        expect(result.current.isLoading).toBe(false);
      });

      expect(result.current.canUseAny([])).toBe(false);
    });

    it('returns true when multiple features are available', async () => {
      vi.mocked(getCookie).mockReturnValue('valid-token');

      const mockBusiness = {
        id: 1,
        name: 'Business',
        subdomain: 'biz',
        tier: 'Business',
        plan_permissions: {
          sms_reminders: true,
          webhooks: true,
          api_access: true,
          custom_domain: true,
          white_label: false,
          custom_oauth: false,
          plugins: false,
          tasks: false,
          export_data: true,
          video_conferencing: true,
          two_factor_auth: false,
          masked_calling: false,
          pos_system: false,
          mobile_app: false,
          contracts: false,
        },
      };
      vi.mocked(apiClient.get).mockResolvedValue({ data: mockBusiness });

      const { result } = renderHook(() => usePlanFeatures(), {
        wrapper: createWrapper(),
      });

      await waitFor(() => {
        expect(result.current.isLoading).toBe(false);
      });

      expect(result.current.canUseAny(['sms_reminders', 'webhooks'])).toBe(true);
      expect(result.current.canUseAny(['api_access', 'custom_domain', 'export_data'])).toBe(true);
    });
  });

  describe('canUseAll', () => {
    it('returns true when all features are available', async () => {
      vi.mocked(getCookie).mockReturnValue('valid-token');

      const mockBusiness = {
        id: 1,
        name: 'Test Business',
        subdomain: 'test',
        tier: 'Professional',
        plan_permissions: {
          sms_reminders: true,
          webhooks: true,
          api_access: true,
          custom_domain: false,
          white_label: false,
          custom_oauth: false,
          plugins: false,
          tasks: false,
          export_data: false,
          video_conferencing: false,
          two_factor_auth: false,
          masked_calling: false,
          pos_system: false,
          mobile_app: false,
          contracts: false,
        },
      };
      vi.mocked(apiClient.get).mockResolvedValue({ data: mockBusiness });

      const { result } = renderHook(() => usePlanFeatures(), {
        wrapper: createWrapper(),
      });

      await waitFor(() => {
        expect(result.current.isLoading).toBe(false);
      });

      expect(result.current.canUseAll(['sms_reminders', 'webhooks', 'api_access'])).toBe(true);
      expect(result.current.canUseAll(['sms_reminders'])).toBe(true);
    });

    it('returns false when any feature is unavailable', async () => {
      vi.mocked(getCookie).mockReturnValue('valid-token');

      const mockBusiness = {
        id: 1,
        name: 'Test Business',
        subdomain: 'test',
        tier: 'Professional',
        plan_permissions: {
          sms_reminders: true,
          webhooks: false,
          api_access: true,
          custom_domain: false,
          white_label: false,
          custom_oauth: false,
          plugins: false,
          tasks: false,
          export_data: false,
          video_conferencing: false,
          two_factor_auth: false,
          masked_calling: false,
          pos_system: false,
          mobile_app: false,
          contracts: false,
        },
      };
      vi.mocked(apiClient.get).mockResolvedValue({ data: mockBusiness });

      const { result } = renderHook(() => usePlanFeatures(), {
        wrapper: createWrapper(),
      });

      await waitFor(() => {
        expect(result.current.isLoading).toBe(false);
      });

      expect(result.current.canUseAll(['sms_reminders', 'webhooks', 'api_access'])).toBe(false);
      expect(result.current.canUseAll(['webhooks'])).toBe(false);
    });

    it('handles empty array', async () => {
      vi.mocked(getCookie).mockReturnValue('valid-token');

      const mockBusiness = {
        id: 1,
        name: 'Test Business',
        subdomain: 'test',
        tier: 'Free',
        plan_permissions: {
          sms_reminders: false,
          webhooks: false,
          api_access: false,
          custom_domain: false,
          white_label: false,
          custom_oauth: false,
          plugins: false,
          tasks: false,
          export_data: false,
          video_conferencing: false,
          two_factor_auth: false,
          masked_calling: false,
          pos_system: false,
          mobile_app: false,
          contracts: false,
        },
      };
      vi.mocked(apiClient.get).mockResolvedValue({ data: mockBusiness });

      const { result } = renderHook(() => usePlanFeatures(), {
        wrapper: createWrapper(),
      });

      await waitFor(() => {
        expect(result.current.isLoading).toBe(false);
      });

      expect(result.current.canUseAll([])).toBe(true);
    });

    it('returns false when all features are unavailable', async () => {
      vi.mocked(getCookie).mockReturnValue('valid-token');

      const mockBusiness = {
        id: 1,
        name: 'Test Business',
        subdomain: 'test',
        tier: 'Free',
        plan_permissions: {
          sms_reminders: false,
          webhooks: false,
          api_access: false,
          custom_domain: false,
          white_label: false,
          custom_oauth: false,
          plugins: false,
          tasks: false,
          export_data: false,
          video_conferencing: false,
          two_factor_auth: false,
          masked_calling: false,
          pos_system: false,
          mobile_app: false,
          contracts: false,
        },
      };
      vi.mocked(apiClient.get).mockResolvedValue({ data: mockBusiness });

      const { result } = renderHook(() => usePlanFeatures(), {
        wrapper: createWrapper(),
      });

      await waitFor(() => {
        expect(result.current.isLoading).toBe(false);
      });

      expect(result.current.canUseAll(['webhooks', 'api_access', 'custom_domain'])).toBe(false);
    });
  });

  describe('plan property', () => {
    it('returns the current plan tier', async () => {
      vi.mocked(getCookie).mockReturnValue('valid-token');

      const mockBusiness = {
        id: 1,
        name: 'Test Business',
        subdomain: 'test',
        tier: 'Professional',
        plan_permissions: {
          sms_reminders: true,
          webhooks: false,
          api_access: false,
          custom_domain: false,
          white_label: false,
          custom_oauth: false,
          plugins: false,
          tasks: false,
          export_data: false,
          video_conferencing: false,
          two_factor_auth: false,
          masked_calling: false,
          pos_system: false,
          mobile_app: false,
          contracts: false,
        },
      };
      vi.mocked(apiClient.get).mockResolvedValue({ data: mockBusiness });

      const { result } = renderHook(() => usePlanFeatures(), {
        wrapper: createWrapper(),
      });

      await waitFor(() => {
        expect(result.current.isLoading).toBe(false);
      });

      expect(result.current.plan).toBe('Professional');
    });

    it('handles different plan tiers', async () => {
      const plans = ['Free', 'Professional', 'Business', 'Enterprise'];

      for (const tier of plans) {
        vi.clearAllMocks();
        vi.mocked(getCookie).mockReturnValue('valid-token');

        const mockBusiness = {
          id: 1,
          name: 'Test Business',
          subdomain: 'test',
          tier,
          plan_permissions: {
            sms_reminders: false,
            webhooks: false,
            api_access: false,
            custom_domain: false,
            white_label: false,
            custom_oauth: false,
            plugins: false,
            tasks: false,
            export_data: false,
            video_conferencing: false,
            two_factor_auth: false,
            masked_calling: false,
            pos_system: false,
            mobile_app: false,
            contracts: false,
          },
        };
        vi.mocked(apiClient.get).mockResolvedValue({ data: mockBusiness });

        const { result } = renderHook(() => usePlanFeatures(), {
          wrapper: createWrapper(),
        });

        await waitFor(() => {
          expect(result.current.isLoading).toBe(false);
        });

        expect(result.current.plan).toBe(tier);
      }
    });
  });

  describe('permissions property', () => {
    it('returns all plan permissions', async () => {
      vi.mocked(getCookie).mockReturnValue('valid-token');

      const mockPermissions = {
        sms_reminders: true,
        webhooks: true,
        api_access: false,
        custom_domain: true,
        white_label: false,
        custom_oauth: false,
        plugins: true,
        tasks: true,
        export_data: false,
        video_conferencing: true,
        two_factor_auth: false,
        masked_calling: false,
        pos_system: false,
        mobile_app: true,
        contracts: false,
      };

      const mockBusiness = {
        id: 1,
        name: 'Test Business',
        subdomain: 'test',
        tier: 'Business',
        plan_permissions: mockPermissions,
      };
      vi.mocked(apiClient.get).mockResolvedValue({ data: mockBusiness });

      const { result } = renderHook(() => usePlanFeatures(), {
        wrapper: createWrapper(),
      });

      await waitFor(() => {
        expect(result.current.isLoading).toBe(false);
      });

      expect(result.current.permissions).toEqual(mockPermissions);
    });
  });

  describe('isLoading property', () => {
    it('reflects the loading state of the business query', async () => {
      vi.mocked(getCookie).mockReturnValue('valid-token');

      let resolvePromise: (value: any) => void;
      const promise = new Promise((resolve) => {
        resolvePromise = resolve;
      });
      vi.mocked(apiClient.get).mockReturnValue(promise as any);

      const { result } = renderHook(() => usePlanFeatures(), {
        wrapper: createWrapper(),
      });

      // Initially loading
      expect(result.current.isLoading).toBe(true);

      // Resolve the promise
      resolvePromise!({
        data: {
          id: 1,
          name: 'Test Business',
          subdomain: 'test',
          tier: 'Professional',
          plan_permissions: {
            sms_reminders: true,
            webhooks: false,
            api_access: false,
            custom_domain: false,
            white_label: false,
            custom_oauth: false,
            plugins: false,
            tasks: false,
            export_data: false,
            video_conferencing: false,
            two_factor_auth: false,
            masked_calling: false,
            pos_system: false,
            mobile_app: false,
            contracts: false,
          },
        },
      });

      // Wait for loading to complete
      await waitFor(() => {
        expect(result.current.isLoading).toBe(false);
      });
    });
  });
});

describe('FEATURE_NAMES', () => {
  it('contains all feature keys', () => {
    const expectedFeatures = [
      'sms_reminders',
      'webhooks',
      'api_access',
      'custom_domain',
      'white_label',
      'custom_oauth',
      'automations',
      'can_create_automations',
      'tasks',
      'export_data',
      'video_conferencing',
      'two_factor_auth',
      'masked_calling',
      'pos_system',
      'mobile_app',
      'contracts',
    ];

    expectedFeatures.forEach((feature) => {
      expect(FEATURE_NAMES).toHaveProperty(feature);
      expect(typeof FEATURE_NAMES[feature as keyof typeof FEATURE_NAMES]).toBe('string');
      expect(FEATURE_NAMES[feature as keyof typeof FEATURE_NAMES].length).toBeGreaterThan(0);
    });
  });

  it('has user-friendly display names', () => {
    expect(FEATURE_NAMES.sms_reminders).toBe('SMS Reminders');
    expect(FEATURE_NAMES.webhooks).toBe('Webhooks');
    expect(FEATURE_NAMES.api_access).toBe('API Access');
    expect(FEATURE_NAMES.custom_domain).toBe('Custom Domain');
    expect(FEATURE_NAMES.white_label).toBe('White Label');
    expect(FEATURE_NAMES.custom_oauth).toBe('Custom OAuth');
    expect(FEATURE_NAMES.automations).toBe('Automations');
    expect(FEATURE_NAMES.can_create_automations).toBe('Custom Automation Creation');
    expect(FEATURE_NAMES.tasks).toBe('Scheduled Tasks');
    expect(FEATURE_NAMES.export_data).toBe('Data Export');
    expect(FEATURE_NAMES.video_conferencing).toBe('Video Conferencing');
    expect(FEATURE_NAMES.two_factor_auth).toBe('Two-Factor Authentication');
    expect(FEATURE_NAMES.masked_calling).toBe('Masked Calling');
    expect(FEATURE_NAMES.pos_system).toBe('POS System');
    expect(FEATURE_NAMES.mobile_app).toBe('Mobile App');
    expect(FEATURE_NAMES.contracts).toBe('Contracts');
  });
});

describe('FEATURE_DESCRIPTIONS', () => {
  it('contains all feature keys', () => {
    const expectedFeatures = [
      'sms_reminders',
      'webhooks',
      'api_access',
      'custom_domain',
      'white_label',
      'custom_oauth',
      'automations',
      'can_create_automations',
      'tasks',
      'export_data',
      'video_conferencing',
      'two_factor_auth',
      'masked_calling',
      'pos_system',
      'mobile_app',
      'contracts',
    ];

    expectedFeatures.forEach((feature) => {
      expect(FEATURE_DESCRIPTIONS).toHaveProperty(feature);
      expect(typeof FEATURE_DESCRIPTIONS[feature as keyof typeof FEATURE_DESCRIPTIONS]).toBe('string');
      expect(FEATURE_DESCRIPTIONS[feature as keyof typeof FEATURE_DESCRIPTIONS].length).toBeGreaterThan(0);
    });
  });

  it('has descriptive text for upgrade prompts', () => {
    expect(FEATURE_DESCRIPTIONS.sms_reminders).toContain('SMS reminders');
    expect(FEATURE_DESCRIPTIONS.webhooks).toContain('webhooks');
    expect(FEATURE_DESCRIPTIONS.api_access).toContain('API');
    expect(FEATURE_DESCRIPTIONS.custom_domain).toContain('custom domain');
    expect(FEATURE_DESCRIPTIONS.white_label).toContain('branding');
    expect(FEATURE_DESCRIPTIONS.custom_oauth).toContain('OAuth');
    expect(FEATURE_DESCRIPTIONS.automations).toContain('Automate');
    expect(FEATURE_DESCRIPTIONS.can_create_automations).toContain('automations');
    expect(FEATURE_DESCRIPTIONS.tasks).toContain('task');
    expect(FEATURE_DESCRIPTIONS.export_data).toContain('Export');
    expect(FEATURE_DESCRIPTIONS.video_conferencing).toContain('video');
    expect(FEATURE_DESCRIPTIONS.two_factor_auth).toContain('two-factor');
    expect(FEATURE_DESCRIPTIONS.masked_calling).toContain('masked');
    expect(FEATURE_DESCRIPTIONS.pos_system).toContain('Point of Sale');
    expect(FEATURE_DESCRIPTIONS.mobile_app).toContain('mobile');
    expect(FEATURE_DESCRIPTIONS.contracts).toContain('contract');
  });
});
