-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(pci-common): add tooltip relative to 1AZ feature flipping
Signed-off-by: Simon Chaumet <[email protected]>
- Loading branch information
1 parent
6cdd0bf
commit 16c419a
Showing
8 changed files
with
141 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
packages/manager/modules/manager-pci-common/src/hooks/useIs1AZ/useIs1AZ.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { | ||
useFeatureAvailability, | ||
UseFeatureAvailabilityResult, | ||
} from '@ovh-ux/manager-react-components'; | ||
import { vi } from 'vitest'; | ||
import { renderHook } from '@testing-library/react'; | ||
import { FEATURE_REGION_1AZ, useIs1AZ } from './useIs1AZ'; | ||
|
||
vi.mock('@ovh-ux/manager-react-components'); | ||
|
||
describe('useIs1AZ', () => { | ||
it('should return false if data is undefined', () => { | ||
vi.mocked(useFeatureAvailability).mockImplementationOnce( | ||
() => | ||
({ | ||
data: undefined, | ||
isLoading: true, | ||
} as UseFeatureAvailabilityResult), | ||
); | ||
|
||
const { result } = renderHook(() => useIs1AZ()); | ||
expect(result.current).toBe(false); | ||
}); | ||
|
||
it('should return false if feature is set to false', () => { | ||
vi.mocked(useFeatureAvailability).mockImplementationOnce( | ||
(features) => | ||
({ | ||
data: { | ||
...Object.fromEntries(features.map((feature) => [feature, false])), | ||
[FEATURE_REGION_1AZ]: false, | ||
}, | ||
isLoading: false, | ||
} as UseFeatureAvailabilityResult), | ||
); | ||
|
||
const { result } = renderHook(() => useIs1AZ()); | ||
expect(result.current).toBe(false); | ||
}); | ||
|
||
it('should return true if feature is set to true', () => { | ||
vi.mocked(useFeatureAvailability).mockImplementationOnce( | ||
(features) => | ||
({ | ||
data: { | ||
...Object.fromEntries(features.map((feature) => [feature, false])), | ||
[FEATURE_REGION_1AZ]: true, | ||
}, | ||
isLoading: false, | ||
} as UseFeatureAvailabilityResult), | ||
); | ||
|
||
const { result } = renderHook(() => useIs1AZ()); | ||
expect(result.current).toBe(true); | ||
}); | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/manager/modules/manager-pci-common/src/hooks/useIs1AZ/useIs1AZ.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { useFeatureAvailability } from '@ovh-ux/manager-react-components'; | ||
|
||
export const FEATURE_REGION_1AZ = 'public-cloud:region-1AZ'; | ||
|
||
export const useIs1AZ = () => { | ||
const { data } = useFeatureAvailability([FEATURE_REGION_1AZ]); | ||
|
||
return data?.[FEATURE_REGION_1AZ] || false; | ||
}; |