diff --git a/packages/manager-react-components/src/hooks/services/services.type.ts b/packages/manager-react-components/src/hooks/services/services.type.ts index 9b3f00f70a03..adc33a345a1f 100644 --- a/packages/manager-react-components/src/hooks/services/services.type.ts +++ b/packages/manager-react-components/src/hooks/services/services.type.ts @@ -55,6 +55,21 @@ export type ResourceStatus = | 'toDelete' | 'toSuspend'; +export type Renew = { + current: CurrentRenew; + capacities: RenewCapacities; +}; + +export type CurrentRenew = { + mode: RenewMode | null; + nextDate: string | null; + period: string; +}; + +export type RenewCapacities = { + mode: RenewMode[]; +}; + export type ServiceDetails = { billing: { engagement: { @@ -115,15 +130,9 @@ export type ServiceDetails = { pricingMode: string; pricingType: PricingType; }; + renew?: Renew; }; - renew: { - capacities: { mode: RenewMode[] }; - current: { - mode: RenewMode | null; - nextDate: string | null; - period: string; - }; - }; + renew?: Renew; customer: { contacts: CustomerContact[]; }; diff --git a/packages/manager/apps/hycu/.gitignore b/packages/manager/apps/hycu/.gitignore index e06831cfdeb4..0b4d91f6ad34 100644 --- a/packages/manager/apps/hycu/.gitignore +++ b/packages/manager/apps/hycu/.gitignore @@ -1,2 +1,3 @@ e2e/reports e2e/coverage +coverage diff --git a/packages/manager/apps/hycu/package.json b/packages/manager/apps/hycu/package.json index 6c027e737c9e..cdc635374f38 100644 --- a/packages/manager/apps/hycu/package.json +++ b/packages/manager/apps/hycu/package.json @@ -16,7 +16,8 @@ "start": "lerna exec --stream --scope='@ovh-ux/manager-hycu-app' --include-dependencies -- npm run build --if-present", "start:dev": "lerna exec --stream --scope='@ovh-ux/manager-hycu-app' --include-dependencies -- npm run dev --if-present", "start:watch": "lerna exec --stream --parallel --scope='@ovh-ux/manager-hycu-app' --include-dependencies -- npm run dev:watch --if-present", - "test": "vitest run" + "test": "vitest run", + "test:coverage": "vitest run --coverage" }, "dependencies": { "@ovh-ux/manager-config": "*", @@ -46,17 +47,20 @@ "devDependencies": { "@cucumber/cucumber": "^10.3.1", "@ovh-ux/manager-vite-config": "*", + "@ovh-ux/url-builder": "^1.2.0", "@testing-library/jest-dom": "^6.5.0", "@testing-library/react": "^16.0.1", + "@testing-library/react-hooks": "^8.0.1", "@testing-library/user-event": "^14.5.2", "@types/jest": "^29.5.13", "@vitejs/plugin-react": "^4.3.2", + "@vitest/coverage-v8": "^2.1.3", "element-internals-polyfill": "^1.3.12", "eslint-plugin-prettier": "^5.2.1", "msw": "2.1.7", "typescript": "^5.1.6", "vite": "^5.2.13", - "vitest": "^2.1.2" + "vitest": "^2.1.3" }, "regions": [ "CA", diff --git a/packages/manager/apps/hycu/public/translations/dashboard/Messages_fr_FR.json b/packages/manager/apps/hycu/public/translations/dashboard/Messages_fr_FR.json deleted file mode 100644 index f42a27b3366a..000000000000 --- a/packages/manager/apps/hycu/public/translations/dashboard/Messages_fr_FR.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "title": "Dashboard page", - "error_service": "No services info", - "general_informations": "Informations générales", - "tab2": "Tab 2", - "back_link": "Retour à la liste" -} diff --git a/packages/manager/apps/hycu/public/translations/hycu/Messages_fr_FR.json b/packages/manager/apps/hycu/public/translations/hycu/Messages_fr_FR.json index 36d8b913e6d9..a9a3a8b8dee5 100644 --- a/packages/manager/apps/hycu/public/translations/hycu/Messages_fr_FR.json +++ b/packages/manager/apps/hycu/public/translations/hycu/Messages_fr_FR.json @@ -2,5 +2,9 @@ "hycu_crumb": "HYCU", "tabs_2": "Tabs 2", "hycu_description": "Simplifiez vos sauvegardes, plans de reprise après sinistre et migrations de votre infrastructure Nutanix. Ce service vous propose différents packs de licences HYCU Hybrid Cloud pour protéger vos charges de travail Nutanix.", - "hycu_cloud_vm_pack_unknown": "Pack inconnu" + "hycu_cloud_vm_pack_unknown": "Pack inconnu", + "hycu_status_activated": "Active", + "hycu_status_toActivate": "À activer", + "hycu_status_pending": "En cours d'activation", + "hycu_status_error": "Erreur d'activation" } diff --git a/packages/manager/apps/hycu/public/translations/hycu/dashboard/Messages_fr_FR.json b/packages/manager/apps/hycu/public/translations/hycu/dashboard/Messages_fr_FR.json new file mode 100644 index 000000000000..4f6227f18791 --- /dev/null +++ b/packages/manager/apps/hycu/public/translations/hycu/dashboard/Messages_fr_FR.json @@ -0,0 +1,25 @@ +{ + "hycu_dashboard_generals_informations_title": "Informations générales", + "hycu_dashboard_label_name": "Nom", + "hycu_dashboard_label_status": "Statut", + "hycu_dashboard_label_pack_type": "Type de pack", + "hycu_dashboard_label_controller_id": "Controller ID", + "hycu_dashboard_label_license_key": "Clé de licence", + "hycu_dashboard_shortcuts_title": "Raccourcis", + "hycu_dashboard_link_activate": "Activer la licence", + "hycu_dashboard_link_reactivate": "Regénérer la licence", + "hycu_dashboard_link_terminated": "Résilier la licence", + "hycu_dashboard_link_change_pack_type": "Modifier le type de pack", + "hycu_dashboard_field_label_contacts": "Contacts", + "hycu_dashboard_contact_type_administrator": "Administrateur", + "hycu_dashboard_contact_type_technical": "Technique", + "hycu_dashboard_contact_type_billing": "Facturation", + "hycu_dashboard_action_billing_terminate": "Résilier", + "hycu_dashboard_field_label_manage_contacts": "Gérer les contacts", + "hycu_dashboard_label_renew": "Renouvellement automatique", + "hycu_dashboard_subscription_title": "Abonnement", + "hycu_dashboard_field_label_date_creation": "Date de création", + "hycu_dashboard_download_license_file": "Télécharger la license", + "hycu_dashboard_back_link": "Retour à la liste", + "hycu_dashboard_wait_for_activation": "En attente d'activation" +} diff --git a/packages/manager/apps/hycu/public/translations/hycu/listing/Messages_fr_FR.json b/packages/manager/apps/hycu/public/translations/hycu/listing/Messages_fr_FR.json index ea668aab4db9..0a8af73eb2b5 100644 --- a/packages/manager/apps/hycu/public/translations/hycu/listing/Messages_fr_FR.json +++ b/packages/manager/apps/hycu/public/translations/hycu/listing/Messages_fr_FR.json @@ -1,8 +1,4 @@ { - "hycu_status_activated": "Active", - "hycu_status_toActivate": "À activer", - "hycu_status_pending": "En cours d'activation", - "hycu_status_error": "Erreur d'activation", "hycu_cloud_vm_pack_unknown": "Pack inconnu", "hycu_name": "Nom", "hycu_controller_id": "Controller ID", diff --git a/packages/manager/apps/hycu/src/components/Loading/Loading.component.tsx b/packages/manager/apps/hycu/src/components/Loading/Loading.component.tsx index bb74a4fa8e15..8623d319f92b 100644 --- a/packages/manager/apps/hycu/src/components/Loading/Loading.component.tsx +++ b/packages/manager/apps/hycu/src/components/Loading/Loading.component.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { OsdsSpinner } from '@ovhcloud/ods-components/react'; +/* v8 ignore start */ export default function Loading() { return (
diff --git a/packages/manager/apps/hycu/src/data/api/hycu.ts b/packages/manager/apps/hycu/src/data/api/hycu.ts index 7068dc242d81..b7ebf0617df5 100644 --- a/packages/manager/apps/hycu/src/data/api/hycu.ts +++ b/packages/manager/apps/hycu/src/data/api/hycu.ts @@ -1,8 +1,10 @@ +import { AxiosResponse } from 'axios'; import { fetchIcebergV6, apiClient } from '@ovh-ux/manager-core-api'; +import { IHycuDetails } from '@/type/hycu.details.interface'; export type GetlicenseHycuListParams = { /** Filter resources on IAM tags */ - iamTags: any; + iamTags: string; }; export const getlicenseHycuListQueryKey = ['get/license/hycu']; @@ -10,7 +12,7 @@ export const getlicenseHycuListQueryKey = ['get/license/hycu']; /** * Manage HYCU licenses : Get list of owned HYCU licenses */ -export const getlicenseHycuList = async ( +export const getlicenseHycuList = ( params: GetlicenseHycuListParams, ): Promise => apiClient.v6.get('/license/hycu', { data: params }); @@ -19,16 +21,13 @@ export type GetlicenseHycuServiceParams = { serviceName?: string; }; -export const getlicenseHycuServiceQueryKey = ( - params: GetlicenseHycuServiceParams, -) => [`get/license/hycu/${params.serviceName}`]; - /** * Manage HYCU licenses : Get HYCU license info */ -export const getlicenseHycuService = async ( +export const getlicenseHycuService = ( params: GetlicenseHycuServiceParams, -): Promise => apiClient.v6.get(`/license/hycu/${params.serviceName}`); +): Promise> => + apiClient.v6.get(`/license/hycu/${params.serviceName}`); /** * Get listing with iceberg V6 diff --git a/packages/manager/apps/hycu/src/hooks/api/license.ts b/packages/manager/apps/hycu/src/hooks/api/license.ts new file mode 100644 index 000000000000..3c7854b22c14 --- /dev/null +++ b/packages/manager/apps/hycu/src/hooks/api/license.ts @@ -0,0 +1,15 @@ +import { AxiosResponse } from 'axios'; +import { DefinedInitialDataOptions, useQuery } from '@tanstack/react-query'; +import { getlicenseHycuService } from '@/data/api/hycu'; +import { IHycuDetails } from '@/type/hycu.details.interface'; + +export const useDetailsLicenseHYCU = ( + serviceName: string, + options?: DefinedInitialDataOptions>, +) => { + return useQuery({ + queryKey: ['license/hycu', 'get', serviceName], + queryFn: () => getlicenseHycuService({ serviceName }), + ...(options ?? {}), + }); +}; diff --git a/packages/manager/apps/hycu/src/hooks/shell/useNavigationGetUrl.spec.tsx b/packages/manager/apps/hycu/src/hooks/shell/useNavigationGetUrl.spec.tsx new file mode 100644 index 000000000000..8d17bd356869 --- /dev/null +++ b/packages/manager/apps/hycu/src/hooks/shell/useNavigationGetUrl.spec.tsx @@ -0,0 +1,44 @@ +import { ShellContext } from '@ovh-ux/manager-react-shell-client'; +import { vitest } from 'vitest'; +import { ParamValueType } from '@ovh-ux/url-builder'; +import React, { PropsWithChildren, useState } from 'react'; +import { renderHook, waitFor } from '@testing-library/react'; +import { QueryClient, QueryClientProvider } from '@tanstack/react-query'; +import { useNavigationGetUrl } from './useNavigationGetUrl'; + +const mockGetURL = vitest.fn(); + +const Wrapper = ({ children }: PropsWithChildren) => { + const [queryClient] = useState(new QueryClient()); + const [mockContextValue] = useState({ + shell: { navigation: { getURL: mockGetURL } }, + }); + return ( + + {children} + + ); +}; + +describe('useNavigationGetUrl', () => { + it('should call navigation.getURL with correct linkParams', async () => { + const linkParams: [string, string, Record] = [ + 'param1', + 'param2', + { key: 'value' }, + ]; + mockGetURL.mockResolvedValue('mockedUrl'); + + const { result } = renderHook( + () => useNavigationGetUrl(linkParams, { retry: false }), + { + wrapper: Wrapper, + }, + ); + + await waitFor(() => result.current.isSuccess); + + await waitFor(() => expect(mockGetURL).toHaveBeenCalledWith(...linkParams)); + expect(result.current.data).toBe('mockedUrl'); + }); +}); diff --git a/packages/manager/apps/hycu/src/hooks/shell/useNavigationGetUrl.ts b/packages/manager/apps/hycu/src/hooks/shell/useNavigationGetUrl.ts new file mode 100644 index 000000000000..77cf71a49b0e --- /dev/null +++ b/packages/manager/apps/hycu/src/hooks/shell/useNavigationGetUrl.ts @@ -0,0 +1,21 @@ +import { ParamValueType } from '@ovh-ux/url-builder'; +import { ShellContext } from '@ovh-ux/manager-react-shell-client'; +import { DefinedInitialDataOptions, useQuery } from '@tanstack/react-query'; +import { useContext } from 'react'; + +export const useNavigationGetUrl = ( + linkParams: [string, string, Record], + options?: Partial>, +) => { + const { + shell: { navigation }, + } = useContext(ShellContext); + + return useQuery({ + queryKey: ['shell', 'getUrl', linkParams], + queryFn: () => navigation.getURL(...linkParams), + refetchOnReconnect: false, + refetchOnWindowFocus: false, + ...(options ?? {}), + }); +}; diff --git a/packages/manager/apps/hycu/src/mocks/index.ts b/packages/manager/apps/hycu/src/mocks/index.ts index 202f88045626..1d92b2f2ffea 100644 --- a/packages/manager/apps/hycu/src/mocks/index.ts +++ b/packages/manager/apps/hycu/src/mocks/index.ts @@ -1 +1,2 @@ export * from './licenseHycu/licenseHycu'; +export * from './serviceLicenseHycu/serviceLicenseHycu'; diff --git a/packages/manager/apps/hycu/src/mocks/licenseHycu/licenseHycu.data.ts b/packages/manager/apps/hycu/src/mocks/licenseHycu/licenseHycu.data.ts index 260accd6ab47..998a3e14e3fb 100644 --- a/packages/manager/apps/hycu/src/mocks/licenseHycu/licenseHycu.data.ts +++ b/packages/manager/apps/hycu/src/mocks/licenseHycu/licenseHycu.data.ts @@ -21,7 +21,7 @@ export const licensesHycu: IHycuDetails[] = [ }, comment: '', serviceName: 'c1b7cb4f-6b63-45da-9a8a-f731f1a67b2c', - controllerId: '', + controllerId: 'test-id', licenseStatus: LicenseStatus.ACTIVATED, expirationDate: '0001-01-01T00:00:00Z', }, diff --git a/packages/manager/apps/hycu/src/mocks/licenseHycu/licenseHycu.ts b/packages/manager/apps/hycu/src/mocks/licenseHycu/licenseHycu.ts index 664d5fb4e95f..9d12981a842b 100644 --- a/packages/manager/apps/hycu/src/mocks/licenseHycu/licenseHycu.ts +++ b/packages/manager/apps/hycu/src/mocks/licenseHycu/licenseHycu.ts @@ -1,14 +1,17 @@ +import { LicenseStatus } from '@/type/hycu.details.interface'; import { Handler } from '../../../../../../../playwright-helpers'; import { licensesHycu } from './licenseHycu.data'; export type GetLicenseHycuMocksParams = { isGetLicenseHycuKo?: boolean; nbLicenseHycu?: number; + licenseStatus?: LicenseStatus; }; export const getLicenseHycuMocks = ({ isGetLicenseHycuKo, nbLicenseHycu = Number.POSITIVE_INFINITY, + licenseStatus = LicenseStatus.TO_ACTIVATE, }: GetLicenseHycuMocksParams): Handler[] => { return [ { @@ -17,7 +20,24 @@ export const getLicenseHycuMocks = ({ ? { message: 'Backup error', } - : licensesHycu.slice(0, nbLicenseHycu), + : licensesHycu + .slice(0, nbLicenseHycu) + .map((license) => ({ ...license, licenseStatus })), + status: isGetLicenseHycuKo ? 500 : 200, + api: 'v6', + }, + { + url: 'license/hycu/:serviceName', + response: isGetLicenseHycuKo + ? { + message: 'Backup error', + } + : { + ...licensesHycu[0], + licenseStatus, + controllerId: + licenseStatus !== LicenseStatus.TO_ACTIVATE ? 'test-id' : '', + }, status: isGetLicenseHycuKo ? 500 : 200, api: 'v6', }, diff --git a/packages/manager/apps/hycu/src/mocks/serviceLicenseHycu/serviceLicenseHycu.data.ts b/packages/manager/apps/hycu/src/mocks/serviceLicenseHycu/serviceLicenseHycu.data.ts new file mode 100644 index 000000000000..40aa4f70141d --- /dev/null +++ b/packages/manager/apps/hycu/src/mocks/serviceLicenseHycu/serviceLicenseHycu.data.ts @@ -0,0 +1,95 @@ +import { CurrencyCode, ServiceDetails } from '@ovh-ux/manager-react-components'; + +export const licensesHycuService: ServiceDetails = { + route: { + path: '/license/hycu/{serviceName}', + url: '/license/hycu/425802fa-fb70-4b2a-9d5b-ec4de86bb40c', + vars: [ + { + key: 'serviceName', + value: '425802fa-fb70-4b2a-9d5b-ec4de86bb40c', + }, + ], + }, + billing: { + nextBillingDate: '2024-11-03T15:24:23Z', + expirationDate: '2024-11-03T15:24:23Z', + plan: { + code: 'hycu-vms-pack-25', + invoiceName: 'HYCU Hybrid Cloud - 25 VMs', + }, + pricing: { + capacities: 'renew', + description: 'rental for 1 month', + interval: 1, + duration: 'P1M', + minimumQuantity: 1, + maximumQuantity: null, + minimumRepeat: 1, + maximumRepeat: null, + price: { + currencyCode: CurrencyCode.EUR, + text: '157.50 €', + value: 157.5, + priceInUcents: 0, + }, + priceInUcents: 15750000000, + pricingMode: 'default', + pricingType: 'rental', + engagementConfiguration: null, + }, + group: null, + lifecycle: { + current: { + pendingActions: [], + terminationDate: null, + creationDate: '2024-10-03T15:24:23Z', + state: 'active', + }, + capacities: { + actions: ['earlyRenewal', 'terminateAtExpirationDate'], + }, + }, + renew: { + current: { + mode: 'automatic', + nextDate: '2024-11-03T15:24:23Z', + period: 'P1M', + }, + capacities: { + mode: ['automatic', 'manual'], + }, + }, + engagement: null, + engagementRequest: null, + }, + resource: { + displayName: '425802fa-fb70-4b2a-9d5b-ec4de86bb40c', + name: '425802fa-fb70-4b2a-9d5b-ec4de86bb40c', + state: 'active', + product: { + name: 'hycu-cloud-vm-pack-25', + description: 'HYCU Hybrid Cloud - 25 VMs', + }, + resellingProvider: null, + }, + serviceId: 128622602, + parentServiceId: null, + customer: { + contacts: [ + { + customerCode: 'ls148374-ovh', + type: 'administrator', + }, + { + customerCode: 'ls148374-ovh', + type: 'technical', + }, + { + customerCode: 'ls148374-ovh', + type: 'billing', + }, + ], + }, + tags: [], +}; diff --git a/packages/manager/apps/hycu/src/mocks/serviceLicenseHycu/serviceLicenseHycu.ts b/packages/manager/apps/hycu/src/mocks/serviceLicenseHycu/serviceLicenseHycu.ts new file mode 100644 index 000000000000..8168d84c5468 --- /dev/null +++ b/packages/manager/apps/hycu/src/mocks/serviceLicenseHycu/serviceLicenseHycu.ts @@ -0,0 +1,25 @@ +import { LicenseStatus } from '@/type/hycu.details.interface'; +import { Handler } from '../../../../../../../playwright-helpers'; +import { licensesHycuService } from './serviceLicenseHycu.data'; + +export type GetServiceLicenseHycuMocksParams = { + isGetServiceLicenseHycuKo?: boolean; + licenseStatus?: LicenseStatus; +}; + +export const getServiceLicenseHycuMocks = ({ + isGetServiceLicenseHycuKo, +}: GetServiceLicenseHycuMocksParams): Handler[] => { + return [ + { + url: 'services/:id', + response: isGetServiceLicenseHycuKo + ? { + message: 'Backup error', + } + : licensesHycuService, + status: isGetServiceLicenseHycuKo ? 500 : 200, + api: 'v6', + }, + ]; +}; diff --git a/packages/manager/apps/hycu/src/pages/dashboard/Dashboard.page.spec.tsx b/packages/manager/apps/hycu/src/pages/dashboard/Dashboard.page.spec.tsx new file mode 100644 index 000000000000..5bab4a2ccd8d --- /dev/null +++ b/packages/manager/apps/hycu/src/pages/dashboard/Dashboard.page.spec.tsx @@ -0,0 +1,31 @@ +import { screen, waitFor } from '@testing-library/react'; +import { renderTestApp } from '@/utils/tests/renderTestApp'; +import '@testing-library/jest-dom'; + +describe('License Hycu Dashboard route test suite', () => { + it('should show informations of services', async () => { + await renderTestApp('/fake-id'); + + await waitFor( + () => + expect( + screen.getAllByText('425802fa-fb70-4b2a-9d5b-ec4de86bb40c')[0], + ).toBeVisible(), + { timeout: 30_000 }, + ); + + expect(screen.queryByAltText('OOPS')).not.toBeInTheDocument(); + }); + + it('should show error if api services fail', async () => { + await renderTestApp('/fake-id', { + getServicesKo: true, + isGetLicenseHycuKo: true, + isGetServiceLicenseHycuKo: true, + }); + + await waitFor(() => expect(screen.getByAltText('OOPS')).toBeVisible(), { + timeout: 30_000, + }); + }); +}); diff --git a/packages/manager/apps/hycu/src/pages/dashboard/Dashboard.page.tsx b/packages/manager/apps/hycu/src/pages/dashboard/Dashboard.page.tsx index 665a301e9a95..4f718e86902f 100644 --- a/packages/manager/apps/hycu/src/pages/dashboard/Dashboard.page.tsx +++ b/packages/manager/apps/hycu/src/pages/dashboard/Dashboard.page.tsx @@ -5,8 +5,8 @@ import { NavLink, useLocation, useNavigate, - useParams, useResolvedPath, + useParams, } from 'react-router-dom'; import { OsdsTabs, @@ -14,9 +14,14 @@ import { OsdsTabBarItem, } from '@ovhcloud/ods-components/react'; -import { BaseLayout } from '@ovh-ux/manager-react-components'; +import { + BaseLayout, + useServiceDetails, +} from '@ovh-ux/manager-react-components'; import Breadcrumb from '@/components/Breadcrumb/Breadcrumb.component'; +import Errors from '@/components/Error/Error'; +import { urls } from '@/routes/routes.constant'; export type DashboardTabItemProps = { name: string; @@ -29,22 +34,22 @@ export type DashboardLayoutProps = { }; export default function DashboardPage() { + const { serviceName } = useParams(); const [panel, setActivePanel] = useState(''); const location = useLocation(); const navigate = useNavigate(); - const { t } = useTranslation('dashboard'); + const { t } = useTranslation('hycu/dashboard'); + + const { data: serviceDetails, error } = useServiceDetails({ + resourceName: serviceName, + }); const tabsList = [ { name: 'general_informations', - title: 'Informations générales', + title: t('hycu_dashboard_generals_informations_title'), to: useResolvedPath('').pathname, }, - { - name: 'Tab 2', - title: 'Tab 2', - to: useResolvedPath('Tab2').pathname, - }, ] as const; useEffect(() => { @@ -58,14 +63,26 @@ export default function DashboardPage() { }, [location.pathname]); const header = { - title: t('title'), + title: serviceDetails?.data.resource.displayName, + description: serviceName, }; + if (error) { + return ( + } header={header}> + + + ); + } + return ( } header={header} - description="Description du hycu" + backLinkLabel={t('hycu_dashboard_back_link')} + onClickReturn={() => { + navigate(urls.listing); + }} tabs={ diff --git a/packages/manager/apps/hycu/src/pages/dashboard/general-information/BillingInformations/BillingInformationsTile.spec.tsx b/packages/manager/apps/hycu/src/pages/dashboard/general-information/BillingInformations/BillingInformationsTile.spec.tsx new file mode 100644 index 000000000000..b5562fb9a1ac --- /dev/null +++ b/packages/manager/apps/hycu/src/pages/dashboard/general-information/BillingInformations/BillingInformationsTile.spec.tsx @@ -0,0 +1,32 @@ +import { screen, waitFor } from '@testing-library/react'; +import { renderTestApp } from '@/utils/tests/renderTestApp'; +import '@testing-library/jest-dom'; +import { labels } from '@/utils/tests/init.i18n'; + +describe('License Hycu billing information tile for dashboard test suite', () => { + it('should show informations of services', async () => { + await renderTestApp('/fake-id'); + + await waitFor( + () => + expect( + screen.getAllByText( + labels.dashboard.hycu_dashboard_subscription_title, + )[0], + ).toBeVisible(), + { timeout: 30_000 }, + ); + + expect( + screen.getByText(labels.dashboard.hycu_dashboard_label_renew), + ).toBeVisible(); + expect( + screen.getByText(labels.dashboard.hycu_dashboard_field_label_contacts), + ).toBeVisible(); + expect( + screen.getByText( + labels.dashboard.hycu_dashboard_field_label_date_creation, + ), + ).toBeVisible(); + }); +}); diff --git a/packages/manager/apps/hycu/src/pages/dashboard/general-information/BillingInformations/BillingInformationsTile.tsx b/packages/manager/apps/hycu/src/pages/dashboard/general-information/BillingInformations/BillingInformationsTile.tsx new file mode 100644 index 000000000000..cef4561d3014 --- /dev/null +++ b/packages/manager/apps/hycu/src/pages/dashboard/general-information/BillingInformations/BillingInformationsTile.tsx @@ -0,0 +1,128 @@ +import { + DashboardTile, + DateFormat, + Description, + Renew, + useFormattedDate, + useServiceDetails, +} from '@ovh-ux/manager-react-components'; +import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; +import { ODS_ICON_NAME, ODS_ICON_SIZE } from '@ovhcloud/ods-components'; +import { + OsdsIcon, + OsdsLink, + OsdsSkeleton, +} from '@ovhcloud/ods-components/react'; +import React from 'react'; +import { useTranslation } from 'react-i18next'; +import { useNavigationGetUrl } from '@/hooks/shell/useNavigationGetUrl'; + +const BillingInformationsTile = ({ serviceName }: { serviceName: string }) => { + const { t } = useTranslation('hycu/dashboard'); + + const { data: serviceDetails, isLoading } = useServiceDetails({ + resourceName: serviceName, + }); + + const renewDate = useFormattedDate({ + dateString: (serviceDetails?.data.billing.renew as Renew)?.current.nextDate, + format: DateFormat.display, + }); + + const creationDate = useFormattedDate({ + dateString: serviceDetails?.data.billing.lifecycle.current.creationDate, + format: DateFormat.display, + }); + + const { + data: contactUrl, + isLoading: isContactUrlLoading, + } = useNavigationGetUrl([ + 'dedicated', + '#/contacts/services', + { serviceName }, + ]); + + return ( + + ) : ( + {renewDate} + ), + }, + { + id: 'contact', + label: t('hycu_dashboard_field_label_contacts'), + value: ( +
+
+ {isLoading + ? Array.from({ length: 3 }).map((_, index) => ( + + )) + : serviceDetails?.data.customer.contacts.map((contact) => ( + {`${ + contact.customerCode + } ${t( + `hycu_dashboard_contact_type_${contact.type}`, + )}`} + ))} +
+ +
+ + {t('hycu_dashboard_field_label_manage_contacts')} + + + + +
+
+ ), + }, + { + id: 'date_creation', + label: t('hycu_dashboard_field_label_date_creation'), + value: isLoading ? ( + + ) : ( + {creationDate} + ), + }, + { + id: 'link_terminated', + value: ( + + {t('hycu_dashboard_link_terminated')} + + + + + ), + }, + ]} + >
+ ); +}; + +export default BillingInformationsTile; diff --git a/packages/manager/apps/hycu/src/pages/dashboard/general-information/DashboardGeneralInformation.page.tsx b/packages/manager/apps/hycu/src/pages/dashboard/general-information/DashboardGeneralInformation.page.tsx index a785e6d2ff0f..09627a1c37c2 100644 --- a/packages/manager/apps/hycu/src/pages/dashboard/general-information/DashboardGeneralInformation.page.tsx +++ b/packages/manager/apps/hycu/src/pages/dashboard/general-information/DashboardGeneralInformation.page.tsx @@ -1,7 +1,25 @@ import React from 'react'; +import { useParams } from 'react-router-dom'; +import BillingInformationsTile from './BillingInformations/BillingInformationsTile'; +import GeneralInformationsTile from './GeneralInformationsTiles/GeneralInformationsTile'; +import ShortcutsTile from './ShortcutsTile/ShortcutsTile'; function GeneralInfos() { - return
Information Générales Tab
; + const { serviceName } = useParams(); + + return ( +
+
+ +
+
+ +
+
+ +
+
+ ); } export default GeneralInfos; diff --git a/packages/manager/apps/hycu/src/pages/dashboard/general-information/GeneralInformationsTiles/GeneralInformationsTile.spec.tsx b/packages/manager/apps/hycu/src/pages/dashboard/general-information/GeneralInformationsTiles/GeneralInformationsTile.spec.tsx new file mode 100644 index 000000000000..850d04f7e0f6 --- /dev/null +++ b/packages/manager/apps/hycu/src/pages/dashboard/general-information/GeneralInformationsTiles/GeneralInformationsTile.spec.tsx @@ -0,0 +1,99 @@ +import { screen, waitFor } from '@testing-library/react'; +import { renderTestApp } from '@/utils/tests/renderTestApp'; +import '@testing-library/jest-dom'; +import { labels } from '@/utils/tests/init.i18n'; +import { LicenseStatus } from '@/type/hycu.details.interface'; + +describe('License Hycu general informations tile for dashboard test suite', () => { + it('should show informations of services', async () => { + await renderTestApp('/fake-id'); + + await waitFor( + () => + expect( + screen.getAllByText( + labels.dashboard.hycu_dashboard_generals_informations_title, + )[1], + ).toBeVisible(), + { timeout: 30_000 }, + ); + + expect( + screen.getByText(labels.dashboard.hycu_dashboard_label_name), + ).toBeVisible(); + expect( + screen.getByText(labels.dashboard.hycu_dashboard_label_status), + ).toBeVisible(); + expect( + screen.getByText(labels.dashboard.hycu_dashboard_label_pack_type), + ).toBeVisible(); + expect( + screen.getByText(labels.dashboard.hycu_dashboard_label_controller_id), + ).toBeVisible(); + expect( + screen.getByText(labels.dashboard.hycu_dashboard_label_license_key), + ).toBeVisible(); + + expect( + screen.queryByText(labels.dashboard.hycu_dashboard_download_license_file), + ).not.toBeInTheDocument(); + }); + + it('should show download license button when license is activated', async () => { + await renderTestApp('/fake-id', { licenseStatus: LicenseStatus.ACTIVATED }); + + await waitFor( + () => + expect( + screen.getAllByText( + labels.dashboard.hycu_dashboard_generals_informations_title, + )[1], + ).toBeVisible(), + { timeout: 30_000 }, + ); + + await waitFor( + () => + expect( + screen.getByText( + labels.dashboard.hycu_dashboard_download_license_file, + ), + ).toBeVisible(), + { timeout: 30_000 }, + ); + + expect( + screen.queryByText(labels.dashboard.hycu_dashboard_wait_for_activation), + ).not.toBeInTheDocument(); + }); + + it('should show wait for activation if license is not activated', async () => { + await renderTestApp('/fake-id', { + licenseStatus: LicenseStatus.TO_ACTIVATE, + }); + + await waitFor( + () => + expect( + screen.getAllByText( + labels.dashboard.hycu_dashboard_generals_informations_title, + )[1], + ).toBeVisible(), + { timeout: 10_000 }, + ); + + await waitFor( + () => + expect( + screen.getAllByText( + labels.dashboard.hycu_dashboard_wait_for_activation, + )[0], + ).toBeVisible(), + { timeout: 10_000 }, + ); + + expect( + screen.queryByText(labels.dashboard.hycu_dashboard_download_license_file), + ).not.toBeInTheDocument(); + }); +}); diff --git a/packages/manager/apps/hycu/src/pages/dashboard/general-information/GeneralInformationsTiles/GeneralInformationsTile.tsx b/packages/manager/apps/hycu/src/pages/dashboard/general-information/GeneralInformationsTiles/GeneralInformationsTile.tsx new file mode 100644 index 000000000000..b453d3984efa --- /dev/null +++ b/packages/manager/apps/hycu/src/pages/dashboard/general-information/GeneralInformationsTiles/GeneralInformationsTile.tsx @@ -0,0 +1,150 @@ +import { + DashboardTile, + Description, + useServiceDetails, +} from '@ovh-ux/manager-react-components'; +import { + OsdsChip, + OsdsIcon, + OsdsButton, + OsdsSkeleton, + OsdsLink, +} from '@ovhcloud/ods-components/react'; +import { + ODS_BUTTON_SIZE, + ODS_BUTTON_VARIANT, + ODS_CHIP_SIZE, + ODS_ICON_NAME, + ODS_ICON_SIZE, +} from '@ovhcloud/ods-components'; + +import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; + +import React from 'react'; +import { useTranslation } from 'react-i18next'; +import { getStatusColor } from '@/utils/statusColor'; +import { useDetailsLicenseHYCU } from '@/hooks/api/license'; +import { LicenseStatus } from '@/type/hycu.details.interface'; + +const DownloadHycuLicense = ({ serviceName }: { serviceName: string }) => { + const { t } = useTranslation('hycu/dashboard'); + const { data: hycuDetail, isLoading } = useDetailsLicenseHYCU(serviceName); + + if (isLoading) return ; + if (LicenseStatus.ACTIVATED !== hycuDetail.data.licenseStatus) + return <>{t('hycu_dashboard_wait_for_activation')}; + return ( + + {t('hycu_dashboard_download_license_file')} + + + + + ); +}; + +const ControllerIdHycuLicense = ({ serviceName }: { serviceName: string }) => { + const { t } = useTranslation('hycu/dashboard'); + const { data: hycuDetail, isLoading } = useDetailsLicenseHYCU(serviceName); + + if (isLoading) return ; + if (!hycuDetail?.data.controllerId) + return <>{t('hycu_dashboard_wait_for_activation')}; + return {hycuDetail?.data.controllerId}; +}; + +const GeneralInformationsTile = ({ serviceName }: { serviceName: string }) => { + const { t: tCommon } = useTranslation('hycu'); + const { t } = useTranslation('hycu/dashboard'); + const { data: hycuDetail } = useDetailsLicenseHYCU(serviceName); + const { data: serviceDetails, isLoading } = useServiceDetails({ + resourceName: serviceName, + }); + + return ( + + ) : ( +
+ + {serviceDetails?.data.resource.displayName} + + + + + +
+ ), + }, + { + id: 'status', + label: t('hycu_dashboard_label_status'), + value: isLoading ? ( + + ) : ( + + {tCommon([ + `hycu_status_${hycuDetail?.data.licenseStatus}`, + 'hycu_status_error', + ])} + + ), + }, + { + id: 'pack_type', + label: t('hycu_dashboard_label_pack_type'), + value: isLoading ? ( + + ) : ( + + {serviceDetails?.data.resource.product.description} + + ), + }, + { + id: 'controller_id', + label: t('hycu_dashboard_label_controller_id'), + value: ControllerIdHycuLicense({ serviceName }), + }, + { + id: 'license_key', + label: t('hycu_dashboard_label_license_key'), + value: isLoading ? ( + + ) : ( + + ), + }, + ]} + >
+ ); +}; + +export default GeneralInformationsTile; diff --git a/packages/manager/apps/hycu/src/pages/dashboard/general-information/ShortcutsTile/ShortcutsTile.spec.tsx b/packages/manager/apps/hycu/src/pages/dashboard/general-information/ShortcutsTile/ShortcutsTile.spec.tsx new file mode 100644 index 000000000000..f28b5348f1be --- /dev/null +++ b/packages/manager/apps/hycu/src/pages/dashboard/general-information/ShortcutsTile/ShortcutsTile.spec.tsx @@ -0,0 +1,65 @@ +import '@testing-library/jest-dom'; +import { screen, waitFor } from '@testing-library/react'; +import { renderTestApp } from '@/utils/tests/renderTestApp'; +import { labels } from '@/utils/tests/init.i18n'; +import { LicenseStatus } from '@/type/hycu.details.interface'; + +describe('License Hycu shortcuts tile for dashboard test suite', () => { + it('should show links of service to activate', async () => { + await renderTestApp('/fake-id', { + licenseStatus: LicenseStatus.TO_ACTIVATE, + }); + + await waitFor( + () => + expect( + screen.getAllByText( + labels.dashboard.hycu_dashboard_shortcuts_title, + )[0], + ).toBeVisible(), + { timeout: 30_000 }, + ); + + await waitFor( + () => + expect( + screen.getByText(labels.dashboard.hycu_dashboard_link_activate), + ).toBeVisible(), + { timeout: 30_000 }, + ); + expect( + screen.queryByText(labels.dashboard.hycu_dashboard_link_change_pack_type), + ).not.toBeInTheDocument(); + }); + + it('should show links of services activated', async () => { + await renderTestApp('/fake-id', { licenseStatus: LicenseStatus.ACTIVATED }); + + await waitFor( + () => + expect( + screen.getAllByText( + labels.dashboard.hycu_dashboard_shortcuts_title, + )[0], + ).toBeVisible(), + { timeout: 30_000 }, + ); + + await waitFor( + () => + expect( + screen.getByText(labels.dashboard.hycu_dashboard_link_reactivate), + ).toBeVisible(), + { timeout: 20_000 }, + ); + await waitFor( + () => + expect( + screen.getByText( + labels.dashboard.hycu_dashboard_link_change_pack_type, + ), + ).toBeVisible(), + { timeout: 20_000 }, + ); + }); +}); diff --git a/packages/manager/apps/hycu/src/pages/dashboard/general-information/ShortcutsTile/ShortcutsTile.tsx b/packages/manager/apps/hycu/src/pages/dashboard/general-information/ShortcutsTile/ShortcutsTile.tsx new file mode 100644 index 000000000000..055cf9ee3029 --- /dev/null +++ b/packages/manager/apps/hycu/src/pages/dashboard/general-information/ShortcutsTile/ShortcutsTile.tsx @@ -0,0 +1,65 @@ +import { OsdsLink, OsdsIcon } from '@ovhcloud/ods-components/react'; +import { DashboardTile } from '@ovh-ux/manager-react-components'; + +import React from 'react'; +import { useTranslation } from 'react-i18next'; +import { ODS_ICON_NAME } from '@ovhcloud/ods-components'; +import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; +import { useDetailsLicenseHYCU } from '@/hooks/api/license'; +import { LicenseStatus } from '@/type/hycu.details.interface'; + +const ShortcutsItem = ({ + children, + ...rest +}: React.ComponentProps) => ( + +
+
{children}
+ +
+
+); + +const ShortcutsTile = ({ serviceName }: { serviceName: string }) => { + const { data: hycuDetail } = useDetailsLicenseHYCU(serviceName); + const { t } = useTranslation('hycu/dashboard'); + + const links = { + linkActivated: { + id: 'link_activated', + value: {t('hycu_dashboard_link_activate')}, + }, + linkReactivated: { + id: 'link_reactivated', + value: ( + {t('hycu_dashboard_link_reactivate')} + ), + }, + linkChangePackType: { + id: 'link_change_pack_type', + value: ( + + {t('hycu_dashboard_link_change_pack_type')} + + ), + }, + } as const; + + return ( + + ); +}; + +export default ShortcutsTile; diff --git a/packages/manager/apps/hycu/src/pages/dashboard/tab2/index.tsx b/packages/manager/apps/hycu/src/pages/dashboard/tab2/index.tsx deleted file mode 100644 index 9cb100623734..000000000000 --- a/packages/manager/apps/hycu/src/pages/dashboard/tab2/index.tsx +++ /dev/null @@ -1,7 +0,0 @@ -import React from 'react'; - -function Tab2() { - return
Tab 2
; -} - -export default Tab2; diff --git a/packages/manager/apps/hycu/src/pages/listing/Listing.page.tsx b/packages/manager/apps/hycu/src/pages/listing/Listing.page.tsx index 9d2f1c69b728..0028e304b05e 100644 --- a/packages/manager/apps/hycu/src/pages/listing/Listing.page.tsx +++ b/packages/manager/apps/hycu/src/pages/listing/Listing.page.tsx @@ -58,11 +58,11 @@ const DatagridIdCell = (hycuDetail: IHycuDetails) => { }; const DatagridControllerIdCell = (hycuDetail: IHycuDetails) => { - return {hycuDetail.controllerId}; + return {hycuDetail.controllerId || '-'}; }; const DatagridStatusCell = (hycuDetail: IHycuDetails) => { - const { t } = useTranslation('hycu/listing'); + const { t } = useTranslation('hycu'); return ( diff --git a/packages/manager/apps/hycu/src/pages/listing/Listing.spec.tsx b/packages/manager/apps/hycu/src/pages/listing/Listing.spec.tsx index 396747dc0831..fc4739d31029 100644 --- a/packages/manager/apps/hycu/src/pages/listing/Listing.spec.tsx +++ b/packages/manager/apps/hycu/src/pages/listing/Listing.spec.tsx @@ -8,7 +8,7 @@ import HYCU_CONFIG from '@/hycu.config'; describe('License Hycu listing test suite', () => { it('should redirect to the onboarding page when the license hycu list is empty', async () => { - await renderTestApp({ nbLicenseHycu: 0 }); + await renderTestApp('/', { nbLicenseHycu: 0 }); expect(screen.getByText(HYCU_CONFIG.rootLabel)).toBeVisible(); expect( @@ -40,7 +40,9 @@ describe('License Hycu listing test suite', () => { await waitFor( () => expect( - screen.getByText(labels.dashboard.general_informations), + screen.getAllByText( + labels.dashboard.hycu_dashboard_generals_informations_title, + )[0], ).toBeVisible(), { timeout: 30_000 }, ); diff --git a/packages/manager/apps/hycu/src/routes/routes.tsx b/packages/manager/apps/hycu/src/routes/routes.tsx index 0fa1bc776da3..28fafd148573 100644 --- a/packages/manager/apps/hycu/src/routes/routes.tsx +++ b/packages/manager/apps/hycu/src/routes/routes.tsx @@ -51,17 +51,6 @@ export const Routes: any = [ }, }, }, - { - id: 'dashboard.tab2', - path: 'Tab2', - ...lazyRouteConfig(() => import('@/pages/dashboard/tab2')), - handle: { - tracking: { - pageName: 'tab2', - pageType: PageType.dashboard, - }, - }, - }, ], }, { diff --git a/packages/manager/apps/hycu/src/utils/statusColor.ts b/packages/manager/apps/hycu/src/utils/statusColor.ts index 1aedb85a5ad8..75efb753736a 100644 --- a/packages/manager/apps/hycu/src/utils/statusColor.ts +++ b/packages/manager/apps/hycu/src/utils/statusColor.ts @@ -1,6 +1,7 @@ import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; import { LicenseStatus } from '@/type/hycu.details.interface'; +/* v8 ignore start */ export const getStatusColor = ( licenseStatus: LicenseStatus, ): ODS_THEME_COLOR_INTENT => { diff --git a/packages/manager/apps/hycu/src/utils/tests/TestApp.tsx b/packages/manager/apps/hycu/src/utils/tests/TestApp.tsx index b016f4d6ec24..0ec94df2580f 100644 --- a/packages/manager/apps/hycu/src/utils/tests/TestApp.tsx +++ b/packages/manager/apps/hycu/src/utils/tests/TestApp.tsx @@ -3,9 +3,9 @@ import { QueryClientProvider, QueryClient } from '@tanstack/react-query'; import { createMemoryRouter, RouterProvider } from 'react-router-dom'; import { Routes } from '../../routes/routes'; -export function TestApp() { +export function TestApp({ initialRoute = '/' }: { initialRoute: string }) { const router = createMemoryRouter(Routes, { - initialEntries: ['/'], + initialEntries: [initialRoute], initialIndex: 0, }); diff --git a/packages/manager/apps/hycu/src/utils/tests/init.i18n.ts b/packages/manager/apps/hycu/src/utils/tests/init.i18n.ts index 9af278be892c..6a1248a254ba 100644 --- a/packages/manager/apps/hycu/src/utils/tests/init.i18n.ts +++ b/packages/manager/apps/hycu/src/utils/tests/init.i18n.ts @@ -1,6 +1,7 @@ -import i18next, { i18n } from 'i18next'; +import i18next, { i18n, InitOptions } from 'i18next'; +import error from '@ovh-ux/manager-react-components/src/components/templates/error/translations/Messages_fr_FR.json'; import common from '../../../public/translations/hycu/Messages_fr_FR.json'; -import dashboard from '../../../public/translations/dashboard/Messages_fr_FR.json'; +import dashboard from '../../../public/translations/hycu/dashboard/Messages_fr_FR.json'; import listing from '../../../public/translations/hycu/listing/Messages_fr_FR.json'; import onboarding from '../../../public/translations/hycu/onboarding/Messages_fr_FR.json'; @@ -10,9 +11,10 @@ export const defaultAvailableLocales = [defaultLocale]; function addTranslations() { i18next .addResources(defaultLocale, 'hycu', common) - .addResources(defaultLocale, 'dashboard', dashboard) + .addResources(defaultLocale, 'hycu/dashboard', dashboard) .addResources(defaultLocale, 'hycu/listing', listing) .addResources(defaultLocale, 'hycu/onboarding', onboarding) + .addResources(defaultLocale, 'error', error) .use({ type: 'postProcessor', name: 'normalize', @@ -21,18 +23,20 @@ function addTranslations() { }); } +export const getTesti18nParams = (): InitOptions => ({ + lng: defaultLocale, + defaultNS: 'hycu', + ns: [], + supportedLngs: defaultAvailableLocales, + postProcess: 'normalize', + interpolation: { + escapeValue: false, + }, +}); + export const initTestI18n = () => new Promise((resolve) => { - i18next.init({ - lng: defaultLocale, - defaultNS: 'hycu', - ns: [], - supportedLngs: defaultAvailableLocales, - postProcess: 'normalize', - interpolation: { - escapeValue: false, - }, - }); + i18next.init(getTesti18nParams()); if (i18next.isInitialized) { addTranslations(); @@ -49,4 +53,5 @@ export const labels = { dashboard, listing, onboarding, + error, }; diff --git a/packages/manager/apps/hycu/src/utils/tests/renderTestApp.tsx b/packages/manager/apps/hycu/src/utils/tests/renderTestApp.tsx index fb0e6a88d311..fc96e1e3d01d 100644 --- a/packages/manager/apps/hycu/src/utils/tests/renderTestApp.tsx +++ b/packages/manager/apps/hycu/src/utils/tests/renderTestApp.tsx @@ -12,22 +12,33 @@ import { GetServicesMocksParams, } from '@ovh-ux/manager-react-components/src/hooks/services/mocks/services.mock'; import { TestApp } from './TestApp'; -import { initTestI18n } from './init.i18n'; +import { getTesti18nParams, initTestI18n } from './init.i18n'; import { toMswHandlers } from '../../../../../../../playwright-helpers'; import { getAuthenticationMocks } from '../../../../../../../playwright-helpers/mocks/auth'; -import { getLicenseHycuMocks, GetLicenseHycuMocksParams } from '@/mocks'; +import { + getLicenseHycuMocks, + GetLicenseHycuMocksParams, + getServiceLicenseHycuMocks, + GetServiceLicenseHycuMocksParams, +} from '@/mocks'; let context: ShellContextType; let i18nValue: i18n; export const renderTestApp = async ( - mockParams: GetServicesMocksParams & GetLicenseHycuMocksParams = {}, + initialRoute = '/', + mockParams: GetServicesMocksParams & + GetLicenseHycuMocksParams & + GetServicesMocksParams & + GetServicesMocksParams & + GetServiceLicenseHycuMocksParams = {}, ) => { global.server?.resetHandlers( ...toMswHandlers([ ...getAuthenticationMocks({ isAuthMocked: true }), - ...getServicesMocks(mockParams), ...getLicenseHycuMocks(mockParams), + ...getServiceLicenseHycuMocks(mockParams), + ...getServicesMocks(mockParams), ]), ); @@ -42,18 +53,20 @@ export const renderTestApp = async ( const result = render( - + , ); - await waitFor( - () => - expect( - screen.getAllByText('HYCU', { exact: false }).length, - ).toBeGreaterThan(0), - { timeout: 30000 }, - ); + if (!initialRoute || initialRoute === '/') { + await waitFor( + () => + expect( + screen.getAllByText('HYCU', { exact: false }).length, + ).toBeGreaterThan(0), + { timeout: 30000 }, + ); + } return result; }; diff --git a/packages/manager/apps/hycu/vitest.config.js b/packages/manager/apps/hycu/vitest.config.js index 5ad6ce3dccf7..9075895638be 100644 --- a/packages/manager/apps/hycu/vitest.config.js +++ b/packages/manager/apps/hycu/vitest.config.js @@ -10,8 +10,11 @@ export default defineConfig({ environment: 'jsdom', setupFiles: ['./src/setupTests.tsx'], coverage: { + provider: 'v8', + reporter: ['text'], include: ['src'], exclude: [ + 'src/mocks', 'src/App.tsx', 'src/index.tsx', 'src/tracking.constant.ts', diff --git a/yarn.lock b/yarn.lock index cc37038f8459..7107dfd05c12 100644 --- a/yarn.lock +++ b/yarn.lock @@ -938,6 +938,13 @@ resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.24.7.tgz#9a5226f92f0c5c8ead550b750f5608e766c8ce85" integrity sha512-9uUYRm6OqQrCqQdG1iCBwBPZgN8ciDBro2nIOFaiRz1/BCxaI7CNvQbDHvsArAC7Tw9Hda/B3U+6ui9u4HWXPw== +"@babel/parser@^7.25.4": + version "7.25.8" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.25.8.tgz#f6aaf38e80c36129460c1657c0762db584c9d5e2" + integrity sha512-HcttkxzdPucv3nNFmfOOMfFf64KgdJVqm1KaCm25dPGMLElo9nsLvXeJECQg8UzPuBGLyTSA0ZzqCtDSzKTEoQ== + dependencies: + "@babel/types" "^7.25.8" + "@babel/parser@^7.25.7": version "7.25.7" resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.25.7.tgz#99b927720f4ddbfeb8cd195a363ed4532f87c590" @@ -2086,6 +2093,15 @@ "@babel/helper-validator-identifier" "^7.24.7" to-fast-properties "^2.0.0" +"@babel/types@^7.25.4", "@babel/types@^7.25.8": + version "7.25.8" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.25.8.tgz#5cf6037258e8a9bcad533f4979025140cb9993e1" + integrity sha512-JWtuCu8VQsMladxVz/P4HzHUGCAwpuqacmowgXFs5XjxIgKuNjnLokQzuVjlTvIzODaDmpjT3oxcC48vyk9EWg== + dependencies: + "@babel/helper-string-parser" "^7.25.7" + "@babel/helper-validator-identifier" "^7.25.7" + to-fast-properties "^2.0.0" + "@babel/types@^7.25.7": version "7.25.7" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.25.7.tgz#1b7725c1d3a59f328cb700ce704c46371e6eef9b" @@ -8524,6 +8540,14 @@ lodash "^4.17.21" redent "^3.0.0" +"@testing-library/react-hooks@^8.0.1": + version "8.0.1" + resolved "https://registry.yarnpkg.com/@testing-library/react-hooks/-/react-hooks-8.0.1.tgz#0924bbd5b55e0c0c0502d1754657ada66947ca12" + integrity sha512-Aqhl2IVmLt8IovEVarNDFuJDVWVvhnr9/GCU6UUnrYXwgDFF9h2L2o2P9KBni1AST5sT6riAyoukFLyjQUgD/g== + dependencies: + "@babel/runtime" "^7.12.5" + react-error-boundary "^3.1.0" + "@testing-library/react@14.0.0": version "14.0.0" resolved "https://registry.yarnpkg.com/@testing-library/react/-/react-14.0.0.tgz#59030392a6792450b9ab8e67aea5f3cc18d6347c" @@ -9661,7 +9685,7 @@ strip-literal "^2.0.0" test-exclude "^6.0.0" -"@vitest/coverage-v8@^2.1.2": +"@vitest/coverage-v8@^2.1.3": version "2.1.3" resolved "https://registry.yarnpkg.com/@vitest/coverage-v8/-/coverage-v8-2.1.3.tgz#22d519e5e56385ec126305492f5a3cfe5b44b14d" integrity sha512-2OJ3c7UPoFSmBZwqD2VEkUw6A/tzPF0LmW0ZZhhB8PFxuc+9IBG/FaSM+RLEenc7ljzFvGN+G0nGQoZnh7sy2A== @@ -9824,7 +9848,7 @@ resolved "https://registry.yarnpkg.com/@vitest/spy/-/spy-1.3.1.tgz#814245d46d011b99edd1c7528f5725c64e85a88b" integrity sha512-xAcW+S099ylC9VLU7eZfdT9myV67Nor9w9zhf0mGCYJSO+zM2839tOeROTdikOi/8Qeusffvxb/MyBSOja1Uig== dependencies: - "@vitest/pretty-format" "2.1.2" + "@vitest/pretty-format" "2.1.3" magic-string "^0.30.11" pathe "^1.1.2" @@ -21052,7 +21076,7 @@ magic-string@^0.30.0, magic-string@^0.30.1, magic-string@^0.30.5, magic-string@^ dependencies: "@jridgewell/sourcemap-codec" "^1.4.15" -magic-string@^0.30.10, magic-string@^0.30.11: +magic-string@^0.30.10: version "0.30.11" resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.30.11.tgz#301a6f93b3e8c2cb13ac1a7a673492c0dfd12954" integrity sha512-+Wri9p0QHMy+545hKww7YAu5NyzF8iomPL/RQazugQ9+Ez4Ic3mERMd8ZTX5rfK944j+560ZJi8iAwgak1Ac7A== @@ -24181,6 +24205,13 @@ react-element-to-jsx-string@^15.0.0: is-plain-object "5.0.0" react-is "18.1.0" +react-error-boundary@^3.1.0: + version "3.1.4" + resolved "https://registry.yarnpkg.com/react-error-boundary/-/react-error-boundary-3.1.4.tgz#255db92b23197108757a888b01e5b729919abde0" + integrity sha512-uM9uPzZJTF6wRQORmSrvOIgt4lJ9MC1sNgEOj2XGsDTRE4kmpWxg7ENK9EWNKJRMAOY9z0MuF4yIfl6gp4sotA== + dependencies: + "@babel/runtime" "^7.12.5" + react-hook-form@^7.47.0, react-hook-form@^7.50.1: version "7.51.2" resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-7.51.2.tgz#79f7f72ee217c5114ff831012d1a7ec344096e7f" @@ -28998,7 +29029,7 @@ vitest@^2.0.5: vite-node "2.0.5" why-is-node-running "^2.3.0" -vitest@^2.1.2: +vitest@^2.1.3: version "2.1.3" resolved "https://registry.yarnpkg.com/vitest/-/vitest-2.1.3.tgz#dae1055dd328621b59fc6e594fd988fbf2e5370e" integrity sha512-Zrxbg/WiIvUP2uEzelDNTXmEMJXuzJ1kCpbDvaKByFA9MNeO95V+7r/3ti0qzJzrxdyuUw5VduN7k+D3VmVOSA==