Skip to content

Commit

Permalink
feat(vcd): add datacentre integration tests (#13751)
Browse files Browse the repository at this point in the history
  ref: MANAGER-15653

Signed-off-by: Paul Dickerson <[email protected]>
  • Loading branch information
pauldkn authored and chipp972 committed Nov 13, 2024
1 parent d39e978 commit ba5d567
Show file tree
Hide file tree
Showing 24 changed files with 877 additions and 125 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { IamCheckResponse } from '@ovh-ux/manager-react-components';
import { datacentreList } from '../vcd-organization/vcd-datacentre.mock';
import { organizationList } from '../vcd-organization/vcd-organization.mock';
import { iamActions } from '@/utils/iam.constants';

Expand All @@ -19,4 +20,11 @@ export const resourceList: IamCheckResponse[] = [
],
unauthorizedActions: [],
},
{
urn: datacentreList[0].iam.urn,
authorizedActions: [
iamActions.vmwareCloudDirectorApiovhOrganizationVirtualDataCenterEdit,
],
unauthorizedActions: [],
},
];
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './iam/iam.handler';
export * from './vcd-organization/vcd-organization.handler';
export * from './vcd-organization/vcd-datacentre-order.handler';
export * from './veeam-backup/veeam-backup.handler';
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
import { TVcdCatalog } from '../../src/types/vcd-catalog.interface';

