Skip to content

Commit

Permalink
feat(*): add test and common-api module
Browse files Browse the repository at this point in the history
ref: MANAGER-15700

Signed-off-by: Nicolas Pierre-charles <[email protected]>
  • Loading branch information
Nicolas Pierre-charles committed Nov 21, 2024
1 parent d5cc773 commit e539b2b
Show file tree
Hide file tree
Showing 100 changed files with 1,520 additions and 759 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/run-bdd-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
yarn exec turbo -- run build --filter="./packages/manager/core/*" --concurrency=5
yarn exec turbo -- run build --filter="./packages/manager-react-components" --concurrency=5
yarn exec turbo -- run build --filter="./packages/manager/modules/order" --concurrency=5
yarn exec turbo -- run build --filter="./packages/manager/modules/common-api" --concurrency=5
yarn exec turbo -- run build --filter="./packages/manager/modules/vcd-api" --concurrency=5
# This task is for running the jest tests outside microApps
- name: Run tests Jest
run: yarn test:jest
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"packages/manager/core/url-builder",
"packages/manager/core/utils",
"packages/manager/core/vite-config",
"packages/manager/core/test-utils",
"packages/manager/modules/*",
"packages/manager/tools/*",
"packages/manager-react-components"
Expand Down
20 changes: 0 additions & 20 deletions packages/manager/apps/hpc-vmware-managed-vcd/cucumber.js

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

21 changes: 0 additions & 21 deletions packages/manager/apps/hpc-vmware-managed-vcd/e2e/utils/network.ts

This file was deleted.

