Click or drag to upload files.
({
// mock react cache
const testCache = (func: T) => func;
-vi.mock("react", () => {
- const originalModule = vi.importActual("react");
+vi.mock("react", async () => {
+ const react = await vi.importActual("react");
+
return {
- ...originalModule,
+ ...react,
cache: testCache,
};
});
+vi.mock("@tolgee/react", () => ({
+ useTranslate: () => {
+ return {
+ t: (key: string) => key,
+ };
+ },
+}));
+
+vi.mock("next/navigation", () => ({
+ useRouter: () => ({
+ push: vi.fn(),
+ replace: vi.fn(),
+ back: vi.fn(),
+ forward: vi.fn(),
+ prefetch: vi.fn(),
+ refresh: vi.fn(),
+ }),
+}));
+
// mock server-only
vi.mock("server-only", () => {
return {};
});
+vi.mock("@prisma/client", async () => {
+ const actual = await vi.importActual("@prisma/client");
+
+ return {
+ ...actual,
+ Prisma: actual.Prisma,
+ PrismaClient: class {
+ $connect() {
+ return Promise.resolve();
+ }
+ $disconnect() {
+ return Promise.resolve();
+ }
+ $extends() {
+ return this;
+ }
+ },
+ };
+});
+
+if (typeof URL.revokeObjectURL !== "function") {
+ URL.revokeObjectURL = () => {};
+}
+
+if (typeof URL.createObjectURL !== "function") {
+ URL.createObjectURL = () => "blob://fake-url";
+}
+
beforeEach(() => {
vi.resetModules();
vi.resetAllMocks();
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 0a8c63488b..5dd8164b33 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -330,6 +330,9 @@ importers:
'@tanstack/react-table':
specifier: 8.20.6
version: 8.20.6(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
+ '@testing-library/jest-dom':
+ specifier: 6.6.3
+ version: 6.6.3
'@tolgee/cli':
specifier: 2.8.1
version: 2.8.1(jiti@2.4.1)(typescript@5.7.2)
@@ -532,6 +535,9 @@ importers:
'@neshca/cache-handler':
specifier: 1.9.0
version: 1.9.0(next@15.1.2(@opentelemetry/api@1.9.0)(@playwright/test@1.49.1)(react-dom@19.0.0(react@19.0.0))(react@19.0.0))(redis@4.7.0)
+ '@testing-library/react':
+ specifier: 16.2.0
+ version: 16.2.0(@testing-library/dom@10.4.0)(@types/react-dom@19.0.2(@types/react@19.0.1))(@types/react@19.0.1)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
'@types/bcryptjs':
specifier: 2.4.6
version: 2.4.6
@@ -553,6 +559,9 @@ importers:
'@types/qrcode':
specifier: 1.5.5
version: 1.5.5
+ '@types/testing-library__react':
+ specifier: 10.2.0
+ version: 10.2.0(@testing-library/dom@10.4.0)(@types/react-dom@19.0.2(@types/react@19.0.1))(@types/react@19.0.1)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
'@vitest/coverage-v8':
specifier: 2.1.8
version: 2.1.8(vitest@3.0.7(@types/debug@4.1.12)(@types/node@22.10.2)(jiti@2.4.1)(jsdom@25.0.1)(lightningcss@1.27.0)(terser@5.37.0)(tsx@4.19.2)(yaml@2.7.0))
@@ -5575,6 +5584,25 @@ packages:
resolution: {integrity: sha512-xGGHpBXYSHUUr6XsKBfs85TWlYKpTc37cSBBVrXcib2MkHLboWlkClhWF37JKlDb9KEq3dHs+f2xR7XJEWGBxA==}
engines: {node: '>=14', npm: '>=6', yarn: '>=1'}
+ '@testing-library/jest-dom@6.6.3':
+ resolution: {integrity: sha512-IteBhl4XqYNkM54f4ejhLRJiZNqcSCoXUOG2CPK7qbD322KjQozM4kHQOfkG2oln9b9HTYqs+Sae8vBATubxxA==}
+ engines: {node: '>=14', npm: '>=6', yarn: '>=1'}
+
+ '@testing-library/react@16.2.0':
+ resolution: {integrity: sha512-2cSskAvA1QNtKc8Y9VJQRv0tm3hLVgxRGDB+KYhIaPQJ1I+RHbhIXcM+zClKXzMes/wshsMVzf4B9vS4IZpqDQ==}
+ engines: {node: '>=18'}
+ peerDependencies:
+ '@testing-library/dom': ^10.0.0
+ '@types/react': ^18.0.0 || ^19.0.0
+ '@types/react-dom': ^18.0.0 || ^19.0.0
+ react: ^18.0.0 || ^19.0.0
+ react-dom: ^18.0.0 || ^19.0.0
+ peerDependenciesMeta:
+ '@types/react':
+ optional: true
+ '@types/react-dom':
+ optional: true
+
'@testing-library/user-event@14.5.2':
resolution: {integrity: sha512-YAh82Wh4TIrxYLmfGcixwD18oIjyC1pFQC2Y01F2lzV2HTMiYrI0nze0FD0ocB//CKS/7jIUgae+adPqxK5yCQ==}
engines: {node: '>=12', npm: '>=6'}
@@ -5816,6 +5844,10 @@ packages:
'@types/tedious@4.0.14':
resolution: {integrity: sha512-KHPsfX/FoVbUGbyYvk1q9MMQHLPeRZhRJZdO45Q4YjvFkv4hMNghCWTvy7rdKessBsmtz4euWCWAB6/tVpI1Iw==}
+ '@types/testing-library__react@10.2.0':
+ resolution: {integrity: sha512-KbU7qVfEwml8G5KFxM+xEfentAAVj/SOQSjW0+HqzjPE0cXpt0IpSamfX4jGYCImznDHgQcfXBPajS7HjLZduw==}
+ deprecated: This is a stub types definition. testing-library__react provides its own type definitions, so you do not need this installed.
+
'@types/trusted-types@2.0.7':
resolution: {integrity: sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==}
@@ -20003,6 +20035,26 @@ snapshots:
lodash: 4.17.21
redent: 3.0.0
+ '@testing-library/jest-dom@6.6.3':
+ dependencies:
+ '@adobe/css-tools': 4.4.1
+ aria-query: 5.3.2
+ chalk: 3.0.0
+ css.escape: 1.5.1
+ dom-accessibility-api: 0.6.3
+ lodash: 4.17.21
+ redent: 3.0.0
+
+ '@testing-library/react@16.2.0(@testing-library/dom@10.4.0)(@types/react-dom@19.0.2(@types/react@19.0.1))(@types/react@19.0.1)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)':
+ dependencies:
+ '@babel/runtime': 7.26.7
+ '@testing-library/dom': 10.4.0
+ react: 19.0.0
+ react-dom: 19.0.0(react@19.0.0)
+ optionalDependencies:
+ '@types/react': 19.0.1
+ '@types/react-dom': 19.0.2(@types/react@19.0.1)
+
'@testing-library/user-event@14.5.2(@testing-library/dom@10.4.0)':
dependencies:
'@testing-library/dom': 10.4.0
@@ -20263,6 +20315,16 @@ snapshots:
dependencies:
'@types/node': 22.10.2
+ '@types/testing-library__react@10.2.0(@testing-library/dom@10.4.0)(@types/react-dom@19.0.2(@types/react@19.0.1))(@types/react@19.0.1)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)':
+ dependencies:
+ '@testing-library/react': 16.2.0(@testing-library/dom@10.4.0)(@types/react-dom@19.0.2(@types/react@19.0.1))(@types/react@19.0.1)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)
+ transitivePeerDependencies:
+ - '@testing-library/dom'
+ - '@types/react'
+ - '@types/react-dom'
+ - react
+ - react-dom
+
'@types/trusted-types@2.0.7':
optional: true
diff --git a/sonar-project.properties b/sonar-project.properties
index 897155f65b..e7a41cb5a7 100644
--- a/sonar-project.properties
+++ b/sonar-project.properties
@@ -9,8 +9,6 @@ sonar.exclusions=**/node_modules/**,**/.next/**,**/dist/**,**/build/**,**/*.test
sonar.tests=apps/web
sonar.test.inclusions=**/*.test.*,**/*.spec.*
sonar.javascript.lcov.reportPaths=apps/web/coverage/lcov.info
-sonar.coverage.exclusions=**/constants.ts,**/route.ts,**/openapi.ts,**/openapi-document.ts,modules/**/types/**,playwright/**,**/*.test.*,**/*.spec.*
-sonar.cpd.exclusions=**/*.test.*,**/*.spec.*,**/constants.ts,**/route.ts,**/openapi.ts,**/openapi-document.ts,modules/**/types/**
# TypeScript configuration
sonar.typescript.tsconfigPath=apps/web/tsconfig.json
@@ -23,5 +21,5 @@ sonar.scm.exclusions.disabled=false
sonar.sourceEncoding=UTF-8
# Coverage
-sonar.coverage.exclusions=**/*.test.*,**/*.spec.*,**/constants.ts,**/route.ts,modules/**/types/**,**/*.stories.*,**/mocks/**
-sonar.cpd.exclusions=**/*.test.*,**/*.spec.*,**/constants.ts,**/route.ts,modules/**/types/**
\ No newline at end of file
+sonar.coverage.exclusions=**/*.test.*,**/*.spec.*,**/constants.ts,**/route.ts,modules/**/types/**,**/*.stories.*,**/mocks/**,**/openapi.ts,**/openapi-document.ts,playwright/**
+sonar.cpd.exclusions=**/*.test.*,**/*.spec.*,**/constants.ts,**/route.ts,modules/**/types/**,**/openapi.ts,**/openapi-document.ts