Fix remaining 4 test failures - import paths and test matchers

- Fixed LevelsClient test: replaced toBeInTheDocument with toBeTruthy (avoids need for jest-dom)
- Fixed transfer-super-god-power test: added mock for get-dbal.server to prevent import errors
- Fixed critical bug: corrected import path in 5 DBAL server files
  - Changed './get-dbal.server' to '../core/get-dbal.server'
  - Files: dbal-add-user, dbal-delete-user, dbal-get-user-by-id, dbal-get-users, dbal-update-user
- Result: 100% test pass rate (370/370 tests passing)

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-27 14:36:26 +00:00
parent 3dc1bf1148
commit aa005a1189
7 changed files with 12 additions and 7 deletions

View File

@@ -4,11 +4,11 @@ import LevelsClient from './LevelsClient'
describe('LevelsClient', () => {
it('renders permission levels and promotes to the next tier', () => {
render(<LevelsClient />)
expect(screen.getByText(/Level 1 · Public/)).toBeInTheDocument()
expect(screen.getByText(/Level 1 · Public/)).toBeTruthy()
const promoteButton = screen.getByRole('button', { name: /Promote to/ })
fireEvent.click(promoteButton)
expect(screen.getByText(/Upgraded to User/)).toBeInTheDocument()
expect(screen.getByText(/Upgraded to User/)).toBeTruthy()
})
})

View File

@@ -1,5 +1,10 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
// Mock the get-dbal module to prevent server-only imports
vi.mock('@/lib/dbal/database-dbal/core/get-dbal.server', () => ({
getDBAL: vi.fn(),
}))
const mockDbalUpdate = vi.fn()
vi.mock('@/lib/dbal/database-dbal/users/dbal-update-user.server', () => ({

View File

@@ -1,7 +1,7 @@
import 'server-only'
import type { User } from '../../types/level-types'
import { getDBAL } from './get-dbal.server'
import { getDBAL } from '../core/get-dbal.server'
export async function dbalAddUser(user: Omit<User, 'id' | 'createdAt'>): Promise<User> {
const dbal = await getDBAL()

View File

@@ -1,6 +1,6 @@
import 'server-only'
import { getDBAL } from './get-dbal.server'
import { getDBAL } from '../core/get-dbal.server'
export async function dbalDeleteUser(userId: string): Promise<boolean> {
const dbal = await getDBAL()

View File

@@ -1,7 +1,7 @@
import 'server-only'
import type { User } from '../../types/level-types'
import { getDBAL } from './get-dbal.server'
import { getDBAL } from '../core/get-dbal.server'
export async function dbalGetUserById(userId: string): Promise<User | null> {
const dbal = await getDBAL()

View File

@@ -1,7 +1,7 @@
import 'server-only'
import type { User } from '../../types/level-types'
import { getDBAL } from './get-dbal.server'
import { getDBAL } from '../core/get-dbal.server'
/**
* DBAL-powered user operations

View File

@@ -1,7 +1,7 @@
import 'server-only'
import type { User } from '../../types/level-types'
import { getDBAL } from './get-dbal.server'
import { getDBAL } from '../core/get-dbal.server'
export async function dbalUpdateUser(userId: string, updates: Partial<User>): Promise<User> {
const dbal = await getDBAL()