Skip to content

Commit

Permalink
refactor(hycu): remove playwright
Browse files Browse the repository at this point in the history
Signed-off-by: Thibault Barske <[email protected]>
  • Loading branch information
tibs245 committed Oct 10, 2024
1 parent da166e4 commit 165549e
Show file tree
Hide file tree
Showing 18 changed files with 463 additions and 224 deletions.
12 changes: 0 additions & 12 deletions packages/manager/apps/hycu/e2e/features/error.feature

This file was deleted.

7 changes: 0 additions & 7 deletions packages/manager/apps/hycu/e2e/features/onboarding.feature

This file was deleted.

53 changes: 0 additions & 53 deletions packages/manager/apps/hycu/e2e/step-definitions/error.step.ts

This file was deleted.

32 changes: 0 additions & 32 deletions packages/manager/apps/hycu/e2e/step-definitions/onboarding.step.ts

This file was deleted.

7 changes: 0 additions & 7 deletions packages/manager/apps/hycu/e2e/utils/constants.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/manager/apps/hycu/e2e/utils/index.tsx

This file was deleted.

28 changes: 0 additions & 28 deletions packages/manager/apps/hycu/e2e/utils/network.ts

This file was deleted.

6 changes: 2 additions & 4 deletions packages/manager/apps/hycu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
"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:e2e": "tsc && node ../../../../scripts/run-playwright-bdd.js",
"test:e2e:ci": "tsc && node ../../../../scripts/run-playwright-bdd.js --ci"
"test": "vitest run"
},
"dependencies": {
"@ovh-ux/manager-config": "*",
Expand Down Expand Up @@ -48,7 +46,7 @@
"devDependencies": {
"@cucumber/cucumber": "^10.3.1",
"@ovh-ux/manager-vite-config": "*",
"@playwright/test": "^1.41.2",
"@testing-library/jest-dom": "^6.5.0",
"@testing-library/react": "^16.0.1",
"@types/jest": "^29.5.13",
"@vitejs/plugin-react": "^4.3.2",
Expand Down
20 changes: 0 additions & 20 deletions packages/manager/apps/hycu/playwright.config.ts

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const licenseHycu: unknown[] = [
{
displayName: '425802fa-fb70-4b2a-9d5b-ec4de86bb40c',
extraParams: null,
parentName: null,
serviceName: '425802fa-fb70-4b2a-9d5b-ec4de86bb40c',
stateParams: ['425802fa-fb70-4b2a-9d5b-ec4de86bb40c'],
url: '#/425802fa-fb70-4b2a-9d5b-ec4de86bb40c',
},
{
displayName: 'c1b7cb4f-6b63-45da-9a8a-f731f1a67b2c',
extraParams: null,
parentName: null,
serviceName: 'c1b7cb4f-6b63-45da-9a8a-f731f1a67b2c',
stateParams: ['c1b7cb4f-6b63-45da-9a8a-f731f1a67b2c'],
url: '#/c1b7cb4f-6b63-45da-9a8a-f731f1a67b2c',
},
];
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { Handler } from '../../../../../../../playwright-helpers';
import backupList from './licenseHycu-data.json';
import { licenseHycu } from './licenseHycu.data';

export type GetLicenseHycuMocksParams = {
isBackupKo?: boolean;
nbBackup?: number;
nbLicenseHycu?: number;
};

export const getLicenseHycuMocks = ({
isBackupKo,
nbBackup = Number.POSITIVE_INFINITY,
nbLicenseHycu = Number.POSITIVE_INFINITY,
}: GetLicenseHycuMocksParams): Handler[] => {
return [
{
Expand All @@ -17,7 +17,7 @@ export const getLicenseHycuMocks = ({
? {
message: 'Backup error',
}
: backupList.slice(0, nbBackup),
: licenseHycu.slice(0, nbLicenseHycu),
status: isBackupKo ? 500 : 200,
api: 'v6',
},
Expand Down
12 changes: 7 additions & 5 deletions packages/manager/apps/hycu/src/pages/listing/Listing.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { describe, it } from 'vitest';
import { setupTest } from '@/utils/tests/setup-test';
import { screen } from '@testing-library/react';
import { renderTestApp } from '@/utils/tests/renderTestApp';
import '@testing-library/jest-dom';
import { labels } from '@/utils/tests/init.i18n';

describe('HYCU listing test suite', () => {
it('should redirect to the onboarding page when the license list is empty', async () => {
await setupTest();
describe('KMS listing test suite', () => {
it('should redirect to the onboarding page when the kms list is empty', async () => {
await renderTestApp({ nbLicenseHycu: 0 });
});
});
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import { beforeAll, afterAll } from 'vitest';
import { odsSetup } from '@ovhcloud/ods-common-core';
import { setupServer } from 'msw/node';
import { toMswHandlers } from '../../../../playwright-helpers';
import { getAuthenticationMocks } from '../../../../playwright-helpers/mocks/auth';
import { SetupServer, setupServer } from 'msw/node';
import { toMswHandlers } from '../../../../../playwright-helpers';
import { getAuthenticationMocks } from '../../../../../playwright-helpers/mocks/auth';
import '@testing-library/jest-dom';
import 'element-internals-polyfill';

odsSetup();

declare global {
// eslint-disable-next-line vars-on-top, no-var
var server: SetupServer;
// eslint-disable-next-line vars-on-top, no-var, @typescript-eslint/naming-convention
var __VERSION__: string;
}

const server = setupServer(
...toMswHandlers([
...getAuthenticationMocks({ isAuthMocked: true, region: 'EU' }),
Expand Down
8 changes: 4 additions & 4 deletions packages/manager/apps/hycu/src/utils/tests/init.i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ export const defaultAvailableLocales = [defaultLocale];

function addTranslations() {
i18next
.addResources(defaultLocale, 'hycu/common', common)
.addResources(defaultLocale, 'hycu/dashboard', dashboard)
.addResources(defaultLocale, 'hycu/listing', listing)
.addResources(defaultLocale, 'hycu/onboarding', onboarding)
.addResources(defaultLocale, 'common', common)
.addResources(defaultLocale, 'dashboard', dashboard)
.addResources(defaultLocale, 'listing', listing)
.addResources(defaultLocale, 'onboarding', onboarding)
.use({
type: 'postProcessor',
name: 'normalize',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,48 +1,46 @@
import React from 'react';
import { SetupServer } from 'msw/node';
import { i18n } from 'i18next';
import { I18nextProvider } from 'react-i18next';
import {
initShellContext,
ShellContext,
ShellContextType,
initShellContext,
} from '@ovh-ux/manager-react-shell-client';
import { i18n } from 'i18next';
import { I18nextProvider } from 'react-i18next';
import { render, waitFor, screen } from '@testing-library/react';
import {
getServicesMocks,
GetServicesMocksParams,
} from '@ovh-ux/manager-react-components/src/hooks/services/mocks/services.mock';
import { expect } from 'vitest';
import { TestApp } from './TestApp';
import { initTestI18n } from './init.i18n';
import { toMswHandlers } from '../../../../../../../playwright-helpers';
import { getAuthenticationMocks } from '../../../../../../../playwright-helpers/mocks/auth';
import { getLicenseHycuMocks, GetLicenseHycuMocksParams } from '../../mocks';
import { initTestI18n } from './init.i18n';
import { TestApp } from './TestApp';
import { getLicenseHycuMocks, GetLicenseHycuMocksParams } from '@/mocks';

let context: ShellContextType;
let i18n: i18n;
let i18nValue: i18n;

export const setupTest = async (
mockParams: GetLicenseHycuMocksParams & GetServicesMocksParams = {},
export const renderTestApp = async (
mockParams: GetServicesMocksParams & GetLicenseHycuMocksParams = {},
) => {
(global.server as SetupServer)?.resetHandlers(
global.server?.resetHandlers(
...toMswHandlers([
...getAuthenticationMocks({ isAuthMocked: true }),
...getLicenseHycuMocks(mockParams),
...getServicesMocks(mockParams),
...getLicenseHycuMocks(mockParams),
]),
);

if (!context) {
context = await initShellContext('hycu');
}

if (!i18n) {
i18n = await initTestI18n();
if (!i18nValue) {
i18nValue = await initTestI18n();
}

const result = render(
<I18nextProvider i18n={i18n}>
<I18nextProvider i18n={i18nValue}>
<ShellContext.Provider value={context}>
<TestApp />
</ShellContext.Provider>
Expand All @@ -52,7 +50,7 @@ export const setupTest = async (
await waitFor(
() =>
expect(
screen.getAllByText('title', { exact: false }).length,
screen.getAllByText('HYCU', { exact: false }).length,
).toBeGreaterThan(0),
{ timeout: 30000 },
);
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/apps/hycu/vitest.config.js
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: ['./setup-test.tsx'],
setupFiles: ['./src/setupTests.tsx'],
coverage: {
include: ['src'],
exclude: [
Expand Down
Loading

0 comments on commit 165549e

Please sign in to comment.