import { describe, test, expect } from 'vitest';

import { orgHasFeature, OrgFeature, OrgVersion } from './index.js';

describe('orgHasFeature', () => {
  describe('V1-only features', () => {
    const v1OnlyFeatures = [
      OrgFeature.LegacyAuditLogs,
      OrgFeature.LegacyObservability,
      OrgFeature.LegacySourceControl,
      OrgFeature.LegacySuperblocksOcr,
      OrgFeature.LegacySuperblocksEmail,
      OrgFeature.LegacyGoogleSheets,
      OrgFeature.LegacyExecutionToken,
      OrgFeature.LegacySecretsManagement,
      OrgFeature.LegacyStreamingIntegrations,
      OrgFeature.InternalLegacyEndpoints,
      OrgFeature.Workflows,
      OrgFeature.ScheduledJobs,
      OrgFeature.LegacyApps
    ];

    test.each(v1OnlyFeatures)('%s is available for V1 orgs', (feature) => {
      expect(orgHasFeature(OrgVersion.V1, feature)).toBe(true);
    });

    test.each(v1OnlyFeatures)('%s is NOT available for V2 orgs', (feature) => {
      expect(orgHasFeature(OrgVersion.V2, feature)).toBe(false);
    });
  });

  describe('V2-only features', () => {
    const v2OnlyFeatures = [OrgFeature.ReactApps, OrgFeature.Knowledge];

    test.each(v2OnlyFeatures)('%s is NOT available for V1 orgs', (feature) => {
      expect(orgHasFeature(OrgVersion.V1, feature)).toBe(false);
    });

    test.each(v2OnlyFeatures)('%s is available for V2 orgs', (feature) => {
      expect(orgHasFeature(OrgVersion.V2, feature)).toBe(true);
    });
  });
});
