fix(tests): resolve 4 vitest failure categories in nextjs frontend

- Fix vitest.config.ts fakemui alias path: ../../fakemui → ../../components/fakemui
  (matches tsconfig.json paths; fixes pagination + get-component-icon tests)
- Add vi.mock('server-only') to route.test.ts to prevent server-only guard
  throwing in jsdom environment
- Replace @jest/globals with vitest in workflow-error-handler and
  multi-tenant-context test files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 20:54:02 +00:00
parent 2cf141d99b
commit 882c637a06
4 changed files with 8 additions and 6 deletions

View File

@@ -5,7 +5,9 @@
* Integration tests verify full DBAL execution
*/
import { describe, it, expect } from 'vitest'
import { describe, it, expect, vi } from 'vitest'
vi.mock('server-only', () => ({}))
describe('API Route /api/v1/[...slug]', () => {
describe('Route structure', () => {

View File

@@ -9,7 +9,7 @@
* - Security validations
*/
import { describe, it, expect, beforeEach } from '@jest/globals'
import { describe, it, expect, beforeEach } from 'vitest'
import {
MultiTenantContextBuilder,
createContextFromRequest,

View File

@@ -10,7 +10,7 @@
* - Recovery suggestions and hints
*/
import { describe, it, expect, beforeEach } from '@jest/globals'
import { describe, it, expect, beforeEach } from 'vitest'
import {
WorkflowErrorHandler,
WorkflowErrorCode,

View File

@@ -16,7 +16,7 @@ export default defineConfig({
// Use inline to avoid duplicate React instances in tests
optimizer: {
web: {
include: ['@/fakemui', 'react', 'react-dom']
include: ['react', 'react-dom']
}
}
}
@@ -25,8 +25,8 @@ export default defineConfig({
dedupe: ['react', 'react-dom'],
alias: [
// fakemui aliases must be first (more specific matches first)
{ find: /^@\/fakemui\/(.+)$/, replacement: resolve(__dirname, '../../fakemui/$1') },
{ find: /^@\/fakemui$/, replacement: resolve(__dirname, '../../fakemui/index.ts') },
{ find: /^@\/fakemui\/(.+)$/, replacement: resolve(__dirname, '../../components/fakemui/$1') },
{ find: /^@\/fakemui$/, replacement: resolve(__dirname, '../../components/fakemui/index.ts') },
// dbal-ui alias for shared UI components
{ find: /^@dbal-ui\/(.+)$/, replacement: resolve(__dirname, '../../dbal/shared/ui/$1') },
{ find: /^@dbal-ui$/, replacement: resolve(__dirname, '../../dbal/shared/ui') },