diff --git a/frontend/src/feature-flags/__tests__/FeatureFlagsProvider.test.ts b/frontend/src/feature-flags/__tests__/FeatureFlagsProvider.test.ts index 515d3c0d..9473c8f1 100644 --- a/frontend/src/feature-flags/__tests__/FeatureFlagsProvider.test.ts +++ b/frontend/src/feature-flags/__tests__/FeatureFlagsProvider.test.ts @@ -155,37 +155,40 @@ describe('given a feature flags provider and a list of rules', () => { }) }) - describe('when the version is at or above 3.9.0', () => { - it('should return the list of available features', async () => { - const features = await subject('3.9.0', region) - expect(features).toEqual([ - 'multiuser_cluster', - 'fsx_ontap', - 'fsx_openzsf', - 'lustre_persistent2', - 'memory_based_scheduling', - 'slurm_queue_update_strategy', - 'ebs_deletion_policy', - 'cost_monitoring', - 'slurm_accounting', - 'queues_multiple_instance_types', - 'dynamic_fs_mount', - 'efs_deletion_policy', - 'lustre_deletion_policy', - 'imds_support', - 'multi_az', - 'on_node_updated', - 'rhel8', - 'new_resources_limits', - 'ubuntu2204', - 'login_nodes', - 'amazon_file_cache', - 'job_exclusive_allocation', - 'memory_based_scheduling_with_multiple_instance_types', - 'rhel9', - ]) + for (const version of ["3.9.0", "3.10.0"]) { + describe(`when the version is ${version}`, () => { + it('should return the list of available features', async () => { + const features = await subject(version, region) + expect(features).toEqual([ + 'multiuser_cluster', + 'fsx_ontap', + 'fsx_openzsf', + 'lustre_persistent2', + 'memory_based_scheduling', + 'slurm_queue_update_strategy', + 'ebs_deletion_policy', + 'cost_monitoring', + 'slurm_accounting', + 'queues_multiple_instance_types', + 'dynamic_fs_mount', + 'efs_deletion_policy', + 'lustre_deletion_policy', + 'imds_support', + 'multi_az', + 'on_node_updated', + 'rhel8', + 'new_resources_limits', + 'ubuntu2204', + 'login_nodes', + 'amazon_file_cache', + 'job_exclusive_allocation', + 'memory_based_scheduling_with_multiple_instance_types', + 'rhel9', + ]) + }) }) - }) + } + describe('when an additional feature has been enabled through the browser session storage', () => { beforeEach(() => { diff --git a/frontend/src/feature-flags/featureFlagsProvider.ts b/frontend/src/feature-flags/featureFlagsProvider.ts index cbb382f8..785912e0 100644 --- a/frontend/src/feature-flags/featureFlagsProvider.ts +++ b/frontend/src/feature-flags/featureFlagsProvider.ts @@ -50,12 +50,16 @@ const featureToDeperecatedVersionMap: Partial< ubuntu1804: '3.7.0', } +function isVersionGraterOrEqualThan(version: string, other: string): boolean { + return version != null && version.localeCompare(other, undefined, { numeric: true, sensitivity: 'base' }) >= 0 +} + function isNotDeprecated( feature: AvailableFeature, currentVersion: string, ): boolean { if (feature in featureToDeperecatedVersionMap) { - if (currentVersion >= featureToDeperecatedVersionMap[feature]!) { + if (isVersionGraterOrEqualThan(currentVersion, featureToDeperecatedVersionMap[feature]!)) { return false } } @@ -86,7 +90,7 @@ function composeFlagsListByVersion(currentVersion: string): AvailableFeature[] { let features: Set = new Set([]) for (let version in versionToFeaturesMap) { - if (currentVersion >= version) { + if (isVersionGraterOrEqualThan(currentVersion, version)) { features = new Set([...features, ...versionToFeaturesMap[version]]) } } diff --git a/frontend/src/feature-flags/useFeatureFlag.ts b/frontend/src/feature-flags/useFeatureFlag.ts index ba270c70..a70335c1 100644 --- a/frontend/src/feature-flags/useFeatureFlag.ts +++ b/frontend/src/feature-flags/useFeatureFlag.ts @@ -24,6 +24,9 @@ export function isFeatureEnabled( feature: AvailableFeature, ): boolean { const features = new Set(featureFlagsProvider(version, region)) - - return features.has(feature) + const enabled = features.has(feature) + if (!enabled) { + console.log(`FEATURE FLAG: Feature ${feature} is disabled`) + } + return enabled }