export const catalogProductList: TVcdCatalog = [
{
productName: 'pack-3264',
mandatory: false,
exclusive: false,
family: 'host_order',
productType: 'cloud_service',
planCode: 'pack-3264',
prices: [
{
priceInUcents: 0,
pricingType: 'rental',
maximumRepeat: 1,
price: { currencyCode: 'EUR', text: '0.00 €', value: 0 },
minimumRepeat: 1,
capacities: ['installation'],
duration: 'P0D',
maximumQuantity: null,
interval: 0,
description: 'Installation pricing',
pricingMode: 'default',
minimumQuantity: 1,
},
{
pricingMode: 'default',
minimumQuantity: 1,
description: 'Installation pricing',
interval: 1,
maximumQuantity: null,
duration: 'P1M',
capacities: ['renew'],
minimumRepeat: 1,
price: { value: 80, text: '80.00 €', currencyCode: 'EUR' },
maximumRepeat: null,
pricingType: 'rental',
priceInUcents: 8_000_000_000,
},
],
},
{
productName: 'pack-1664',
mandatory: false,
exclusive: false,
family: 'host_order',
productType: 'cloud_service',
planCode: 'pack-1664',
prices: [
{
capacities: ['installation'],
minimumRepeat: 1,
duration: 'P0D',
pricingType: 'rental',
priceInUcents: 0,
price: { text: '0.00 €', currencyCode: 'EUR', value: 0 },
maximumRepeat: 1,
description: 'Installation pricing',
minimumQuantity: 1,
pricingMode: 'default',
maximumQuantity: null,
interval: 0,
},
{
pricingMode: 'default',
minimumQuantity: 1,
description: 'Installation pricing',
maximumQuantity: null,
interval: 1,
duration: 'P1M',
capacities: ['renew'],
minimumRepeat: 1,
pricingType: 'rental',
priceInUcents: 8_000_000_000,
price: { text: '80.00 €', currencyCode: 'EUR', value: 80 },
maximumRepeat: null,
},
],
},
{
productType: 'cloud_service',
planCode: 'pack-16128',
prices: [
{
maximumQuantity: null,
interval: 0,
minimumQuantity: 1,
pricingMode: 'default',
description: 'Installation pricing',
priceInUcents: 0,
pricingType: 'rental',
maximumRepeat: 1,
price: { value: 0, text: '0.00 €', currencyCode: 'EUR' },
duration: 'P0D',
minimumRepeat: 1,
capacities: ['installation'],
},
{
minimumQuantity: 1,
pricingMode: 'default',
description: 'Installation pricing',
interval: 1,
maximumQuantity: null,
duration: 'P1M',
minimumRepeat: 1,
capacities: ['renew'],
maximumRepeat: null,
price: { value: 80, currencyCode: 'EUR', text: '80.00 €' },
priceInUcents: 8_000_000_000,
pricingType: 'rental',
},
],
productName: 'pack-16128',
mandatory: false,
family: 'host_order',
exclusive: false,
},
{
prices: [
{
maximumQuantity: null,
interval: 0,
description: 'Installation pricing',
minimumQuantity: 1,
pricingMode: 'default',
pricingType: 'rental',
priceInUcents: 0,
price: { value: 0, currencyCode: 'EUR', text: '0.00 €' },
maximumRepeat: 1,
capacities: ['installation'],
minimumRepeat: 1,
duration: 'P0D',
},
{
minimumRepeat: 1,
capacities: ['renew'],
duration: 'P1M',
priceInUcents: 8_000_000_000,
pricingType: 'rental',
maximumRepeat: null,
price: { value: 80, currencyCode: 'EUR', text: '80.00 €' },
description: 'Installation pricing',
pricingMode: 'default',
minimumQuantity: 1,
maximumQuantity: null,
interval: 1,
},
],
planCode: 'vcd-datastore-1000',
productType: 'cloud_service',
family: 'storage_order',
exclusive: false,
mandatory: false,
productName: 'vcd-datastore-1000',
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { IVdcOrderableResourceData } from '@/types/vcd-vdc-orderable-resource.interface';
import { Handler } from '../../../../../../playwright-helpers';
import { catalogProductList } from './vcd-catalog.mock';
import { orderableResourceData } from './vdc-orderable-resource.mock';

export type GetDatacentreOrderMocksParams = {
isCatalogKO?: boolean;
nbCatalogProduct?: number;
isOrderableResourceKO?: boolean;
nbOrderableResource?: number;
};

export const getDatacentreOrderMocks = ({
isCatalogKO,
nbCatalogProduct = Number.POSITIVE_INFINITY,
isOrderableResourceKO,
nbOrderableResource = Number.POSITIVE_INFINITY,
}: GetDatacentreOrderMocksParams): Handler[] => {
const selectedOrderableResource: IVdcOrderableResourceData = {
compute: orderableResourceData.compute.slice(0, nbOrderableResource),
storage: orderableResourceData.storage.slice(0, nbOrderableResource),
};

return [
{
url:
'/vmwareCloudDirector/organization/:id/virtualDataCenter/:id/orderableResource',
response: isOrderableResourceKO
? { message: 'OrderableResource error' }
: selectedOrderableResource,
api: 'v2',
status: isOrderableResourceKO ? 500 : 200,
},
{
url: '/order/cartServiceOption/vmwareCloudDirector/:id',
response: isCatalogKO
? { message: 'Catalog error' }
: catalogProductList.slice(0, nbCatalogProduct),
api: 'v6',
status: isCatalogKO ? 500 : 200,
},
];
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ export const datacentreList: IVcdDatacentre[] = [
resourceStatus: 'READY',
currentState: {
commercialRange: 'STANDARD',
description:
'Pour vous proposer une description adaptée, pourriez-vous me donner plus de détails sur votre service ? Cela me permettra de créer une description précise et impactante qui tient dans la limite des 255 caractères.',
description: 'VDC Description',
ipQuota: 10,
memoryQuota: 64,
name: 'vdc-eu-central-waw-adc311b5-0c0b-4071-b48f-b20813868bcf',
Expand All @@ -18,8 +17,7 @@ export const datacentreList: IVcdDatacentre[] = [
},
currentTasks: [],
targetSpec: {
description:
'Pour vous proposer une description adaptée, pourriez-vous me donner plus de détails sur votre service ? Cela me permettra de créer une description précise et impactante qui tient dans la limite des 255 caractères.',
description: 'VDC Description targetSpec',
vCPUSpeed: 3,
},
updatedAt: '2024-09-23T13:53:49Z',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,92 @@ import { PathParams } from 'msw';
import { Handler } from '../../../../../../playwright-helpers';
import { organizationList } from './vcd-organization.mock';
import { datacentreList } from './vcd-datacentre.mock';
import { computeList } from './vdc-compute.mock';
import { storageList } from './vdc-storage.mock';

export type GetOrganizationMocksParams = {
isOrganizationKo?: boolean;
isOrganizationUpdateKo?: boolean;
nbOrganization?: number;
allOrgsBackedUp?: boolean;
isDatacentresKo?: boolean;
isDatacentreUpdateKo?: boolean;
nbDatacentres?: number;
isComputeKO?: boolean;
nbCompute?: number;
isStorageKO?: boolean;
nbStorage?: number;
};

const findOrganizationById = (params: PathParams) =>
organizationList.find(({ id }) => id === params.id);

const findDatacentreById = (params: PathParams) =>
datacentreList.find(({ id }) => id === params.id);

export const getOrganizationMocks = ({
isOrganizationKo,
isOrganizationUpdateKo,
nbOrganization = Number.POSITIVE_INFINITY,
allOrgsBackedUp,
isDatacentresKo,
isDatacentreUpdateKo,
nbDatacentres = Number.POSITIVE_INFINITY,
isComputeKO,
nbCompute = Number.POSITIVE_INFINITY,
isStorageKO,
nbStorage = Number.POSITIVE_INFINITY,
}: GetOrganizationMocksParams): Handler[] => {
const nb = allOrgsBackedUp ? 1 : nbOrganization;
return [
{
url:
'/vmwareCloudDirector/organization/:id/virtualDataCenter/:id/storage',
response: isStorageKO
? { message: 'Storage error' }
: storageList.slice(0, nbStorage),
api: 'v2',
status: isStorageKO ? 500 : 200,
},
{
url:
'/vmwareCloudDirector/organization/:id/virtualDataCenter/:id/compute',
response: isComputeKO
? { message: 'Compute error' }
: computeList.slice(0, nbCompute),
api: 'v2',
status: isComputeKO ? 500 : 200,
},
{
url: '/vmwareCloudDirector/organization/:id/virtualDataCenter',
response: isDatacentresKo
? {
message: 'Datacentres error',
}
? { message: 'Datacentres error' }
: datacentreList.slice(0, nbDatacentres),
api: 'v2',
status: isDatacentresKo ? 500 : 200,
},
{
url: '/vmwareCloudDirector/organization/:id/virtualDataCenter/:id',
response: (_: unknown, params: PathParams) =>
isDatacentresKo
? { message: 'Datacentre error' }
: findDatacentreById(params),
api: 'v2',
status: isDatacentresKo ? 500 : 200,
},
{
url: '/vmwareCloudDirector/organization/:id/virtualDataCenter/:id',
response: isDatacentreUpdateKo
? { message: 'Datacentre update error' }
: {},
method: 'put',
api: 'v2',
status: isDatacentreUpdateKo ? 500 : 200,
},
{
url: '/vmwareCloudDirector/organization/:id',
response: isOrganizationUpdateKo
? {
message: 'Organization update error',
}
? { message: 'Organization update error' }
: {},
method: 'put',
api: 'v2',
Expand All @@ -50,19 +97,15 @@ export const getOrganizationMocks = ({
url: '/vmwareCloudDirector/organization/:id',
response: (_: unknown, params: PathParams) =>
isOrganizationKo
? {
message: 'Organization error',
}
? { message: 'Organization error' }
: findOrganizationById(params),
api: 'v2',
status: isOrganizationKo ? 500 : 200,
},
{
url: '/vmwareCloudDirector/organization',
response: isOrganizationKo
? {
message: 'Organization error',
}
? { message: 'Organization error' }
: organizationList.slice(0, nb),
status: isOrganizationKo ? 500 : 200,
api: 'v2',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ export const organizationList: IVcdOrganization[] = [
id: '6cfa2c69-c62c-4853-80ee-c9682e6727f0',
resourceStatus: 'UPDATING',
targetSpec: {
description: 'Company production VCD Organization',
fullName: 'Company VCD',
description: 'Company VCD Organization targetSpec',
fullName: 'Company VCD targetSpec',
},
updatedAt: '2024-06-14T09:21:21.943Z',
iam: {
Expand All @@ -48,8 +48,8 @@ export const organizationList: IVcdOrganization[] = [
id: '61ebdcec-0623-4a61-834f-a1719cd475b4',
resourceStatus: 'READY',
targetSpec: {
description: 'My demo VCD Organization',
fullName: 'Demo VCD',
description: 'My demo VCD Organization targetSpec',
fullName: 'Demo VCD targetSpec',
},
updatedAt: '2024-06-14T09:21:21.943Z',
iam: {
Expand Down
Loading

0 comments on commit ba5d567

Please sign in to comment.