7 changes: 3 additions & 4 deletions packages/manager/apps/hpc-vmware-managed-vcd/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
"license": "BSD-3-Clause",
"author": "OVH SAS",
"scripts": {
"beta-test:e2e": "tsc && node ../../../../scripts/run-playwright-bdd.js",
"beta-test:e2e:cii": "tsc && node ../../../../scripts/run-playwright-bdd.js --ci",
"build": "tsc && vite build",
"coverage": "vitest run --coverage",
"dev": "tsc && vite",
Expand All @@ -26,10 +24,11 @@
"@ovh-ux/manager-config": "^8.0.0",
"@ovh-ux/manager-core-api": "^0.9.0",
"@ovh-ux/manager-core-utils": "*",
"@ovh-ux/manager-react-core-application": "^0.11.1",
"@ovh-ux/manager-module-common-api": "^0.1.0",
"@ovh-ux/manager-module-order": "^0.7.1",
"@ovh-ux/manager-module-vcd-api": "^0.1.0",
"@ovh-ux/manager-react-components": "^1.41.1",
"@ovh-ux/manager-react-core-application": "^0.11.1",
"@ovh-ux/manager-react-shell-client": "^0.8.1",
"@ovh-ux/manager-tailwind-config": "*",
"@ovh-ux/request-tagger": "^0.4.0",
Expand All @@ -51,8 +50,8 @@
},
"devDependencies": {
"@cucumber/cucumber": "^10.3.1",
"@ovh-ux/manager-core-test-utils": "^0.1.0",
"@ovh-ux/manager-vite-config": "^0.8.2",
"@playwright/test": "^1.41.2",
"@testing-library/dom": "^10.1.0",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/react": "^16.0.0",
Expand Down
20 changes: 0 additions & 20 deletions packages/manager/apps/hpc-vmware-managed-vcd/playwright.config.ts

This file was deleted.

35 changes: 0 additions & 35 deletions packages/manager/apps/hpc-vmware-managed-vcd/setupTests.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,15 @@ import {
} from '@ovh-ux/manager-module-vcd-api';
import OrganizationDataProtectionTile from './OrganizationDataProtectionTile.component';

vi.mock('@ovh-ux/manager-module-vcd-api', () => ({
useVeeamBackup: vi.fn(),
getBackupIdFromOrganization: vi.fn(),
}));
vi.mock('@ovh-ux/manager-module-vcd-api', async (original) => {
const actual: any = await original();
return {
...actual,
useVeeamBackup: vi.fn(),
getBackupIdFromOrganization: vi.fn(),
};
});

vi.mocked(useVeeamBackup).mockReturnValue(
{} as UseQueryResult<ApiResponse<VeeamBackup>, ApiError>,
);
Expand Down
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-module-common-api';
import {
getVeeamBackupMocks,
getOrganizationMocks,
Expand All @@ -24,9 +24,12 @@ import {
GetVeeamBackupMocksParams,
getIamMocks,
} from '@ovh-ux/manager-module-vcd-api';
import { toMswHandlers } from '../../../../../../playwright-helpers';
import { getAuthenticationMocks } from '../../../../../../playwright-helpers/mocks/auth';
import { initTestI18n, labels } from './test-i18n';
import {
initTestI18n,
getAuthenticationMocks,
toMswHandlers,
} from '@ovh-ux/manager-core-test-utils';
import { translations, labels } from './test-i18n';
import { TestApp } from './TestApp';
import { APP_NAME } from '@/tracking.constant';

Expand Down Expand Up @@ -60,7 +63,7 @@ export const renderTest = async ({
}

if (!i18nState) {
i18nState = await initTestI18n();
i18nState = await initTestI18n(APP_NAME, translations);
}

const result = render(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import i18next, { i18n } from 'i18next';
import listing from '../../public/translations/listing/Messages_fr_FR.json';
import dashboard from '../../public/translations/dashboard/Messages_fr_FR.json';
import onboarding from '../../public/translations/onboarding/Messages_fr_FR.json';
Expand All @@ -19,62 +18,17 @@ const error = {
'Une erreur est survenue lors du chargement de la page.',
};

export const defaultLocale = 'fr_FR';
export const defaultAvailableLocales = [defaultLocale];

function addTranslations() {
i18next
.addResources(defaultLocale, APP_NAME, common)
.addResources(defaultLocale, 'listing', listing)
.addResources(defaultLocale, 'dashboard', dashboard)
.addResources(defaultLocale, 'onboarding', onboarding)
.addResources(defaultLocale, `${APP_NAME}/datacentres`, datacentres)
.addResources(
defaultLocale,
`${APP_NAME}/datacentres/compute`,
datacentresCompute,
)
.addResources(
defaultLocale,
`${APP_NAME}/datacentres/order`,
datacentresOrder,
)
.addResources(
defaultLocale,
`${APP_NAME}/datacentres/storage`,
datacentresStorage,
)
.addResources(defaultLocale, 'error', error)
.use({
type: 'postProcessor',
name: 'normalize',
process: (value: string) =>
value ? value.replace(/&amp;/g, '&') : value,
});
}

export const initTestI18n = () =>
new Promise<i18n>((resolve) => {
i18next.init({
lng: defaultLocale,
defaultNS: APP_NAME,
ns: [],
supportedLngs: defaultAvailableLocales,
postProcess: 'normalize',
interpolation: {
escapeValue: false,
},
});

if (i18next.isInitialized) {
addTranslations();
} else {
i18next.on('initialized', () => {
addTranslations();
resolve(i18next);
});
}
});
export const translations = {
[APP_NAME]: common,
listing,
dashboard,
onboarding,
[`${APP_NAME}/datacentres`]: datacentres,
[`${APP_NAME}/datacentres/compute`]: datacentresCompute,
[`${APP_NAME}/datacentres/order`]: datacentresOrder,
[`${APP_NAME}/datacentres/storage`]: datacentresStorage,
error,
};

export const labels = {
common,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default defineConfig({
test: {
globals: true,
environment: 'jsdom',
setupFiles: './setupTests.ts',
setupFiles: '@ovh-ux/manager-core-test-utils/setup-file-msw-ods17.tsx',
coverage: {
include: ['src'],
exclude: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,13 @@ exports[`PlanStep > should render 1`] = `
class="flex flex-col md:flex-row"
>
<div
class="font-sans font-normal p-0 m-0 w-full md:w-5/6 leading-10 text-[1.25rem] text-[grey]"
class="font-sans font-normal p-0 m-0 w-full md:w-5/6 flex text-[grey]"
>
private_registry_create_choose_plan
<div
class="leading-10 text-[1.25rem]"
>
private_registry_create_choose_plan
</div>
</div>
</div>
</div>
Expand Down
20 changes: 0 additions & 20 deletions packages/manager/apps/veeam-backup/cucumber.js

This file was deleted.

This file was deleted.

Loading

0 comments on commit e539b2b

Please sign in to comment.