Skip to content

Commit

Permalink
feat(*): split services mock file
Browse files Browse the repository at this point in the history
ref: ISSUE-13805

Signed-off-by: Nicolas Pierre-charles <[email protected]>
  • Loading branch information
Nicolas Pierre-charles authored and anooparveti committed Nov 4, 2024
1 parent 84a0527 commit 16c3cab
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 73 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './services.handler';
export * from './services.mock';
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { ServiceDetails } from '../services.type';
import { defaultServiceResponse, servicesMockErrors } from './services.mock';

export type GetServicesMocksParams = {
getServicesKo?: boolean;
getDetailsServicesKo?: boolean;
updateServicesKo?: boolean;
deleteServicesKo?: boolean;
serviceResponse?: ServiceDetails;
};

export const getServicesMocks = ({
getServicesKo,
getDetailsServicesKo,
updateServicesKo,
deleteServicesKo,
serviceResponse = defaultServiceResponse,
}: GetServicesMocksParams): any[] => [
{
url: '/services/:id/terminate',
response: () =>
deleteServicesKo
? {
message: servicesMockErrors.delete,
}
: null,
status: deleteServicesKo ? 500 : 200,
method: 'post',
api: 'v6',
},
{
url: '/services/:id',
response: () =>
updateServicesKo
? {
message: servicesMockErrors.update,
}
: null,
status: updateServicesKo ? 500 : 200,
method: 'put',
api: 'v6',
},
{
url: '/services/:id',
response: () =>
getDetailsServicesKo
? {
message: servicesMockErrors.getDetails,
}
: serviceResponse,
status: getDetailsServicesKo ? 500 : 200,
method: 'get',
api: 'v6',
},
{
url: '/services',
response: () =>
getServicesKo
? {
message: servicesMockErrors.get,
}
: [1234567890],
status: getServicesKo ? 500 : 200,
method: 'get',
api: 'v6',
},
];
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import { CurrencyCode } from '../../../enumTypes';
import { ServiceDetails } from '../services.type';

export type GetServicesMocksParams = {
getServicesKo?: boolean;
getDetailsServicesKo?: boolean;
updateServicesKo?: boolean;
deleteServicesKo?: boolean;
serviceResponse?: ServiceDetails;
};

export const servicesMockErrors = {
delete: 'Delete services error',
update: 'Update services error',
Expand Down Expand Up @@ -102,60 +94,3 @@ export const defaultServiceResponse: ServiceDetails = {
},
tags: [],
};

export const getServicesMocks = ({
getServicesKo,
getDetailsServicesKo,
updateServicesKo,
deleteServicesKo,
serviceResponse = defaultServiceResponse,
}: GetServicesMocksParams): any[] => [
{
url: '/services/:id/terminate',
response: () =>
deleteServicesKo
? {
message: servicesMockErrors.delete,
}
: null,
status: deleteServicesKo ? 500 : 200,
method: 'post',
api: 'v6',
},
{
url: '/services/:id',
response: () =>
updateServicesKo
? {
message: servicesMockErrors.update,
}
: null,
status: updateServicesKo ? 500 : 200,
method: 'put',
api: 'v6',
},
{
url: '/services/:id',
response: () =>
getDetailsServicesKo
? {
message: servicesMockErrors.getDetails,
}
: serviceResponse,
status: getDetailsServicesKo ? 500 : 200,
method: 'get',
api: 'v6',
},
{
url: '/services',
response: () =>
getServicesKo
? {
message: servicesMockErrors.get,
}
: [1234567890],
status: getServicesKo ? 500 : 200,
method: 'get',
api: 'v6',
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { render, waitFor, screen } from '@testing-library/react';
import {
getServicesMocks,
GetServicesMocksParams,
} from '@ovh-ux/manager-react-components/src/hooks/services/mocks/services.mock';
} from '@ovh-ux/manager-react-components/src/hooks/services/mocks';
import { toMswHandlers } from '../../../../../../playwright-helpers';
import { getAuthenticationMocks } from '../../../../../../playwright-helpers/mocks/auth';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { render, waitFor, screen } from '@testing-library/react';
import {
getServicesMocks,
GetServicesMocksParams,
} from '@ovh-ux/manager-react-components/src/hooks/services/mocks/services.mock';
} from '@ovh-ux/manager-react-components/src/hooks/services/mocks';
import { TestApp } from './TestApp';
import { initTestI18n } from './init.i18n';
import { toMswHandlers } from '../../../../../../../playwright-helpers';
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/apps/veeam-backup/e2e/utils/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BrowserContext } from '@playwright/test';
import {
getServicesMocks,
GetServicesMocksParams,
} from '@ovh-ux/manager-react-components/src/hooks/services/mocks/services.mock';
} from '@ovh-ux/manager-react-components/src/hooks/services/mocks';
import {
ICustomWorld,
toPlaywrightMockHandler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ export const SubscriptionTile: React.FC<VeeamBackupWithIam> = ({
) : (
<>
<Description className="block">{nextBillingDate}</Description>
{data?.data?.renew?.current?.mode && (
{data?.data?.billing?.renew?.current?.mode && (
<OsdsChip
className="mt-5"
inline
color={ODS_THEME_COLOR_INTENT.success}
>
{t(`${data.data.renew.current.mode}_renew`)}
{t(`${data.data.billing.renew.current.mode}_renew`)}
</OsdsChip>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { render, waitFor, screen } from '@testing-library/react';
import {
getServicesMocks,
GetServicesMocksParams,
} from '@ovh-ux/manager-react-components/src/hooks/services/mocks/services.mock';
} from '@ovh-ux/manager-react-components/src/hooks/services/mocks';
import { toMswHandlers } from '../../../../../../playwright-helpers';
import { getAuthenticationMocks } from '../../../../../../playwright-helpers/mocks/auth';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Given } from '@cucumber/cucumber';
import { ICustomWorld } from '@playwright-helpers';
import { vsUpdateErrorMessage } from '../../mocks/vrack-services/vrack-services';
import { servicesMockErrors } from '../../../../../manager-react-components/src/hooks/services/mocks/services.mock';
import { servicesMockErrors } from '../../../../../manager-react-components/src/hooks/services/mocks';
import { labels } from '../utils';
import { ConfigParams } from '../../mocks/handlers';
import vrackServicesList from '../../mocks/vrack-services/get-vrack-services.json';
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/apps/vrack-services/mocks/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import {
GetServicesMocksParams,
getServicesMocks,
} from '@ovh-ux/manager-react-components/src/hooks/services/mocks/services.mock';
} from '@ovh-ux/manager-react-components/src/hooks/services/mocks';
import {
getFeatureAvailabilityMocks,
GetFeatureAvailabilityMocksParams,
Expand Down

0 comments on commit 16c3cab

Please sign in to comment.