-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/pci kubernetes show etcd 3 tapc 23 #14143
Merged
anooparveti
merged 14 commits into
release/public-cloud-w48
from
feat/pci-kubernetes_show-etcd-3_tapc-23
Nov 22, 2024
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
2bcf5d3
fix(i18n): add missing translations [CDS 3343]
ovh-ux-cds a3cd471
feat(pci.kubernetes): init etcd component
440cc2d
feat(pci.kubernetes): add cluster ETCD component and tests
6352186
feat(pci.kubernetes): add tile and sonar fix
687ad73
feat(pci.kubernetes): fix build
3113620
feat(pci.kubernetes): pr review 1
34276e6
feat(pci.kubernetes): use query instead of suspense
43b3ed2
feat(pci.kubernetes): delete react boundary
172ef16
feat(pci.kubernetes): delete useless dependancy
352964c
feat(pci.kubernetes): fix product review
8361389
feat(pci.kubernetes): delete uselesss shcem
3a109be
fix(i18n): add missing translations [CDS 132]
5988e72
feat(pci.kubernetes): fix translation
5def5b3
feat(pci.kubernetes): fix 100 case
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
30 changes: 30 additions & 0 deletions
30
packages/manager/apps/pci-kubernetes/src/components/input/PopoverTrigger.component.tsx
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,30 @@ | ||
import { | ||
ODS_ICON_NAME, | ||
ODS_ICON_SIZE, | ||
ODS_TEXT_COLOR_INTENT, | ||
ODS_TEXT_LEVEL, | ||
ODS_TEXT_SIZE, | ||
} from '@ovhcloud/ods-components'; | ||
import { OsdsText, OsdsIcon } from '@ovhcloud/ods-components/react'; | ||
|
||
const PopoverTrigger = ({ title }: { title: string }) => ( | ||
<span slot="popover-trigger"> | ||
<OsdsText | ||
className="mb-4" | ||
size={ODS_TEXT_SIZE._200} | ||
level={ODS_TEXT_LEVEL.heading} | ||
color={ODS_TEXT_COLOR_INTENT.text} | ||
onClick={(event) => event.stopPropagation()} | ||
> | ||
{title} | ||
</OsdsText> | ||
<OsdsIcon | ||
name={ODS_ICON_NAME.HELP} | ||
size={ODS_ICON_SIZE.xs} | ||
className="ml-4 cursor-help" | ||
color={ODS_TEXT_COLOR_INTENT.primary} | ||
/> | ||
</span> | ||
); | ||
|
||
export default PopoverTrigger; |
95 changes: 95 additions & 0 deletions
95
packages/manager/apps/pci-kubernetes/src/components/service/ClusterETCD.component.spec.tsx
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,95 @@ | ||
import { render, waitFor } from '@testing-library/react'; | ||
import * as manager from '@ovh-ux/manager-react-components'; | ||
import { vi } from 'vitest'; | ||
import { UseQueryResult } from '@tanstack/react-query'; | ||
import ClusterEtcd from './ClusterETCD.component'; | ||
import { wrapper } from '@/wrapperRenders'; | ||
import * as useKubernetesModule from '@/api/hooks/useKubernetes'; | ||
import { getColorByPercentage } from '@/helpers'; | ||
|
||
describe('ClusterEtcd', () => { | ||
it('renders progress bar and usage text correctly', async () => { | ||
const mockUsage = 500; | ||
const mockQuota = 1000; | ||
const mockPercentage = (mockUsage / mockQuota) * 100; | ||
|
||
vi.spyOn(useKubernetesModule, 'useGetClusterEtcdUsage').mockReturnValue(({ | ||
data: { usage: mockUsage, quota: mockQuota }, | ||
isPending: false, | ||
} as unknown) as UseQueryResult<{ usage: number; quota: number }>); | ||
|
||
const { getByText, container } = render(<ClusterEtcd />, { wrapper }); | ||
|
||
await waitFor(() => { | ||
const progressBar = container.querySelector('osds-progress-bar'); | ||
const progressBarColor = getColorByPercentage(mockPercentage); | ||
|
||
expect(progressBar).toBeInTheDocument(); | ||
expect(progressBar?.getAttribute('color')).toBe(progressBarColor); | ||
expect(progressBar?.getAttribute('value')).toBe( | ||
mockPercentage.toString(), | ||
); | ||
expect( | ||
getByText('500 unit_size_B / 1000 unit_size_B'), | ||
).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
it('applies correct styles based on progress percentage', async () => { | ||
const mockUsage = 700; | ||
const mockQuota = 1000; | ||
const mockPercentage = (mockUsage / mockQuota) * 100; | ||
|
||
vi.spyOn(useKubernetesModule, 'useGetClusterEtcdUsage').mockReturnValue(({ | ||
data: { usage: mockUsage, quota: mockQuota }, | ||
isPending: false, | ||
} as unknown) as UseQueryResult<{ usage: number; quota: number }>); | ||
|
||
const { container } = render(<ClusterEtcd />, { wrapper }); | ||
|
||
await waitFor(() => { | ||
const progressBar = container.querySelector('osds-progress-bar'); | ||
const progressBarStyle = getColorByPercentage(mockPercentage); | ||
|
||
expect(progressBar).toBeInTheDocument(); | ||
expect(progressBar).toHaveProperty('color', progressBarStyle); | ||
}); | ||
}); | ||
|
||
it('renders correct usage and quota information', async () => { | ||
const mockUsage = 300; | ||
const mockQuota = 600; | ||
|
||
vi.spyOn(useKubernetesModule, 'useGetClusterEtcdUsage').mockReturnValue(({ | ||
data: { usage: mockUsage, quota: mockQuota }, | ||
isPending: false, | ||
} as unknown) as UseQueryResult<{ usage: number; quota: number }>); | ||
|
||
const { getByText } = render(<ClusterEtcd />, { wrapper }); | ||
|
||
await waitFor(() => { | ||
expect( | ||
getByText('300 unit_size_B / 600 unit_size_B'), | ||
).toBeInTheDocument(); | ||
}); | ||
}); | ||
it('should call addError only once when percentage is over 80%', async () => { | ||
const mockUsage = 550; | ||
const mockQuota = 600; | ||
const addWarning = vi.fn(); | ||
vi.spyOn(manager, 'useNotifications').mockReturnValue({ | ||
addWarning, | ||
}); | ||
|
||
// Mock useGetClusterEtcdUsage to return usage leading to percentage > 80% | ||
vi.spyOn(useKubernetesModule, 'useGetClusterEtcdUsage').mockReturnValue(({ | ||
data: { usage: mockUsage, quota: mockQuota }, | ||
isPending: false, | ||
} as unknown) as UseQueryResult<{ usage: number; quota: number }>); | ||
|
||
// Render the component | ||
render(<ClusterEtcd />); | ||
await waitFor(() => expect(addWarning).toHaveBeenCalledTimes(1)); | ||
// Check that addWarning is called only once | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.